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

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

Issue 23701014: Revert "Replace style sharing cousin list search with LRU" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compiler error 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"
40 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
41 #include "wtf/HashSet.h" 40 #include "wtf/HashSet.h"
42 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
43 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
44 43
45 namespace WebCore { 44 namespace WebCore {
46 45
47 class CSSAnimationUpdate; 46 class CSSAnimationUpdate;
48 class CSSFontSelector; 47 class CSSFontSelector;
49 class CSSRuleList; 48 class CSSRuleList;
(...skipping 29 matching lines...) Expand all
79 78
80 // MatchOnlyUserAgentRules is used in media queries, where relative units 79 // MatchOnlyUserAgentRules is used in media queries, where relative units
81 // are interpreted according to the document root element style, and styled only 80 // are interpreted according to the document root element style, and styled only
82 // from the User Agent Stylesheet rules. 81 // from the User Agent Stylesheet rules.
83 enum RuleMatchingBehavior { 82 enum RuleMatchingBehavior {
84 MatchAllRules, 83 MatchAllRules,
85 MatchAllRulesExcludingSMIL, 84 MatchAllRulesExcludingSMIL,
86 MatchOnlyUserAgentRules, 85 MatchOnlyUserAgentRules,
87 }; 86 };
88 87
89 const unsigned styleSharingListSize = 40;
90 typedef WTF::Deque<RefPtr<Element>, styleSharingListSize> StyleSharingList;
91
92 #undef STYLE_STATS 88 #undef STYLE_STATS
93 89
94 #ifdef STYLE_STATS 90 #ifdef STYLE_STATS
95 struct StyleSharingStats { 91 struct StyleSharingStats {
96 void addSearch() { ++m_searches; ++m_totalSearches; } 92 void addSearch() { ++m_searches; ++m_totalSearches; }
97 void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_to talElementsEligibleForSharing; } 93 void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_to talElementsEligibleForSharing; }
98 void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; } 94 void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; }
99 void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; + +m_totalSearchFoundSiblingForSharing; } 95 void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; + +m_totalSearchFoundSiblingForSharing; }
100 void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearches MissedSharing; } 96 void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearches MissedSharing; }
101 void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_total MatchedPropertiesSearches; } 97 void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_total MatchedPropertiesSearches; }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; } 266 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; }
271 267
272 enum ViewportOrigin { UserAgentOrigin, AuthorOrigin }; 268 enum ViewportOrigin { UserAgentOrigin, AuthorOrigin };
273 269
274 // Exposed for ScopedStyleResolver. 270 // Exposed for ScopedStyleResolver.
275 // FIXME: Likely belongs on viewportStyleResolver. 271 // FIXME: Likely belongs on viewportStyleResolver.
276 void collectViewportRules(RuleSet*, ViewportOrigin); 272 void collectViewportRules(RuleSet*, ViewportOrigin);
277 273
278 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } 274 const RuleFeatureSet& ruleFeatureSet() const { return m_features; }
279 275
280 StyleSharingList& styleSharingList() { return m_styleSharingList; }
281
282 void addToStyleSharingList(Element*);
283 void clearStyleSharingList();
284
285 #ifdef STYLE_STATS 276 #ifdef STYLE_STATS
286 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; } 277 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; }
287 #endif 278 #endif
288 private: 279 private:
289 // FIXME: This should probably go away, folded into FontBuilder. 280 // FIXME: This should probably go away, folded into FontBuilder.
290 void updateFont(StyleResolverState&); 281 void updateFont(StyleResolverState&);
291 282
292 void matchUARules(ElementRuleCollector&, RuleSet*); 283 void matchUARules(ElementRuleCollector&, RuleSet*);
293 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s); 284 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s);
294 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es); 285 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul es);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them 349 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them
359 // between various parts of machinery smells wrong. This needs to be better somehow. 350 // between various parts of machinery smells wrong. This needs to be better somehow.
360 RuleFeatureSet m_features; 351 RuleFeatureSet m_features;
361 OwnPtr<RuleSet> m_siblingRuleSet; 352 OwnPtr<RuleSet> m_siblingRuleSet;
362 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; 353 OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
363 354
364 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 355 InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
365 356
366 StyleResourceLoader m_styleResourceLoader; 357 StyleResourceLoader m_styleResourceLoader;
367 358
368 StyleSharingList m_styleSharingList;
369
370 #ifdef STYLE_STATS 359 #ifdef STYLE_STATS
371 static StyleSharingStats m_styleSharingStats; 360 static StyleSharingStats m_styleSharingStats;
372 #endif 361 #endif
373 }; 362 };
374 363
375 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement) 364 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi onElement)
376 { 365 {
377 if (!regionSelector || !regionElement) 366 if (!regionSelector || !regionElement)
378 return false; 367 return false;
379 368
380 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules); 369 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker:: QueryingRules);
381 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) { 370 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) {
382 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled); 371 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi onElement, SelectorChecker::VisitedMatchDisabled);
383 PseudoId ignoreDynamicPseudo = NOPSEUDO; 372 PseudoId ignoreDynamicPseudo = NOPSEUDO;
384 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 373 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
385 return true; 374 return true;
386 } 375 }
387 return false; 376 return false;
388 } 377 }
389 378
390 } // namespace WebCore 379 } // namespace WebCore
391 380
392 #endif // StyleResolver_h 381 #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