LibWeb: Hand layout a Rust-owned style container instead of a mirror - #10945
Merged
kalenikaliaksandr merged 1 commit intoJul 31, 2026
Merged
Conversation
Layout read style through a per-node side table in the node arena that mirrored all 23 group payload pointers, copied out of ComputedValues on every style application. The mirror was 184 bytes per node of duplicated pointers whose validity rested on the rewrite-on-set protocol alone: nothing owned the payloads on the Rust side, and the generation-keyed side table existed only to keep stale copies from being read after slot reuse. Every built ComputedValues now lazily creates a style container on first request: a Rust-owned refcounted allocation, using the same header-before-payload scheme as the group payloads themselves, holding the group pointer array and retaining every group. NodeData.style points at the container's array, which the layout side reads in place as the payload array, so style application shrinks to publishing one pointer and the side table, its generation keying, and the per-set 23-pointer copy are deleted. The container is created after group adoption has settled (adopt_identical_group_payloads now asserts it runs first) and released with its ComputedValues, making payload ownership explicit where the mirror only had it by protocol. It also gives the style a single identity usable for future retention from paintables and for input-keyed layout caching.
|
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 (9)
📝 WalkthroughWalkthroughChangesStyle container migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ComputedValues
participant NodeData
participant LayoutNodeArena
participant FormattingContext
ComputedValues->>ComputedValues: create and cache style container
ComputedValues->>NodeData: publish style container
FormattingContext->>LayoutNodeArena: request style payloads
LayoutNodeArena->>NodeData: read published style pointer
NodeData-->>FormattingContext: return style payload array
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.
Layout read style through a per-node side table in the node arena that mirrored all 23 group payload pointers, copied out of ComputedValues on every style application. The mirror was 184 bytes per node of duplicated pointers whose validity rested on the rewrite-on-set protocol alone: nothing owned the payloads on the Rust side, and the generation-keyed side table existed only to keep stale copies from being read after slot reuse.
Every built ComputedValues now lazily creates a style container on first request: a Rust-owned refcounted allocation, using the same header-before-payload scheme as the group payloads themselves, holding the group pointer array and retaining every group. NodeData.style points at the container's array, which the layout side reads in place as the payload array, so style application shrinks to publishing one pointer and the side table, its generation keying, and the per-set 23-pointer copy are deleted. The container is created after group adoption has settled (adopt_identical_group_payloads now asserts it runs first) and released with its ComputedValues, making payload ownership explicit where the mirror only had it by protocol. It also gives the style a single identity usable for future retention from paintables and for input-keyed layout caching.