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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2012 Google Inc. All rights reserved. 5 * Copyright (C) 2012 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ruleSet.fontFaceRules(); 76 ruleSet.fontFaceRules();
77 for (auto& fontFaceRule : fontFaceRules) { 77 for (auto& fontFaceRule : fontFaceRules) {
78 if (FontFace* fontFace = FontFace::create(&document, fontFaceRule)) 78 if (FontFace* fontFace = FontFace::create(&document, fontFaceRule))
79 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, 79 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule,
80 fontFace); 80 fontFace);
81 } 81 }
82 if (fontFaceRules.size()) 82 if (fontFaceRules.size())
83 document.styleResolver()->invalidateMatchedPropertiesCache(); 83 document.styleResolver()->invalidateMatchedPropertiesCache();
84 } 84 }
85 85
86 void ScopedStyleResolver::appendCSSStyleSheet( 86 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) {
87 CSSStyleSheet& cssSheet, 87 RuleSet* ruleSet =
88 const MediaQueryEvaluator& medium) { 88 treeScope().document().styleEngine().ruleSetForSheet(cssSheet);
89
90 m_viewportDependentMediaQueryResults.appendVector(
91 cssSheet.viewportDependentMediaQueryResults());
92 m_deviceDependentMediaQueryResults.appendVector(
93 cssSheet.deviceDependentMediaQueryResults());
94 if (!ruleSet)
95 return;
96
89 unsigned index = m_authorStyleSheets.size(); 97 unsigned index = m_authorStyleSheets.size();
90 m_authorStyleSheets.append(&cssSheet); 98 m_authorStyleSheets.append(&cssSheet);
91 StyleSheetContents* sheet = cssSheet.contents(); 99 addKeyframeRules(*ruleSet);
92 AddRuleFlags addRuleFlags = 100 addFontFaceRules(*ruleSet);
93 treeScope().document().getSecurityOrigin()->canRequest(sheet->baseURL()) 101 addTreeBoundaryCrossingRules(*ruleSet, &cssSheet, index);
94 ? RuleHasDocumentSecurityOrigin
95 : RuleHasNoSpecialState;
96 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
97
98 addKeyframeRules(ruleSet);
99 addFontFaceRules(ruleSet);
100 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
101 treeScope().document().styleResolver()->addViewportDependentMediaQueries(
102 ruleSet.viewportDependentMediaQueryResults());
103 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(
104 ruleSet.deviceDependentMediaQueryResults());
105 } 102 }
106 103
107 void ScopedStyleResolver::appendActiveStyleSheets( 104 void ScopedStyleResolver::appendActiveStyleSheets(
108 unsigned index, 105 unsigned index,
109 const ActiveStyleSheetVector& activeSheets) { 106 const ActiveStyleSheetVector& activeSheets) {
110 for (auto activeIterator = activeSheets.begin() + index; 107 for (auto activeIterator = activeSheets.begin() + index;
111 activeIterator != activeSheets.end(); activeIterator++) { 108 activeIterator != activeSheets.end(); activeIterator++) {
112 CSSStyleSheet* sheet = activeIterator->first; 109 CSSStyleSheet* sheet = activeIterator->first;
110 m_viewportDependentMediaQueryResults.appendVector(
111 sheet->viewportDependentMediaQueryResults());
112 m_deviceDependentMediaQueryResults.appendVector(
113 sheet->deviceDependentMediaQueryResults());
113 if (!activeIterator->second) 114 if (!activeIterator->second)
114 continue; 115 continue;
115 const RuleSet& ruleSet = *activeIterator->second; 116 const RuleSet& ruleSet = *activeIterator->second;
116 m_authorStyleSheets.append(sheet); 117 m_authorStyleSheets.append(sheet);
117 addKeyframeRules(ruleSet); 118 addKeyframeRules(ruleSet);
118 addFontFaceRules(ruleSet); 119 addFontFaceRules(ruleSet);
119 addTreeBoundaryCrossingRules(ruleSet, sheet, index++); 120 addTreeBoundaryCrossingRules(ruleSet, sheet, index++);
120 } 121 }
121 } 122 }
122 123
123 void ScopedStyleResolver::collectFeaturesTo( 124 void ScopedStyleResolver::collectFeaturesTo(
124 RuleFeatureSet& features, 125 RuleFeatureSet& features,
125 HeapHashSet<Member<const StyleSheetContents>>& 126 HeapHashSet<Member<const StyleSheetContents>>&
126 visitedSharedStyleSheetContents) const { 127 visitedSharedStyleSheetContents) const {
128 features.viewportDependentMediaQueryResults().appendVector(
129 m_viewportDependentMediaQueryResults);
130 features.deviceDependentMediaQueryResults().appendVector(
131 m_deviceDependentMediaQueryResults);
132
127 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 133 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
128 ASSERT(m_authorStyleSheets[i]->ownerNode()); 134 ASSERT(m_authorStyleSheets[i]->ownerNode());
129 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); 135 StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
130 if (contents->hasOneClient() || 136 if (contents->hasOneClient() ||
131 visitedSharedStyleSheetContents.add(contents).isNewEntry) 137 visitedSharedStyleSheetContents.add(contents).isNewEntry)
132 features.add(contents->ruleSet().features()); 138 features.add(contents->ruleSet().features());
133 } 139 }
134 140
135 if (!m_treeBoundaryCrossingRuleSet) 141 if (!m_treeBoundaryCrossingRuleSet)
136 return; 142 return;
137 143
138 for (const auto& rules : *m_treeBoundaryCrossingRuleSet) 144 for (const auto& rules : *m_treeBoundaryCrossingRuleSet)
139 features.add(rules->m_ruleSet->features()); 145 features.add(rules->m_ruleSet->features());
140 } 146 }
141 147
142 void ScopedStyleResolver::resetAuthorStyle() { 148 void ScopedStyleResolver::resetAuthorStyle() {
143 m_authorStyleSheets.clear(); 149 m_authorStyleSheets.clear();
150 m_viewportDependentMediaQueryResults.clear();
151 m_deviceDependentMediaQueryResults.clear();
144 m_keyframesRuleMap.clear(); 152 m_keyframesRuleMap.clear();
145 m_treeBoundaryCrossingRuleSet = nullptr; 153 m_treeBoundaryCrossingRuleSet = nullptr;
146 m_hasDeepOrShadowSelector = false; 154 m_hasDeepOrShadowSelector = false;
147 } 155 }
148 156
149 StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation( 157 StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(
150 const StringImpl* animationName) { 158 const StringImpl* animationName) {
151 if (m_keyframesRuleMap.isEmpty()) 159 if (m_keyframesRuleMap.isEmpty())
152 return nullptr; 160 return nullptr;
153 161
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Only consider the global author RuleSet for @page rules, as per the HTML5 263 // Only consider the global author RuleSet for @page rules, as per the HTML5
256 // spec. 264 // spec.
257 ASSERT(m_scope->rootNode().isDocumentNode()); 265 ASSERT(m_scope->rootNode().isDocumentNode());
258 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) 266 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
259 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet()); 267 collector.matchPageRules(&m_authorStyleSheets[i]->contents()->ruleSet());
260 } 268 }
261 269
262 DEFINE_TRACE(ScopedStyleResolver) { 270 DEFINE_TRACE(ScopedStyleResolver) {
263 visitor->trace(m_scope); 271 visitor->trace(m_scope);
264 visitor->trace(m_authorStyleSheets); 272 visitor->trace(m_authorStyleSheets);
273 visitor->trace(m_viewportDependentMediaQueryResults);
274 visitor->trace(m_deviceDependentMediaQueryResults);
265 visitor->trace(m_keyframesRuleMap); 275 visitor->trace(m_keyframesRuleMap);
266 visitor->trace(m_treeBoundaryCrossingRuleSet); 276 visitor->trace(m_treeBoundaryCrossingRuleSet);
267 } 277 }
268 278
269 static void addRules(RuleSet* ruleSet, 279 static void addRules(RuleSet* ruleSet,
270 const HeapVector<MinimalRuleData>& rules) { 280 const HeapVector<MinimalRuleData>& rules) {
271 for (unsigned i = 0; i < rules.size(); ++i) { 281 for (unsigned i = 0; i < rules.size(); ++i) {
272 const MinimalRuleData& info = rules[i]; 282 const MinimalRuleData& info = rules[i];
273 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags); 283 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags);
274 } 284 }
(...skipping 29 matching lines...) Expand all
304 m_treeBoundaryCrossingRuleSet->append( 314 m_treeBoundaryCrossingRuleSet->append(
305 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope)); 315 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope));
306 } 316 }
307 317
308 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) { 318 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) {
309 visitor->trace(m_parentStyleSheet); 319 visitor->trace(m_parentStyleSheet);
310 visitor->trace(m_ruleSet); 320 visitor->trace(m_ruleSet);
311 } 321 }
312 322
313 } // namespace blink 323 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698