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

Unified Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 810893002: Remove global set of ScopedStyleResolvers. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/TreeScope.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/StyleEngine.cpp
diff --git a/sky/engine/core/dom/StyleEngine.cpp b/sky/engine/core/dom/StyleEngine.cpp
index b0fc8b8fbca05b989d252b47642cd1537541a4f0..293b81d3fd31a87b198251505e4603814e1cdd73 100644
--- a/sky/engine/core/dom/StyleEngine.cpp
+++ b/sky/engine/core/dom/StyleEngine.cpp
@@ -33,6 +33,7 @@
#include "sky/engine/core/css/FontFaceCache.h"
#include "sky/engine/core/css/StyleSheetContents.h"
#include "sky/engine/core/dom/Element.h"
+#include "sky/engine/core/dom/ElementTraversal.h"
#include "sky/engine/core/dom/StyleSheetCollection.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/frame/Settings.h"
@@ -73,9 +74,6 @@ void StyleEngine::detachFromDocument()
m_fontSelector.clear();
m_resolver.clear();
m_styleSheetCollectionMap.clear();
- for (ScopedStyleResolverSet::iterator it = m_scopedStyleResolvers.begin(); it != m_scopedStyleResolvers.end(); ++it)
- const_cast<TreeScope&>((*it)->treeScope()).clearScopedStyleResolver();
- m_scopedStyleResolvers.clear();
}
const Vector<RefPtr<CSSStyleSheet>>& StyleEngine::activeAuthorStyleSheetsFor(TreeScope& treeScope)
@@ -178,8 +176,6 @@ void StyleEngine::updateActiveStyleSheets()
void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot)
{
- if (shadowRoot->scopedStyleResolver())
- removeScopedStyleResolver(shadowRoot->scopedStyleResolver());
m_styleSheetCollectionMap.remove(shadowRoot);
}
@@ -205,7 +201,6 @@ void StyleEngine::createResolver()
ASSERT(m_document->frame());
m_resolver = adoptPtr(new StyleResolver(*m_document));
- addScopedStyleResolver(&m_document->ensureScopedStyleResolver());
appendActiveAuthorStyleSheets();
}
@@ -213,10 +208,6 @@ void StyleEngine::createResolver()
void StyleEngine::clearResolver()
{
ASSERT(!m_document->inStyleRecalc());
-
- for (ScopedStyleResolverSet::iterator it = m_scopedStyleResolvers.begin(); it != m_scopedStyleResolvers.end(); ++it)
- const_cast<TreeScope&>((*it)->treeScope()).clearScopedStyleResolver();
- m_scopedStyleResolvers.clear();
m_resolver.clear();
}
@@ -317,11 +308,21 @@ void StyleEngine::removeSheet(StyleSheetContents* contents)
m_sheetToTextCache.remove(contents);
}
+// TODO(esprehn): This walks the entire document to collect features, instead
+// we should store features per scope and get rid of the global set.
+static void collectFeatures(TreeScope& scope, RuleFeatureSet& features, HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents)
+{
+ scope.scopedStyleResolver().collectFeaturesTo(features, visitedSharedStyleSheetContents);
+ for (Element* element = ElementTraversal::firstWithin(scope.rootNode()); element; element = ElementTraversal::next(*element, &scope.rootNode())) {
+ if (ShadowRoot* root = element->shadowRoot())
+ collectFeatures(*root, features, visitedSharedStyleSheetContents);
+ }
+}
+
void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const
{
HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents;
- for (ScopedStyleResolverSet::iterator it = m_scopedStyleResolvers.begin(); it != m_scopedStyleResolvers.end(); ++it)
- (*it)->collectFeaturesTo(features, visitedSharedStyleSheetContents);
+ collectFeatures(*m_document, features, visitedSharedStyleSheetContents);
}
void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/TreeScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698