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

Side by Side Diff: Source/core/css/resolver/StyleResolver.h

Issue 23049008: Replace style sharing cousin list search with LRU (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updating to ToT Created 7 years, 3 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
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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 18 matching lines...) Expand all
29 #include "core/css/RuleFeature.h" 29 #include "core/css/RuleFeature.h"
30 #include "core/css/RuleSet.h" 30 #include "core/css/RuleSet.h"
31 #include "core/css/SelectorChecker.h" 31 #include "core/css/SelectorChecker.h"
32 #include "core/css/SelectorFilter.h" 32 #include "core/css/SelectorFilter.h"
33 #include "core/css/SiblingTraversalStrategies.h" 33 #include "core/css/SiblingTraversalStrategies.h"
34 #include "core/css/resolver/MatchedPropertiesCache.h" 34 #include "core/css/resolver/MatchedPropertiesCache.h"
35 #include "core/css/resolver/ScopedStyleResolver.h" 35 #include "core/css/resolver/ScopedStyleResolver.h"
36 #include "core/css/resolver/StyleBuilder.h" 36 #include "core/css/resolver/StyleBuilder.h"
37 #include "core/css/resolver/StyleResolverState.h" 37 #include "core/css/resolver/StyleResolverState.h"
38 #include "core/css/resolver/StyleResourceLoader.h" 38 #include "core/css/resolver/StyleResourceLoader.h"
39 #include "wtf/Deque.h"
39 #include "wtf/HashMap.h" 40 #include "wtf/HashMap.h"
40 #include "wtf/HashSet.h" 41 #include "wtf/HashSet.h"
41 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
42 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 class CSSAnimationUpdate; 47 class CSSAnimationUpdate;
47 class CSSFontSelector; 48 class CSSFontSelector;
48 class CSSRuleList; 49 class CSSRuleList;
(...skipping 29 matching lines...) Expand all
78 79
79 // MatchOnlyUserAgentRules is used in media queries, where relative units 80 // MatchOnlyUserAgentRules is used in media queries, where relative units
80 // are interpreted according to the document root element style, and styled only 81 // are interpreted according to the document root element style, and styled only
81 // from the User Agent Stylesheet rules. 82 // from the User Agent Stylesheet rules.
82 enum RuleMatchingBehavior { 83 enum RuleMatchingBehavior {
83 MatchAllRules, 84 MatchAllRules,
84 MatchAllRulesExcludingSMIL, 85 MatchAllRulesExcludingSMIL,
85 MatchOnlyUserAgentRules, 86 MatchOnlyUserAgentRules,
86 }; 87 };
87 88
89 const unsigned styleSharingListSize = 40;
90 typedef WTF::Deque<RefPtr<Element>, styleSharingListSize> StyleSharingList;
91
88 #undef STYLE_STATS 92 #undef STYLE_STATS
89 93
90 #ifdef STYLE_STATS 94 #ifdef STYLE_STATS
91 struct StyleSharingStats { 95 struct StyleSharingStats {
92 void addSearch() { ++m_searches; ++m_totalSearches; } 96 void addSearch() { ++m_searches; ++m_totalSearches; }
93 void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_to talElementsEligibleForSharing; } 97 void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_to talElementsEligibleForSharing; }
94 void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; } 98 void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; }
95 void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; + +m_totalSearchFoundSiblingForSharing; } 99 void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; + +m_totalSearchFoundSiblingForSharing; }
96 void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearches MissedSharing; } 100 void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearches MissedSharing; }
97 void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_total MatchedPropertiesSearches; } 101 void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_total MatchedPropertiesSearches; }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 268
265 // FIXME: StyleResolver should not have this member or method. 269 // FIXME: StyleResolver should not have this member or method.
266 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; } 270 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; }
267 271
268 // Exposed for ScopedStyleResolver. 272 // Exposed for ScopedStyleResolver.
269 // FIXME: Likely belongs on viewportStyleResolver. 273 // FIXME: Likely belongs on viewportStyleResolver.
270 void collectViewportRules(RuleSet*); 274 void collectViewportRules(RuleSet*);
271 275
272 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } 276 const RuleFeatureSet& ruleFeatureSet() const { return m_features; }
273 277
278 StyleSharingList& styleSharingList() { return m_styleSharingList; }
279
280 void addToStyleSharingList(Element*);
281 void clearStyleSharingList();
282
274 #ifdef STYLE_STATS 283 #ifdef STYLE_STATS
275 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; } 284 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; }
276 #endif 285 #endif
277 private: 286 private:
278 // FIXME: This should probably go away, folded into FontBuilder. 287 // FIXME: This should probably go away, folded into FontBuilder.
279 void updateFont(StyleResolverState&); 288 void updateFont(StyleResolverState&);
280 289
281 void matchUARules(ElementRuleCollector&, RuleSet*); 290 void matchUARules(ElementRuleCollector&, RuleSet*);
282 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s); 291 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s);
283 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es); 292 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them 356 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them
348 // between various parts of machinery smells wrong. This needs to be better somehow. 357 // between various parts of machinery smells wrong. This needs to be better somehow.
349 RuleFeatureSet m_features; 358 RuleFeatureSet m_features;
350 OwnPtr<RuleSet> m_siblingRuleSet; 359 OwnPtr<RuleSet> m_siblingRuleSet;
351 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; 360 OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
352 361
353 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 362 InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
354 363
355 StyleResourceLoader m_styleResourceLoader; 364 StyleResourceLoader m_styleResourceLoader;
356 365
366 StyleSharingList m_styleSharingList;
367
357 #ifdef STYLE_STATS 368 #ifdef STYLE_STATS
358 static StyleSharingStats m_styleSharingStats; 369 static StyleSharingStats m_styleSharingStats;
359 #endif 370 #endif
360 }; 371 };
361 372
362 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement) 373 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement)
363 { 374 {
364 if (!regionSelector || !regionElement) 375 if (!regionSelector || !regionElement)
365 return false; 376 return false;
366 377
367 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules); 378 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules);
368 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) { 379 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) {
369 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled); 380 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled);
370 PseudoId ignoreDynamicPseudo = NOPSEUDO; 381 PseudoId ignoreDynamicPseudo = NOPSEUDO;
371 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 382 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
372 return true; 383 return true;
373 } 384 }
374 return false; 385 return false;
375 } 386 }
376 387
377 } // namespace WebCore 388 } // namespace WebCore
378 389
379 #endif // StyleResolver_h 390 #endif // StyleResolver_h
OLDNEW
« no previous file with comments | « Source/core/css/resolver/SharedStyleFinder.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698