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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp

Issue 2528633003: Move MediaQueryResults to RuleFeatureSet. (Closed)
Patch Set: Removed members. Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) { 208 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) {
209 DCHECK(!cssSheet.disabled()); 209 DCHECK(!cssSheet.disabled());
210 DCHECK(cssSheet.ownerDocument()); 210 DCHECK(cssSheet.ownerDocument());
211 DCHECK(cssSheet.ownerNode()); 211 DCHECK(cssSheet.ownerNode());
212 DCHECK(isHTMLStyleElement(cssSheet.ownerNode()) || 212 DCHECK(isHTMLStyleElement(cssSheet.ownerNode()) ||
213 isSVGStyleElement(cssSheet.ownerNode()) || 213 isSVGStyleElement(cssSheet.ownerNode()) ||
214 cssSheet.ownerNode()->isConnected()); 214 cssSheet.ownerNode()->isConnected());
215 215
216 const MediaQueryEvaluator& evaluator =
217 document().styleEngine().ensureMediaQueryEvaluator();
218 if (cssSheet.mediaQueries() &&
219 !evaluator.eval(cssSheet.mediaQueries(),
220 &m_viewportDependentMediaQueryResults,
221 &m_deviceDependentMediaQueryResults))
222 return;
223
224 TreeScope* treeScope = &cssSheet.ownerNode()->treeScope(); 216 TreeScope* treeScope = &cssSheet.ownerNode()->treeScope();
225 // TODO(rune@opera.com): This is a workaround for crbug.com/559292 217 // TODO(rune@opera.com): This is a workaround for crbug.com/559292
226 // when we're in the middle of removing a subtree with a style element 218 // when we're in the middle of removing a subtree with a style element
227 // and the treescope has been changed but inDocument and isInShadowTree 219 // and the treescope has been changed but inDocument and isInShadowTree
228 // are not. 220 // are not.
229 // 221 //
230 // This check can be removed when crbug.com/567021 is fixed. 222 // This check can be removed when crbug.com/567021 is fixed.
231 if (cssSheet.ownerNode()->isInShadowTree() && 223 if (cssSheet.ownerNode()->isInShadowTree() &&
232 treeScope->rootNode().isDocumentNode()) 224 treeScope->rootNode().isDocumentNode())
233 return; 225 return;
234 226
235 // Sheets in the document scope of HTML imports apply to the main document 227 // Sheets in the document scope of HTML imports apply to the main document
236 // (m_document), so we override it for all document scoped sheets. 228 // (m_document), so we override it for all document scoped sheets.
237 if (treeScope->rootNode().isDocumentNode()) 229 if (treeScope->rootNode().isDocumentNode())
238 treeScope = m_document; 230 treeScope = m_document;
239 treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet, 231 treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet);
240 evaluator);
241 } 232 }
242 233
243 void StyleResolver::appendPendingAuthorStyleSheets() { 234 void StyleResolver::appendPendingAuthorStyleSheets() {
244 for (const auto& styleSheet : m_pendingStyleSheets) 235 for (const auto& styleSheet : m_pendingStyleSheets)
245 appendCSSStyleSheet(*styleSheet); 236 appendCSSStyleSheet(*styleSheet);
246 237
247 m_pendingStyleSheets.clear(); 238 m_pendingStyleSheets.clear();
248 } 239 }
249 240
250 void StyleResolver::appendAuthorStyleSheets( 241 void StyleResolver::appendAuthorStyleSheets(
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 state.setStyle(style); 1828 state.setStyle(style);
1838 1829
1839 for (CSSPropertyID property : properties) { 1830 for (CSSPropertyID property : properties) {
1840 if (property == CSSPropertyLineHeight) 1831 if (property == CSSPropertyLineHeight)
1841 updateFont(state); 1832 updateFont(state);
1842 StyleBuilder::applyProperty(property, state, 1833 StyleBuilder::applyProperty(property, state,
1843 *propertySet.getPropertyCSSValue(property)); 1834 *propertySet.getPropertyCSSValue(property));
1844 } 1835 }
1845 } 1836 }
1846 1837
1847 void StyleResolver::addViewportDependentMediaQueries(
1848 const MediaQueryResultList& list) {
1849 for (size_t i = 0; i < list.size(); ++i)
1850 m_viewportDependentMediaQueryResults.append(list[i]);
1851 }
1852
1853 void StyleResolver::addDeviceDependentMediaQueries(
1854 const MediaQueryResultList& list) {
1855 for (size_t i = 0; i < list.size(); ++i)
1856 m_deviceDependentMediaQueryResults.append(list[i]);
1857 }
1858
1859 bool StyleResolver::mediaQueryAffectedByViewportChange() const {
1860 const MediaQueryEvaluator& evaluator =
1861 document().styleEngine().ensureMediaQueryEvaluator();
1862 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
1863 if (evaluator.eval(m_viewportDependentMediaQueryResults[i]->expression()) !=
1864 m_viewportDependentMediaQueryResults[i]->result())
1865 return true;
1866 }
1867 return false;
1868 }
1869
1870 bool StyleResolver::mediaQueryAffectedByDeviceChange() const {
1871 const MediaQueryEvaluator& evaluator =
1872 document().styleEngine().ensureMediaQueryEvaluator();
1873 for (unsigned i = 0; i < m_deviceDependentMediaQueryResults.size(); ++i) {
1874 if (evaluator.eval(m_deviceDependentMediaQueryResults[i]->expression()) !=
1875 m_deviceDependentMediaQueryResults[i]->result())
1876 return true;
1877 }
1878 return false;
1879 }
1880
1881 void StyleResolver::updateMediaType() { 1838 void StyleResolver::updateMediaType() {
1882 if (FrameView* view = document().view()) { 1839 if (FrameView* view = document().view()) {
1883 m_printMediaType = 1840 m_printMediaType =
1884 equalIgnoringCase(view->mediaType(), MediaTypeNames::print); 1841 equalIgnoringCase(view->mediaType(), MediaTypeNames::print);
1885 } 1842 }
1886 } 1843 }
1887 1844
1888 DEFINE_TRACE(StyleResolver) { 1845 DEFINE_TRACE(StyleResolver) {
1889 visitor->trace(m_matchedPropertiesCache); 1846 visitor->trace(m_matchedPropertiesCache);
1890 visitor->trace(m_viewportDependentMediaQueryResults);
1891 visitor->trace(m_deviceDependentMediaQueryResults);
1892 visitor->trace(m_selectorFilter); 1847 visitor->trace(m_selectorFilter);
1893 visitor->trace(m_styleSharingLists); 1848 visitor->trace(m_styleSharingLists);
1894 visitor->trace(m_pendingStyleSheets); 1849 visitor->trace(m_pendingStyleSheets);
1895 visitor->trace(m_document); 1850 visitor->trace(m_document);
1896 visitor->trace(m_tracker); 1851 visitor->trace(m_tracker);
1897 } 1852 }
1898 1853
1899 } // namespace blink 1854 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleResolver.h ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698