Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 2528633003: Move MediaQueryResults to RuleFeatureSet. (Closed)
Patch Set: Removed members. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/StyleEngineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698