[wpt-sync] Sync PR 64329 - Prevent dirty slot assignments during layout and frame rect updates
Categories
(Core :: DOM: Core & HTML, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Attachments
(1 file)
|
111.32 KB,
text/plain
|
Details |
Sync web-platform-tests PR 64329 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/64329
Details from upstream follow.
Mason Freed <masonf@chromium.org> wrote:
Prevent dirty slot assignments during layout and frame rect updates
FlatTreeTraversal::TraverseParent calls Node::AssignedSlot, which
triggers SlotAssignment::RecalcAssignment if a shadow root still has
NeedsSlotAssignmentRecalc() set. During RecalcAssignment,
HTMLSlotElement::DetachDisplayLockedAssignedNodesLayoutTreeIfNeeded
synchronously detaches the layout tree of display-locked assigned
nodes. If a shadow root remains dirty into layout (e.g.
BlockNode::AttachScrollMarkers) or frame rect propagation
(LocalFrameView::PropagateFrameRectsRecursively), detaching the layout
tree mutates vectors being iterated on the stack, such as
ColumnPseudoElementsVector or LocalFrameView::plugins_.A slottable Node stores two slot pointers on FlatTreeNodeData:
assigned_slot_ (the \<slot> it is currently slotted into in the flat
tree as a direct child of that slot's host) and manually_assigned_slot_
(the candidate \<slot> imperatively assigned via
HTMLSlotElement.prototype.assign(), which the DOM spec requires
preserving even while the node is outside the shadow host). However,
Blink also uses SlotAssignmentMode::kManual internally for User-Agent
shadow roots on \, \<select>, and \<optgroup>, which run
Element::ManuallyAssignSlots() during
SlotAssignment::RecalcAssignment() and call ua_slot->Assign() on their
current children.Shadow roots could remain dirty past
SlotAssignmentEngine::RecalcSlotAssignments() for two reasons:
HTMLSlotElement::Assign() treated UA slots identically to author
slots and shared Node::ManuallyAssignedSlot() for both. When a node
previously passed to an author slot's assign() was moved into a
\element, \
's UA slot assignment ran
ManuallyAssignSlots() -> content_slot_->Assign() inside
RecalcAssignment(), saw previous_slot = node->ManuallyAssignedSlot()
pointing to the author \<slot>, erased the node from the author
slot's manually_assigned_nodes_, overwrote
node->SetManuallyAssignedSlot(content_slot_), and called
DidSlotChange() -> SetNeedsAssignmentRecalc() on the author shadow
root mid-recalc. Because
SlotAssignmentEngine::RecalcSlotAssignments() performs a single pass
over a snapshot of shadow_roots_needing_recalc_, the newly dirtied
author shadow root remained dirty after RecalcSlotAssignments()
returned. Sharing Node::ManuallyAssignedSlot() also violated the DOM
spec by destroying the node's author slot.assign() association when
moved into \(and conversely allowed
author_slot.assign(details_child) to steal a child from \'s
UA slot).SlotAssignment::DidRemoveSlot() for manual slotting cleared
candidate nodes without calling SetNeedsAssignmentRecalc().This patch fixes these issues by construction:
- In HTMLSlotElement::Assign(), only read or modify
Node::ManuallyAssignedSlot() and previous_slot when
!IsInUserAgentShadowRoot(). UA slots only update their own
manually_assigned_nodes_ set without touching
Node::ManuallyAssignedSlot() or dirtying author shadow roots. In
SlotAssignment::FindSlotInManualSlotting(), check the UA slots'
ManuallyAssignedNodes() when owner_->IsUserAgent() is true.- Call SetNeedsAssignmentRecalc() in SlotAssignment::DidRemoveSlot()
when a removed manual slot had candidate assigned nodes.- Add SlotAssignmentRecalcForbiddenScope in
LocalFrameView::PerformLayout() and
LocalFrameView::PropagateFrameRectsRecursively() to enforce via
DCHECK that slot assignment recalculation is never triggered in those
phases.Fixed: 576736463, 575533210
Change-Id: Ib359a4b0ce88d60d6f90fdf5964979c0fdd23878
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8652233
Reviewed-by: Daniel Cheng \<dcheng@chromium.org>
Auto-Submit: Mason Freed \<masonf@chromium.org>
Commit-Queue: Daniel Cheng \<dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1729487}
| Assignee | ||
Updated•13 days ago
|
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Comment 1•9 days ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=116567
| Assignee | ||
Comment 2•8 days ago
|
||
CI Results
Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 570 tests and 1 subtests
Status Summary
Firefox
OK : 1[GitHub] 368[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 369[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS : 2[GitHub] 64[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 15225[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 15249[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 15263[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 320[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 405[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 406[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview]
TIMEOUT: 3[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 5[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
ERROR : 2
NOTRUN : 3
Chrome
OK : 1
PASS : 2
Safari
OK : 1
PASS : 2
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
(See attachment for full changes)
Comment 4•4 days ago
|
||
| bugherder | ||
Description
•