Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b71cc01dd5ba9c5971f161436349097259db9270
      
https://github.com/WebKit/WebKit/commit/b71cc01dd5ba9c5971f161436349097259db9270
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-05 (Mon, 05 Oct 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-invalidation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-invalidation.html
    M Source/WebCore/style/ElementRuleCollector.cpp

  Log Message:
  -----------
  @scope start (scoping root) selector matching drops style relations, so 
structural DOM mutations don't invalidate scope membership
https://bugs.webkit.org/show_bug.cgi?id=325287
rdar://188398757

Reviewed by Antti Koivisto.

ElementRuleCollector::ruleMatches() merges the style relations recorded
during selector matching into m_styleRelations, which are later committed
(commitRelationsToRenderStyle / commitRelations) to set flags such as
childrenAffectedByForwardPositionalRules, styleAffectedByEmpty, and
childIndex on the relevant elements. ChildChangeInvalidation reads those
flags to decide whether a structural DOM mutation (child insertion or
removal) must re-evaluate positional or :empty selectors.

ElementRuleCollector::scopeRulesMatch() matches the @scope prelude
(scoping root) selector against ancestors using a local CheckingContext,
but never merged the style relations it accumulated into m_styleRelations.
As a result, when a scoping root selector used a structural pseudo-class
(:nth-child(), :empty, :first-child, ...), the corresponding affected-by
flags were never set, and a later structural mutation that changed which
element is a scoping root failed to invalidate, leaving stale styles.

Merge the style relations recorded while matching the scoping root
selector into m_styleRelations, mirroring ruleMatches(). Relations are
committed after each match (including non-matches, since those
dependencies still drive future invalidation) and the buffer is cleared
between calls to avoid duplicate accumulation in the reused context.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-invalidation-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-invalidation.html:
* Source/WebCore/style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::scopeRulesMatch):

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



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

Reply via email to