Invalidate current element style on class change accurately
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jan 2018 09:01:53 +0000 (09:01 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jan 2018 09:01:53 +0000 (09:01 +0000)
commit7d2997447e3cf5362109c237986a36574c07d53b
treea6712e0b160b7b6bc303756326830c99d72ea33f
parentffeb6f3457c3f2bd902de329e81a7f7a73fbdd5d
Invalidate current element style on class change accurately
https://bugs.webkit.org/show_bug.cgi?id=181210

Reviewed by Zalan Bujtas.

Source/WebCore:

* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::collectFeatures const):
(WebCore::DocumentRuleSets::subjectClassRules const):

    New rule set containing class rules affecting the subject element.

(WebCore::DocumentRuleSets::ancestorClassRules const):
* css/DocumentRuleSets.h:
* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):

    Classify selector components into various buckets based on the elements they match relative to
    the subject element. There are more categories than this patch strictly needs, for future use.

(WebCore::RuleFeatureSet::collectFeatures):
(WebCore::RuleFeatureSet::add):
(WebCore::RuleFeatureSet::clear):
(WebCore::RuleFeatureSet::shrinkToFit):
* css/RuleFeature.h:
* css/StyleResolver.h:
(WebCore::StyleResolver::hasSelectorForClass const): Deleted.
* style/ClassChangeInvalidation.cpp:
(WebCore::Style::elementNeedsInvalidation):
(WebCore::Style::ClassChangeInvalidation::computeInvalidation):

    Don't invalidate current element unconditionally on class change. Instead find the subject rulesets
    that might affect it use them to perform invalidation.

(WebCore::Style::ClassChangeInvalidation::invalidateStyleWithRuleSets):
(WebCore::Style::ClassChangeInvalidation::invalidateStyle): Deleted.
(WebCore::Style::ClassChangeInvalidation::invalidateDescendantStyle): Deleted.
* style/ClassChangeInvalidation.h:
(WebCore::Style::ClassChangeInvalidation::ClassChangeInvalidation):
(WebCore::Style::ClassChangeInvalidation::~ClassChangeInvalidation):
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::classNamesAffectedByRules const):

LayoutTests:

* fast/css/set-inline-style-recalc-expected.txt:
* fast/css/set-inline-style-recalc.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/set-inline-style-recalc-expected.txt
LayoutTests/fast/css/set-inline-style-recalc.html
Source/WebCore/ChangeLog
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/DocumentRuleSets.h
Source/WebCore/css/RuleFeature.cpp
Source/WebCore/css/RuleFeature.h
Source/WebCore/css/StyleResolver.h
Source/WebCore/style/ClassChangeInvalidation.cpp
Source/WebCore/style/ClassChangeInvalidation.h
Source/WebCore/style/StyleSharingResolver.cpp