diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index b9313dd45cd9..de60239ed047 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5493,6 +5493,32 @@ 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 diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index b84b83c24a21..54343530fdc5 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1649,6 +1649,14 @@ 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); diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 52761d11f434..7d10e7fa5b75 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -226,12 +226,15 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx, nsPoint pt(mRect.x, mRect.y); if (wm.IsVertical()) { if (wm.IsVerticalLR()) { - pt.x += mAscent; + pt.x = NSToCoordFloor( + nsLayoutUtils::GetSnappedBaselineX(mFrame, aCtx, pt.x, mAscent)); } else { - pt.x += mRect.width - mAscent; + pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX( + mFrame, aCtx, pt.x + mRect.width, -mAscent)); } } else { - pt.y += mAscent; + pt.y = NSToCoordFloor( + nsLayoutUtils::GetSnappedBaselineY(mFrame, aCtx, pt.y, mAscent)); } pt += aOffsetFromRect; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 941cd6193334..985258714ef3 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -6414,16 +6414,21 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams, gfx::Point textBaselinePt; if (verticalRun) { if (wm.IsVerticalLR()) { - textBaselinePt.x = aParams.framePt.x + mAscent; + textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX( + this, aParams.context, nscoord(aParams.framePt.x), mAscent); } else { - textBaselinePt.x = aParams.framePt.x + frameWidth - mAscent; + textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX( + this, aParams.context, nscoord(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, - aParams.framePt.y + mAscent); + textBaselinePt = + gfx::Point(reversed ? aParams.framePt.x.value + frameWidth + : aParams.framePt.x.value, + nsLayoutUtils::GetSnappedBaselineY( + this, aParams.context, aParams.framePt.y, mAscent)); } Range range = ComputeTransformedRange(provider); uint32_t startOffset = range.start; diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 8925292c5461..8ba08fa2a999 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -2060,7 +2060,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(geckoview,251-255,1392-1405) skip-if(Android) == 1562733-rotated-nastaliq-1.html 1562733-rotated-nastaliq-1-ref.html #Bug 1604765 +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(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 @@ -2096,7 +2096,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-4,0-8) fuzzy-if(Android,0-3,0-1901) fuzzy-if(winWidget,0-154,0-118) == 1738700-1.html 1738700-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 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 diff --git a/layout/reftests/css-ruby/reftest.list b/layout/reftests/css-ruby/reftest.list index f186fa1e1a62..e432c794269c 100644 --- a/layout/reftests/css-ruby/reftest.list +++ b/layout/reftests/css-ruby/reftest.list @@ -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(OSX||Android,0-198,0-70) == ruby-intercharacter-1.htm ruby-intercharacter-1-ref.htm +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,false) != ruby-intercharacter-1.htm ruby-intercharacter-1-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,true) == 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. diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index 6885dbb5a510..ba62955b041b 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -176,7 +176,7 @@ skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-596) == colrv1-0 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-6806) == 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-8804) == colrv1-01.html#K colrv1-01-ref.html#K +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-67,0-9494) == colrv1-01.html#L colrv1-01-ref.html#L skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-3578) == colrv1-01.html#M colrv1-01-ref.html#M skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-64,0-6116) == colrv1-01.html#N colrv1-01-ref.html#N @@ -188,8 +188,8 @@ skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy(0-255,0-373) == colrv1- 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(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-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-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 diff --git a/layout/reftests/text-svgglyphs/reftest.list b/layout/reftests/text-svgglyphs/reftest.list index 4f37b788ccee..bf606ff350cc 100644 --- a/layout/reftests/text-svgglyphs/reftest.list +++ b/layout/reftests/text-svgglyphs/reftest.list @@ -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(46-77,300-600) == bug1320197-1.html bug1320197-1-ref.html +fuzzy-if(cocoaWidget,0-1,0-33) == 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 diff --git a/layout/reftests/transform-3d/reftest.list b/layout/reftests/transform-3d/reftest.list index 84540a476f9f..e73b31ac585b 100644 --- a/layout/reftests/transform-3d/reftest.list +++ b/layout/reftests/transform-3d/reftest.list @@ -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-255,0-374) == preserve3d-1a.html preserve3d-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 == preserve3d-1b.html about:blank == preserve3d-clipped.html about:blank == preserve3d-2a.html preserve3d-2-ref.html diff --git a/testing/web-platform/meta/css/css-transforms/transform3d-preserve3d-001.html.ini b/testing/web-platform/meta/css/css-transforms/transform3d-preserve3d-001.html.ini index ff5d937a7c93..a42497d31792 100644 --- a/testing/web-platform/meta/css/css-transforms/transform3d-preserve3d-001.html.ini +++ b/testing/web-platform/meta/css/css-transforms/transform3d-preserve3d-001.html.ini @@ -2,4 +2,4 @@ fuzzy: if os == "android": maxDifference=4;totalPixels=185 if os == "mac": maxDifference=198;totalPixels=308 - if os == "win": maxDifference=255;totalPixels=374 + if os == "win": maxDifference=174;totalPixels=240 diff --git a/testing/web-platform/meta/css/css-writing-modes/mongolian-orientation-002.html.ini b/testing/web-platform/meta/css/css-writing-modes/mongolian-orientation-002.html.ini index c47a764bcd6c..ca5f0a6ed869 100644 --- a/testing/web-platform/meta/css/css-writing-modes/mongolian-orientation-002.html.ini +++ b/testing/web-platform/meta/css/css-writing-modes/mongolian-orientation-002.html.ini @@ -1,5 +1,4 @@ [mongolian-orientation-002.html] expected: if (os == "android"): PASS - if (os == "linux"): PASS FAIL