From 735a5635db9f794cf1a9b355345c31e963e7c961 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 5 Oct 2018 14:03:49 -0400 Subject: [PATCH] Apply a basis change on the perspective transform. When applying async scrolling transforms, the perspective matrix also needs to be adjusted with a basis change. This is a version of #3154 that doesn't break async scrolling on 2D-transformed elements. Although this passes the required test cases and displays correct behaviour, the intuition behind why this works is not really clear to me; see https://bugzilla.mozilla.org/show_bug.cgi?id=1415272#c23 onwards for some discussion. --- webrender/src/spatial_node.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webrender/src/spatial_node.rs b/webrender/src/spatial_node.rs index 529b8b8ad6..bccbf90d41 100644 --- a/webrender/src/spatial_node.rs +++ b/webrender/src/spatial_node.rs @@ -251,10 +251,15 @@ impl SpatialNode { SpatialNodeType::ReferenceFrame(ref mut info) => { // Resolve the transform against any property bindings. let source_transform = scene_properties.resolve_layout_transform(&info.source_transform); + // Do a change-basis operation on the perspective matrix using + // the scroll offset. + let scrolled_perspective = info.source_perspective + .pre_translate(&state.parent_accumulated_scroll_offset) + .post_translate(-state.parent_accumulated_scroll_offset); info.resolved_transform = LayoutFastTransform::with_vector(info.origin_in_parent_reference_frame) .pre_mul(&source_transform.into()) - .pre_mul(&info.source_perspective); + .pre_mul(&scrolled_perspective); // The transformation for this viewport in world coordinates is the transformation for // our parent reference frame, plus any accumulated scrolling offsets from nodes