LibWeb: Return slot ids instead of shells from layout FC callbacks - #10903
Merged
kalenikaliaksandr merged 1 commit intoJul 28, 2026
Merged
Conversation
The formatting-context callbacks handed raw Layout::Node pointers back into Rust in three places (static position containing block, anchor lookup, and the list item marker in the list item facts), forcing the Rust side to reconstruct arena slot ids by reading the NodeData pointer at a byte displacement inside the C++ object. That displacement had to be computed at runtime and defended by a vtable-sampling verification walk over the layout tree, all resting on the assumption that every layout node class keeps its NodeData member at one process-wide offset. Slot ids are already the canonical cross-boundary node reference: the topology synchronization writes them into NodeData, and Node::slot_id() is a single field read carrying the packed index and generation. Return slot ids from the three callbacks directly, which lets the displacement field, the verification walk, and the Rust-side unsafe pointer arithmetic all be deleted with no replacement. The anchor lookup's bool-plus-out-pointer shape collapses into returning an invalid slot id for "not found", and the marker link in the list item facts still reads the C++ WeakPtr at fetch time, so a detached marker stays absent rather than becoming a stale slot reference.
|
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 (8)
💤 Files with no reviewable changes (3)
📝 WalkthroughWalkthroughFormatting-context callbacks and list-item marker facts now use arena-backed ChangesNodeSlotId FFI migration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant LayoutRustBridge
participant FfiLayoutFcCallbacks
participant AbsposEngine
participant LayoutNodeArena
LayoutRustBridge->>FfiLayoutFcCallbacks: provide NodeSlotId callbacks
AbsposEngine->>FfiLayoutFcCallbacks: request static containing block
FfiLayoutFcCallbacks-->>AbsposEngine: return NodeSlotId
AbsposEngine->>FfiLayoutFcCallbacks: perform anchor lookup
FfiLayoutFcCallbacks->>LayoutNodeArena: resolve NodeData by Node
FfiLayoutFcCallbacks-->>AbsposEngine: return NodeSlotId or INVALID
Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Comment |
This was referenced Jul 28, 2026
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.
The formatting-context callbacks handed raw Layout::Node pointers back into Rust in three places (static position containing block, anchor lookup, and the list item marker in the list item facts), forcing the Rust side to reconstruct arena slot ids by reading the NodeData pointer at a byte displacement inside the C++ object. That displacement had to be computed at runtime and defended by a vtable-sampling verification walk over the layout tree, all resting on the assumption that every layout node class keeps its NodeData member at one process-wide offset.
Slot ids are already the canonical cross-boundary node reference: the topology synchronization writes them into NodeData, and Node::slot_id() is a single field read carrying the packed index and generation. Return slot ids from the three callbacks directly, which lets the displacement field, the verification walk, and the Rust-side unsafe pointer arithmetic all be deleted with no replacement. The anchor lookup's bool-plus-out-pointer shape collapses into returning an invalid slot id for "not found", and the marker link in the list item facts still reads the C++ WeakPtr at fetch time, so a detached marker stays absent rather than becoming a stale slot reference.