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

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

Issue 24106007: Replace style sharing cousin list search with LRU (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updating with esprehn's changes 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; } 270 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; }
267 271
268 enum ViewportOrigin { UserAgentOrigin, AuthorOrigin }; 272 enum ViewportOrigin { UserAgentOrigin, AuthorOrigin };
269 273
270 // Exposed for ScopedStyleResolver. 274 // Exposed for ScopedStyleResolver.
271 // FIXME: Likely belongs on viewportStyleResolver. 275 // FIXME: Likely belongs on viewportStyleResolver.
272 void collectViewportRules(RuleSet*, ViewportOrigin); 276 void collectViewportRules(RuleSet*, ViewportOrigin);
273 277
274 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } 278 const RuleFeatureSet& ruleFeatureSet() const { return m_features; }
275 279
280 StyleSharingList& styleSharingList() { return m_styleSharingList; }
281
282 bool supportsStyleSharing(Element*);
283
284 void addToStyleSharingList(Element*);
285 void clearStyleSharingList();
286
276 #ifdef STYLE_STATS 287 #ifdef STYLE_STATS
277 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; } 288 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; }
278 #endif 289 #endif
279 private: 290 private:
280 // FIXME: This should probably go away, folded into FontBuilder. 291 // FIXME: This should probably go away, folded into FontBuilder.
281 void updateFont(StyleResolverState&); 292 void updateFont(StyleResolverState&);
282 293
283 void matchUARules(ElementRuleCollector&, RuleSet*); 294 void matchUARules(ElementRuleCollector&, RuleSet*);
284 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s); 295 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s);
285 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es); 296 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them 360 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them
350 // between various parts of machinery smells wrong. This needs to be better somehow. 361 // between various parts of machinery smells wrong. This needs to be better somehow.
351 RuleFeatureSet m_features; 362 RuleFeatureSet m_features;
352 OwnPtr<RuleSet> m_siblingRuleSet; 363 OwnPtr<RuleSet> m_siblingRuleSet;
353 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; 364 OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
354 365
355 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 366 InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
356 367
357 StyleResourceLoader m_styleResourceLoader; 368 StyleResourceLoader m_styleResourceLoader;
358 369
370 StyleSharingList m_styleSharingList;
371
359 #ifdef STYLE_STATS 372 #ifdef STYLE_STATS
360 static StyleSharingStats m_styleSharingStats; 373 static StyleSharingStats m_styleSharingStats;
361 #endif 374 #endif
362 }; 375 };
363 376
364 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement) 377 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement)
365 { 378 {
366 if (!regionSelector || !regionElement) 379 if (!regionSelector || !regionElement)
367 return false; 380 return false;
368 381
369 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules); 382 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules);
370 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) { 383 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) {
371 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled); 384 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled);
372 PseudoId ignoreDynamicPseudo = NOPSEUDO; 385 PseudoId ignoreDynamicPseudo = NOPSEUDO;
373 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 386 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
374 return true; 387 return true;
375 } 388 }
376 return false; 389 return false;
377 } 390 }
378 391
379 } // namespace WebCore 392 } // namespace WebCore
380 393
381 #endif // StyleResolver_h 394 #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