зеркало из https://github.com/mozilla/gecko-dev.git
Bug 628825 - Don't break line by Break After. r=TYLin,jfkthame
Legacy segmenter breaks line by some Break After properties. But UAX#14 rule doesn't break Break After (BA) at force. So I would like to remove some legacy rules that isn't ASCII white space from `nsLineBreaker`. Differential Revision: https://phabricator.services.mozilla.com/D192174
This commit is contained in:
Родитель
11d085b63c
Коммит
c9e6ad1c35
|
@ -252,7 +252,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
NS_ASSERTION(!mAfterBreakableSpace && !mBreakHere,
|
NS_ASSERTION(!mAfterBreakableSpace && !mBreakHere,
|
||||||
"These should not be set");
|
"These should not be set");
|
||||||
|
|
||||||
while (offset < aLength && !IsSpace(aText[offset])) {
|
while (offset < aLength && !IsSegmentSpace(aText[offset])) {
|
||||||
mCurrentWord.AppendElement(aText[offset]);
|
mCurrentWord.AppendElement(aText[offset]);
|
||||||
if (!mCurrentWordMightBeBreakable &&
|
if (!mCurrentWordMightBeBreakable &&
|
||||||
!IsNonBreakableChar<char16_t>(aText[offset], mLegacyBehavior)) {
|
!IsNonBreakableChar<char16_t>(aText[offset], mLegacyBehavior)) {
|
||||||
|
@ -306,7 +306,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
offset = aLength;
|
offset = aLength;
|
||||||
while (offset > start) {
|
while (offset > start) {
|
||||||
--offset;
|
--offset;
|
||||||
if (IsSpace(aText[offset])) {
|
if (IsSegmentSpace(aText[offset])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char16_t ch = aText[offset];
|
char16_t ch = aText[offset];
|
||||||
bool isSpace = IsSpace(ch);
|
bool isSpace = IsSegmentSpace(ch);
|
||||||
bool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
|
bool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
|
||||||
|
|
||||||
if (aSink && !noBreaksNeeded) {
|
if (aSink && !noBreaksNeeded) {
|
||||||
|
@ -442,7 +442,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
NS_ASSERTION(!mAfterBreakableSpace && !mBreakHere,
|
NS_ASSERTION(!mAfterBreakableSpace && !mBreakHere,
|
||||||
"These should not be set");
|
"These should not be set");
|
||||||
|
|
||||||
while (offset < aLength && !IsSpace(aText[offset])) {
|
while (offset < aLength && !IsSegmentSpace(aText[offset])) {
|
||||||
mCurrentWord.AppendElement(aText[offset]);
|
mCurrentWord.AppendElement(aText[offset]);
|
||||||
if (!mCurrentWordMightBeBreakable &&
|
if (!mCurrentWordMightBeBreakable &&
|
||||||
!IsNonBreakableChar<uint8_t>(aText[offset], mLegacyBehavior)) {
|
!IsNonBreakableChar<uint8_t>(aText[offset], mLegacyBehavior)) {
|
||||||
|
@ -486,7 +486,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
offset = aLength;
|
offset = aLength;
|
||||||
while (offset > start) {
|
while (offset > start) {
|
||||||
--offset;
|
--offset;
|
||||||
if (IsSpace(aText[offset])) {
|
if (IsSegmentSpace(aText[offset])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ nsresult nsLineBreaker::AppendText(nsAtom* aHyphenationLanguage,
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint8_t ch = aText[offset];
|
uint8_t ch = aText[offset];
|
||||||
bool isSpace = IsSpace(ch);
|
bool isSpace = IsSegmentSpace(ch);
|
||||||
bool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
|
bool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
|
||||||
|
|
||||||
if (aSink) {
|
if (aSink) {
|
||||||
|
|
|
@ -242,6 +242,16 @@ class nsLineBreaker {
|
||||||
const char16_t* aTextStart,
|
const char16_t* aTextStart,
|
||||||
const char16_t* aTextLimit, uint8_t* aBreakState);
|
const char16_t* aTextLimit, uint8_t* aBreakState);
|
||||||
|
|
||||||
|
inline constexpr bool IsSegmentSpace(char16_t u) const {
|
||||||
|
if (mLegacyBehavior) {
|
||||||
|
return nsLineBreaker::IsSpace(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
return u == 0x0020 || // SPACE u
|
||||||
|
u == 0x0009 || // CHARACTER TABULATION
|
||||||
|
u == 0x000D; // CARRIAGE RETURN
|
||||||
|
}
|
||||||
|
|
||||||
AutoTArray<char16_t, 100> mCurrentWord;
|
AutoTArray<char16_t, 100> mCurrentWord;
|
||||||
// All the items that contribute to mCurrentWord
|
// All the items that contribute to mCurrentWord
|
||||||
AutoTArray<TextItem, 2> mTextItems;
|
AutoTArray<TextItem, 2> mTextItems;
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[word-break-break-all-ethiopic.html]
|
|
||||||
expected: FAIL
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>CSS Text — line breaking around Break After and Exclamation</title>
|
||||||
|
<meta name=assert content="When ‘white-space’ allows wrapping, line breaking behavior defined for BA and EX line-breaking classes in [UAX14] must be honored.">
|
||||||
|
<link rel=help href="https://www.w3.org/TR/css-text-3/#line-breaking">
|
||||||
|
<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=628825">
|
||||||
|
<link rel=author title="Makoto Kato" href="mailto:m_kato@ga2.so-net.ne.jp">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<style>
|
||||||
|
.test > div {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 25px;
|
||||||
|
width: 1ch;
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="test">
|
||||||
|
<div id="nonbreakable1">X፡!</div>
|
||||||
|
<div id="nonbreakable2">X !</div>
|
||||||
|
<div id="nonbreakable3">X !</div>
|
||||||
|
<div id="nonbreakable4">X !</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
test(function() {
|
||||||
|
assert_true(document.getElementById('nonbreakable1').offsetHeight <= 35);
|
||||||
|
}, "U+0x1361 (BA) and U+0x0021 (EX)");
|
||||||
|
test(function() {
|
||||||
|
assert_true(document.getElementById('nonbreakable2').offsetHeight <= 35);
|
||||||
|
}, "U+0x1680 (BA) and U+0x0021 (EX)");
|
||||||
|
test(function() {
|
||||||
|
assert_true(document.getElementById('nonbreakable3').offsetHeight <= 35);
|
||||||
|
}, "U+0x2009 (BA) and U+0x0021 (EX)");
|
||||||
|
test(function() {
|
||||||
|
assert_true(document.getElementById('nonbreakable4').offsetHeight <= 35);
|
||||||
|
}, "U+0x205F (BA) and U+0x0021 (EX)");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id='log'></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче