Closed Bug 2077024 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63147 - Skip siblings pending re-attach when finding the next layout sibling

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox159 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 63147 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/63147
Details from upstream follow.

Misha Nasledov <misha@nasledov.com> wrote:

Skip siblings pending re-attach when finding the next layout sibling

moveBefore() does not detach the layout tree of the node it moves. The
node is marked for a forced re-attach instead, so until the next layout
tree rebuild its LayoutObject is still a child of its old parent's
LayoutObject, while in the DOM it is already a sibling of its new
siblings.

If one of those new siblings changes between in-flow and out-of-flow
(position: absolute/fixed, or float) in the same frame,
Element::RecalcOwnStyle() removes its LayoutObject and re-inserts it
before LayoutTreeBuilderTraversal::NextSiblingLayoutObject(). That
returned the moved node's stale LayoutObject, which is not in the
parent's layout subtree at all. AddChild() then took the
AddChildBeforeDescendant() path, walked up from the stale object past
the LayoutView looking for a child of the parent, and dereferenced
null.

moveBefore() is one way to get there, not the only one: re-slotting a
shadow host's child marks it for a forced re-attach the same way, and
ClusterFuzz reached the same crash through \<select>'s manual slot
assignment. This change also stops the ClusterFuzz testcase for that
bug from crashing.

A sibling that is pending re-attach is not a valid insertion point, and
does not need to be one: it is inserted relative to its own siblings
when it is re-attached. Skip such siblings in
NextSiblingLayoutObjectInternal(), next to the existing skip for
LayoutObjects that are reparented into the top layer or an overscroll
area.

Fixed: 541682083
Test: external/wpt/dom/nodes/moveBefore/moveBefore-out-of-flow-sibling-crash.html
Change-Id: Ia4fcfef31aa1571d8ea9f73ac29710e1257358e1

Reviewed-on: https://chromium-review.googlesource.com/8467632
WPT-Export-Revision: c5f15a7800bf65b349649677db42dc36b5a556ea

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 63 tests

Status Summary

Firefox

OK : 53
PASS : 1[GitHub] 8[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 127[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 129[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-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 9

Chrome

CRASH: 1

Safari

PASS : 1

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/72df4e0a5fa5 https://hg.mozilla.org/integration/autoland/rev/dc121729b40e [wpt PR 63147] - Skip siblings pending re-attach when finding the next layout sibling, a=testonly
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch
You need to log in before you can comment on or make changes to this bug.