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

Side by Side Diff: Source/core/css/MediaQueryMatcher.cpp

Issue 242883002: Remove MediaValues' dependency on RenderStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modified minimal recalc tests to represent reduced recalc. Created 6 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « Source/core/css/MediaQueryEvaluatorTest.cpp ('k') | Source/core/css/MediaValues.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return nullAtom; 70 return nullAtom;
71 71
72 return m_document->frame()->view()->mediaType(); 72 return m_document->frame()->view()->mediaType();
73 } 73 }
74 74
75 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const 75 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const
76 { 76 {
77 if (!m_document || !m_document->frame()) 77 if (!m_document || !m_document->frame())
78 return nullptr; 78 return nullptr;
79 79
80 Element* documentElement = m_document->documentElement(); 80 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame()));
81 if (!documentElement)
82 return nullptr;
83
84 StyleResolver& styleResolver = m_document->ensureStyleResolver();
85 RefPtr<RenderStyle> rootStyle = styleResolver.styleForElement(documentElemen t, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules);
eseidel 2014/04/19 00:42:15 Yes, you're removing this recalc, so it's not surp
86
87 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), ro otStyle.get()));
88 } 81 }
89 82
90 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) 83 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media)
91 { 84 {
92 if (!media) 85 if (!media)
93 return false; 86 return false;
94 87
95 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator()); 88 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator());
96 return evaluator && evaluator->eval(media); 89 return evaluator && evaluator->eval(media);
97 } 90 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void MediaQueryMatcher::trace(Visitor* visitor) 147 void MediaQueryMatcher::trace(Visitor* visitor)
155 { 148 {
156 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >). 149 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >).
157 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled. 150 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled.
158 #if ENABLE(OILPAN) 151 #if ENABLE(OILPAN)
159 visitor->trace(m_listeners); 152 visitor->trace(m_listeners);
160 #endif 153 #endif
161 } 154 }
162 155
163 } 156 }
OLDNEW
« no previous file with comments | « Source/core/css/MediaQueryEvaluatorTest.cpp ('k') | Source/core/css/MediaValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698