OLD | NEW |
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 Loading... |
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 Loading... |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 272 |
269 // FIXME: StyleResolver should not have this member or method. | 273 // FIXME: StyleResolver should not have this member or method. |
270 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr
appers; } | 274 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr
appers; } |
271 | 275 |
272 // Exposed for ScopedStyleResolver. | 276 // Exposed for ScopedStyleResolver. |
273 // FIXME: Likely belongs on viewportStyleResolver. | 277 // FIXME: Likely belongs on viewportStyleResolver. |
274 void collectViewportRules(RuleSet*); | 278 void collectViewportRules(RuleSet*); |
275 | 279 |
276 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } | 280 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } |
277 | 281 |
| 282 StyleSharingList& styleSharingList() { return m_styleSharingList; } |
| 283 |
| 284 void addToStyleSharingList(Element*); |
| 285 void clearStyleSharingList(); |
| 286 |
278 #ifdef STYLE_STATS | 287 #ifdef STYLE_STATS |
279 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style
SharingStats; } | 288 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style
SharingStats; } |
280 #endif | 289 #endif |
281 private: | 290 private: |
282 // FIXME: This should probably go away, folded into FontBuilder. | 291 // FIXME: This should probably go away, folded into FontBuilder. |
283 void updateFont(StyleResolverState&); | 292 void updateFont(StyleResolverState&); |
284 | 293 |
285 void matchUARules(ElementRuleCollector&, RuleSet*); | 294 void matchUARules(ElementRuleCollector&, RuleSet*); |
286 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); | 295 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); |
287 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 Loading... |
351 // 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 |
352 // 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. |
353 RuleFeatureSet m_features; | 362 RuleFeatureSet m_features; |
354 OwnPtr<RuleSet> m_siblingRuleSet; | 363 OwnPtr<RuleSet> m_siblingRuleSet; |
355 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; | 364 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; |
356 | 365 |
357 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; | 366 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; |
358 | 367 |
359 StyleResourceLoader m_styleResourceLoader; | 368 StyleResourceLoader m_styleResourceLoader; |
360 | 369 |
| 370 StyleSharingList m_styleSharingList; |
| 371 |
361 #ifdef STYLE_STATS | 372 #ifdef STYLE_STATS |
362 static StyleSharingStats m_styleSharingStats; | 373 static StyleSharingStats m_styleSharingStats; |
363 #endif | 374 #endif |
364 }; | 375 }; |
365 | 376 |
366 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) | 377 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) |
367 { | 378 { |
368 if (!regionSelector || !regionElement) | 379 if (!regionSelector || !regionElement) |
369 return false; | 380 return false; |
370 | 381 |
371 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); | 382 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); |
372 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ | 383 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ |
373 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); | 384 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); |
374 PseudoId ignoreDynamicPseudo = NOPSEUDO; | 385 PseudoId ignoreDynamicPseudo = NOPSEUDO; |
375 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | 386 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) |
376 return true; | 387 return true; |
377 } | 388 } |
378 return false; | 389 return false; |
379 } | 390 } |
380 | 391 |
381 } // namespace WebCore | 392 } // namespace WebCore |
382 | 393 |
383 #endif // StyleResolver_h | 394 #endif // StyleResolver_h |
OLD | NEW |