Backed out 2 changesets (bug 1851952) for reftest failure on hyphens-1.html

Backed out changeset e6e18eed2d76 (bug 1851952)
Backed out changeset 3c81bf22f846 (bug 1851952)
This commit is contained in:
Narcis Beleuzu 2024-01-09 21:15:52 +02:00
Родитель 2f962cf032
Коммит a8c700aee3
14 изменённых файлов: 57 добавлений и 134 удалений

Просмотреть файл

@ -32,7 +32,6 @@
#include "gfxHarfBuzzShaper.h"
#include "gfxUserFontSet.h"
#include "nsCRT.h"
#include "nsContentUtils.h"
#include "nsSpecialCasingData.h"
#include "nsTextRunTransformations.h"
#include "nsUGenCategory.h"
@ -729,30 +728,10 @@ void gfxShapedText::SetupClusterBoundaries(uint32_t aOffset,
// preceding letter by any letter-spacing or justification.
const char16_t kBengaliVirama = 0x09CD;
const char16_t kBengaliYa = 0x09AF;
// Characters treated as hyphens for the purpose of "emergency" breaking
// when the content would otherwise overflow.
auto isHyphen = [](char16_t c) {
return c == char16_t('-') || // HYPHEN-MINUS
c == 0x2010 || // HYPHEN
c == 0x2012 || // FIGURE DASH
c == 0x2013 || // EN DASH
c == 0x058A; // ARMENIAN HYPHEN
};
bool prevWasHyphen = false;
while (pos < aLength) {
const char16_t ch = aString[pos];
if (prevWasHyphen) {
if (nsContentUtils::IsAlphanumeric(ch)) {
glyphs[pos].SetCanBreakBefore(
CompressedGlyph::FLAG_BREAK_TYPE_EMERGENCY_WRAP);
}
prevWasHyphen = false;
}
if (ch == char16_t(' ') || ch == kIdeographicSpace) {
glyphs[pos].SetIsSpace();
} else if (isHyphen(ch) && pos &&
nsContentUtils::IsAlphanumeric(aString[pos - 1])) {
prevWasHyphen = true;
} else if (ch == kBengaliYa) {
// Unless we're at the start, check for a preceding virama.
if (pos > 0 && aString[pos - 1] == kBengaliVirama) {
@ -774,25 +753,14 @@ void gfxShapedText::SetupClusterBoundaries(uint32_t aOffset,
const uint8_t* aString,
uint32_t aLength) {
CompressedGlyph* glyphs = GetCharacterGlyphs() + aOffset;
uint32_t pos = 0;
bool prevWasHyphen = false;
while (pos < aLength) {
uint8_t ch = aString[pos];
if (prevWasHyphen) {
if (nsContentUtils::IsAlphanumeric(ch)) {
glyphs->SetCanBreakBefore(
CompressedGlyph::FLAG_BREAK_TYPE_EMERGENCY_WRAP);
}
prevWasHyphen = false;
}
if (ch == uint8_t(' ')) {
const uint8_t* limit = aString + aLength;
while (aString < limit) {
if (*aString == uint8_t(' ')) {
glyphs->SetIsSpace();
} else if (ch == uint8_t('-') && pos &&
nsContentUtils::IsAlphanumeric(aString[pos - 1])) {
prevWasHyphen = true;
}
++pos;
++glyphs;
aString++;
glyphs++;
}
}

Просмотреть файл

@ -762,8 +762,6 @@ class gfxShapedText {
FLAG_BREAK_TYPE_NONE = 0,
FLAG_BREAK_TYPE_NORMAL = 1,
FLAG_BREAK_TYPE_HYPHEN = 2,
// Allow break before this position if needed to avoid overflow:
FLAG_BREAK_TYPE_EMERGENCY_WRAP = 3,
FLAG_CHAR_IS_SPACE = 0x10000000U,
@ -888,7 +886,7 @@ class gfxShapedText {
}
// Returns FLAGS_CAN_BREAK_BEFORE if the setting changed, 0 otherwise
uint32_t SetCanBreakBefore(uint8_t aCanBreakBefore) {
MOZ_ASSERT(aCanBreakBefore <= 3, "Bogus break-flags value!");
MOZ_ASSERT(aCanBreakBefore <= 2, "Bogus break-before value!");
uint32_t breakMask = (uint32_t(aCanBreakBefore) << FLAGS_CAN_BREAK_SHIFT);
uint32_t toggle = breakMask ^ (mValue & FLAGS_CAN_BREAK_BEFORE);
mValue ^= toggle;
@ -1371,7 +1369,6 @@ class gfxShapedWord final : public gfxShapedText {
memset(mCharGlyphsStorage, 0, aLength * sizeof(CompressedGlyph));
uint8_t* text = reinterpret_cast<uint8_t*>(&mCharGlyphsStorage[aLength]);
memcpy(text, aText, aLength * sizeof(uint8_t));
SetupClusterBoundaries(0, aText, aLength);
}
gfxShapedWord(const char16_t* aText, uint32_t aLength, Script aRunScript,

Просмотреть файл

@ -249,11 +249,7 @@ bool gfxTextRun::SetPotentialLineBreaks(Range aRange,
canBreak = CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
}
// If a break is allowed here, set the break flag, but don't clear a
// possible pre-existing emergency-break flag already in the run.
if (canBreak) {
changed |= cg->SetCanBreakBefore(canBreak);
}
changed |= cg->SetCanBreakBefore(canBreak);
++cg;
}
return changed != 0;
@ -931,8 +927,6 @@ uint32_t gfxTextRun::BreakAndMeasureText(
gfxFloat aWidth, const PropertyProvider& aProvider,
SuppressBreak aSuppressBreak, gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, bool aCanWordWrap, bool aCanWhitespaceWrap,
bool aIsBreakSpaces,
// output params:
TrimmableWS* aOutTrimmableWhitespace, Metrics& aOutMetrics,
bool& aOutUsedHyphenation, uint32_t& aOutLastBreak,
gfxBreakPriority& aBreakPriority) {
@ -1039,8 +1033,7 @@ uint32_t gfxTextRun::BreakAndMeasureText(
// would trigger an infinite loop.
if (aSuppressBreak != eSuppressAllBreaks &&
(aSuppressBreak != eSuppressInitialBreak || i > aStart)) {
bool atNaturalBreak = mCharacterGlyphs[i].CanBreakBefore() ==
CompressedGlyph::FLAG_BREAK_TYPE_NORMAL;
bool atNaturalBreak = mCharacterGlyphs[i].CanBreakBefore() == 1;
// atHyphenationBreak indicates we're at a "soft" hyphen, where an extra
// hyphen glyph will need to be painted. It is NOT set for breaks at an
// explicit hyphen present in the text.
@ -1053,20 +1046,16 @@ uint32_t gfxTextRun::BreakAndMeasureText(
atHyphenationBreak &&
hyphenBuffer[i - aStart] == HyphenType::AutoWithManualInSameWord;
bool atBreak = atNaturalBreak || atHyphenationBreak;
bool wordWrapping =
(aCanWordWrap ||
(aCanWhitespaceWrap &&
mCharacterGlyphs[i].CanBreakBefore() ==
CompressedGlyph::FLAG_BREAK_TYPE_EMERGENCY_WRAP)) &&
mCharacterGlyphs[i].IsClusterStart() &&
aBreakPriority <= gfxBreakPriority::eWordWrapBreak;
bool wordWrapping = aCanWordWrap &&
mCharacterGlyphs[i].IsClusterStart() &&
aBreakPriority <= gfxBreakPriority::eWordWrapBreak;
bool whitespaceWrapping = false;
if (i > aStart) {
// The spec says the breaking opportunity is *after* whitespace.
auto const& g = mCharacterGlyphs[i - 1];
whitespaceWrapping =
aIsBreakSpaces &&
aCanWhitespaceWrap &&
(g.CharIsSpace() || g.CharIsTab() || g.CharIsNewline());
}

Просмотреть файл

@ -464,7 +464,6 @@ class gfxTextRun : public gfxShapedText {
gfxFloat aWidth, const PropertyProvider& aProvider,
SuppressBreak aSuppressBreak, gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, bool aCanWordWrap, bool aCanWhitespaceWrap,
bool aIsBreakSpaces,
// Output parameters:
TrimmableWS* aOutTrimmableWhitespace, // may be null
Metrics& aOutMetrics, bool& aOutUsedHyphenation, uint32_t& aOutLastBreak,

Просмотреть файл

@ -9566,8 +9566,7 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
uint32_t transformedCharsFit = mTextRun->BreakAndMeasureText(
transformedOffset, transformedLength, HasAnyStateBits(TEXT_START_OF_LINE),
availWidth, provider, suppressBreak, boundingBoxType, aDrawTarget,
textStyle->WordCanWrap(this), textStyle->WhiteSpaceCanWrap(this),
isBreakSpaces,
textStyle->WordCanWrap(this), isBreakSpaces,
// The following are output parameters:
canTrimTrailingWhitespace || whitespaceCanHang ? &trimmableWS : nullptr,
textMetrics, usedHyphenation, transformedLastBreak,

Просмотреть файл

@ -4,9 +4,9 @@
</head>
<body>
<p>6-<br>Bromo-<br>2,4,5-<br>trichlorophenol</p>
<p>6-Bromo-<br>2,4,5-<br>trichlorophenol<p>
<p>2,3,5,6-<br>Tetrafluorophenol</p>
<p>4-<br>Bromo-<br>2-<br>fluoro-<br>6-<br>nitrophenol</p>
<p>4-Bromo-<br>2-fluoro-<br>6-nitrophenol</p>
</body>
</html>

Просмотреть файл

@ -4,7 +4,7 @@
</head>
<body>
<p>6-Bromo-2,4,5-trichlorophenol</p>
<p>6-Bromo-2,4,5-trichlorophenol<p>
<p>2,3,5,6-Tetrafluorophenol</p>
<p>4-Bromo-2-fluoro-6-nitrophenol</p>

Просмотреть файл

@ -18,6 +18,12 @@ p {
</head>
<body>
The green examples should break at all their hyphens; the red ones should not.
<p class="nobreak">
T-shirt
</p>
<p class="nobreak">
billy-o
</p>
<p class="break">
tally-<br>ho
</p>
@ -58,19 +64,5 @@ Lee-<br>on-<br>the-<br>Solent
<p class="nobreak">
:-D
</p>
<!-- these break due to "emergency" overflow wrapping -->
<p class="break">
T-<br>shirt
</p>
<p class="break">
billy-<br>o
</p>
<!-- but here the emergency wrap is not forced -->
<p class="nobreak">
Supersized<br>T-shirt
</p>
<p class="nobreak">
Going like<br>billy-o
</p>
</body>
</html>

Просмотреть файл

@ -19,6 +19,12 @@ p {
</head>
<body>
The green examples should break at all their hyphens; the red ones should not.
<p class="nobreak">
T-shirt
</p>
<p class="nobreak">
billy-o
</p>
<p class="break">
tally-ho
</p>
@ -59,19 +65,5 @@ Lee-on-the-Solent
<p class="nobreak">
:-D
</p>
<!-- these break due to "emergency" overflow wrapping -->
<p class="break">
T-shirt
</p>
<p class="break">
billy-o
</p>
<!-- but here the emergency wrap is not forced -->
<p class="nobreak" style="width:17ch">
Supersized T-shirt
</p>
<p class="nobreak" style="width:17ch">
Going like billy-o
</p>
</body>
</html>

Просмотреть файл

@ -4,12 +4,12 @@
</head>
<body>
<p>2007-<br>01-<br>01</p>
<p>2007-<br>Jan-<br>01</p>
<p>Jan-<br>01-<br>2007</p>
<p>2007-<br>01-<br>01&nbsp;00:00:00</p>
<p>2007-<br>Jan-<br>01&nbsp;00:00:00</p>
<p>Jan-<br>01-<br>2007&nbsp;00:00:00</p>
<p>2007-01-01</p>
<p>2007-<br>Jan-01</p>
<p>Jan-01-2007</p>
<p>2007-01-01&nbsp;00:00:00</p>
<p>2007-<br>Jan-01&nbsp;00:00:00</p>
<p>Jan-01-2007&nbsp;00:00:00</p>
<p>2007/01/01</p>
<p>2007/Jan/01</p>

Просмотреть файл

@ -1,46 +1,39 @@
<html>
<head>
<style type="text/css">
p {
font-family: "Times New Roman", serif;
margin: 5px 1em;
width: 0;
white-space: nowrap;
}
</style>
<style type="text/css"> p { margin: 5px 1em; width: 0; white-space: nowrap; } </style>
</head>
<body>
<p>ab-<br>ab</p>
<p>a-<br>ab</p>
<p>ab-<br>a</p>
<p>a-ab</p>
<p>ab-a</p>
<p>abcdef--<br>abcdef</p>
<p>------abcdef<p>
<!-- U+058A is ARMENIAN HYPHEN -->
<p>&#x561;&#x562;&#x058A;<br>&#x561;&#x562;</p>
<p>&#x561;&#x058A;<br>&#x561;&#x562;</p>
<p>&#x561;&#x562;&#x058A;<br>&#x561;</p>
<p>&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;&#x058A;&#x058A;<br>&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;</p>
<p>&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;<p>
<p>ab&#x058A;<br>ab</p>
<p>a&#x058A;ab</p>
<p>ab&#x058A;a</p>
<p>abcdef&#x058A;&#x058A;<br>abcdef</p>
<p>&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;abcdef<p>
<!-- U+2010 is HYPHEN -->
<p>ab&#x2010;<br>ab</p>
<p>a&#x2010;<br>ab</p>
<p>ab&#x2010;<br>a</p>
<p>a&#x2010;ab</p>
<p>ab&#x2010;a</p>
<p>abcdef&#x2010;&#x2010;<br>abcdef</p>
<p>&#x2010;&#x2010;&#x2010;&#x2010;&#x2010;&#x2010;abcdef<p>
<!-- U+2012 is FIGURE DASH -->
<p>ab&#x2012;<br>ab</p>
<p>a&#x2012;<br>ab</p>
<p>ab&#x2012;<br>a</p>
<p>a&#x2012;ab</p>
<p>ab&#x2012;a</p>
<p>abcdef&#x2012;&#x2012;<br>abcdef</p>
<p>&#x2012;&#x2012;&#x2012;&#x2012;&#x2012;&#x2012;abcdef<p>
<p>ab&ndash;<br>ab</p>
<p>a&ndash;<br>ab</p>
<p>ab&ndash;<br>a</p>
<p>a&ndash;ab</p>
<p>ab&ndash;a</p>
<p>abcdef&ndash;&ndash;<br>abcdef</p>
<p>&ndash;&ndash;&ndash;&ndash;&ndash;&ndash;abcdef<p>

Просмотреть файл

@ -1,12 +1,6 @@
<html>
<head>
<style type="text/css">
p {
font-family: "Times New Roman", serif;
margin: 5px 1em;
width: 0;
}
</style>
<style type="text/css"> p { margin: 5px 1em; width: 0; } </style>
</head>
<body>
@ -17,11 +11,11 @@ p {
<p>------abcdef<p>
<!-- U+058A is ARMENIAN HYPHEN -->
<p>&#x561;&#x562;&#x058A;&#x561;&#x562;</p>
<p>&#x561;&#x058A;&#x561;&#x562;</p>
<p>&#x561;&#x562;&#x058A;&#x561;</p>
<p>&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;&#x058A;&#x058A;&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;</p>
<p>&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x561;&#x562;&#x563;&#x564;&#x565;&#x566;<p>
<p>ab&#x058A;ab</p>
<p>a&#x058A;ab</p>
<p>ab&#x058A;a</p>
<p>abcdef&#x058A;&#x058A;abcdef</p>
<p>&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;&#x058A;abcdef<p>
<!-- U+2010 is HYPHEN -->
<p>ab&#x2010;ab</p>

Просмотреть файл

@ -1,2 +1,2 @@
<!DOCTYPE html>
<div lang="en">e-<br>mail-<br>ing</div>
<div lang="en">e-mail-<br>ing</div>

Просмотреть файл

@ -6,6 +6,6 @@
</head>
<body>
<div>f<br/>o<br/>x<br/>f<br/>-<br/>o<br/></div><br/>
<div>fox<br/>f-<br>o</div><br/>
<div>fox<br/>f-o</div><br/>
</body>
</html>