commit 2fb01a56fc98fe55c5558c6703a74362b21603ed
parent 101c9c53771bbfb63c316098a28a00b0dd6fc105
Author: Glenn Watson <git@chillybin.org>
Date: Wed, 3 Dec 2025 07:43:56 +0000
Bug 2001073 - Fix another scrolling jitter issue with fractional scrolling enabled. r=gfx-reviewers,lsalzman
This partially undoes the fix in #1999575, but retains an adjusted
reftest from that patch. The separate fix in #1971253 is actually
the correct fix for this problem, and fixes both of those bugs,
without needing the change in #1999575. Add an additional reftest for
the specific case in this bug.
Differential Revision: https://phabricator.services.mozilla.com/D274881
Diffstat:
5 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/gfx/tests/reftest/2001073-ref.html b/gfx/tests/reftest/2001073-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html class="reftest-wait" style="overflow:hidden">
+<div style="position:sticky;top:0;transform:translateY(100%)">H</div>
+<div style="height:1500px"></div>
+<script>
+window.scrollTo(0, 100.6);
+document.documentElement.classList.remove("reftest-wait");
+</script>
diff --git a/gfx/tests/reftest/2001073.html b/gfx/tests/reftest/2001073.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html class="reftest-wait" style="overflow:hidden">
+<div style="position:sticky;top:0;transform:translateY(100%)">H</div>
+<div style="height:1500px"></div>
+<script>
+window.scrollTo(0, 100.4);
+document.documentElement.classList.remove("reftest-wait");
+</script>
diff --git a/gfx/tests/reftest/reftest.list b/gfx/tests/reftest/reftest.list
@@ -51,3 +51,4 @@ fuzzy(0-2,0-6229) random-if(Android) == 1912431-emoji-globalAlpha.html 1912431-e
== 1961387-1.html 1961387-1-ref.html
== 1961387-2.html 1961387-2-ref.html
skip-if(!cocoaWidget) == 1964225-1.html 1964225-1-ref.html
+skip-if(useDrawSnapshot) == 2001073.html 2001073-ref.html
diff --git a/gfx/wr/webrender/src/spatial_tree.rs b/gfx/wr/webrender/src/spatial_tree.rs
@@ -120,33 +120,14 @@ pub trait SpatialNodeContainer {
fn get_snapping_info(
&self,
parent_index: Option<SpatialNodeIndex>
- ) -> Option<(ScaleOffset, LayoutVector2D)> {
+ ) -> Option<ScaleOffset> {
match parent_index {
Some(parent_index) => {
let node_info = self.get_node_info(parent_index);
-
- match node_info.snapping_transform {
- Some(snapping_transform) => {
- let content_offset = match node_info.node_type {
- SpatialNodeType::StickyFrame(ref info) => {
- info.previously_applied_offset
- }
- SpatialNodeType::ScrollFrame(ref info) => {
- info.external_scroll_offset
- }
- SpatialNodeType::ReferenceFrame(..) => {
- LayoutVector2D::zero()
- }
- };
- Some((snapping_transform, content_offset))
- }
- None => {
- None
- }
- }
+ node_info.snapping_transform
}
None => {
- Some((ScaleOffset::identity(), LayoutVector2D::zero()))
+ Some(ScaleOffset::identity())
}
}
}
@@ -1420,32 +1401,21 @@ pub fn get_external_scroll_offset<S: SpatialNodeContainer>(
}
fn calculate_snapping_transform(
- parent_info: Option<(ScaleOffset, LayoutVector2D)>,
+ parent_scale_offset: Option<ScaleOffset>,
node_type: &SpatialNodeType,
) -> Option<ScaleOffset> {
// We need to incorporate the parent scale/offset with the child.
// If the parent does not have a scale/offset, then we know we are
// not 2d axis aligned and thus do not need to snap its children
// either.
- let (parent_scale_offset, content_fract_offset) = match parent_info {
- Some((transform, content_offset)) => {
- (
- transform,
- LayoutVector2D::new(
- content_offset.x.fract(),
- content_offset.y.fract(),
- )
- )
- }
+ let parent_scale_offset = match parent_scale_offset {
+ Some(transform) => transform,
None => return None,
};
let scale_offset = match node_type {
SpatialNodeType::ReferenceFrame(ref info) => {
- // Ensure that if a parent external scroll offset has a fractional component
- // that this doesn't affect the snapping calculations during scene building
- // (the overall scroll offset is snapped to device pixel by the spatial tree)
- let origin_offset = info.origin_in_parent_reference_frame - content_fract_offset;
+ let origin_offset = info.origin_in_parent_reference_frame;
match info.source_transform {
PropertyBinding::Value(ref value) => {
diff --git a/gfx/wr/wrench/reftests/snap/content-offset.yaml b/gfx/wr/wrench/reftests/snap/content-offset.yaml
@@ -11,6 +11,7 @@ root:
external-scroll-offset: [0, 50.1]
items:
- type: stacking-context
+ bounds: [0, -1.0, 0, 0]
transform: translate(100, 0.4)
items:
- type: rect