Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6839061acafdc69f6912285318a711a2c4c22c03
      
https://github.com/WebKit/WebKit/commit/6839061acafdc69f6912285318a711a2c4c22c03
  Author: Luke Warlow <[email protected]>
  Date:   2026-10-07 (Wed, 07 Oct 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/fire-focusin-focusout-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/focus-within-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-child-list-selector-invalidation-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-child-list-selector-invalidation.html
    M 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-from-light-to-shadow-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-into-display-none-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-into-display-none.html
    M Source/WebCore/dom/ContainerNode.cpp
    M Source/WebCore/style/ChildChangeInvalidation.cpp

  Log Message:
  -----------
  moveBefore() leaves selectors that depend on the child list stale
https://bugs.webkit.org/show_bug.cgi?id=326182

Reviewed by Ryosuke Niwa.

moveBefore() wasn't running any style invalidation for the parents involved in 
a move, unlike other operations.
Selectors that depend on a parent's children, like :has(), :empty, :nth-child() 
and sibling combinators, kept their old results after a move.

This adds a Style::ChildChangeInvalidation around each half of the move, one 
for the old parent and one for the new parent.

It also fixes the insertion ChildChange being created after the node was 
already inserted. That made the moved node its own previous sibling.
It's now created before the insertion, like it is for appendChild().

Finally, moving a node somewhere it isn't rendered, such as under a display: 
none element, left its old renderers behind.
Normally they're rebuilt once the render tree update reaches the node's new 
position, but in that case the update never gets there.
moveBefore() now tears them down when that happens, the same way removal does.

Tests: 
imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-child-list-selector-invalidation.html
       
imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-into-display-none.html

* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/fire-focusin-focusout-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/focus-within-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-child-list-selector-invalidation-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-child-list-selector-invalidation.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-from-light-to-shadow-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-into-display-none-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/moveBefore/moveBefore-into-display-none.html:
 Added.
* Source/WebCore/dom/ContainerNode.cpp:
(WebCore::renderTreeUpdateCanReachMovedNode):
(WebCore::ContainerNode::moveBefore):
* Source/WebCore/style/ChildChangeInvalidation.cpp:
(WebCore::Style::isInsertionForStyle):
(WebCore::Style::isElementRemovalForStyle):
(WebCore::Style::ChildChangeInvalidation::emptyStateMayChange const):
(WebCore::Style::ChildChangeInvalidation::invalidateForHasSiblings):
(WebCore::Style::ChildChangeInvalidation::traverseRemovedElements):
(WebCore::Style::ChildChangeInvalidation::traverseAddedElements):
(WebCore::Style::ChildChangeInvalidation::checkForSiblingStyleChanges):

Canonical link: https://commits.webkit.org/323044@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to