Updating class name of a shadow host does not update the style applied by descendants...
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2017 12:31:49 +0000 (12:31 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2017 12:31:49 +0000 (12:31 +0000)
commite461d62668ad607d8f6acceb177a4ee45de52144
treee7ee043564ab817463ef4853c25f28c91a5f3f1d
parent344b4e2997b20890dd402f78151cb613a2714fcd
Updating class name of a shadow host does not update the style applied by descendants of :host()
https://bugs.webkit.org/show_bug.cgi?id=170762
<rdar://problem/31572668>

Reviewed by Ryosuke Niwa.

Source/WebCore:

We need to invalidate shadow tree style when host classes or attributes change if it may be
affected by host rules.

Test: fast/shadow-dom/css-scoping-host-class-and-attribute-mutation.html

* css/RuleSet.cpp:
(WebCore::isHostSelectorMatchingInShadowTree):
(WebCore::RuleSet::addRule):

    Check if we have :host selectors that affect shadow tree.

* css/RuleSet.h:
(WebCore::RuleSet::hasHostPseudoClassRulesMatchingInShadowTree):
* style/AttributeChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::AttributeChangeInvalidation::invalidateStyle):

    Invalidate the whole subtree if there is a class change that may affect shadow tree style.

* style/ClassChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::ClassChangeInvalidation::invalidateStyle):
* style/IdChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::IdChangeInvalidation::invalidateStyle):

    Same for classes and ids.
    This should be refactored at some point to reduce copy-code.

LayoutTests:

* fast/shadow-dom/css-scoping-host-class-and-attribute-mutation-expected.html: Added.
* fast/shadow-dom/css-scoping-host-class-and-attribute-mutation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/css-scoping-host-class-and-attribute-mutation-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/css-scoping-host-class-and-attribute-mutation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/RuleSet.cpp
Source/WebCore/css/RuleSet.h
Source/WebCore/style/AttributeChangeInvalidation.cpp
Source/WebCore/style/ClassChangeInvalidation.cpp
Source/WebCore/style/IdChangeInvalidation.cpp