 Chromium Code Reviews
 Chromium Code Reviews Issue 42543007:
  StyleResolver should update RuleSets lazily.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 42543007:
  StyleResolver should update RuleSets lazily.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| Index: Source/core/css/resolver/StyleResolver.h | 
| diff --git a/Source/core/css/resolver/StyleResolver.h b/Source/core/css/resolver/StyleResolver.h | 
| index 51d87a6e34177017176ee62c432aa0b6ac3feb78..c651f7344022921436997ccb12a2ae437d9f8888 100644 | 
| --- a/Source/core/css/resolver/StyleResolver.h | 
| +++ b/Source/core/css/resolver/StyleResolver.h | 
| @@ -40,6 +40,7 @@ | 
| #include "wtf/Deque.h" | 
| #include "wtf/HashMap.h" | 
| #include "wtf/HashSet.h" | 
| +#include "wtf/ListHashSet.h" | 
| #include "wtf/RefPtr.h" | 
| #include "wtf/Vector.h" | 
| @@ -216,6 +217,11 @@ public: | 
| void resetAtHostRules(const ShadowRoot*); | 
| void finishAppendAuthorStyleSheets(); | 
| + void lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >&); | 
| + void removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); | 
| + void appendPendingAuthorStyleSheets(); | 
| + bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size() > 0 || m_needCollectFeatures; } | 
| + | 
| DocumentRuleSets& ruleSets() { return m_ruleSets; } | 
| const DocumentRuleSets& ruleSets() const { return m_ruleSets; } | 
| SelectorFilter& selectorFilter() { return m_selectorFilter; } | 
| @@ -265,6 +271,12 @@ public: | 
| InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; } | 
| const RuleFeatureSet& ruleFeatureSet() const { return m_features; } | 
| 
eseidel
2013/11/06 01:39:10
I'm confused.  This can now be stale right?  Don't
 
tasak
2013/11/06 05:42:26
I left the method for fast-path, e.g. Document::cr
 | 
| + const RuleFeatureSet& ensureRuleFeatureSet() | 
| + { | 
| + if (hasPendingAuthorStyleSheets()) | 
| + appendPendingAuthorStyleSheets(); // slow path. | 
| + return m_features; | 
| + } | 
| StyleSharingList& styleSharingList() { return m_styleSharingList; } | 
| @@ -285,6 +297,10 @@ private: | 
| // FIXME: This should probably go away, folded into FontBuilder. | 
| void updateFont(StyleResolverState&); | 
| + void filterFontFaceAndViewportRules(const Vector<RefPtr<StyleRuleBase> >& rules, bool& needsResolveViewport); | 
| + void filterFontFaceAndViewportRulesFromSheet(StyleSheetContents*, bool& needsResolveViewport); | 
| + bool filterFontFaceAndViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets); | 
| + | 
| void collectPseudoRulesForElement(Element*, ElementRuleCollector&, PseudoId, unsigned rulesToInclude); | 
| void matchUARules(ElementRuleCollector&, RuleSet*); | 
| void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRules); | 
| @@ -295,6 +311,7 @@ private: | 
| void matchUserRules(ElementRuleCollector&, bool includeEmptyRules); | 
| void collectFeatures(); | 
| void collectTreeBoundaryCrossingRules(ElementRuleCollector&, bool includeEmptyRules); | 
| + void resetRuleFeatures(); | 
| bool fastRejectSelector(const RuleData&) const; | 
| @@ -350,6 +367,8 @@ private: | 
| RefPtr<ViewportStyleResolver> m_viewportStyleResolver; | 
| + ListHashSet<CSSStyleSheet*, 16> m_pendingStyleSheets; | 
| + | 
| ScopedStyleTree m_styleTree; | 
| // FIXME: The entire logic of collecting features on StyleResolver, as well astransferring them | 
| @@ -357,6 +376,7 @@ private: | 
| RuleFeatureSet m_features; | 
| OwnPtr<RuleSet> m_siblingRuleSet; | 
| OwnPtr<RuleSet> m_uncommonAttributeRuleSet; | 
| + bool m_needCollectFeatures; | 
| InspectorCSSOMWrappers m_inspectorCSSOMWrappers; | 
| @@ -384,6 +404,18 @@ inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi | 
| return false; | 
| } | 
| +inline bool isDocumentScope(const ContainerNode* scope) | 
| +{ | 
| + return !scope || scope->isDocumentNode(); | 
| +} | 
| + | 
| +inline void appendPendingStyleSheetsIfNeeded(StyleResolver* styleResolver) | 
| +{ | 
| + if (!styleResolver || !styleResolver->hasPendingAuthorStyleSheets()) | 
| + return; | 
| + styleResolver->appendPendingAuthorStyleSheets(); | 
| +} | 
| + | 
| } // namespace WebCore | 
| #endif // StyleResolver_h |