summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-06-10 07:35:22 +0000
committerMoonchild <moonchild@palemoon.org>2022-06-10 07:35:22 +0000
commit9ad788853f6f2be403ec54d1c56e8bd608014f02 (patch)
tree60432437fd2c907483ede17e1f566b45792189a6 /gfx
parentd8070a8e0d7f6df5ac864e4052bc293f5442b967 (diff)
downloaduxp-9ad788853f6f2be403ec54d1c56e8bd608014f02.tar.gz
Issue #1914 - Implement white-space: break-spaces
This also simplifies GetCSSWhitespaceToCompressionMode (FFS with the function names, Mozilla!) to be less fragile.
Diffstat (limited to 'gfx')
-rw-r--r--gfx/thebes/gfxTextRun.cpp16
-rw-r--r--gfx/thebes/gfxTextRun.h1
2 files changed, 14 insertions, 3 deletions
diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp
index fd97615366..438f6f61ae 100644
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -851,6 +851,7 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
bool *aUsedHyphenation,
uint32_t *aLastBreak,
bool aCanWordWrap,
+ bool aCanWhitespaceWrap,
gfxBreakPriority *aBreakPriority)
{
aMaxLength = std::min(aMaxLength, GetLength() - aStart);
@@ -918,7 +919,15 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
aCanWordWrap && mCharacterGlyphs[i].IsClusterStart() &&
*aBreakPriority <= gfxBreakPriority::eWordWrapBreak;
- if (atBreak || wordWrapping) {
+ bool whitespaceWrapping = false;
+ if (i > aStart) {
+ // The spec says the breaking opportunity is *after* whitespace.
+ auto const& g = mCharacterGlyphs[i - 1];
+ whitespaceWrapping = aCanWhitespaceWrap &&
+ (g.CharIsSpace() || g.CharIsTab() || g.CharIsNewline());
+ }
+
+ if (atBreak || wordWrapping || whitespaceWrapping) {
gfxFloat hyphenatedAdvance = advance;
if (atHyphenationBreak) {
hyphenatedAdvance += aProvider->GetHyphenWidth();
@@ -930,8 +939,9 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
lastBreakTrimmableChars = trimmableChars;
lastBreakTrimmableAdvance = trimmableAdvance;
lastBreakUsedHyphenation = atHyphenationBreak;
- *aBreakPriority = atBreak ? gfxBreakPriority::eNormalBreak
- : gfxBreakPriority::eWordWrapBreak;
+ *aBreakPriority = (atBreak || whitespaceWrapping)
+ ? gfxBreakPriority::eNormalBreak
+ : gfxBreakPriority::eWordWrapBreak;
}
width += advance;
diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h
index d61992527b..2ef835f189 100644
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -409,6 +409,7 @@ public:
bool *aUsedHyphenation,
uint32_t *aLastBreak,
bool aCanWordWrap,
+ bool aCanWhitespaceWrap,
gfxBreakPriority *aBreakPriority);
// Utility getters