Backed out 4 changesets (bug 1765093) for causing web-platform-test failures on boundary-shaping-010.html CLOSED TREE

Backed out changeset 4f24833ac254 (bug 1765093)
Backed out changeset 6e5b336588d1 (bug 1765093)
Backed out changeset 17d5218d84b7 (bug 1765093)
Backed out changeset bbc194412080 (bug 1765093)
This commit is contained in:
Cristian Tuns 2022-05-06 17:08:52 -04:00
parent 858d232088
commit f1a3cc8348
7 changed files with 52 additions and 150 deletions

View File

@ -68,8 +68,6 @@
"talos/tests/perf-reftest-singletons/style-attr-1.html",
"talos/tests/perf-reftest-singletons/style-sharing-style-attr.html",
"talos/tests/perf-reftest-singletons/style-sharing.html",
"talos/tests/perf-reftest-singletons/svg-text-textLength-1.html",
"talos/tests/perf-reftest-singletons/svg-text-getExtentOfChar-1.html",
"talos/tests/perf-reftest-singletons/tiny-traversal-singleton.html",
"talos/tests/perf-reftest-singletons/window-named-property-get.html",
"webkit/PerformanceTests/Speedometer/index.html",

View File

@ -409,26 +409,21 @@ bool gfxTextRun::GetAdjustedSpacingArray(
return true;
}
bool gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange) const {
if (aRange->start >= aRange->end) {
return false;
}
void gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange) const {
if (aRange->start >= aRange->end) return;
const CompressedGlyph* charGlyphs = mCharacterGlyphs;
bool adjusted = false;
while (aRange->start < aRange->end &&
!charGlyphs[aRange->start].IsLigatureGroupStart()) {
++aRange->start;
adjusted = true;
}
if (aRange->end < GetLength()) {
while (aRange->end > aRange->start &&
!charGlyphs[aRange->end].IsLigatureGroupStart()) {
--aRange->end;
adjusted = true;
}
}
return adjusted;
}
void gfxTextRun::DrawGlyphs(gfxFont* aFont, Range aRange, gfx::Point* aPt,
@ -674,12 +669,11 @@ void gfxTextRun::Draw(const Range aRange, const gfx::Point aPt,
}
Range ligatureRange(runRange);
bool adjusted = ShrinkToLigatureBoundaries(&ligatureRange);
ShrinkToLigatureBoundaries(&ligatureRange);
bool drawPartial =
adjusted &&
((aParams.drawMode & (DrawMode::GLYPH_FILL | DrawMode::GLYPH_STROKE)) ||
(aParams.drawMode == DrawMode::GLYPH_PATH && aParams.callbacks));
(aParams.drawMode & (DrawMode::GLYPH_FILL | DrawMode::GLYPH_STROKE)) ||
(aParams.drawMode == DrawMode::GLYPH_PATH && aParams.callbacks);
gfx::Point origPt = pt;
if (drawPartial) {
@ -737,13 +731,11 @@ void gfxTextRun::DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
uint32_t start = iter.GetStringStart();
uint32_t end = iter.GetStringEnd();
Range ligatureRange(start, end);
bool adjusted = ShrinkToLigatureBoundaries(&ligatureRange);
ShrinkToLigatureBoundaries(&ligatureRange);
if (adjusted) {
inlineCoord +=
direction * ComputePartialLigatureWidth(
Range(start, ligatureRange.start), aProvider);
}
inlineCoord +=
direction * ComputePartialLigatureWidth(
Range(start, ligatureRange.start), aProvider);
AutoTArray<PropertyProvider::Spacing, 200> spacingBuffer;
bool haveSpacing = GetAdjustedSpacingArray(ligatureRange, aProvider,
@ -752,10 +744,8 @@ void gfxTextRun::DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
font->DrawEmphasisMarks(this, &aPt, ligatureRange.start,
ligatureRange.Length(), params);
if (adjusted) {
inlineCoord += direction * ComputePartialLigatureWidth(
Range(ligatureRange.end, end), aProvider);
}
inlineCoord += direction * ComputePartialLigatureWidth(
Range(ligatureRange.end, end), aProvider);
}
}
@ -820,17 +810,12 @@ gfxTextRun::Metrics gfxTextRun::MeasureText(
uint32_t start = iter.GetStringStart();
uint32_t end = iter.GetStringEnd();
Range ligatureRange(start, end);
bool adjusted = ShrinkToLigatureBoundaries(&ligatureRange);
ShrinkToLigatureBoundaries(&ligatureRange);
if (adjusted) {
AccumulatePartialLigatureMetrics(
font, Range(start, ligatureRange.start), aBoundingBoxType,
aRefDrawTarget, aProvider, iter.GetGlyphRun()->mOrientation,
&accumulatedMetrics);
AccumulatePartialLigatureMetrics(
font, Range(ligatureRange.end, end), aBoundingBoxType, aRefDrawTarget,
aProvider, iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
}
AccumulatePartialLigatureMetrics(
font, Range(start, ligatureRange.start), aBoundingBoxType,
aRefDrawTarget, aProvider, iter.GetGlyphRun()->mOrientation,
&accumulatedMetrics);
// XXX This sucks. We have to get glyph extents just so we can detect
// glyphs outside the font box, even when aBoundingBoxType is LOOSE,
@ -840,26 +825,15 @@ gfxTextRun::Metrics gfxTextRun::MeasureText(
AccumulateMetricsForRun(
font, ligatureRange, aBoundingBoxType, aRefDrawTarget, aProvider,
ligatureRange, iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
AccumulatePartialLigatureMetrics(
font, Range(ligatureRange.end, end), aBoundingBoxType, aRefDrawTarget,
aProvider, iter.GetGlyphRun()->mOrientation, &accumulatedMetrics);
}
return accumulatedMetrics;
}
void gfxTextRun::GetLineHeightMetrics(Range aRange, gfxFloat& aAscent,
gfxFloat& aDescent) const {
Metrics accumulatedMetrics;
GlyphRunIterator iter(this, aRange);
while (iter.NextRun()) {
gfxFont* font = iter.GetGlyphRun()->mFont;
auto metrics =
font->Measure(this, 0, 0, gfxFont::LOOSE_INK_EXTENTS, nullptr, nullptr,
iter.GetGlyphRun()->mOrientation);
accumulatedMetrics.CombineWith(metrics, false);
}
aAscent = accumulatedMetrics.mAscent;
aDescent = accumulatedMetrics.mDescent;
}
#define MEASUREMENT_BUFFER_SIZE 100
void gfxTextRun::ClassifyAutoHyphenations(uint32_t aStart, Range aRange,
@ -1218,14 +1192,12 @@ gfxFloat gfxTextRun::GetAdvanceWidth(
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
Range ligatureRange = aRange;
bool adjusted = ShrinkToLigatureBoundaries(&ligatureRange);
ShrinkToLigatureBoundaries(&ligatureRange);
gfxFloat result =
adjusted ? ComputePartialLigatureWidth(
Range(aRange.start, ligatureRange.start), aProvider) +
ComputePartialLigatureWidth(
Range(ligatureRange.end, aRange.end), aProvider)
: 0.0;
gfxFloat result = ComputePartialLigatureWidth(
Range(aRange.start, ligatureRange.start), aProvider) +
ComputePartialLigatureWidth(
Range(ligatureRange.end, aRange.end), aProvider);
if (aSpacing) {
aSpacing->mBefore = aSpacing->mAfter = 0;
@ -1257,15 +1229,13 @@ gfxFloat gfxTextRun::GetMinAdvanceWidth(Range aRange) {
MOZ_ASSERT(aRange.end <= GetLength(), "Substring out of range");
Range ligatureRange = aRange;
bool adjusted = ShrinkToLigatureBoundaries(&ligatureRange);
ShrinkToLigatureBoundaries(&ligatureRange);
gfxFloat result =
adjusted
? std::max(ComputePartialLigatureWidth(
Range(aRange.start, ligatureRange.start), nullptr),
ComputePartialLigatureWidth(
Range(ligatureRange.end, aRange.end), nullptr))
: 0.0;
std::max(ComputePartialLigatureWidth(
Range(aRange.start, ligatureRange.start), nullptr),
ComputePartialLigatureWidth(Range(ligatureRange.end, aRange.end),
nullptr));
// Compute min advance width by assuming each grapheme cluster takes its own
// line.

View File

@ -312,12 +312,6 @@ class gfxTextRun : public gfxShapedText {
aDrawTargetForTightBoundingBox, aProvider);
}
void GetLineHeightMetrics(Range aRange, gfxFloat& aAscent,
gfxFloat& aDescent) const;
void GetLineHeightMetrics(gfxFloat& aAscent, gfxFloat& aDescent) const {
GetLineHeightMetrics(Range(this), aAscent, aDescent);
}
/**
* Computes just the advance width for a substring.
* Uses GetSpacing from aBreakProvider.
@ -834,8 +828,7 @@ class gfxTextRun : public gfxShapedText {
// Advance aRange.start to the start of the nearest ligature, back
// up aRange.end to the nearest ligature end; may result in
// aRange->start == aRange->end.
// Returns whether any adjustment was made.
bool ShrinkToLigatureBoundaries(Range* aRange) const;
void ShrinkToLigatureBoundaries(Range* aRange) const;
// result in appunits
gfxFloat GetPartialLigatureWidth(Range aRange,
PropertyProvider* aProvider) const;

View File

@ -126,7 +126,13 @@ static void GetAscentAndDescentInAppUnits(nsTextFrame* aFrame,
gfxTextRun::Range range = ConvertOriginalToSkipped(
it, aFrame->GetContentOffset(), aFrame->GetContentLength());
textRun->GetLineHeightMetrics(range, aAscent, aDescent);
// We pass in null for the PropertyProvider since letter-spacing and
// word-spacing should not affect the ascent and descent values we get.
gfxTextRun::Metrics metrics =
textRun->MeasureText(range, gfxFont::LOOSE_INK_EXTENTS, nullptr, nullptr);
aAscent = metrics.mAscent;
aDescent = metrics.mDescent;
}
/**
@ -273,23 +279,26 @@ static nscoord GetBaselinePosition(nsTextFrame* aFrame, gfxTextRun* aTextRun,
StyleDominantBaseline aDominantBaseline,
float aFontSizeScaleFactor) {
WritingMode writingMode = aFrame->GetWritingMode();
gfxFloat ascent, descent;
aTextRun->GetLineHeightMetrics(ascent, descent);
// We pass in null for the PropertyProvider since letter-spacing and
// word-spacing should not affect the ascent and descent values we get.
gfxTextRun::Metrics metrics =
aTextRun->MeasureText(gfxFont::LOOSE_INK_EXTENTS, nullptr);
auto convertIfVerticalRL = [&](gfxFloat dominantBaseline) {
return writingMode.IsVerticalRL() ? ascent + descent - dominantBaseline
: dominantBaseline;
return writingMode.IsVerticalRL()
? metrics.mAscent + metrics.mDescent - dominantBaseline
: dominantBaseline;
};
switch (aDominantBaseline) {
case StyleDominantBaseline::Hanging:
return convertIfVerticalRL(ascent * 0.2);
return convertIfVerticalRL(metrics.mAscent * 0.2);
case StyleDominantBaseline::TextBeforeEdge:
return convertIfVerticalRL(0);
case StyleDominantBaseline::Alphabetic:
return writingMode.IsVerticalRL()
? ascent * 0.5
? metrics.mAscent * 0.5
: aFrame->GetLogicalBaseline(writingMode);
case StyleDominantBaseline::Auto:
@ -303,12 +312,13 @@ static nscoord GetBaselinePosition(nsTextFrame* aFrame, gfxTextRun* aTextRun,
case StyleDominantBaseline::TextAfterEdge:
case StyleDominantBaseline::Ideographic:
return writingMode.IsVerticalLR() ? 0 : ascent + descent;
return writingMode.IsVerticalLR() ? 0
: metrics.mAscent + metrics.mDescent;
case StyleDominantBaseline::Central:
return (ascent + descent) / 2.0;
return (metrics.mAscent + metrics.mDescent) / 2.0;
case StyleDominantBaseline::Mathematical:
return convertIfVerticalRL(ascent / 2.0);
return convertIfVerticalRL(metrics.mAscent / 2.0);
}
MOZ_ASSERT_UNREACHABLE("unexpected dominant-baseline value");

View File

@ -28,8 +28,6 @@
% http://localhost/tests/perf-reftest-singletons/style-attr-1.html
% http://localhost/tests/perf-reftest-singletons/style-sharing-style-attr.html
% http://localhost/tests/perf-reftest-singletons/style-sharing.html
% http://localhost/tests/perf-reftest-singletons/svg-text-textLength-1.html
% http://localhost/tests/perf-reftest-singletons/svg-text-getExtentOfChar-1.html
% http://localhost/tests/perf-reftest-singletons/tiny-traversal-singleton.html
% http://localhost/tests/perf-reftest-singletons/window-named-property-get.html
# When modifying this list, please also update build/pgo/index.html.

View File

@ -1,36 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="util.js"></script>
<body>
<svg width="144130" height="20" style="visibility:hidden">
<rect width="144130" height="20" fill="#555"/>
<g fill="#fff" font-family="sans-serif" font-size="110">
<!-- The use of textLength here forces adjusted positioning of all the glyphs,
which may put the SVG layout engine under some strain -->
<text id="test" x="500" y="140" transform="scale(.1)" textLength="2440730"></text>
</g>
</svg>
<script>
window.onload = function() {
// "word0 word1 word2 ... word99 " -> 690 chars
text = "";
for (i = 0; i < 100; i++) {
text = text + "word" + i + " ";
}
// 6 doublings -> approx 44k chars
for (i = 0; i < 6; i++) {
text = text + text;
}
// set the text and force a reflow
testElem = document.getElementById("test");
testElem.textContent = text;
flush_layout();
// try calling getExtentOfChar for some of the characters
len = text.length / 2;
perf_start();
for (i = 0; i < len; i++) {
testElem.getExtentOfChar(i);
}
perf_finish();
}
</script>

View File

@ -1,31 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="util.js"></script>
<body>
<svg width="144130" height="20" style="visibility:hidden">
<rect width="144130" height="20" fill="#555"/>
<g fill="#fff" font-family="sans-serif" font-size="110">
<!-- The use of textLength here forces adjusted positioning of all the glyphs,
which may put the SVG layout engine under some strain -->
<text id="test" x="500" y="140" transform="scale(.1)" textLength="2440730"></text>
</g>
</svg>
<script>
window.onload = function() {
// "word0 word1 word2 ... word99 " -> 690 chars
text = "";
for (i = 0; i < 100; i++) {
text = text + "word" + i + " ";
}
// 6 doublings -> approx 44k chars
for (i = 0; i < 6; i++) {
text = text + text;
}
// set the text and time how long a reflow takes
testElem = document.getElementById("test");
testElem.textContent = text;
perf_start();
flush_layout();
perf_finish();
}
</script>