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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 class ElementRuleCollector; | 58 class ElementRuleCollector; |
59 class KeyframeList; | 59 class KeyframeList; |
60 class KeyframeValue; | 60 class KeyframeValue; |
61 class MediaQueryEvaluator; | 61 class MediaQueryEvaluator; |
62 class MediaQueryResult; | 62 class MediaQueryResult; |
63 class RenderRegion; | 63 class RenderRegion; |
64 class RuleData; | 64 class RuleData; |
65 class Settings; | 65 class Settings; |
66 class StyleKeyframe; | 66 class StyleKeyframe; |
67 class StylePropertySet; | 67 class StylePropertySet; |
| 68 class StyleResolverStats; |
68 class StyleRule; | 69 class StyleRule; |
69 class StyleRuleKeyframes; | 70 class StyleRuleKeyframes; |
70 class StyleRulePage; | 71 class StyleRulePage; |
71 class ViewportStyleResolver; | 72 class ViewportStyleResolver; |
72 | 73 |
73 struct MatchResult; | 74 struct MatchResult; |
74 | 75 |
75 enum StyleSharingBehavior { | 76 enum StyleSharingBehavior { |
76 AllowStyleSharing, | 77 AllowStyleSharing, |
77 DisallowStyleSharing, | 78 DisallowStyleSharing, |
78 }; | 79 }; |
79 | 80 |
80 // MatchOnlyUserAgentRules is used in media queries, where relative units | 81 // MatchOnlyUserAgentRules is used in media queries, where relative units |
81 // are interpreted according to the document root element style, and styled only | 82 // are interpreted according to the document root element style, and styled only |
82 // from the User Agent Stylesheet rules. | 83 // from the User Agent Stylesheet rules. |
83 enum RuleMatchingBehavior { | 84 enum RuleMatchingBehavior { |
84 MatchAllRules, | 85 MatchAllRules, |
85 MatchAllRulesExcludingSMIL, | 86 MatchAllRulesExcludingSMIL, |
86 MatchOnlyUserAgentRules, | 87 MatchOnlyUserAgentRules, |
87 }; | 88 }; |
88 | 89 |
89 const unsigned styleSharingListSize = 40; | 90 const unsigned styleSharingListSize = 40; |
90 typedef WTF::Deque<Element*, styleSharingListSize> StyleSharingList; | 91 typedef WTF::Deque<Element*, styleSharingListSize> StyleSharingList; |
91 | 92 |
92 #undef STYLE_STATS | |
93 | |
94 #ifdef STYLE_STATS | |
95 struct StyleSharingStats { | |
96 void addSearch() { ++m_searches; ++m_totalSearches; } | |
97 void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_to
talElementsEligibleForSharing; } | |
98 void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; } | |
99 void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; +
+m_totalSearchFoundSiblingForSharing; } | |
100 void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearches
MissedSharing; } | |
101 void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_total
MatchedPropertiesSearches; } | |
102 void addMatchedPropertiesHit() { ++m_matchedPropertiesHit; ++m_totalMatchedP
ropertiesHit; } | |
103 void addMatchedPropertiesHitSharedInherited() { ++m_matchedPropertiesSharedI
nheritedHit; ++m_totalMatchedPropertiesSharedInheritedHit; } | |
104 void addMatchedPropertiesToCache() { ++m_matchedPropertiesToCache; ++m_total
MatchedPropertiesToCache; } | |
105 void addMatchedPropertiesEnteredIntoCache() { ++m_matchedPropertiesEnteredIn
toCache; ++m_totalMatchedPropertiesEnteredIntoCache; } | |
106 | |
107 void clear() | |
108 { | |
109 m_searches = m_elementsEligibleForSharing = m_stylesShared = m_searchesM
issedSharing = m_searchFoundSiblingForSharing = | |
110 m_matchedPropertiesSearches = m_matchedPropertiesHit = m_matchedProp
ertiesSharedInheritedHit = m_matchedPropertiesToCache = | |
111 m_matchedPropertiesEnteredIntoCache = 0; | |
112 } | |
113 | |
114 void printStats() const; | |
115 | |
116 unsigned m_searches; | |
117 unsigned m_elementsEligibleForSharing; | |
118 unsigned m_stylesShared; | |
119 unsigned m_searchFoundSiblingForSharing; | |
120 unsigned m_searchesMissedSharing; | |
121 unsigned m_matchedPropertiesSearches; | |
122 unsigned m_matchedPropertiesHit; | |
123 unsigned m_matchedPropertiesSharedInheritedHit; | |
124 unsigned m_matchedPropertiesToCache; | |
125 unsigned m_matchedPropertiesEnteredIntoCache; | |
126 | |
127 unsigned m_totalSearches; | |
128 unsigned m_totalElementsEligibleForSharing; | |
129 unsigned m_totalStylesShared; | |
130 unsigned m_totalSearchFoundSiblingForSharing; | |
131 unsigned m_totalSearchesMissedSharing; | |
132 unsigned m_totalMatchedPropertiesSearches; | |
133 unsigned m_totalMatchedPropertiesHit; | |
134 unsigned m_totalMatchedPropertiesSharedInheritedHit; | |
135 unsigned m_totalMatchedPropertiesToCache; | |
136 unsigned m_totalMatchedPropertiesEnteredIntoCache; | |
137 }; | |
138 | |
139 #define STYLE_STATS_ADD_SEARCH() StyleResolver::styleSharingStats().addSearch(); | |
140 #define STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING() StyleResolver::styleShari
ngStats().addElementEligibleForSharing(); | |
141 #define STYLE_STATS_ADD_STYLE_SHARED() StyleResolver::styleSharingStats().addSty
leShared(); | |
142 #define STYLE_STATS_ADD_SEARCH_FOUND_SIBLING_FOR_SHARING() StyleResolver::styleS
haringStats().addSearchFoundSiblingForSharing(); | |
143 #define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() StyleResolver::styleSharingStats
().addSearchMissedSharing(); | |
144 #define STYLE_STATS_PRINT() StyleResolver::styleSharingStats().printStats(); | |
145 #define STYLE_STATS_CLEAR() StyleResolver::styleSharingStats().clear(); | |
146 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH() StyleResolver::styleSharingS
tats().addMatchedPropertiesSearch(); | |
147 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT() StyleResolver::styleSharingStat
s().addMatchedPropertiesHit(); | |
148 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT_SHARED_INHERITED() StyleResolver:
:styleSharingStats().addMatchedPropertiesHitSharedInherited(); | |
149 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE() StyleResolver::styleSharin
gStats().addMatchedPropertiesToCache(); | |
150 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_ENTERED_INTO_CACHE() StyleResolver::s
tyleSharingStats().addMatchedPropertiesEnteredIntoCache(); | |
151 #else | |
152 #define STYLE_STATS_ADD_SEARCH() (void(0)); | |
153 #define STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING() (void(0)); | |
154 #define STYLE_STATS_ADD_STYLE_SHARED() (void(0)); | |
155 #define STYLE_STATS_ADD_SEARCH_FOUND_SIBLING_FOR_SHARING() (void(0)); | |
156 #define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() (void(0)); | |
157 #define STYLE_STATS_PRINT() (void(0)); | |
158 #define STYLE_STATS_CLEAR() (void(0)); | |
159 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH() (void(0)); | |
160 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT() (void(0)); | |
161 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT_SHARED_INHERITED() (void(0)); | |
162 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE() (void(0)); | |
163 #define STYLE_STATS_ADD_MATCHED_PROPERTIES_ENTERED_INTO_CACHE() (void(0)); | |
164 #endif | |
165 | |
166 struct CSSPropertyValue { | 93 struct CSSPropertyValue { |
167 CSSPropertyValue(CSSPropertyID property, CSSValue* value) | 94 CSSPropertyValue(CSSPropertyID property, CSSValue* value) |
168 : property(property), value(value) { } | 95 : property(property), value(value) { } |
169 // Stores value=propertySet.getPropertyCSSValue(id).get(). | 96 // Stores value=propertySet.getPropertyCSSValue(id).get(). |
170 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); | 97 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); |
171 CSSPropertyID property; | 98 CSSPropertyID property; |
172 CSSValue* value; | 99 CSSValue* value; |
173 }; | 100 }; |
174 | 101 |
175 // This class selects a RenderStyle for a given element based on a collection of
stylesheets. | 102 // This class selects a RenderStyle for a given element based on a collection of
stylesheets. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 200 |
274 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } | 201 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } |
275 | 202 |
276 StyleSharingList& styleSharingList() { return m_styleSharingList; } | 203 StyleSharingList& styleSharingList() { return m_styleSharingList; } |
277 | 204 |
278 bool hasRulesForId(const AtomicString&) const; | 205 bool hasRulesForId(const AtomicString&) const; |
279 | 206 |
280 void addToStyleSharingList(Element&); | 207 void addToStyleSharingList(Element&); |
281 void clearStyleSharingList(); | 208 void clearStyleSharingList(); |
282 | 209 |
283 #ifdef STYLE_STATS | 210 StyleResolverStats* stats() { return m_styleResolverStats.get(); } |
284 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style
SharingStats; } | 211 StyleResolverStats* statsTotals() { return m_styleResolverStatsTotals.get();
} |
285 #endif | 212 enum StatsReportType { ReportDefaultStats, ReportSlowStats }; |
| 213 void enableStats(StatsReportType = ReportDefaultStats); |
| 214 void disableStats(); |
| 215 void printStats(); |
286 | 216 |
287 private: | 217 private: |
288 // FontSelectorClient implementation. | 218 // FontSelectorClient implementation. |
289 virtual void fontsNeedUpdate(FontSelector*); | 219 virtual void fontsNeedUpdate(FontSelector*); |
290 | 220 |
291 private: | 221 private: |
292 void initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& watchedSelec
tors); | 222 void initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& watchedSelec
tors); |
293 | 223 |
294 // FIXME: This should probably go away, folded into FontBuilder. | 224 // FIXME: This should probably go away, folded into FontBuilder. |
295 void updateFont(StyleResolverState&); | 225 void updateFont(StyleResolverState&); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 | 296 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 |
367 OwnPtr<RuleSet> m_watchedSelectorsRules; | 297 OwnPtr<RuleSet> m_watchedSelectorsRules; |
368 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; | 298 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; |
369 | 299 |
370 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; | 300 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; |
371 | 301 |
372 StyleResourceLoader m_styleResourceLoader; | 302 StyleResourceLoader m_styleResourceLoader; |
373 | 303 |
374 StyleSharingList m_styleSharingList; | 304 StyleSharingList m_styleSharingList; |
375 | 305 |
376 #ifdef STYLE_STATS | 306 OwnPtr<StyleResolverStats> m_styleResolverStats; |
377 static StyleSharingStats m_styleSharingStats; | 307 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; |
378 #endif | 308 unsigned m_styleResolverStatsSequence; |
379 }; | 309 }; |
380 | 310 |
381 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) | 311 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) |
382 { | 312 { |
383 if (!regionSelector || !regionElement) | 313 if (!regionSelector || !regionElement) |
384 return false; | 314 return false; |
385 | 315 |
386 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); | 316 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); |
387 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ | 317 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ |
388 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); | 318 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); |
389 PseudoId ignoreDynamicPseudo = NOPSEUDO; | 319 PseudoId ignoreDynamicPseudo = NOPSEUDO; |
390 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | 320 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) |
391 return true; | 321 return true; |
392 } | 322 } |
393 return false; | 323 return false; |
394 } | 324 } |
395 | 325 |
396 } // namespace WebCore | 326 } // namespace WebCore |
397 | 327 |
398 #endif // StyleResolver_h | 328 #endif // StyleResolver_h |
OLD | NEW |