summaryrefslogtreecommitdiffstats
path: root/gfx/thebes
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-10-06 09:32:46 +0000
committerMoonchild <moonchild@palemoon.org>2020-10-06 09:32:46 +0000
commita98d06380fe706e3b1b602411c597b9882516b3e (patch)
tree60452c5f39b8dc60a8e97454d4103baf2cd194ae /gfx/thebes
parent63a0006985036b062eed7e9e83324581d8ab247c (diff)
parent1e8d07cac205a5db3d7d416d7f414a213fd892ff (diff)
downloadUXP-a98d06380fe706e3b1b602411c597b9882516b3e.tar
UXP-a98d06380fe706e3b1b602411c597b9882516b3e.tar.gz
UXP-a98d06380fe706e3b1b602411c597b9882516b3e.tar.lz
UXP-a98d06380fe706e3b1b602411c597b9882516b3e.tar.xz
UXP-a98d06380fe706e3b1b602411c597b9882516b3e.zip
Merge branch 'redwood' into release
Diffstat (limited to 'gfx/thebes')
-rw-r--r--gfx/thebes/gfxTextRun.cpp28
-rw-r--r--gfx/thebes/gfxTextRun.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp
index 2e2a0d239..d6cb1bdb2 100644
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -1072,6 +1072,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 3c9ded1dc..a565075cd 100644
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -299,6 +299,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.