Use separate style resolver for user agent shadow trees
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Sep 2015 15:39:15 +0000 (15:39 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Sep 2015 15:39:15 +0000 (15:39 +0000)
commit4c01d4c55c37d04c26ceab4815be77986e27709e
tree86380be7f9d5926b82ca53263d2e9ed17f7f777c
parentf103addba84e0cad39ed27a012c64b0aa4f9d638
Use separate style resolver for user agent shadow trees
https://bugs.webkit.org/show_bug.cgi?id=149626

Reviewed by Andreas Kling.

We now support separate style resolvers for shadow trees. Use this mechanism to have a separate
per-document style resolver for user agent shadow trees. This isolates user agent shadow trees
from author style better and simplifies the style resolver. It can also avoid some unnecessary style recalcs.

* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::resetAuthorStyle):
(WebCore::DocumentRuleSets::appendAuthorStyleSheets):

    Change interface so that only the new rules are provided.

* css/DocumentRuleSets.h:
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::addElementStyleProperties):
(WebCore::ElementRuleCollector::collectMatchingRules):

    We can remove special bailout as shadow tree style resolver won't have other author style

(WebCore::ElementRuleCollector::sortAndTransferMatchedRules):

    Remove the exception that disables property whitelists for UA stylesheets. We don't seem to use the feature.

(WebCore::ElementRuleCollector::matchUARules):
(WebCore::MatchingUARulesScope::MatchingUARulesScope): Deleted.
(WebCore::MatchingUARulesScope::~MatchingUARulesScope): Deleted.
(WebCore::MatchingUARulesScope::isMatchingUARules): Deleted.

    Remove this unnecessary hack.

* css/ElementRuleCollector.h:
(WebCore::ElementRuleCollector::ElementRuleCollector):
* css/RuleSet.cpp:
(WebCore::RuleSet::addStyleRule):
(WebCore::RuleSet::copyShadowPseudoElementRulesFrom):

    Also copy WebVTT rules. They are currently a sort of mixture of UA and author shadow tree.

(WebCore::shrinkMapVectorsToFit):
* css/RuleSet.h:
(WebCore::RuleData::containsUncommonAttributeSelector):
(WebCore::RuleData::linkMatchType):
(WebCore::RuleData::hasDocumentSecurityOrigin):
(WebCore::RuleData::propertyWhitelistType):
(WebCore::RuleData::descendantSelectorIdentifierHashes):
(WebCore::RuleSet::ruleCount):
(WebCore::RuleSet::hasShadowPseudoElementRules):
* css/StyleInvalidationAnalysis.cpp:
(WebCore::StyleInvalidationAnalysis::StyleInvalidationAnalysis):
(WebCore::StyleInvalidationAnalysis::invalidateIfNeeded):

    Don't invalidate the whole tree when author shadow pseudo element rules change. Just invalidate the shadow trees.

(WebCore::StyleInvalidationAnalysis::invalidateStyleForTree):
(WebCore::StyleInvalidationAnalysis::invalidateStyle):
(WebCore::invalidateIfNeeded): Deleted.
(WebCore::invalidateStyleForTree): Deleted.
* css/StyleInvalidationAnalysis.h:
(WebCore::StyleInvalidationAnalysis::dirtiesAllStyle):
(WebCore::StyleInvalidationAnalysis::hasShadowPseudoElementRulesInAuthorSheet):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::MatchResult::addMatchedProperties):
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::appendAuthorStyleSheets):

    Simpler interface.

* css/StyleResolver.h:
(WebCore::StyleResolver::document):
(WebCore::StyleResolver::documentSettings):
(WebCore::StyleResolver::ruleSets):
* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::collectActiveStyleSheets):
(WebCore::AuthorStyleSheets::analyzeStyleSheetChange):

    Cleanups.

(WebCore::filterEnabledNonemptyCSSStyleSheets):
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):
(WebCore::AuthorStyleSheets::updateStyleResolver):

    Factor to a function.
    Copy any author shadow pseudo elements to user agent shadow tree resolver.

(WebCore::AuthorStyleSheets::activeStyleSheetsForInspector):
* dom/AuthorStyleSheets.h:
* dom/Document.cpp:
(WebCore::Document::createStyleResolver):
(WebCore::Document::userAgentShadowTreeStyleResolver):

    Use separate resolver.

(WebCore::Document::fontsNeedUpdate):
(WebCore::Document::clearStyleResolver):
* dom/Document.h:
(WebCore::Document::ensureStyleResolver):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::styleResolver):

    Return document-global shadow tree resolver for ua trees.

* style/StyleResolveTree.cpp:
(WebCore::Style::resolveShadowTree):

    Take styleChange of shadow root into account.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190347 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/DocumentRuleSets.h
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/ElementRuleCollector.h
Source/WebCore/css/RuleSet.cpp
Source/WebCore/css/RuleSet.h
Source/WebCore/css/StyleInvalidationAnalysis.cpp
Source/WebCore/css/StyleInvalidationAnalysis.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/AuthorStyleSheets.cpp
Source/WebCore/dom/AuthorStyleSheets.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/style/StyleResolveTree.cpp
Source/WebCore/svg/SVGElement.cpp