Add ChildrenAffectedByForwardPositionalRules bit for nth-child pseudo class marking
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Mar 2018 05:59:08 +0000 (05:59 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Mar 2018 05:59:08 +0000 (05:59 +0000)
commitfa14bdcb80c7cb97bf250a06afe2903029748356
treecbabaccbfe3085506846d2a0a0b58428711b0f70
parentfd4dc8cda4fefc7c946e61f073aebbe4f31bfbee
Add ChildrenAffectedByForwardPositionalRules bit for nth-child pseudo class marking
https://bugs.webkit.org/show_bug.cgi?id=183341
<rdar://problem/38151470>

Reviewed by Zalan Bujtas.

Use it instead of AffectsNextSibling/AffectedByPreviousSibling bits, similar to ChildrenAffectedByBackwardPositionalRules bit.
This is more efficient and requires way less marking.

* css/SelectorChecker.cpp:
(WebCore::countElementsBefore):
(WebCore::countElementsOfTypeBefore):
(WebCore::SelectorChecker::checkOne const):

    Mark with ChildrenAffectedByForwardPositionalRules.

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChildOf):

     Mark with ChildrenAffectedByForwardPositionalRules.

* dom/Element.cpp:
(WebCore::checkForSiblingStyleChanges):

    Invalidate siblings after added/removed element.

(WebCore::Element::setChildrenAffectedByForwardPositionalRules):
(WebCore::Element::hasFlagsSetDuringStylingOfChildren const):
(WebCore::Element::rareDataChildrenAffectedByForwardPositionalRules const):

    Add the new marking bit.

* dom/Element.h:
(WebCore::Element::childrenAffectedByForwardPositionalRules const):
(WebCore::Element::attributeWithoutSynchronization const):

    Remove assert so we can use this to get the current unresolved lazy value of style attrbute.

* dom/ElementRareData.h:
(WebCore::ElementRareData::childrenAffectedByForwardPositionalRules const):
(WebCore::ElementRareData::setChildrenAffectedByForwardPositionalRules):
(WebCore::ElementRareData::ElementRareData):
(WebCore::ElementRareData::resetStyleRelations):

     Add the new marking bit.

* dom/StyledElement.cpp:
(WebCore::StyledElement::invalidateStyleAttribute):

    In special case where we have attribute selectors for style attribute, synchronize the attribute immediately so we get invalidation right.
    Tested by fast/css/style-attribute-invalidation-propagates-to-counted-siblings.html

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

    Commit the new bit.

* style/StyleRelations.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229307 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementRareData.h
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/style/StyleRelations.cpp
Source/WebCore/style/StyleRelations.h