LibWeb: Drop the post-pass anchor-inset writeback into computed values - #10943
Merged
kalenikaliaksandr merged 1 commit intoJul 31, 2026
Conversation
Once the outermost layout pass returned, the bridge rewrote the computed inset values of every anchor-positioned box, replacing their anchor() functions with the pixel values the pass had resolved. The writeback dates from when the style itself was the carrier of resolved anchor insets: resolution overwrote the inset properties so that every later read, inside or after the pass, would see resolved pixels. Since 0d42286 the pass no longer works that way. Resolved anchor insets go into a per-pass override store, and every inset read inside the pass is masked by that store, so the pass is self-sufficient and the writeback could only matter to code running after layout. Neither of its two remaining consumers actually wants it: - getComputedStyle reports resolved insets through the used-value path, which reads the box model of the laid-out box. It does not need resolved pixels smuggled into computed values. - Later layout passes are actively harmed by it. With resolved pixels persisted in computed values, a relayout that skipped style recalc reused the previous pass's anchor positions even if the anchor had moved since, and the resolution early-out then cleared the stored default-anchor scroll shift without re-establishing it, silently losing scroll compensation. So the writeback machinery can simply go: the deferred-inset batch and its recording callback, the bridge's pending vector, and the writeback in ActiveLayoutPassScope's destructor. Anchor insets now resolve fresh in every pass from the pristine computed values, fixing the stale anchor positions and the lost scroll shift, and computed values become immutable from the moment a layout pass first reads them until the next style recalculation.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (3)
📝 WalkthroughWalkthroughDeferred resolved-anchor-inset storage, callbacks, commit reporting, and pass-end application were removed. Absolute-position layout continues to update resolved anchor insets directly. ChangesAnchor-inset writeback
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Once the outermost layout pass returned, the bridge rewrote the computed inset values of every anchor-positioned box, replacing their anchor() functions with the pixel values the pass had resolved. The writeback dates from when the style itself was the carrier of resolved anchor insets: resolution overwrote the inset properties so that every later read, inside or after the pass, would see resolved pixels.
Since 0d42286 the pass no longer works that way. Resolved anchor insets go into a per-pass override store, and every inset read inside the pass is masked by that store, so the pass is self-sufficient and the writeback could only matter to code running after layout. Neither of its two remaining consumers actually wants it:
getComputedStyle reports resolved insets through the used-value path, which reads the box model of the laid-out box. It does not need resolved pixels smuggled into computed values.
Later layout passes are actively harmed by it. With resolved pixels persisted in computed values, a relayout that skipped style recalc reused the previous pass's anchor positions even if the anchor had moved since, and the resolution early-out then cleared the stored default-anchor scroll shift without re-establishing it, silently losing scroll compensation.
So the writeback machinery can simply go: the deferred-inset batch and its recording callback, the bridge's pending vector, and the writeback in ActiveLayoutPassScope's destructor. Anchor insets now resolve fresh in every pass from the pristine computed values, fixing the stale anchor positions and the lost scroll shift, and computed values become immutable from the moment a layout pass first reads them until the next style recalculation.