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 23 matching lines...) Expand all Loading... |
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/ScopedStyleTree.h" | 36 #include "core/css/resolver/ScopedStyleTree.h" |
37 #include "core/css/resolver/StyleBuilder.h" | 37 #include "core/css/resolver/StyleBuilder.h" |
38 #include "core/css/resolver/StyleResolverIncludes.h" | 38 #include "core/css/resolver/StyleResolverIncludes.h" |
39 #include "core/css/resolver/StyleResolverState.h" | 39 #include "core/css/resolver/StyleResolverState.h" |
40 #include "core/css/resolver/StyleResourceLoader.h" | 40 #include "core/css/resolver/StyleResourceLoader.h" |
41 #include "wtf/Deque.h" | 41 #include "wtf/Deque.h" |
42 #include "wtf/HashMap.h" | 42 #include "wtf/HashMap.h" |
43 #include "wtf/HashSet.h" | 43 #include "wtf/HashSet.h" |
| 44 #include "wtf/ListHashSet.h" |
44 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
45 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
46 | 47 |
47 namespace WebCore { | 48 namespace WebCore { |
48 | 49 |
49 class CSSAnimationUpdate; | 50 class CSSAnimationUpdate; |
50 class CSSFontSelector; | 51 class CSSFontSelector; |
51 class CSSRuleList; | 52 class CSSRuleList; |
52 class CSSSelector; | 53 class CSSSelector; |
53 class CSSStyleSheet; | 54 class CSSStyleSheet; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. | 140 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. |
140 // https://bugs.webkit.org/show_bug.cgi?id=108890 | 141 // https://bugs.webkit.org/show_bug.cgi?id=108890 |
141 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle
Sheet> >&); | 142 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle
Sheet> >&); |
142 void resetAuthorStyle(const ContainerNode*); | 143 void resetAuthorStyle(const ContainerNode*); |
143 void resetAtHostRules(const ShadowRoot*); | 144 void resetAtHostRules(const ShadowRoot*); |
144 void finishAppendAuthorStyleSheets(); | 145 void finishAppendAuthorStyleSheets(); |
145 | 146 |
146 TreeBoundaryCrossingRules& treeBoundaryCrossingRules() { return m_treeBounda
ryCrossingRules; } | 147 TreeBoundaryCrossingRules& treeBoundaryCrossingRules() { return m_treeBounda
ryCrossingRules; } |
147 void processScopedRules(const RuleSet& authorRules, const KURL&, ContainerNo
de* scope = 0); | 148 void processScopedRules(const RuleSet& authorRules, const KURL&, ContainerNo
de* scope = 0); |
148 | 149 |
| 150 void lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSS
tyleSheet> >&); |
| 151 void removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); |
| 152 void appendPendingAuthorStyleSheets(); |
| 153 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size(
) > 0 || m_needCollectFeatures; } |
| 154 |
149 SelectorFilter& selectorFilter() { return m_selectorFilter; } | 155 SelectorFilter& selectorFilter() { return m_selectorFilter; } |
150 | 156 |
151 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB
uildInDocumentOrder(enabled); } | 157 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB
uildInDocumentOrder(enabled); } |
152 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI
nDocumentOrder(); } | 158 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI
nDocumentOrder(); } |
153 bool styleTreeHasOnlyScopedResolverForDocument() const { return m_styleTree.
hasOnlyScopedResolverForDocument(); } | 159 bool styleTreeHasOnlyScopedResolverForDocument() const { return m_styleTree.
hasOnlyScopedResolverForDocument(); } |
154 ScopedStyleResolver* styleTreeScopedStyleResolverForDocument() const { retur
n m_styleTree.scopedStyleResolverForDocument(); } | 160 ScopedStyleResolver* styleTreeScopedStyleResolverForDocument() const { retur
n m_styleTree.scopedStyleResolverForDocument(); } |
155 | 161 |
156 ScopedStyleResolver* ensureScopedStyleResolver(ContainerNode* scope) | 162 ScopedStyleResolver* ensureScopedStyleResolver(ContainerNode* scope) |
157 { | 163 { |
158 return m_styleTree.ensureScopedStyleResolver(scope ? *scope : document()
); | 164 return m_styleTree.ensureScopedStyleResolver(scope ? *scope : document()
); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 198 |
193 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. | 199 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. |
194 void invalidateMatchedPropertiesCache(); | 200 void invalidateMatchedPropertiesCache(); |
195 | 201 |
196 // Exposed for RenderStyle::isStyleAvilable(). | 202 // Exposed for RenderStyle::isStyleAvilable(). |
197 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} | 203 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} |
198 | 204 |
199 // FIXME: StyleResolver should not have this member or method. | 205 // FIXME: StyleResolver should not have this member or method. |
200 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr
appers; } | 206 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr
appers; } |
201 | 207 |
202 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } | 208 const RuleFeatureSet& ensureRuleFeatureSet() |
| 209 { |
| 210 if (hasPendingAuthorStyleSheets()) |
| 211 appendPendingAuthorStyleSheets(); |
| 212 return m_features; |
| 213 } |
203 | 214 |
204 StyleSharingList& styleSharingList() { return m_styleSharingList; } | 215 StyleSharingList& styleSharingList() { return m_styleSharingList; } |
205 | 216 |
206 bool hasRulesForId(const AtomicString&) const; | 217 bool hasRulesForId(const AtomicString&) const; |
207 | 218 |
208 void addToStyleSharingList(Element&); | 219 void addToStyleSharingList(Element&); |
209 void clearStyleSharingList(); | 220 void clearStyleSharingList(); |
210 | 221 |
211 StyleResolverStats* stats() { return m_styleResolverStats.get(); } | 222 StyleResolverStats* stats() { return m_styleResolverStats.get(); } |
212 StyleResolverStats* statsTotals() { return m_styleResolverStatsTotals.get();
} | 223 StyleResolverStats* statsTotals() { return m_styleResolverStatsTotals.get();
} |
213 enum StatsReportType { ReportDefaultStats, ReportSlowStats }; | 224 enum StatsReportType { ReportDefaultStats, ReportSlowStats }; |
214 void enableStats(StatsReportType = ReportDefaultStats); | 225 void enableStats(StatsReportType = ReportDefaultStats); |
215 void disableStats(); | 226 void disableStats(); |
216 void printStats(); | 227 void printStats(); |
217 | 228 |
218 private: | 229 private: |
219 // FontSelectorClient implementation. | 230 // FontSelectorClient implementation. |
220 virtual void fontsNeedUpdate(FontSelector*); | 231 virtual void fontsNeedUpdate(FontSelector*); |
221 | 232 |
222 private: | 233 private: |
223 void initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& watchedSelec
tors); | 234 void initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& watchedSelec
tors); |
224 | 235 |
225 void addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>&, ContainerN
ode* scope); | 236 void addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>&, ContainerN
ode* scope); |
226 | 237 |
227 // FIXME: This should probably go away, folded into FontBuilder. | 238 // FIXME: This should probably go away, folded into FontBuilder. |
228 void updateFont(StyleResolverState&); | 239 void updateFont(StyleResolverState&); |
229 | 240 |
| 241 void filterViewportRules(const Vector<RefPtr<StyleRuleBase> >& rules, bool&
needsResolveViewport); |
| 242 void filterViewportRulesFromSheet(StyleSheetContents*, bool& needsResolveVie
wport); |
| 243 bool filterViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vecto
r<RefPtr<CSSStyleSheet> >& styleSheets); |
| 244 |
230 void collectPseudoRulesForElement(Element*, ElementRuleCollector&, PseudoId,
unsigned rulesToInclude); | 245 void collectPseudoRulesForElement(Element*, ElementRuleCollector&, PseudoId,
unsigned rulesToInclude); |
231 void matchUARules(ElementRuleCollector&, RuleSet*); | 246 void matchUARules(ElementRuleCollector&, RuleSet*); |
232 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); | 247 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); |
233 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc
ludeEmptyRules, Vector<ScopedStyleResolver*, 8>& resolvers, Vector<ScopedStyleRe
solver*, 8>& resolversInShadowTree); | 248 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc
ludeEmptyRules, Vector<ScopedStyleResolver*, 8>& resolvers, Vector<ScopedStyleRe
solver*, 8>& resolversInShadowTree); |
234 void matchHostRules(Element*, ScopedStyleResolver*, ElementRuleCollector&, b
ool includeEmptyRules); | 249 void matchHostRules(Element*, ScopedStyleResolver*, ElementRuleCollector&, b
ool includeEmptyRules); |
235 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); | 250 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); |
236 void matchUARules(ElementRuleCollector&); | 251 void matchUARules(ElementRuleCollector&); |
237 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 | 252 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 |
238 void matchWatchSelectorRules(ElementRuleCollector&); | 253 void matchWatchSelectorRules(ElementRuleCollector&); |
239 void collectFeatures(); | 254 void collectFeatures(); |
240 void collectTreeBoundaryCrossingRules(Element*, ElementRuleCollector&, bool
includeEmptyRules); | 255 void collectTreeBoundaryCrossingRules(Element*, ElementRuleCollector&, bool
includeEmptyRules); |
| 256 void resetRuleFeatures(); |
241 | 257 |
242 bool fastRejectSelector(const RuleData&) const; | 258 bool fastRejectSelector(const RuleData&) const; |
243 | 259 |
244 void applyMatchedProperties(StyleResolverState&, const MatchResult&, Element
* animatingElement); | 260 void applyMatchedProperties(StyleResolverState&, const MatchResult&, Element
* animatingElement); |
245 void applyAnimatedProperties(StyleResolverState&, Element* animatingElement)
; | 261 void applyAnimatedProperties(StyleResolverState&, Element* animatingElement)
; |
246 | 262 |
247 enum StyleApplicationPass { | 263 enum StyleApplicationPass { |
248 VariableDefinitions, | 264 VariableDefinitions, |
249 AnimationProperties, | 265 AnimationProperties, |
250 HighPriorityProperties, | 266 HighPriorityProperties, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 299 |
284 RefPtr<RenderStyle> m_rootDefaultStyle; | 300 RefPtr<RenderStyle> m_rootDefaultStyle; |
285 | 301 |
286 Document& m_document; | 302 Document& m_document; |
287 SelectorFilter m_selectorFilter; | 303 SelectorFilter m_selectorFilter; |
288 | 304 |
289 RefPtr<CSSFontSelector> m_fontSelector; | 305 RefPtr<CSSFontSelector> m_fontSelector; |
290 | 306 |
291 RefPtr<ViewportStyleResolver> m_viewportStyleResolver; | 307 RefPtr<ViewportStyleResolver> m_viewportStyleResolver; |
292 | 308 |
| 309 ListHashSet<CSSStyleSheet*, 16> m_pendingStyleSheets; |
| 310 |
293 ScopedStyleTree m_styleTree; | 311 ScopedStyleTree m_styleTree; |
294 | 312 |
295 // FIXME: The entire logic of collecting features on StyleResolver, as well
astransferring them | 313 // FIXME: The entire logic of collecting features on StyleResolver, as well
astransferring them |
296 // between various parts of machinery smells wrong. This needs to be better
somehow. | 314 // between various parts of machinery smells wrong. This needs to be better
somehow. |
297 RuleFeatureSet m_features; | 315 RuleFeatureSet m_features; |
298 OwnPtr<RuleSet> m_siblingRuleSet; | 316 OwnPtr<RuleSet> m_siblingRuleSet; |
299 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; | 317 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; |
| 318 |
300 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 | 319 // FIXME: watched selectors should be implemented using injected author styl
esheets: http://crbug.com/316960 |
301 OwnPtr<RuleSet> m_watchedSelectorsRules; | 320 OwnPtr<RuleSet> m_watchedSelectorsRules; |
302 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; | 321 TreeBoundaryCrossingRules m_treeBoundaryCrossingRules; |
303 | 322 |
| 323 bool m_needCollectFeatures; |
| 324 |
304 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; | 325 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; |
305 | 326 |
306 StyleResourceLoader m_styleResourceLoader; | 327 StyleResourceLoader m_styleResourceLoader; |
307 | 328 |
308 StyleSharingList m_styleSharingList; | 329 StyleSharingList m_styleSharingList; |
309 | 330 |
310 OwnPtr<StyleResolverStats> m_styleResolverStats; | 331 OwnPtr<StyleResolverStats> m_styleResolverStats; |
311 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; | 332 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; |
312 unsigned m_styleResolverStatsSequence; | 333 unsigned m_styleResolverStatsSequence; |
313 }; | 334 }; |
314 | 335 |
315 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) | 336 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) |
316 { | 337 { |
317 if (!regionSelector || !regionElement) | 338 if (!regionSelector || !regionElement) |
318 return false; | 339 return false; |
319 | 340 |
320 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); | 341 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); |
321 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ | 342 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ |
322 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); | 343 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); |
323 PseudoId ignoreDynamicPseudo = NOPSEUDO; | 344 PseudoId ignoreDynamicPseudo = NOPSEUDO; |
324 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | 345 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) |
325 return true; | 346 return true; |
326 } | 347 } |
327 return false; | 348 return false; |
328 } | 349 } |
329 | 350 |
330 } // namespace WebCore | 351 } // namespace WebCore |
331 | 352 |
332 #endif // StyleResolver_h | 353 #endif // StyleResolver_h |
OLD | NEW |