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

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

Issue 212603002: RuleFeatures argument list cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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/RuleFeature.h ('k') | no next file » | 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) 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 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Fall through! 134 // Fall through!
135 case CSSSelector::SubSelector: 135 case CSSSelector::SubSelector:
136 continue; 136 continue;
137 default: 137 default:
138 return UseLocalStyleChange; 138 return UseLocalStyleChange;
139 } 139 }
140 } 140 }
141 return foundIdent ? AddFeatures : UseLocalStyleChange; 141 return foundIdent ? AddFeatures : UseLocalStyleChange;
142 } 142 }
143 143
144 void extractClassIdTagOrAttribute(const CSSSelector& selector, Vector<AtomicStri ng>& classes, AtomicString& id, AtomicString& tagName, Vector<AtomicString>& att ributes) 144 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features)
145 { 145 {
146 if (selector.m_match == CSSSelector::Tag) 146 if (selector.m_match == CSSSelector::Tag)
147 tagName = selector.tagQName().localName(); 147 features.tagName = selector.tagQName().localName();
148 else if (selector.m_match == CSSSelector::Id) 148 else if (selector.m_match == CSSSelector::Id)
149 id = selector.value(); 149 features.id = selector.value();
150 else if (selector.m_match == CSSSelector::Class) 150 else if (selector.m_match == CSSSelector::Class)
151 classes.append(selector.value()); 151 features.classes.append(selector.value());
152 else if (selector.isAttributeSelector()) 152 else if (selector.isAttributeSelector())
153 attributes.append(selector.attribute().localName()); 153 features.attributes.append(selector.attribute().localName());
154 } 154 }
155 155
156 RuleFeatureSet::RuleFeatureSet() 156 RuleFeatureSet::RuleFeatureSet()
157 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) 157 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled())
158 { 158 {
159 } 159 }
160 160
161 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector) 161 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector)
162 { 162 {
163 if (selector.m_match == CSSSelector::Class) 163 if (selector.m_match == CSSSelector::Class)
164 return &ensureClassInvalidationSet(selector.value()); 164 return &ensureClassInvalidationSet(selector.value());
165 if (selector.isAttributeSelector()) 165 if (selector.isAttributeSelector())
166 return &ensureAttributeInvalidationSet(selector.attribute().localName()) ; 166 return &ensureAttributeInvalidationSet(selector.attribute().localName()) ;
167 return 0; 167 return 0;
168 } 168 }
169 169
170 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) 170 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector)
171 { 171 {
172 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); 172 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector);
173 if (mode != AddFeatures) 173 if (mode != AddFeatures)
174 return mode; 174 return mode;
175 175
176 Vector<AtomicString> classes; 176 InvalidationSetFeatures features;
177 AtomicString id; 177 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur es);
178 AtomicString tagName;
179 Vector<AtomicString> attributes;
180
181 const CSSSelector* current = extractInvalidationSetFeatures(selector, classe s, id, tagName, attributes);
182 if (current) 178 if (current)
183 current = current->tagHistory(); 179 current = current->tagHistory();
184 180
185 if (current) 181 if (current)
186 addFeaturesToInvalidationSets(*current, classes, id, tagName, attributes ); 182 addFeaturesToInvalidationSets(*current, features);
187 return AddFeatures; 183 return AddFeatures;
188 } 184 }
189 185
190 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, Vector<AtomicString>& classes, AtomicString& id, AtomicString& ta gName, Vector<AtomicString>& attributes) 186 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features)
191 { 187 {
192 const CSSSelector* lastSelector = &selector; 188 const CSSSelector* lastSelector = &selector;
193 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { 189 for (; lastSelector; lastSelector = lastSelector->tagHistory()) {
194 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib utes); 190 extractInvalidationSetFeature(*lastSelector, features);
195 // Initialize the entry in the invalidation set map, if supported. 191 // Initialize the entry in the invalidation set map, if supported.
196 invalidationSetForSelector(*lastSelector); 192 invalidationSetForSelector(*lastSelector);
197 if (lastSelector->pseudoType() == CSSSelector::PseudoHost) { 193 if (lastSelector->pseudoType() == CSSSelector::PseudoHost) {
198 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { 194 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) {
199 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 195 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
200 extractInvalidationSetFeatures(*selector, classes, id, tagNa me, attributes); 196 extractInvalidationSetFeatures(*selector, features);
201 } 197 }
202 } 198 }
203 199
204 if (lastSelector->relation() != CSSSelector::SubSelector) 200 if (lastSelector->relation() != CSSSelector::SubSelector)
205 break; 201 break;
206 } 202 }
207 return lastSelector; 203 return lastSelector;
208 } 204 }
209 205
210 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const Vector<AtomicString>& classes, AtomicString id, AtomicString tagName, cons t Vector<AtomicString>& attributes) 206 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const InvalidationSetFeatures& features)
211 { 207 {
212 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 208 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
213 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { 209 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) {
214 if (!id.isEmpty()) 210 if (!features.id.isEmpty())
215 invalidationSet->addId(id); 211 invalidationSet->addId(features.id);
216 if (!tagName.isEmpty()) 212 if (!features.tagName.isEmpty())
217 invalidationSet->addTagName(tagName); 213 invalidationSet->addTagName(features.tagName);
218 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) 214 for (Vector<AtomicString>::const_iterator it = features.classes.begi n(); it != features.classes.end(); ++it)
219 invalidationSet->addClass(*it); 215 invalidationSet->addClass(*it);
220 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i t != attributes.end(); ++it) 216 for (Vector<AtomicString>::const_iterator it = features.attributes.b egin(); it != features.attributes.end(); ++it)
221 invalidationSet->addAttribute(*it); 217 invalidationSet->addAttribute(*it);
222 } else if (current->pseudoType() == CSSSelector::PseudoHost) { 218 } else if (current->pseudoType() == CSSSelector::PseudoHost) {
223 if (const CSSSelectorList* selectorList = current->selectorList()) { 219 if (const CSSSelectorList* selectorList = current->selectorList()) {
224 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 220 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
225 addFeaturesToInvalidationSets(*selector, classes, id, tagNam e, attributes); 221 addFeaturesToInvalidationSets(*selector, features);
226 } 222 }
227 } 223 }
228 } 224 }
229 } 225 }
230 226
231 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) 227 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName)
232 { 228 {
233 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); 229 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName);
234 invalidationSet.setWholeSubtreeInvalid(); 230 invalidationSet.setWholeSubtreeInvalid();
235 } 231 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (node->isElementNode()) 422 if (node->isElementNode())
427 m_pendingInvalidationMap.remove(toElement(node)); 423 m_pendingInvalidationMap.remove(toElement(node));
428 } 424 }
429 425
430 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() 426 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap()
431 { 427 {
432 return m_pendingInvalidationMap; 428 return m_pendingInvalidationMap;
433 } 429 }
434 430
435 } // namespace WebCore 431 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/RuleFeature.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698