| Index: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
|
| index ede3e41e6aab4baeb3d18af774d92350d35fd7fb..4e17cc9aaf76a87b394bcdaefda18fa47de18d8c 100644
|
| --- a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
|
| +++ b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
|
| @@ -35,7 +35,6 @@
|
| #include "core/css/StyleRule.h"
|
| #include "core/css/StyleSheetContents.h"
|
| #include "core/css/resolver/MatchRequest.h"
|
| -#include "core/css/resolver/ViewportStyleResolver.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/StyleEngine.h"
|
| #include "core/dom/shadow/ElementShadow.h"
|
| @@ -74,27 +73,33 @@ void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet)
|
| if (FontFace* fontFace = FontFace::create(&document, fontFaceRule))
|
| cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace);
|
| }
|
| - if (fontFaceRules.size())
|
| + if (fontFaceRules.size() && document.styleResolver())
|
| document.styleResolver()->invalidateMatchedPropertiesCache();
|
| }
|
|
|
| -void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const MediaQueryEvaluator& medium)
|
| +void ScopedStyleResolver::appendActiveStyleSheets(unsigned index, const ActiveStyleSheetVector& activeSheets)
|
| {
|
| - unsigned index = m_authorStyleSheets.size();
|
| - m_authorStyleSheets.append(&cssSheet);
|
| - StyleSheetContents* sheet = cssSheet.contents();
|
| - AddRuleFlags addRuleFlags = treeScope().document().getSecurityOrigin()->canRequest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
|
| - const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
|
| + DCHECK(index == m_authorStyleSheets.size());
|
|
|
| - addKeyframeRules(ruleSet);
|
| - addFontFaceRules(ruleSet);
|
| - addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
|
| - treeScope().document().styleResolver()->addViewportDependentMediaQueries(ruleSet.viewportDependentMediaQueryResults());
|
| - treeScope().document().styleResolver()->addDeviceDependentMediaQueries(ruleSet.deviceDependentMediaQueryResults());
|
| + for (auto activeIterator = activeSheets.begin() + index; activeIterator != activeSheets.end(); activeIterator++) {
|
| + CSSStyleSheet* sheet = activeIterator->first;
|
| + m_viewportDependentMediaQueryResults.appendVector(sheet->viewportDependentMediaQueryResults());
|
| + m_deviceDependentMediaQueryResults.appendVector(sheet->deviceDependentMediaQueryResults());
|
| + if (activeIterator->second == RuleSet::emptyRuleSet())
|
| + continue;
|
| + const RuleSet& ruleSet = *activeIterator->second;
|
| + m_authorStyleSheets.append(sheet);
|
| + addKeyframeRules(ruleSet);
|
| + addFontFaceRules(ruleSet);
|
| + addTreeBoundaryCrossingRules(ruleSet, sheet, index++);
|
| + }
|
| }
|
|
|
| void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HeapHashSet<Member<const StyleSheetContents>>& visitedSharedStyleSheetContents) const
|
| {
|
| + features.viewportDependentMediaQueryResults.appendVector(m_viewportDependentMediaQueryResults);
|
| + features.deviceDependentMediaQueryResults.appendVector(m_deviceDependentMediaQueryResults);
|
| +
|
| for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
|
| ASSERT(m_authorStyleSheets[i]->ownerNode());
|
| StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
|
| @@ -112,6 +117,8 @@ void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HeapHashSe
|
| void ScopedStyleResolver::resetAuthorStyle()
|
| {
|
| m_authorStyleSheets.clear();
|
| + m_viewportDependentMediaQueryResults.clear();
|
| + m_deviceDependentMediaQueryResults.clear();
|
| m_keyframesRuleMap.clear();
|
| m_treeBoundaryCrossingRuleSet = nullptr;
|
| m_hasDeepOrShadowSelector = false;
|
| @@ -181,18 +188,12 @@ void ScopedStyleResolver::matchPageRules(PageRuleCollector& collector)
|
| collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet());
|
| }
|
|
|
| -void ScopedStyleResolver::collectViewportRulesTo(ViewportStyleResolver* resolver) const
|
| -{
|
| - if (!m_scope->rootNode().isDocumentNode())
|
| - return;
|
| - for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
|
| - resolver->collectViewportRules(&m_authorStyleSheets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin);
|
| -}
|
| -
|
| DEFINE_TRACE(ScopedStyleResolver)
|
| {
|
| visitor->trace(m_scope);
|
| visitor->trace(m_authorStyleSheets);
|
| + visitor->trace(m_viewportDependentMediaQueryResults);
|
| + visitor->trace(m_deviceDependentMediaQueryResults);
|
| visitor->trace(m_keyframesRuleMap);
|
| visitor->trace(m_treeBoundaryCrossingRuleSet);
|
| }
|
| @@ -225,7 +226,7 @@ void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRule
|
|
|
| if (!m_treeBoundaryCrossingRuleSet) {
|
| m_treeBoundaryCrossingRuleSet = new CSSStyleSheetRuleSubSet();
|
| - treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(treeScope().rootNode());
|
| + treeScope().document().styleEngine().addTreeBoundaryCrossingScope(treeScope().rootNode());
|
| }
|
|
|
| m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope));
|
|
|