Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp |
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
index 1aafe09b6864acea84da637e6cd980af5d470a3c..ee53599fb880218ad9399b4dfc7afdb9c927476b 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
@@ -447,6 +447,16 @@ void StyleEngine::setRuleUsageTracker(StyleRuleUsageTracker* tracker) { |
m_resolver->setRuleUsageTracker(m_tracker); |
} |
+RuleSet* StyleEngine::ruleSetForSheet(CSSStyleSheet& sheet) { |
+ if (!sheet.matchesMediaQueries(ensureMediaQueryEvaluator())) |
+ return nullptr; |
+ |
+ AddRuleFlags addRuleFlags = RuleHasNoSpecialState; |
+ if (m_document->getSecurityOrigin()->canRequest(sheet.baseURL())) |
+ addRuleFlags = RuleHasDocumentSecurityOrigin; |
+ return &sheet.contents()->ensureRuleSet(*m_mediaQueryEvaluator, addRuleFlags); |
+} |
+ |
void StyleEngine::createResolver() { |
m_resolver = StyleResolver::create(*m_document); |
@@ -1149,6 +1159,28 @@ const MediaQueryEvaluator& StyleEngine::ensureMediaQueryEvaluator() { |
return *m_mediaQueryEvaluator; |
} |
+bool StyleEngine::mediaQueryAffectedByViewportChange() { |
+ const MediaQueryEvaluator& evaluator = ensureMediaQueryEvaluator(); |
+ const auto& results = |
+ m_globalRuleSet.ruleFeatureSet().viewportDependentMediaQueryResults(); |
+ for (unsigned i = 0; i < results.size(); ++i) { |
+ if (evaluator.eval(results[i]->expression()) != results[i]->result()) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+bool StyleEngine::mediaQueryAffectedByDeviceChange() { |
+ const MediaQueryEvaluator& evaluator = ensureMediaQueryEvaluator(); |
+ const auto& results = |
+ m_globalRuleSet.ruleFeatureSet().deviceDependentMediaQueryResults(); |
+ for (unsigned i = 0; i < results.size(); ++i) { |
+ if (evaluator.eval(results[i]->expression()) != results[i]->result()) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
DEFINE_TRACE(StyleEngine) { |
visitor->trace(m_document); |
visitor->trace(m_injectedAuthorStyleSheets); |