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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.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/css/resolver/StyleResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
index afdc23d9e80316fd4e9f7493fb4e1f301c9ecf56..bb2f5de4825d01f1e788c0c9520de57eecd19d2c 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -177,13 +177,8 @@ static void collectScopedResolversForHostedShadowTrees(
}
}
-StyleResolver::StyleResolver(Document& document)
- : m_document(document), m_printMediaType(false), m_styleSharingDepth(0) {
- FrameView* view = document.view();
- DCHECK(view);
- m_medium = new MediaQueryEvaluator(&view->frame());
- m_printMediaType =
- equalIgnoringCase(view->mediaType(), MediaTypeNames::print);
+StyleResolver::StyleResolver(Document& document) : m_document(document) {
+ updateMediaType();
}
StyleResolver::~StyleResolver() {}
@@ -218,8 +213,10 @@ void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) {
isSVGStyleElement(cssSheet.ownerNode()) ||
cssSheet.ownerNode()->isConnected());
+ const MediaQueryEvaluator& evaluator =
+ document().styleEngine().ensureMediaQueryEvaluator();
if (cssSheet.mediaQueries() &&
- !m_medium->eval(cssSheet.mediaQueries(),
+ !evaluator.eval(cssSheet.mediaQueries(),
&m_viewportDependentMediaQueryResults,
&m_deviceDependentMediaQueryResults))
return;
@@ -240,7 +237,7 @@ void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) {
if (treeScope->rootNode().isDocumentNode())
treeScope = m_document;
treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet,
- *m_medium);
+ evaluator);
}
void StyleResolver::appendPendingAuthorStyleSheets() {
@@ -1958,8 +1955,10 @@ void StyleResolver::addDeviceDependentMediaQueries(
}
bool StyleResolver::mediaQueryAffectedByViewportChange() const {
+ const MediaQueryEvaluator& evaluator =
+ document().styleEngine().ensureMediaQueryEvaluator();
for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
- if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression()) !=
+ if (evaluator.eval(m_viewportDependentMediaQueryResults[i]->expression()) !=
m_viewportDependentMediaQueryResults[i]->result())
return true;
}
@@ -1967,17 +1966,25 @@ bool StyleResolver::mediaQueryAffectedByViewportChange() const {
}
bool StyleResolver::mediaQueryAffectedByDeviceChange() const {
+ const MediaQueryEvaluator& evaluator =
+ document().styleEngine().ensureMediaQueryEvaluator();
for (unsigned i = 0; i < m_deviceDependentMediaQueryResults.size(); ++i) {
- if (m_medium->eval(m_deviceDependentMediaQueryResults[i]->expression()) !=
+ if (evaluator.eval(m_deviceDependentMediaQueryResults[i]->expression()) !=
m_deviceDependentMediaQueryResults[i]->result())
return true;
}
return false;
}
+void StyleResolver::updateMediaType() {
+ if (FrameView* view = document().view()) {
+ m_printMediaType =
+ equalIgnoringCase(view->mediaType(), MediaTypeNames::print);
+ }
+}
+
DEFINE_TRACE(StyleResolver) {
visitor->trace(m_matchedPropertiesCache);
- visitor->trace(m_medium);
visitor->trace(m_viewportDependentMediaQueryResults);
visitor->trace(m_deviceDependentMediaQueryResults);
visitor->trace(m_selectorFilter);
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleResolver.h ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698