Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d7d8d592181885f0e2bf9835a1170474183805e2
      
https://github.com/WebKit/WebKit/commit/d7d8d592181885f0e2bf9835a1170474183805e2
  Author: Antti Koivisto <[email protected]>
  Date:   2026-05-28 (Thu, 28 May 2026)

  Changed paths:
    M Source/WebCore/css/SelectorChecker.cpp
    M Source/WebCore/dom/CharacterData.cpp
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/rendering/style/RenderStyle+GettersInlines.h
    M Source/WebCore/rendering/style/RenderStyle+SettersInlines.h
    M Source/WebCore/rendering/style/RenderStyle.h
    M Source/WebCore/style/ChildChangeInvalidation.cpp
    M Source/WebCore/style/ChildChangeInvalidation.h
    M Source/WebCore/style/StyleRelations.cpp
    M Source/WebCore/style/computed/StyleComputedStyle.cpp
    M Source/WebCore/style/computed/StyleComputedStyleBase+ConstructionInlines.h
    M Source/WebCore/style/computed/StyleComputedStyleBase+GettersInlines.h
    M Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h
    M Source/WebCore/style/computed/StyleComputedStyleBase.cpp
    M Source/WebCore/style/computed/StyleComputedStyleBase.h

  Log Message:
  -----------
  Use PseudoClassChangeInvalidation for :empty
https://bugs.webkit.org/show_bug.cgi?id=315655
rdar://178042916

Reviewed by Alan Baradlay.

Route :empty invalidation through the fine-grained PseudoClassChangeInvalidation
machinery instead of the coarse parent.invalidateStyleForSubtree path in
checkForEmptyStyleChange. ChildChangeInvalidation now constructs a
PseudoClassChangeInvalidation for :empty when the parent has the
styleAffectedByEmpty bit set and a fast pre-check decides the upcoming mutation
can flip the parent's :empty state.

The :has(:empty) case used to need a separate path because the per-element
styleAffectedByEmpty bit wasn't set on descendants matched only inside :has().
Forwarding Style::Relation::AffectedByEmpty out of the local hasCheckingContext
in matchHasArgumentSelector fixes that, and the bit is no longer cleared in
resetStyleRelations so it stays set across style recalcs. The :has() :empty
special case is gone.

The dead RenderStyle::emptyState bit (only read by the removed
checkForEmptyStyleChange) is removed.

* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchHasArgumentSelector const):

Forward AffectedByEmpty so the bit gets set on :has(:empty) descendants.

* Source/WebCore/dom/CharacterData.cpp:
(WebCore::makeChildChange):
(WebCore::CharacterData::parserAppendData):
(WebCore::CharacterData::setDataAndUpdate):

Pick a precise ChildChange::Type for text data updates: TextChanged only
when both old and new data are non-empty, TextRemoved when the new data is
empty, TextInserted otherwise. Lets emptyStateMayChange skip the children
traversal for TextChanged.

* Source/WebCore/dom/Element.cpp:
(WebCore::Element::resetStyleRelations):

Stop clearing NodeStyleFlag::StyleAffectedByEmpty. The bit is a hint to fire
m_emptyInvalidation; over-set is correctness-safe.

* Source/WebCore/style/ChildChangeInvalidation.h:
(WebCore::Style::ChildChangeInvalidation::ChildChangeInvalidation):

* Source/WebCore/style/ChildChangeInvalidation.cpp:
(WebCore::Style::elementIsEmptyForCSS):
(WebCore::Style::ChildChangeInvalidation::emptyStateMayChange const):
(WebCore::Style::ChildChangeInvalidation::invalidateForChangedElement):
(WebCore::Style::ChildChangeInvalidation::invalidateForHasBeforeMutation):
(WebCore::Style::ChildChangeInvalidation::invalidateForHasAfterMutation):
(WebCore::Style::ChildChangeInvalidation::invalidateAfterChange):
(WebCore::Style::ChildChangeInvalidation::invalidateAfterFinishedParsingChildren):
(WebCore::Style::rightmostCompoundContainsEmpty): Deleted.
(WebCore::Style::checkForEmptyStyleChange): Deleted.

Add m_emptyInvalidation. Drop checkForEmptyStyleChange, the :has() :empty
special case in invalidateForHas{Before,After}Mutation, the EmptyInvalidation
enum and parameter, and the rightmostCompoundContainsEmpty helper.

* Source/WebCore/rendering/style/RenderStyle+GettersInlines.h:
(WebCore::RenderStyle::emptyState const): Deleted.

* Source/WebCore/rendering/style/RenderStyle+SettersInlines.h:
(WebCore::RenderStyle::setEmptyState): Deleted.

* Source/WebCore/rendering/style/RenderStyle.h:

* Source/WebCore/style/StyleRelations.cpp:
(WebCore::Style::commitRelationsToRenderStyle):
(WebCore::Style::copyRelations):

* Source/WebCore/style/computed/StyleComputedStyle.cpp:

* Source/WebCore/style/computed/StyleComputedStyleBase+ConstructionInlines.h:
(WebCore::Style::ComputedStyleBase::ComputedStyleBase):

* Source/WebCore/style/computed/StyleComputedStyleBase+GettersInlines.h:
(WebCore::Style::ComputedStyleBase::emptyState const): Deleted.

* Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h:
(WebCore::Style::ComputedStyleBase::setEmptyState): Deleted.

* Source/WebCore/style/computed/StyleComputedStyleBase.cpp:
(WebCore::Style::ComputedStyleBase::NonInheritedFlags::dumpDifferences const):

* Source/WebCore/style/computed/StyleComputedStyleBase.h:

Remove RenderStyle::emptyState/setEmptyState and the underlying
m_nonInheritedFlags.emptyState bit.

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



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

Reply via email to