commit fdc8f4dba119903c206a6115035a8f4a95debfd9 parent a49dc3702d34a5175014fb5ea642ffe5588c5fbd Author: Glenn Watson <git@chillybin.org> Date: Mon, 1 Dec 2025 23:06:24 +0000 Bug 2001524 - Disable ShouldSnapToGrid in more cases. r=tnikkel Move snapping of reference frame origins to WR, where we can remove the (potentially fractional) external scroll offset reliably. The old non-WR render paths need to keep snapping enabled here. Mark one animated transform test fuzzy on windows, which appears to be caused by a separate bug in the animation / snapping code, to be fixed as a follow up. Differential Revision: https://phabricator.services.mozilla.com/D273529 Diffstat:
8 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/dom/encoding/test/reftest/reftest.list b/dom/encoding/test/reftest/reftest.list @@ -1,5 +1,5 @@ == bug863728-1.html bug863728-1-ref.html -fuzzy(0-128,0-281) fuzzy-if(winWidget,47-137,211-251) == bug863728-2.html bug863728-2-ref.html # win/fission: bug 1717838 +fuzzy(0-141,0-281) fuzzy-if(winWidget,47-137,211-251) == bug863728-2.html bug863728-2-ref.html # win/fission: bug 1717838 == bug863728-3.html bug863728-3-ref.html == bug945215-1.html bug945215-1-ref.html -fuzzy(0-128,0-281) fuzzy-if(winWidget,47-137,211-251) == bug945215-2.html bug945215-2-ref.html # win/fission: bug 1717838 +fuzzy(0-141,0-281) fuzzy-if(winWidget,47-137,211-251) == bug945215-2.html bug945215-2-ref.html # win/fission: bug 1717838 diff --git a/gfx/wr/webrender/src/spatial_node.rs b/gfx/wr/webrender/src/spatial_node.rs @@ -446,8 +446,34 @@ impl SpatialNode { ReferenceFrameKind::Transform { .. } => source_transform, }; + // Previously, the origin of a stacking context transform was snapped + // in Gecko. However, this causes jittering issues during scrolling in + // some cases when fractional scrolling is enabled. The origin used in + // Gecko doesn't have the external scroll offset from the content process + // removed, so if that content-side scroll amount is fractional, it can + // cause inconsistent snapping during scene building. Instead, we need + // to apply the device-pixel snap _after_ the external scroll offset + // has been removed. To further complicate matters, we _don't_ want to + // snap this if this spatial node has a snapping transform, as we rely + // on the fractional intermediate nodes in order to arrive at a correct + // final snapping result. If we don't have a snapping offset, we've + // reached a spatial node where snapping will no longer apply (e.g. a + // complex transform) and then we need to snap the device pixel position + // of that transform. + let parent_origin = match self.snapping_transform { + Some(..) => { + info.origin_in_parent_reference_frame + } + None => { + snap_offset( + info.origin_in_parent_reference_frame, + state.coordinate_system_relative_scale_offset.scale, + ) + } + }; + let resolved_transform = - LayoutFastTransform::with_vector(info.origin_in_parent_reference_frame) + LayoutFastTransform::with_vector(parent_origin) .pre_transform(&source_transform); // The transformation for this viewport in world coordinates is the transformation for diff --git a/gfx/wr/wrench/reftests/filters/blend-clipped.png b/gfx/wr/wrench/reftests/filters/blend-clipped.png Binary files differ. diff --git a/gfx/wr/wrench/reftests/tiles/tile-cache-raster-root.png b/gfx/wr/wrench/reftests/tiles/tile-cache-raster-root.png Binary files differ. diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp @@ -1925,6 +1925,11 @@ void nsLayoutUtils::PostTranslate(Matrix4x4& aTransform, const nsPoint& aOrigin, } bool nsLayoutUtils::ShouldSnapToGrid(const nsIFrame* aFrame) { + // TODO: Remove this function when this pref is being removed. + if (StaticPrefs::layout_disable_pixel_alignment()) { + return aFrame && aFrame->IsSVGOuterSVGAnonChildFrame(); + } + return !aFrame || !aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || aFrame->IsSVGOuterSVGAnonChildFrame(); } diff --git a/layout/reftests/writing-mode/reftest.list b/layout/reftests/writing-mode/reftest.list @@ -151,7 +151,7 @@ test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLin random-if(gtkWidget) == 1193519-sideways-lr-1.html 1193519-sideways-lr-1-ref.html random-if(gtkWidget) == 1193519-sideways-lr-2.html 1193519-sideways-lr-2-ref.html fuzzy-if(winWidget,0-3,0-84) == 1193519-sideways-lr-3.html 1193519-sideways-lr-3-ref.html -fuzzy-if(winWidget,0-3,0-112) fails-if(Android) random-if(gtkWidget) == 1193519-sideways-lr-4.html 1193519-sideways-lr-4-ref.html # see bug 1366692. Rounding error with WR enabled, and on Android. +fuzzy-if(winWidget,0-3,0-112) random-if(gtkWidget) == 1193519-sideways-lr-4.html 1193519-sideways-lr-4-ref.html # see bug 1366692. Rounding error with WR enabled, and on Android. fuzzy-if(gtkWidget,0-255,0-12) fuzzy-if(cocoaWidget,0-65,0-69) fuzzy-if(geckoview,0-255,0-13) == 1193519-sideways-lr-decoration-1.html 1193519-sideways-lr-decoration-1-ref.html == 1196887-1-computed-display-inline-block.html 1196887-1-computed-display-inline-block-ref.html diff --git a/testing/web-platform/meta/css/css-transforms/individual-transform/animation/individual-transform-combine.html.ini b/testing/web-platform/meta/css/css-transforms/individual-transform/animation/individual-transform-combine.html.ini @@ -0,0 +1,3 @@ +[individual-transform-combine.html] + fuzzy: + if (os == "win") and not swgl: maxDifference=255-255;totalPixels=596-596 diff --git a/testing/web-platform/meta/css/css-transforms/transform-input-009.html.ini b/testing/web-platform/meta/css/css-transforms/transform-input-009.html.ini @@ -0,0 +1,3 @@ +[transform-input-009.html] + fuzzy: + if useDrawSnapshot: maxDifference=0-52;totalPixels=0-115