Bug 1824531 - Remove baseline-snapping from nsTextFrame::PaintText, as it may interact poorly with APZ. r=emilio

In my local testing, this seems to be harmless, but we should be alert for reports of any erratic
or poorly-rasterized text that results.

Differential Revision: https://phabricator.services.mozilla.com/D173633
This commit is contained in:
Jonathan Kew 2023-03-26 21:44:32 +00:00
parent fd46e50bda
commit ee1583a0a9
11 changed files with 38 additions and 79 deletions

View File

@ -5493,32 +5493,6 @@ nscolor nsLayoutUtils::DarkenColorIfNeeded(nsIFrame* aFrame, nscolor aColor) {
return ShouldDarkenColors(aFrame) ? DarkenColor(aColor) : aColor;
}
gfxFloat nsLayoutUtils::GetSnappedBaselineY(nsIFrame* aFrame,
gfxContext* aContext, nscoord aY,
nscoord aAscent) {
gfxFloat appUnitsPerDevUnit = aFrame->PresContext()->AppUnitsPerDevPixel();
gfxFloat baseline = gfxFloat(aY) + aAscent;
gfxRect putativeRect(0, baseline / appUnitsPerDevUnit, 1, 1);
if (!aContext->UserToDevicePixelSnapped(
putativeRect, gfxContext::SnapOption::IgnoreScale)) {
return baseline;
}
return aContext->DeviceToUser(putativeRect.TopLeft()).y * appUnitsPerDevUnit;
}
gfxFloat nsLayoutUtils::GetSnappedBaselineX(nsIFrame* aFrame,
gfxContext* aContext, nscoord aX,
nscoord aAscent) {
gfxFloat appUnitsPerDevUnit = aFrame->PresContext()->AppUnitsPerDevPixel();
gfxFloat baseline = gfxFloat(aX) + aAscent;
gfxRect putativeRect(baseline / appUnitsPerDevUnit, 0, 1, 1);
if (!aContext->UserToDevicePixelSnapped(
putativeRect, gfxContext::SnapOption::IgnoreScale)) {
return baseline;
}
return aContext->DeviceToUser(putativeRect.TopLeft()).x * appUnitsPerDevUnit;
}
// Hard limit substring lengths to 8000 characters ... this lets us statically
// size the cluster buffer array in FindSafeLength
#define MAX_GFX_TEXT_BUF_SIZE 8000

View File

@ -1649,14 +1649,6 @@ class nsLayoutUtils {
return DarkenColorIfNeeded(aFrame, color);
}
// Get a baseline y position in app units that is snapped to device pixels.
static gfxFloat GetSnappedBaselineY(nsIFrame* aFrame, gfxContext* aContext,
nscoord aY, nscoord aAscent);
// Ditto for an x position (for vertical text). Note that for vertical-rl
// writing mode, the ascent value should be negated by the caller.
static gfxFloat GetSnappedBaselineX(nsIFrame* aFrame, gfxContext* aContext,
nscoord aX, nscoord aAscent);
static nscoord AppUnitWidthOfString(char16_t aC, nsFontMetrics& aFontMetrics,
DrawTarget* aDrawTarget) {
return AppUnitWidthOfString(&aC, 1, aFontMetrics, aDrawTarget);

View File

@ -226,15 +226,12 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
nsPoint pt(mRect.x, mRect.y);
if (wm.IsVertical()) {
if (wm.IsVerticalLR()) {
pt.x = NSToCoordFloor(
nsLayoutUtils::GetSnappedBaselineX(mFrame, aCtx, pt.x, mAscent));
pt.x += mAscent;
} else {
pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX(
mFrame, aCtx, pt.x + mRect.width, -mAscent));
pt.x += mRect.width - mAscent;
}
} else {
pt.y = NSToCoordFloor(
nsLayoutUtils::GetSnappedBaselineY(mFrame, aCtx, pt.y, mAscent));
pt.y += mAscent;
}
pt += aOffsetFromRect;

View File

@ -6416,21 +6416,16 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
gfx::Point textBaselinePt;
if (verticalRun) {
if (wm.IsVerticalLR()) {
textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX(
this, aParams.context, nscoord(aParams.framePt.x), mAscent);
textBaselinePt.x = aParams.framePt.x + mAscent;
} else {
textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX(
this, aParams.context, nscoord(aParams.framePt.x) + frameWidth,
-mAscent);
textBaselinePt.x = aParams.framePt.x + frameWidth - mAscent;
}
textBaselinePt.y = reversed ? aParams.framePt.y.value + frameHeight
: aParams.framePt.y.value;
} else {
textBaselinePt =
gfx::Point(reversed ? aParams.framePt.x.value + frameWidth
: aParams.framePt.x.value,
nsLayoutUtils::GetSnappedBaselineY(
this, aParams.context, aParams.framePt.y, mAscent));
textBaselinePt = gfx::Point(reversed ? aParams.framePt.x.value + frameWidth
: aParams.framePt.x.value,
aParams.framePt.y + mAscent);
}
Range range = ComputeTransformedRange(provider);
uint32_t startOffset = range.start;

View File

@ -2064,7 +2064,7 @@ pref(image.downscale-during-decode.enabled,true) skip-if(((gtkWidget&&isDebugBui
== 1558937-1.html 1558937-1-ref.html
!= 1563484.html 1563484-notref.html
== 1563484.html 1563484-ref.html
fuzzy-if(!winWidget,251-255,464-1613) fuzzy-if(geckoview,251-255,1392-1405) skip-if(Android) == 1562733-rotated-nastaliq-1.html 1562733-rotated-nastaliq-1-ref.html #Bug 1604765
fuzzy-if(geckoview,251-255,1392-1405) skip-if(Android) == 1562733-rotated-nastaliq-1.html 1562733-rotated-nastaliq-1-ref.html #Bug 1604765
fuzzy-if(winWidget,0-31,0-3) fuzzy-if(geckoview,0-93,0-87) == 1562733-rotated-nastaliq-2.html 1562733-rotated-nastaliq-2-ref.html
test-pref(plain_text.wrap_long_lines,false) != 1565129.txt 1565129.txt
fuzzy(0-32,0-8) fuzzy-if(Android,0-32,0-1458) == 1576553-1.html 1576553-1-ref.html
@ -2100,7 +2100,7 @@ skip-if(Android) == 1727172-1.xhtml 1727172-1-ref.html
== 1726663-1.html 1726663-1-ref.html
== 1727016-1.html 1727016-1-ref.html
!= 1730314-1.html 1730314-1-ref.html
fuzzy(0-3,0-3) fuzzy-if(Android,0-3,0-1901) fuzzy-if(winWidget,0-154,0-118) == 1738700-1.html 1738700-1-ref.html
fuzzy(0-4,0-8) fuzzy-if(Android,0-3,0-1901) fuzzy-if(winWidget,0-154,0-118) == 1738700-1.html 1738700-1-ref.html
skip-if(Android||!browserIsFission) fuzzy(255-255,171000-171000) HTTP == 1743533-1.html 1743533-1-ref.html # do not decrease the fuzz! this is a not equal test, the high fuzz minimum is to ensure they differ by enough.
== 1743560-1.html 1743560-1-ref.html
== 1743851-1.html 1743851-1-ref.html

View File

@ -23,9 +23,9 @@ test-pref(font.minimum-size.ja,16) == min-font-size-1.html min-font-size-1-ref.h
load nested-ruby-1.html
# Inter-character ruby is not enabled, and its spec is not considered stable enough.
pref(layout.css.ruby.intercharacter.enabled,true) fuzzy-if(Android,0-198,0-70) == ruby-intercharacter-1.htm ruby-intercharacter-1-ref.htm
pref(layout.css.ruby.intercharacter.enabled,true) fuzzy-if(OSX||Android,0-198,0-70) == ruby-intercharacter-1.htm ruby-intercharacter-1-ref.htm
pref(layout.css.ruby.intercharacter.enabled,false) != ruby-intercharacter-1.htm ruby-intercharacter-1-ref.htm
pref(layout.css.ruby.intercharacter.enabled,true) == ruby-intercharacter-2.htm ruby-intercharacter-2-ref.htm
pref(layout.css.ruby.intercharacter.enabled,true) fuzzy-if(OSX||Android,0-83,0-186) == ruby-intercharacter-2.htm ruby-intercharacter-2-ref.htm
pref(layout.css.ruby.intercharacter.enabled,false) != ruby-intercharacter-2.htm ruby-intercharacter-2-ref.htm
# Testing a specific bug for RTL handling.

View File

@ -166,30 +166,30 @@ fuzzy-if(OSX,198-198,172-172) == color-1b.html color-1-ref.html
# These are skipped on Win7 because lack of font-variation support means the COLR table
# in the test font CAhem.ttf will be dropped.
defaults pref(gfx.font_rendering.colr_v1.enabled,true)
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == colrv1-01.html#A colrv1-01-ref.html#A
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == colrv1-01.html#B colrv1-01-ref.html#B
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-10000) == colrv1-01.html#C colrv1-01-ref.html#C
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-600) == colrv1-01.html#D colrv1-01-ref.html#D
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-200) == colrv1-01.html#E colrv1-01-ref.html#E
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-200) == colrv1-01.html#F colrv1-01-ref.html#F
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-400) == colrv1-01.html#G colrv1-01-ref.html#G
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-400) == colrv1-01.html#H colrv1-01-ref.html#H
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-10000) == colrv1-01.html#I colrv1-01-ref.html#I
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-576) == colrv1-01.html#J colrv1-01-ref.html#J
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-748) == colrv1-01.html#K colrv1-01-ref.html#K
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-851) == colrv1-01.html#L colrv1-01-ref.html#L
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-668) == colrv1-01.html#M colrv1-01-ref.html#M
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-848) == colrv1-01.html#N colrv1-01-ref.html#N
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-675) == colrv1-01.html#O colrv1-01-ref.html#O
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == colrv1-01.html#P colrv1-01-ref.html#P
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-138,0-318) == colrv1-01.html#Q colrv1-01-ref.html#Q
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-214,0-158) == colrv1-01.html#R colrv1-01-ref.html#R
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-255,0-156) == colrv1-01.html#S colrv1-01-ref.html#S
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-237,0-277) == colrv1-01.html#T colrv1-01-ref.html#T
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-200) == colrv1-01.html#A colrv1-01-ref.html#A
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-32,0-200) == colrv1-01.html#B colrv1-01-ref.html#B
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-8,0-10100) == colrv1-01.html#C colrv1-01-ref.html#C
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-600) == colrv1-01.html#D colrv1-01-ref.html#D
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-200) == colrv1-01.html#E colrv1-01-ref.html#E
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-200) == colrv1-01.html#F colrv1-01-ref.html#F
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-596) == colrv1-01.html#G colrv1-01-ref.html#G
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-596) == colrv1-01.html#H colrv1-01-ref.html#H
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-10100) == colrv1-01.html#I colrv1-01-ref.html#I
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-6766) == colrv1-01.html#J colrv1-01-ref.html#J
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-748) fuzzy-if(OSX,255-255,8752-8766) == colrv1-01.html#K colrv1-01-ref.html#K
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-67,0-9472) == colrv1-01.html#L colrv1-01-ref.html#L
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-3470) == colrv1-01.html#M colrv1-01-ref.html#M
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-5976) == colrv1-01.html#N colrv1-01-ref.html#N
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-80,0-5376) == colrv1-01.html#O colrv1-01-ref.html#O
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-112,0-300) == colrv1-01.html#P colrv1-01-ref.html#P
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-138,0-484) == colrv1-01.html#Q colrv1-01-ref.html#Q
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-214,0-461) == colrv1-01.html#R colrv1-01-ref.html#R
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-255,0-373) == colrv1-01.html#S colrv1-01-ref.html#S
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-237,0-477) == colrv1-01.html#T colrv1-01-ref.html#T
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-1) == colrv1-03.html colrv1-03-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-1800) fuzzy-if(Android,0-64,0-37100) == colrv1-04.html colrv1-04-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy-if(Android,8-8,1484-1484) == colrv1-05.html colrv1-05-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-1800) fuzzy-if(OSX,128-128,3582-3582) fuzzy-if(Android,0-64,0-37100) == colrv1-04.html colrv1-04-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy-if(Android,8-8,1484-1484) fuzzy-if(OSX,64-64,1200-1200) == colrv1-05.html colrv1-05-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-1,0-291) == colrv1-06.html colrv1-06-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-128,0-264) == colrv1-07.html colrv1-07-ref.html
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == colrv1-08.html colrv1-08-ref.html

View File

@ -27,7 +27,7 @@ fuzzy(0-15,0-152) == svg-glyph-mask.svg svg-glyph-mask-ref.svg
== svg-glyph-transform.svg svg-glyph-transform-ref.svg
== svg-glyph-extents.html svg-glyph-extents-ref.html
== svg-glyph-compressed.html svg-glyph-compressed-ref.html
fuzzy-if(cocoaWidget,0-1,0-33) == bug1320197-1.html bug1320197-1-ref.html
fuzzy(46-77,300-600) == bug1320197-1.html bug1320197-1-ref.html
fuzzy-if(winWidget,0-137,0-198) fuzzy-if(Android,0-81,0-96) == svg-in-ot-bitmap-1.html svg-in-ot-bitmap-1-ref.html
defaults

View File

@ -11,7 +11,7 @@ fuzzy(0-1,0-6) == rotatey-1a.html rotatey-1-ref.html
== rotatex-perspective-1c.html rotatex-1-ref.html
== rotatex-perspective-3a.html rotatex-perspective-3-ref.html
== scalez-1a.html scalez-1-ref.html
fuzzy(0-16,0-346) fuzzy-if(cocoaWidget,0-200,0-310) fuzzy-if(winWidget,0-175,0-250) == preserve3d-1a.html preserve3d-1-ref.html
fuzzy(0-16,0-346) fuzzy-if(cocoaWidget,0-200,0-310) fuzzy-if(winWidget,0-255,0-374) == preserve3d-1a.html preserve3d-1-ref.html
== preserve3d-1b.html about:blank
== preserve3d-clipped.html about:blank
== preserve3d-2a.html preserve3d-2-ref.html

View File

@ -2,4 +2,4 @@
fuzzy:
if os == "android": maxDifference=4;totalPixels=185
if os == "mac": maxDifference=198;totalPixels=308
if os == "win": maxDifference=174;totalPixels=240
if os == "win": maxDifference=255;totalPixels=374

View File

@ -1,4 +1,5 @@
[mongolian-orientation-002.html]
expected:
if (os == "android"): PASS
if (os == "linux"): PASS
FAIL