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

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

Issue 2521063005: Move MediaQueryEvaluator from StyleResolver to StyleEngine. (Closed)
Patch Set: Rebased 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 00b7648b4e1a7bca2d65b40d050a4bec99821368..1aafe09b6864acea84da637e6cd980af5d470a3c 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -265,7 +265,7 @@ bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(
return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate;
}
-void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(
+void StyleEngine::mediaQueryAffectingValueChanged(
UnorderedTreeScopeSet& treeScopes) {
for (TreeScope* treeScope : treeScopes) {
DCHECK(treeScope != m_document);
@@ -276,10 +276,12 @@ void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(
}
}
-void StyleEngine::clearMediaQueryRuleSetStyleSheets() {
+void StyleEngine::mediaQueryAffectingValueChanged() {
resolverChanged(FullStyleUpdate);
documentStyleSheetCollection().clearMediaQueryRuleSetStyleSheets();
- clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes);
+ mediaQueryAffectingValueChanged(m_activeTreeScopes);
+ if (m_resolver)
+ m_resolver->updateMediaType();
}
void StyleEngine::updateStyleSheetsInImport(
@@ -493,7 +495,8 @@ void StyleEngine::clearMasterResolver() {
void StyleEngine::didDetach() {
clearResolver();
- m_viewportResolver.clear();
+ m_viewportResolver = nullptr;
+ m_mediaQueryEvaluator = nullptr;
}
bool StyleEngine::shouldClearResolver() const {
@@ -1136,6 +1139,16 @@ void StyleEngine::applyRuleSetChanges(
scheduleInvalidationsForRuleSets(treeScope, changedRuleSets);
}
+const MediaQueryEvaluator& StyleEngine::ensureMediaQueryEvaluator() {
+ if (!m_mediaQueryEvaluator) {
+ if (document().frame())
+ m_mediaQueryEvaluator = new MediaQueryEvaluator(document().frame());
+ else
+ m_mediaQueryEvaluator = new MediaQueryEvaluator("all");
+ }
+ return *m_mediaQueryEvaluator;
+}
+
DEFINE_TRACE(StyleEngine) {
visitor->trace(m_document);
visitor->trace(m_injectedAuthorStyleSheets);
@@ -1148,6 +1161,7 @@ DEFINE_TRACE(StyleEngine) {
visitor->trace(m_globalRuleSet);
visitor->trace(m_resolver);
visitor->trace(m_viewportResolver);
+ visitor->trace(m_mediaQueryEvaluator);
visitor->trace(m_styleInvalidator);
visitor->trace(m_fontSelector);
visitor->trace(m_textToSheetCache);
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698