Move security origin filtering for getMatchedCSSRules out of StyleResolver
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 23:58:39 +0000 (23:58 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 23:58:39 +0000 (23:58 +0000)
commit4c072bafa186ca412bd7ff77dde4ebb42644bad0
tree47b5241e13d26769bdd7f1e30ce7898bca4d9aa9
parent64f22c792e55debf9607feae480778d4c6d8443a
Move security origin filtering for getMatchedCSSRules out of StyleResolver
https://bugs.webkit.org/show_bug.cgi?id=180468

Reviewed by Zalan Bujtas.

The non-standard getMatchedCSSRules API should not return rules from stylesheets in different security origins.
To implement this we currently have lots of invasive code in StyleResolver, RuleSets and ElementRuleCollector
basically passing around a bit. This also makes RuleSets document specific blocking optimizations.

This patches replaces the mechanism with a bit in StyleRule which is much simpler.

* css/DocumentRuleSets.cpp:
(WebCore::makeRuleSet):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRulesForList):
* css/ElementRuleCollector.h:
(WebCore::ElementRuleCollector::setPseudoStyleRequest):
(WebCore::ElementRuleCollector::setSameOriginOnly): Deleted.
* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::collectFeatures):
* css/RuleFeature.h:
(WebCore::RuleFeature::RuleFeature):
* css/RuleSet.cpp:
(WebCore::RuleData::RuleData):
(WebCore::RuleSet::addRule):
(WebCore::RuleSet::addChildRules):
(WebCore::RuleSet::addRulesFromSheet):
(WebCore::RuleSet::addStyleRule):
* css/RuleSet.h:
(WebCore::RuleData::linkMatchType const):
(WebCore::RuleData::hasDocumentSecurityOrigin const): Deleted.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::pseudoStyleRulesForElement):
* css/StyleResolver.h:
* css/StyleRule.cpp:
(WebCore::StyleRule::StyleRule):
(WebCore::StyleRule::createForSplitting):
(WebCore::StyleRule::splitIntoMultipleRulesWithMaximumSelectorComponentCount const):
(WebCore::StyleRule::create): Deleted.
* css/StyleRule.h:
(WebCore::StyleRuleBase::StyleRuleBase):
(WebCore::StyleRuleBase::hasDocumentSecurityOrigin const):

    Add a bit.

* css/parser/CSSParser.cpp:
(WebCore::CSSParserContext::CSSParserContext):

    Include hasDocumentSecurityOrigin bit to parser context. This means that a stylesheet data structures
    can't be shared between a contexts where this differs. This likely very rare in practice.

(WebCore::operator==):
* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeStyleRule):
* css/parser/CSSParserMode.h:
(WebCore::CSSParserContextHash::hash):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::mergeStyleFromRules):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules const):

    Filter out rules from different security origin after getting them from style resolver.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/ElementRuleCollector.h
Source/WebCore/css/RuleFeature.cpp
Source/WebCore/css/RuleFeature.h
Source/WebCore/css/RuleSet.cpp
Source/WebCore/css/RuleSet.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/StyleRule.cpp
Source/WebCore/css/StyleRule.h
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParserImpl.cpp
Source/WebCore/css/parser/CSSParserMode.h
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/page/DOMWindow.cpp