Bug 1703213 - Disallow soft line break between adjacent IDEOGRAPHIC SPACE characters. r=m_kato

Differential Revision: https://phabricator.services.mozilla.com/D111065
This commit is contained in:
Jonathan Kew 2021-04-08 09:41:48 +00:00
parent cfad2d513e
commit fd668cd57a
26 changed files with 32 additions and 70 deletions

View File

@ -587,8 +587,9 @@ void gfxShapedText::SetupClusterBoundaries(uint32_t aOffset,
}
}
const char16_t kIdeographicSpace = 0x3000;
while (!iter.AtEnd()) {
if (*iter == char16_t(' ')) {
if (*iter == char16_t(' ') || *iter == kIdeographicSpace) {
glyphs->SetIsSpace();
}
// advance iter to the next cluster-start (or end of text)

View File

@ -1014,24 +1014,25 @@ void LineBreaker::GetJISx4051Breaks(const char16_t* aChars, uint32_t aLength,
uint32_t chLen = ch > 0xFFFFu ? 2 : 1;
int8_t cl;
auto prev = [=]() -> char32_t {
if (!cur) {
return 0;
}
char32_t c = aChars[cur - 1];
if (cur > 1 && NS_IS_SURROGATE_PAIR(aChars[cur - 2], c)) {
c = SURROGATE_TO_UCS4(aChars[cur - 2], c);
}
return c;
};
if (NEED_CONTEXTUAL_ANALYSIS(ch)) {
char32_t prev, next;
if (cur > 0) {
// not using state.GetUnicodeCharAt() here because we're looking back
// rather than forward for possible surrogates
prev = aChars[cur - 1];
if (cur > 1 && NS_IS_SURROGATE_PAIR(aChars[cur - 2], prev)) {
prev = SURROGATE_TO_UCS4(aChars[cur - 2], prev);
}
} else {
prev = 0;
}
char32_t next;
if (cur + chLen < aLength) {
next = state.GetUnicodeCharAt(cur + chLen);
} else {
next = 0;
}
cl = ContextualAnalysis(prev, ch, next, state, aLevel,
cl = ContextualAnalysis(prev(), ch, next, state, aLevel,
aIsChineseOrJapanese);
} else {
if (ch == U_EQUAL) state.NotifySeenEqualsSign();
@ -1064,18 +1065,24 @@ void LineBreaker::GetJISx4051Breaks(const char16_t* aChars, uint32_t aLength,
if (cur > 0) {
NS_ASSERTION(CLASS_COMPLEX != lastClass || CLASS_COMPLEX != cl,
"Loop should have prevented adjacent complex chars here");
auto prev = [=]() {
char32_t c = aChars[cur - 1];
if (cur > 1 && NS_IS_SURROGATE_PAIR(aChars[cur - 2], c)) {
c = SURROGATE_TO_UCS4(aChars[cur - 2], c);
}
return c;
};
allowBreak =
(state.UseConservativeBreaking() ? GetPairConservative(lastClass, cl)
: GetPair(lastClass, cl)) &&
(aWordBreak != WordBreak::KeepAll ||
!SuppressBreakForKeepAll(prev(), ch));
: GetPair(lastClass, cl));
// Special cases where a normally-allowed break is suppressed:
if (allowBreak) {
// word-break:keep-all suppresses breaks between certain line-break
// classes.
if (aWordBreak == WordBreak::KeepAll &&
SuppressBreakForKeepAll(prev(), ch)) {
allowBreak = false;
}
// We also don't allow a break within a run of U+3000 chars unless
// word-break:break-all is in effect.
if (ch == 0x3000 && prev() == 0x3000 &&
aWordBreak != WordBreak::BreakAll) {
allowBreak = false;
}
}
}
aBreakBefore[cur] = allowBreak;
if (allowBreak) state.NotifyBreakBefore();

View File

@ -26,7 +26,7 @@ div {
<tr><th>U+2009</th><td><div>&#x2000;&#x2009;</div></td></tr>
<tr><th>U+200A</th><td><div>&#x2000;&#x200A;</div></td></tr>
<tr><th>U+200B</th><td><div>&#x2000;&#x200B;</div></td></tr>
<tr><th>U+3000</th><td><div>&#x3000;<br>&#x3000;</div></td></tr>
<tr><th>U+3000</th><td><div>&#x3000;&#x3000;</div></td></tr>
</table>
</body>
</html>

View File

@ -1,2 +0,0 @@
[hyphens-auto-003.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[text-transform-fullwidth-008.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-003.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-004.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-005.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-006.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-008.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-010.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-011.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-012.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-013.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-014.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-015.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-016.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-017.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-018.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-019.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-020.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-021.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-022.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-023.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-024.html]
expected: FAIL

View File

@ -1,2 +0,0 @@
[trailing-ideographic-space-025.html]
expected: FAIL