When visiting a text frame with many continuations, traversing ancestors to compute the
transform to the ancestor scroll frame can become very hot. This commit changes the
algorithm to translate all the text continuations to an ancestor that can then be
transformed just once.
Differential Revision: https://phabricator.services.mozilla.com/D17730
--HG--
extra : moz-landing-system : lando
A continuation text frame's rect will be considered when visiting the primary
frame via 'FindScrollAnchoringBoundingRect', so we have no reason to compute
the same rect again if for some reason we have excluded the primary text frame.
Differential Revision: https://phabricator.services.mozilla.com/D17729
--HG--
extra : moz-landing-system : lando
The important piece is just that we don't queue a selection for later. This code runs
for each scroll, so we'd be wasting a lot of effort to do that.
Differential Revision: https://phabricator.services.mozilla.com/D17050
--HG--
extra : moz-landing-system : lando
This commit changes ScrollAnchorContainer to store the offset between the scroll anchoring
bounding rect start edge and the scroll-port start edge in the block axis of the scroll frame.
The logic to clamp the negative portions of scroll anchor bounding rect is also amended
to only clamp the portion that is beyond the border start edge in the block axis of the
scroll frame.
Differential Revision: https://phabricator.services.mozilla.com/D16757
--HG--
extra : rebase_source : 43b5bc4ece7f90cb38e3a7186a764d9cddac90f9
extra : source : f26d953d76fcfb02a5fa46cb62e389f852592fe9
This commit adds two new telemetry probes to collect:
1. The amount of scroll anchoring adjustments applied
2. The total absolute length in CSS pixels of scroll anchoring adjustments
Both of these metrics are collected on a per top-level-document basis, and
reported with other use-counters.
Differential Revision: https://phabricator.services.mozilla.com/D16271
--HG--
extra : source : 43081bb8f4eac598a3103753965d5b60dfd1c3fa
extra : amend_source : 3d53dc56616f9e48799b7d8b8c11e96007d3c6eb
extra : intermediate-source : 6da6a7ff2d794c25b61858d16fe97e5f309e0f1f
We currently perform anchor adjustment in three spots:
1. If the target of RestyleManager::RecomputePosition is in a scroll anchor chain
2. If the reflow root is in a scroll anchor chain
3. In nsHTMLScrollFrame::DidReflow, for itself
It looks like it's possible for a scroll anchor container to be adjusted by (1)
and (2 or 3) in the same PresShell flush.
This should be okay, except that we consume mSuppressAnchorAdjustment when
performing an adjustment, and this can lead us to miss the second time that
we perform adjustments in a PresShell flush.
This commit reworks how we run anchor adjustments so that we collect all
scroll anchor containers that should be adjusted, and only perform the
adjustments once.
Differential Revision: https://phabricator.services.mozilla.com/D16407
--HG--
extra : source : cbdbd08379d99f9d55f756c57d728c28331be5da
The scroll anchoring bounding rect of a node can be influenced by absolutely
positioned descendants with very negative offsets. This can cause undesired
scroll adjustments, and has been seen on the web in Gmail. The spec needs to
be amended to say what to do here. Chrome currently will clamp the vertical
offset. This commit implements a stop-gap to clamp the negative portions to
fix this issue, while we do more research and spec-work.
Differential Revision: https://phabricator.services.mozilla.com/D16625
--HG--
extra : rebase_source : 882ac29fca602ae398ffa74bf5747a8eeb4e9329
extra : amend_source : b6537c3626c5bae60285a4e55399b69ad52206b4
extra : source : ecc18f11431e2da2676962c82962932b4465fb38
This commit adds a debug pref that will highlight the frames that are marked as
anchor nodes. This is helpful to debug anchor selection.
Differential Revision: https://phabricator.services.mozilla.com/D13276
--HG--
extra : rebase_source : 4b782de348454ad5660366814d4fe290ff2be152
extra : source : d8eef8f3e396d3a6f82607f53fc280316f184e86
This commit implements the first half of the heuristics to detect style changes
that could lead to feedback loops with scroll anchoring. [1]
When these style changes are made, a suppression flag is added to the anchor
container to ignore any adjustments that would be made at the next layout flush
and to invalidate the anchor at that time.
[1] https://drafts.csswg.org/css-scroll-anchoring/#suppression-triggers
Differential Revision: https://phabricator.services.mozilla.com/D13271
--HG--
extra : rebase_source : db0bf373e51325b7ef537c4c245ede4b4219d0d7
extra : source : d9445a5f3458b560fbdb7aee5faabb5a7a9327f3
This commit implements anchor offset adjustment. When the position of a frame
that is an anchor is changed during reflow, we notify the anchor container. The
anchor container will then post a reflow callback.
Then when reflow is completed, the anchor container will perform a scroll to
keep the anchor node in the same relative position.
Differential Revision: https://phabricator.services.mozilla.com/D13270
--HG--
extra : rebase_source : 9d40a5d5b73777d0da3799f162eeb85bb8e6d8f0
extra : source : d9052f7b34d9857863b66d64797f8b0b82504bec
This commit adds a mechanism for scroll anchor containers to request an anchor
node selection at a future time. Currently this is before styling so that anchor
adjustment suppression will have current anchor nodes.
Differential Revision: https://phabricator.services.mozilla.com/D13269
--HG--
extra : rebase_source : 7af2dcc7953e446eb993625fa7ff32aa5a141eab
extra : source : e7124fecb7215769a5404c5f2268bbe715162393
This commit implements candidate selection for a scroll frame using a frame tree
traversal. It roughly tries to follow the algorithm given in the scroll
anchoring draft specification, adapted to operate on the frame tree [1].
Some details, such as not selecting an anchor if the user hasn't scrolled are
not currently in the specification but will be to match Blink's implementation.
Once a scroll anchor has been selected, we maintain a bit on it and its ancestor
frame's states. This is used in a later commit to detect changes to position
during a reflow so the scroll frame can perform an adjustment.
A scroll anchor will be invalidated when the user scrolls the frame or the
scroll anchor is destroyed. Later commits will add logic to drive selection and
invalidation appropriately.
[1] https://drafts.csswg.org/css-scroll-anchoring/#anchor-node-selection
Differential Revision: https://phabricator.services.mozilla.com/D13268
--HG--
extra : rebase_source : e05ba48662aafef5957322def33ddc5d93f3ca5a
extra : source : bdb766faa8679386bf4e9740781262ea4bb36544
This commit adds a barebones class called 'ScrollAnchorContainer' that will
contain most of the logic for scroll anchoring. It is owned as a member of
ScrollFrameHelper, and has the same lifetime.
Differential Revision: https://phabricator.services.mozilla.com/D13267
--HG--
extra : rebase_source : 41f6f7691af60401f18f98a89f1878cfad2e74d3
extra : source : 3033401ef320414ef5f489c53526d015c38a89d7
This commit adds a debug pref that will highlight the frames that are marked as
anchor nodes. This is helpful to debug anchor selection.
Differential Revision: https://phabricator.services.mozilla.com/D13276
--HG--
extra : rebase_source : 61109b3d967f0e4f8e5a260a71fecc01ebf22c73
extra : histedit_source : d2275fdb4edc3d7f6b006c8c7ab24fca1223998d
This commit implements the first half of the heuristics to detect style changes
that could lead to feedback loops with scroll anchoring. [1]
When these style changes are made, a suppression flag is added to the anchor
container to ignore any adjustments that would be made at the next layout flush
and to invalidate the anchor at that time.
[1] https://drafts.csswg.org/css-scroll-anchoring/#suppression-triggers
Differential Revision: https://phabricator.services.mozilla.com/D13271
--HG--
extra : rebase_source : 7919443bdad49ce3623e5b082decb4f5c4a54158
extra : histedit_source : a2283cc31060103ef0929ae11624b45f95113810
This commit implements anchor offset adjustment. When the position of a frame
that is an anchor is changed during reflow, we notify the anchor container. The
anchor container will then post a reflow callback.
Then when reflow is completed, the anchor container will perform a scroll to
keep the anchor node in the same relative position.
Differential Revision: https://phabricator.services.mozilla.com/D13270
--HG--
extra : rebase_source : 44797fcf6585d5912f83baea90a8e554f39618b5
extra : histedit_source : c4354ba8aac99e0d083f40b515369db6a95f997d
This commit adds a mechanism for scroll anchor containers to request an anchor
node selection at a future time. Currently this is before styling so that anchor
adjustment suppression will have current anchor nodes.
Differential Revision: https://phabricator.services.mozilla.com/D13269
--HG--
extra : rebase_source : ba621678b697847e59203444d7b6b0e737742675
extra : histedit_source : b0c6f8642a01bd8ded312d0fa27eecd55c4422a9
This commit implements candidate selection for a scroll frame using a frame tree
traversal. It roughly tries to follow the algorithm given in the scroll
anchoring draft specification, adapted to operate on the frame tree [1].
Some details, such as not selecting an anchor if the user hasn't scrolled are
not currently in the specification but will be to match Blink's implementation.
Once a scroll anchor has been selected, we maintain a bit on it and its ancestor
frame's states. This is used in a later commit to detect changes to position
during a reflow so the scroll frame can perform an adjustment.
A scroll anchor will be invalidated when the user scrolls the frame or the
scroll anchor is destroyed. Later commits will add logic to drive selection and
invalidation appropriately.
[1] https://drafts.csswg.org/css-scroll-anchoring/#anchor-node-selection
Differential Revision: https://phabricator.services.mozilla.com/D13268
--HG--
extra : rebase_source : 02ace6a966dd1c4bd42b7472501d05c412d6deb8
extra : histedit_source : 84bed6b2d13a308f4aea91c631b8792df293c76a
This commit adds a barebones class called 'ScrollAnchorContainer' that will
contain most of the logic for scroll anchoring. It is owned as a member of
ScrollFrameHelper, and has the same lifetime.
Differential Revision: https://phabricator.services.mozilla.com/D13267
--HG--
extra : rebase_source : 4d58b51aa6b893392d7c152d27750ebda059f784
extra : histedit_source : 9a2841931c47c4358e15d2fa6514ed347e3d0dad