diff options
author | Moonchild <moonchild@palemoon.org> | 2020-10-03 12:45:27 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-10-03 12:45:27 +0000 |
commit | 8e18743ab871bed1e1858ed2714a81f017433a2d (patch) | |
tree | a87331b71a4b5abd85ea07f53d4043c1f2b0cb7a /gfx | |
parent | 15acac52b1f92410f9c0e46737dd5e8413eb6c46 (diff) | |
download | UXP-8e18743ab871bed1e1858ed2714a81f017433a2d.tar UXP-8e18743ab871bed1e1858ed2714a81f017433a2d.tar.gz UXP-8e18743ab871bed1e1858ed2714a81f017433a2d.tar.lz UXP-8e18743ab871bed1e1858ed2714a81f017433a2d.tar.xz UXP-8e18743ab871bed1e1858ed2714a81f017433a2d.zip |
Issue #1665 - Take overflow-wrap into account when calculating min-content intrinsic size.
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/thebes/gfxTextRun.cpp | 28 | ||||
-rw-r--r-- | gfx/thebes/gfxTextRun.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 8794efe68..1025abbd3 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -1071,6 +1071,34 @@ gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider, return result + GetAdvanceForGlyphs(ligatureRange); } +gfxFloat +gfxTextRun::GetMinAdvanceWidth(Range aRange) +{ + MOZ_ASSERT(aRange.end <= GetLength(), "Substring out of range"); + + Range ligatureRange = aRange; + ShrinkToLigatureBoundaries(&ligatureRange); + + gfxFloat result = std::max( + ComputePartialLigatureWidth(Range(aRange.start, ligatureRange.start), + nullptr), + ComputePartialLigatureWidth(Range(ligatureRange.end, aRange.end), + nullptr)); + + // XXX Do we need to take spacing into account? When each grapheme cluster + // takes its own line, we shouldn't be adding spacings around them. + gfxFloat clusterAdvance = 0; + for (uint32_t i = ligatureRange.start; i < ligatureRange.end; ++i) { + clusterAdvance += GetAdvanceForGlyph(i); + if (i + 1 == ligatureRange.end || IsClusterStart(i + 1)) { + result = std::max(result, clusterAdvance); + clusterAdvance = 0; + } + } + + return result; +} + bool gfxTextRun::SetLineBreaks(Range aRange, bool aLineBreakBefore, bool aLineBreakAfter, diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h index beeaad04b..7217eca74 100644 --- a/gfx/thebes/gfxTextRun.h +++ b/gfx/thebes/gfxTextRun.h @@ -298,6 +298,12 @@ public: } /** + * Computes the minimum advance width for a substring assuming line + * breaking is allowed everywhere. + */ + gfxFloat GetMinAdvanceWidth(Range aRange); + + /** * Clear all stored line breaks for the given range (both before and after), * and then set the line-break state before aRange.start to aBreakBefore and * after the last cluster to aBreakAfter. |