From bba96a1ef7646e6f3c0435b80c73043c897e505b Mon Sep 17 00:00:00 2001 From: Xianzhu Wang Date: Fri, 10 May 2024 17:12:24 -0700 Subject: [PATCH] [css-anchor-position-1] Fix flicker with try-option with fixed-position anchor Previously we supposed the default anchor wouldn't change in try-options, but the latest draft spec allows that. When the currently tried option will use a default anchor that is different from the currently used default anchor, checking overflow with the snapshotted AnchorPositionScrollData will be incorrect, and the incorrect results caused oscillation between try options. To resolve that, when the total offset is requested for a different default anchor, we need to calculate it on the fly instead of getting it from the snapshotted result. Also allow one more layout if ValidateSnapshot() (called after the first layout in a document lifecycle update) finds that the snapshotted scroll data needs update, to ensure correct layout and paint with the changed anchor and scroll adjustment in most cases. In rare cases when we need more than one additional layout to get the stable layout, ShouldScheduleNextService() will schedule another lifecycle. Fixed: 338929745 Change-Id: I295fbc605ac8b7f0298eef7aeff4434c6bd54628 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5529048 Reviewed-by: Ian Kilpatrick Reviewed-by: Philip Rogers Commit-Queue: Xianzhu Wang Cr-Commit-Position: refs/heads/main@{#1299608} --- ...tion-try-switch-from-fixed-anchor-ref.html | 33 +++++++++++ ...position-try-switch-from-fixed-anchor.html | 57 +++++++++++++++++++ ...sition-try-switch-to-fixed-anchor-ref.html | 37 ++++++++++++ .../position-try-switch-to-fixed-anchor.html | 53 +++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 css/css-anchor-position/position-try-switch-from-fixed-anchor-ref.html create mode 100644 css/css-anchor-position/position-try-switch-from-fixed-anchor.html create mode 100644 css/css-anchor-position/position-try-switch-to-fixed-anchor-ref.html create mode 100644 css/css-anchor-position/position-try-switch-to-fixed-anchor.html diff --git a/css/css-anchor-position/position-try-switch-from-fixed-anchor-ref.html b/css/css-anchor-position/position-try-switch-from-fixed-anchor-ref.html new file mode 100644 index 00000000000000..72026a2f63e0be --- /dev/null +++ b/css/css-anchor-position/position-try-switch-from-fixed-anchor-ref.html @@ -0,0 +1,33 @@ + + +
+
+
diff --git a/css/css-anchor-position/position-try-switch-from-fixed-anchor.html b/css/css-anchor-position/position-try-switch-from-fixed-anchor.html new file mode 100644 index 00000000000000..904aa55180dafd --- /dev/null +++ b/css/css-anchor-position/position-try-switch-from-fixed-anchor.html @@ -0,0 +1,57 @@ + + + +CSS Anchor Positioning Test: @position-try with different default anchors, + switching to fixed-position anchor on scroll and back on another scroll + + + + + +
+
+
+ diff --git a/css/css-anchor-position/position-try-switch-to-fixed-anchor-ref.html b/css/css-anchor-position/position-try-switch-to-fixed-anchor-ref.html new file mode 100644 index 00000000000000..254cbf3df455da --- /dev/null +++ b/css/css-anchor-position/position-try-switch-to-fixed-anchor-ref.html @@ -0,0 +1,37 @@ + + + +
+
+
+ diff --git a/css/css-anchor-position/position-try-switch-to-fixed-anchor.html b/css/css-anchor-position/position-try-switch-to-fixed-anchor.html new file mode 100644 index 00000000000000..54fcb2e4df3d61 --- /dev/null +++ b/css/css-anchor-position/position-try-switch-to-fixed-anchor.html @@ -0,0 +1,53 @@ + + + +CSS Anchor Positioning Test: @position-try with different default anchors, switching to fixed-position anchor on scroll + + + + + +
+
+
+