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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 { 49 {
50 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) { 50 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) {
51 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver()) 51 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver())
52 return resolver; 52 return resolver;
53 } 53 }
54 return nullptr; 54 return nullptr;
55 } 55 }
56 56
57 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet) 57 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet)
58 { 58 {
59 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule s = ruleSet.keyframesRules(); 59 const HeapVector<Member<StyleRuleKeyframes>> keyframesRules = ruleSet.keyfra mesRules();
60 for (unsigned i = 0; i < keyframesRules.size(); ++i) 60 for (unsigned i = 0; i < keyframesRules.size(); ++i)
61 addKeyframeStyle(keyframesRules[i]); 61 addKeyframeStyle(keyframesRules[i]);
62 } 62 }
63 63
64 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) 64 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet)
65 { 65 {
66 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment. 66 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment.
67 if (!treeScope().rootNode().isDocumentNode()) 67 if (!treeScope().rootNode().isDocumentNode())
68 return; 68 return;
69 69
70 Document& document = treeScope().document(); 70 Document& document = treeScope().document();
71 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector(); 71 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector();
72 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFaceRules(); 72 const HeapVector<Member<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFace Rules();
73 for (auto& fontFaceRule : fontFaceRules) { 73 for (auto& fontFaceRule : fontFaceRules) {
74 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule)) 74 if (RawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule ))
75 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace); 75 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace);
76 } 76 }
77 if (fontFaceRules.size()) 77 if (fontFaceRules.size())
78 document.styleResolver()->invalidateMatchedPropertiesCache(); 78 document.styleResolver()->invalidateMatchedPropertiesCache();
79 } 79 }
80 80
81 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium) 81 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium)
82 { 82 {
83 unsigned index = m_authorStyleSheets.size(); 83 unsigned index = m_authorStyleSheets.size();
84 m_authorStyleSheets.append(&cssSheet); 84 m_authorStyleSheets.append(&cssSheet);
85 StyleSheetContents* sheet = cssSheet.contents(); 85 StyleSheetContents* sheet = cssSheet.contents();
86 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; 86 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
87 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); 87 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
88 88
89 addKeyframeRules(ruleSet); 89 addKeyframeRules(ruleSet);
90 addFontFaceRules(ruleSet); 90 addFontFaceRules(ruleSet);
91 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index); 91 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
92 treeScope().document().styleResolver()->addViewportDependentMediaQueries(rul eSet.viewportDependentMediaQueryResults()); 92 treeScope().document().styleResolver()->addViewportDependentMediaQueries(rul eSet.viewportDependentMediaQueryResults());
93 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(ruleS et.deviceDependentMediaQueryResults()); 93 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(ruleS et.deviceDependentMediaQueryResults());
94 } 94 }
95 95
96 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, WillBeHeap HashSet<RawPtrWillBeMember<const StyleSheetContents>>& visitedSharedStyleSheetCo ntents) const 96 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HeapHashSe t<Member<const StyleSheetContents>>& visitedSharedStyleSheetContents) const
97 { 97 {
98 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 98 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
99 ASSERT(m_authorStyleSheets[i]->ownerNode()); 99 ASSERT(m_authorStyleSheets[i]->ownerNode());
100 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); 100 StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
101 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont ents).isNewEntry) 101 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont ents).isNewEntry)
102 features.add(contents->ruleSet().features()); 102 features.add(contents->ruleSet().features());
103 } 103 }
104 104
105 if (!m_treeBoundaryCrossingRuleSet) 105 if (!m_treeBoundaryCrossingRuleSet)
106 return; 106 return;
(...skipping 15 matching lines...) Expand all
122 if (m_keyframesRuleMap.isEmpty()) 122 if (m_keyframesRuleMap.isEmpty())
123 return nullptr; 123 return nullptr;
124 124
125 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); 125 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName);
126 if (it == m_keyframesRuleMap.end()) 126 if (it == m_keyframesRuleMap.end())
127 return nullptr; 127 return nullptr;
128 128
129 return it->value.get(); 129 return it->value.get();
130 } 130 }
131 131
132 void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr ames> rule) 132 void ScopedStyleResolver::addKeyframeStyle(RawPtr<StyleRuleKeyframes> rule)
133 { 133 {
134 AtomicString s(rule->name()); 134 AtomicString s(rule->name());
135 135
136 if (rule->isVendorPrefixed()) { 136 if (rule->isVendorPrefixed()) {
137 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); 137 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl());
138 if (it == m_keyframesRuleMap.end()) 138 if (it == m_keyframesRuleMap.end())
139 m_keyframesRuleMap.set(s.impl(), rule); 139 m_keyframesRuleMap.set(s.impl(), rule);
140 else if (it->value->isVendorPrefixed()) 140 else if (it->value->isVendorPrefixed())
141 m_keyframesRuleMap.set(s.impl(), rule); 141 m_keyframesRuleMap.set(s.impl(), rule);
142 } else { 142 } else {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 DEFINE_TRACE(ScopedStyleResolver) 189 DEFINE_TRACE(ScopedStyleResolver)
190 { 190 {
191 #if ENABLE(OILPAN) 191 #if ENABLE(OILPAN)
192 visitor->trace(m_scope); 192 visitor->trace(m_scope);
193 visitor->trace(m_authorStyleSheets); 193 visitor->trace(m_authorStyleSheets);
194 visitor->trace(m_keyframesRuleMap); 194 visitor->trace(m_keyframesRuleMap);
195 visitor->trace(m_treeBoundaryCrossingRuleSet); 195 visitor->trace(m_treeBoundaryCrossingRuleSet);
196 #endif 196 #endif
197 } 197 }
198 198
199 static void addRules(RuleSet* ruleSet, const WillBeHeapVector<MinimalRuleData>& rules) 199 static void addRules(RuleSet* ruleSet, const HeapVector<MinimalRuleData>& rules)
200 { 200 {
201 for (unsigned i = 0; i < rules.size(); ++i) { 201 for (unsigned i = 0; i < rules.size(); ++i) {
202 const MinimalRuleData& info = rules[i]; 202 const MinimalRuleData& info = rules[i];
203 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags); 203 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags);
204 } 204 }
205 } 205 }
206 206
207 void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRule s, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex) 207 void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRule s, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex)
208 { 208 {
209 bool isDocumentScope = treeScope().rootNode().isDocumentNode(); 209 bool isDocumentScope = treeScope().rootNode().isDocumentNode();
210 if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty() 210 if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()
211 && (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty( ) && authorRules.slottedPseudoElementRules().isEmpty()))) 211 && (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty( ) && authorRules.slottedPseudoElementRules().isEmpty())))
212 return; 212 return;
213 213
214 if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()) 214 if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty())
215 m_hasDeepOrShadowSelector = true; 215 m_hasDeepOrShadowSelector = true;
216 216
217 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); 217 RawPtr<RuleSet> ruleSetForScope = RuleSet::create();
218 addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRule s()); 218 addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRule s());
219 219
220 if (!isDocumentScope) { 220 if (!isDocumentScope) {
221 addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules()) ; 221 addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules()) ;
222 addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules()) ; 222 addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules()) ;
223 } 223 }
224 224
225 if (!m_treeBoundaryCrossingRuleSet) { 225 if (!m_treeBoundaryCrossingRuleSet) {
226 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule SubSet()); 226 m_treeBoundaryCrossingRuleSet = (new CSSStyleSheetRuleSubSet());
227 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre eScope().rootNode()); 227 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre eScope().rootNode());
228 } 228 }
229 229
230 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release())); 230 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release()));
231 } 231 }
232 232
233 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) 233 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet)
234 { 234 {
235 visitor->trace(m_parentStyleSheet); 235 visitor->trace(m_parentStyleSheet);
236 visitor->trace(m_ruleSet); 236 visitor->trace(m_ruleSet);
237 } 237 }
238 238
239 } // namespace blink 239 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698