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

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

Issue 129633003: Add a first pass of a class descendant invalidator, and a containing RuleSetAnalyzer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Implement tree walk for descendant class invalidation. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/RuleFeature.cpp ('k') | Source/core/css/analyzer/DescendantInvalidationSet.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) 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 21 matching lines...) Expand all
32 #include "HTMLNames.h" 32 #include "HTMLNames.h"
33 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
34 #include "core/css/CSSFontSelector.h" 34 #include "core/css/CSSFontSelector.h"
35 #include "core/css/CSSSelector.h" 35 #include "core/css/CSSSelector.h"
36 #include "core/css/CSSSelectorList.h" 36 #include "core/css/CSSSelectorList.h"
37 #include "core/css/SelectorChecker.h" 37 #include "core/css/SelectorChecker.h"
38 #include "core/css/SelectorCheckerFastPath.h" 38 #include "core/css/SelectorCheckerFastPath.h"
39 #include "core/css/SelectorFilter.h" 39 #include "core/css/SelectorFilter.h"
40 #include "core/css/StyleRuleImport.h" 40 #include "core/css/StyleRuleImport.h"
41 #include "core/css/StyleSheetContents.h" 41 #include "core/css/StyleSheetContents.h"
42 #include "core/css/analyzer/RuleSetAnalyzer.h"
42 #include "core/html/track/TextTrackCue.h" 43 #include "core/html/track/TextTrackCue.h"
43 #include "platform/weborigin/SecurityOrigin.h" 44 #include "platform/weborigin/SecurityOrigin.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
47 using namespace HTMLNames; 48 using namespace HTMLNames;
48 49
49 // ----------------------------------------------------------------- 50 // -----------------------------------------------------------------
50 51
51 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector* sele ctor) 52 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector* sele ctor)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSele ctor(selector())) 201 , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSele ctor(selector()))
201 , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector())) 202 , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector()))
202 , m_hasDocumentSecurityOrigin(addRuleFlags & RuleHasDocumentSecurityOrigin) 203 , m_hasDocumentSecurityOrigin(addRuleFlags & RuleHasDocumentSecurityOrigin)
203 , m_propertyWhitelistType(determinePropertyWhitelistType(addRuleFlags, selec tor())) 204 , m_propertyWhitelistType(determinePropertyWhitelistType(addRuleFlags, selec tor()))
204 { 205 {
205 ASSERT(m_position == position); 206 ASSERT(m_position == position);
206 ASSERT(m_selectorIndex == selectorIndex); 207 ASSERT(m_selectorIndex == selectorIndex);
207 SelectorFilter::collectIdentifierHashes(selector(), m_descendantSelectorIden tifierHashes, maximumIdentifierCount); 208 SelectorFilter::collectIdentifierHashes(selector(), m_descendantSelectorIden tifierHashes, maximumIdentifierCount);
208 } 209 }
209 210
210 static void collectFeaturesFromRuleData(RuleFeatureSet& features, const RuleData & ruleData)
211 {
212 bool foundSiblingSelector = false;
213 unsigned maxDirectAdjacentSelectors = 0;
214 for (const CSSSelector* selector = ruleData.selector(); selector; selector = selector->tagHistory()) {
215 features.collectFeaturesFromSelector(selector);
216
217 if (const CSSSelectorList* selectorList = selector->selectorList()) {
218 for (const CSSSelector* subSelector = selectorList->first(); subSele ctor; subSelector = CSSSelectorList::next(subSelector)) {
219 // FIXME: Shouldn't this be checking subSelector->isSiblingSelec tor()?
220 if (!foundSiblingSelector && selector->isSiblingSelector())
221 foundSiblingSelector = true;
222 if (subSelector->isDirectAdjacentSelector())
223 maxDirectAdjacentSelectors++;
224 features.collectFeaturesFromSelector(subSelector);
225 }
226 } else {
227 if (!foundSiblingSelector && selector->isSiblingSelector())
228 foundSiblingSelector = true;
229 if (selector->isDirectAdjacentSelector())
230 maxDirectAdjacentSelectors++;
231 }
232 }
233 features.setMaxDirectAdjacentSelectors(maxDirectAdjacentSelectors);
234 if (foundSiblingSelector)
235 features.siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selec torIndex(), ruleData.hasDocumentSecurityOrigin()));
236 if (ruleData.containsUncommonAttributeSelector())
237 features.uncommonAttributeRules.append(RuleFeature(ruleData.rule(), rule Data.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
238 }
239
240 void RuleSet::addToRuleSet(StringImpl* key, PendingRuleMap& map, const RuleData& ruleData) 211 void RuleSet::addToRuleSet(StringImpl* key, PendingRuleMap& map, const RuleData& ruleData)
241 { 212 {
242 if (!key) 213 if (!key)
243 return; 214 return;
244 OwnPtr<LinkedStack<RuleData> >& rules = map.add(key, nullptr).iterator->valu e; 215 OwnPtr<LinkedStack<RuleData> >& rules = map.add(key, nullptr).iterator->valu e;
245 if (!rules) 216 if (!rules)
246 rules = adoptPtr(new LinkedStack<RuleData>); 217 rules = adoptPtr(new LinkedStack<RuleData>);
247 rules->push(ruleData); 218 rules->push(ruleData);
248 } 219 }
249 220
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 addToRuleSet(component->tagQName().localName().impl(), ensurePending Rules()->tagRules, ruleData); 263 addToRuleSet(component->tagQName().localName().impl(), ensurePending Rules()->tagRules, ruleData);
293 return true; 264 return true;
294 } 265 }
295 } 266 }
296 return false; 267 return false;
297 } 268 }
298 269
299 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR uleFlags) 270 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR uleFlags)
300 { 271 {
301 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); 272 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags);
302 collectFeaturesFromRuleData(m_features, ruleData); 273 m_features.ensureRuleSetAnalyzer()->collectFeaturesFromRuleData(m_features, ruleData);
303 274
304 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) { 275 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) {
305 // If we didn't find a specialized map to stick it in, file under univer sal rules. 276 // If we didn't find a specialized map to stick it in, file under univer sal rules.
306 m_universalRules.append(ruleData); 277 m_universalRules.append(ruleData);
307 } 278 }
308 } 279 }
309 280
310 void RuleSet::addPageRule(StyleRulePage* rule) 281 void RuleSet::addPageRule(StyleRulePage* rule)
311 { 282 {
312 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called. 283 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 m_universalRules.shrinkToFit(); 418 m_universalRules.shrinkToFit();
448 m_pageRules.shrinkToFit(); 419 m_pageRules.shrinkToFit();
449 m_viewportRules.shrinkToFit(); 420 m_viewportRules.shrinkToFit();
450 m_fontFaceRules.shrinkToFit(); 421 m_fontFaceRules.shrinkToFit();
451 m_keyframesRules.shrinkToFit(); 422 m_keyframesRules.shrinkToFit();
452 m_treeBoundaryCrossingRules.shrinkToFit(); 423 m_treeBoundaryCrossingRules.shrinkToFit();
453 m_shadowDistributedRules.shrinkToFit(); 424 m_shadowDistributedRules.shrinkToFit();
454 } 425 }
455 426
456 } // namespace WebCore 427 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/RuleFeature.cpp ('k') | Source/core/css/analyzer/DescendantInvalidationSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698