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

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

Issue 42543007: StyleResolver should update RuleSets lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 21 matching lines...) Expand all
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/Deque.h"
40 #include "wtf/HashMap.h" 40 #include "wtf/HashMap.h"
41 #include "wtf/HashSet.h" 41 #include "wtf/HashSet.h"
42 #include "wtf/ListHashSet.h"
42 #include "wtf/RefPtr.h" 43 #include "wtf/RefPtr.h"
43 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
47 class CSSAnimationUpdate; 48 class CSSAnimationUpdate;
48 class CSSFontSelector; 49 class CSSFontSelector;
49 class CSSRuleList; 50 class CSSRuleList;
50 class CSSSelector; 51 class CSSSelector;
51 class CSSStyleSheet; 52 class CSSStyleSheet;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // their dependency on Document* instead of grabbing one through StyleResolv er. 209 // their dependency on Document* instead of grabbing one through StyleResolv er.
209 Document& document() { return m_document; } 210 Document& document() { return m_document; }
210 211
211 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() di rectly after we factor StyleRsolver further. 212 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() di rectly after we factor StyleRsolver further.
212 // https://bugs.webkit.org/show_bug.cgi?id=108890 213 // https://bugs.webkit.org/show_bug.cgi?id=108890
213 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle Sheet> >&); 214 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle Sheet> >&);
214 void resetAuthorStyle(const ContainerNode*); 215 void resetAuthorStyle(const ContainerNode*);
215 void resetAtHostRules(const ContainerNode*); 216 void resetAtHostRules(const ContainerNode*);
216 void finishAppendAuthorStyleSheets(); 217 void finishAppendAuthorStyleSheets();
217 218
219 void lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSS tyleSheet> >&);
220 void removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&);
221 void appendPendingAuthorStyleSheets();
222 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size( ) > 0 || m_needCollectFeatures; }
223
218 DocumentRuleSets& ruleSets() { return m_ruleSets; } 224 DocumentRuleSets& ruleSets() { return m_ruleSets; }
219 const DocumentRuleSets& ruleSets() const { return m_ruleSets; } 225 const DocumentRuleSets& ruleSets() const { return m_ruleSets; }
220 SelectorFilter& selectorFilter() { return m_selectorFilter; } 226 SelectorFilter& selectorFilter() { return m_selectorFilter; }
221 227
222 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB uildInDocumentOrder(enabled); } 228 void setBuildScopedStyleTreeInDocumentOrder(bool enabled) { m_styleTree.setB uildInDocumentOrder(enabled); }
223 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI nDocumentOrder(); } 229 bool buildScopedStyleTreeInDocumentOrder() const { return m_styleTree.buildI nDocumentOrder(); }
224 230
225 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope) 231 ScopedStyleResolver* ensureScopedStyleResolver(const ContainerNode* scope)
226 { 232 {
227 return m_styleTree.ensureScopedStyleResolver(scope ? *scope : document() ); 233 return m_styleTree.ensureScopedStyleResolver(scope ? *scope : document() );
(...skipping 28 matching lines...) Expand all
256 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something . 262 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something .
257 void invalidateMatchedPropertiesCache(); 263 void invalidateMatchedPropertiesCache();
258 264
259 // Exposed for RenderStyle::isStyleAvilable(). 265 // Exposed for RenderStyle::isStyleAvilable().
260 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } 266 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; }
261 267
262 // FIXME: StyleResolver should not have this member or method. 268 // FIXME: StyleResolver should not have this member or method.
263 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; } 269 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr appers; }
264 270
265 const RuleFeatureSet& ruleFeatureSet() const { return m_features; } 271 const RuleFeatureSet& ruleFeatureSet() const { return m_features; }
272 const RuleFeatureSet& ensureRuleFeatureSet()
273 {
274 if (hasPendingAuthorStyleSheets())
275 appendPendingAuthorStyleSheets(); // slow path.
276 return m_features;
277 }
266 278
267 StyleSharingList& styleSharingList() { return m_styleSharingList; } 279 StyleSharingList& styleSharingList() { return m_styleSharingList; }
268 280
269 bool hasRulesForId(const AtomicString&) const; 281 bool hasRulesForId(const AtomicString&) const;
270 282
271 void addToStyleSharingList(Element*); 283 void addToStyleSharingList(Element*);
272 void clearStyleSharingList(); 284 void clearStyleSharingList();
273 285
274 #ifdef STYLE_STATS 286 #ifdef STYLE_STATS
275 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; } 287 ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_style SharingStats; }
276 #endif 288 #endif
277 289
278 private: 290 private:
279 // FontSelectorClient implementation. 291 // FontSelectorClient implementation.
280 virtual void fontsNeedUpdate(FontSelector*); 292 virtual void fontsNeedUpdate(FontSelector*);
281 293
282 private: 294 private:
283 // FIXME: This should probably go away, folded into FontBuilder. 295 // FIXME: This should probably go away, folded into FontBuilder.
284 void updateFont(StyleResolverState&); 296 void updateFont(StyleResolverState&);
285 297
286 void matchUARules(ElementRuleCollector&, RuleSet*); 298 void matchUARules(ElementRuleCollector&, RuleSet*);
287 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s); 299 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule s);
288 void collectShadowDistributedRules(ElementRuleCollector&, bool includeEmptyR ules); 300 void collectShadowDistributedRules(ElementRuleCollector&, bool includeEmptyR ules);
289 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc ludeEmptyRules, Vector<ScopedStyleResolver*, 8>& resolvers, Vector<ScopedStyleRe solver*, 8>& resolversInShadowTree); 301 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc ludeEmptyRules, Vector<ScopedStyleResolver*, 8>& resolvers, Vector<ScopedStyleRe solver*, 8>& resolversInShadowTree);
290 void matchHostRules(Element*, ScopedStyleResolver*, ElementRuleCollector&, b ool includeEmptyRules); 302 void matchHostRules(Element*, ScopedStyleResolver*, ElementRuleCollector&, b ool includeEmptyRules);
291 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool matchAut horAndUserStyles, bool includeSMILProperties); 303 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool matchAut horAndUserStyles, bool includeSMILProperties);
292 void matchUARules(ElementRuleCollector&); 304 void matchUARules(ElementRuleCollector&);
293 void matchUserRules(ElementRuleCollector&, bool includeEmptyRules); 305 void matchUserRules(ElementRuleCollector&, bool includeEmptyRules);
294 void collectFeatures(); 306 void collectFeatures();
307 void resetRuleFeatures();
295 308
296 bool fastRejectSelector(const RuleData&) const; 309 bool fastRejectSelector(const RuleData&) const;
297 310
298 void applyMatchedProperties(StyleResolverState&, const MatchResult&); 311 void applyMatchedProperties(StyleResolverState&, const MatchResult&);
299 312
300 enum StyleApplicationPass { 313 enum StyleApplicationPass {
301 VariableDefinitions, 314 VariableDefinitions,
302 AnimationProperties, 315 AnimationProperties,
303 HighPriorityProperties, 316 HighPriorityProperties,
304 LowPriorityProperties 317 LowPriorityProperties
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 353
341 Document& m_document; 354 Document& m_document;
342 SelectorFilter m_selectorFilter; 355 SelectorFilter m_selectorFilter;
343 356
344 bool m_matchAuthorAndUserStyles; 357 bool m_matchAuthorAndUserStyles;
345 358
346 RefPtr<CSSFontSelector> m_fontSelector; 359 RefPtr<CSSFontSelector> m_fontSelector;
347 360
348 RefPtr<ViewportStyleResolver> m_viewportStyleResolver; 361 RefPtr<ViewportStyleResolver> m_viewportStyleResolver;
349 362
363 ListHashSet<CSSStyleSheet*, 16> m_pendingStyleSheets;
364
350 ScopedStyleTree m_styleTree; 365 ScopedStyleTree m_styleTree;
351 366
352 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them 367 // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them
353 // between various parts of machinery smells wrong. This needs to be better somehow. 368 // between various parts of machinery smells wrong. This needs to be better somehow.
354 RuleFeatureSet m_features; 369 RuleFeatureSet m_features;
355 OwnPtr<RuleSet> m_siblingRuleSet; 370 OwnPtr<RuleSet> m_siblingRuleSet;
356 OwnPtr<RuleSet> m_uncommonAttributeRuleSet; 371 OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
372 bool m_needCollectFeatures;
357 373
358 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 374 InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
359 375
360 StyleResourceLoader m_styleResourceLoader; 376 StyleResourceLoader m_styleResourceLoader;
361 377
362 StyleSharingList m_styleSharingList; 378 StyleSharingList m_styleSharingList;
363 379
364 #ifdef STYLE_STATS 380 #ifdef STYLE_STATS
365 static StyleSharingStats m_styleSharingStats; 381 static StyleSharingStats m_styleSharingStats;
366 #endif 382 #endif
(...skipping 10 matching lines...) Expand all
377 PseudoId ignoreDynamicPseudo = NOPSEUDO; 393 PseudoId ignoreDynamicPseudo = NOPSEUDO;
378 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) 394 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
379 return true; 395 return true;
380 } 396 }
381 return false; 397 return false;
382 } 398 }
383 399
384 } // namespace WebCore 400 } // namespace WebCore
385 401
386 #endif // StyleResolver_h 402 #endif // StyleResolver_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/resolver/StyleResolver.cpp » ('j') | Source/core/css/resolver/StyleResolver.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698