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

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

Issue 844133002: Simplify tree scope tracking in StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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/StyleSheetCollection.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 d82012de585289e41aa6e2d45df961dd6502969d..3c75e5bb591db05f7eaa7d0863ce0fb6068a5600 100644
--- a/sky/engine/core/dom/StyleEngine.cpp
+++ b/sky/engine/core/dom/StyleEngine.cpp
@@ -49,6 +49,7 @@ StyleEngine::StyleEngine(Document& document)
, m_fontSelector(CSSFontSelector::create(&document))
{
m_fontSelector->registerForInvalidationCallbacks(this);
+ m_activeTreeScopes.add(&document);
}
StyleEngine::~StyleEngine()
@@ -57,28 +58,14 @@ StyleEngine::~StyleEngine()
m_fontSelector->unregisterForInvalidationCallbacks(this);
}
-void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser)
+void StyleEngine::addTreeScope(TreeScope& scope)
{
- if (!node->inDocument())
- return;
-
- TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_document;
- ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
- StyleSheetCollection& collection = treeScope.styleSheets();
- collection.addStyleSheetCandidateNode(node, createdByParser);
-
- if (treeScope != m_document)
- m_activeTreeScopes.add(&treeScope);
+ m_activeTreeScopes.add(&scope);
}
-void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopingNode, TreeScope& treeScope)
+void StyleEngine::removeTreeScope(TreeScope& scope)
{
- ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
-
- StyleSheetCollection& collection = treeScope.styleSheets();
- collection.removeStyleSheetCandidateNode(node, scopingNode);
-
- m_activeTreeScopes.remove(&treeScope);
+ m_activeTreeScopes.remove(&scope);
}
void StyleEngine::updateActiveStyleSheets()
@@ -88,28 +75,12 @@ void StyleEngine::updateActiveStyleSheets()
if (!m_document->isActive())
return;
- // TODO(esprehn): Remove special case for document.
- m_document->styleSheets().updateActiveStyleSheets(this);
-
- TreeScopeSet treeScopes = m_activeTreeScopes;
- HashSet<TreeScope*> treeScopesRemoved;
-
- for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
- TreeScope* treeScope = *it;
- ASSERT(treeScope != m_document);
- StyleSheetCollection& collection = treeScope->styleSheets();
- collection.updateActiveStyleSheets(this);
- if (!collection.hasStyleSheetCandidateNodes())
- treeScopesRemoved.add(treeScope);
- }
- m_activeTreeScopes.removeAll(treeScopesRemoved);
+ for (TreeScope* treeScope : m_activeTreeScopes)
+ treeScope->styleSheets().updateActiveStyleSheets(this);
}
void StyleEngine::appendActiveAuthorStyleSheets()
{
- // TODO(esprehn): Remove special case for document.
- m_resolver->appendAuthorStyleSheets(m_document->styleSheets().activeAuthorStyleSheets());
-
for (TreeScope* treeScope : m_activeTreeScopes)
m_resolver->appendAuthorStyleSheets(treeScope->styleSheets().activeAuthorStyleSheets());
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | sky/engine/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698