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

Unified Diff: sky/engine/core/html/HTMLStyleElement.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/shadow/ShadowRoot.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/html/HTMLStyleElement.cpp
diff --git a/sky/engine/core/html/HTMLStyleElement.cpp b/sky/engine/core/html/HTMLStyleElement.cpp
index 265fd750e53fc3e16a9d5e60b7fc121663bd1a35..13501168ff7d62c1030f69cbb7f0ab8b388edccc 100644
--- a/sky/engine/core/html/HTMLStyleElement.cpp
+++ b/sky/engine/core/html/HTMLStyleElement.cpp
@@ -30,6 +30,7 @@
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/dom/StyleEngine.h"
+#include "sky/engine/core/dom/StyleSheetCollection.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/platform/TraceEvent.h"
@@ -45,16 +46,6 @@ HTMLStyleElement::~HTMLStyleElement()
{
if (m_sheet)
m_sheet->clearOwnerNode();
-
- // TODO(esprehn): How can we still be in the document when our destructor
- // is running?
- if (inDocument()) {
- ContainerNode* scopingNode = this->scopingNode();
- TreeScope& scope = scopingNode ? scopingNode->treeScope() : treeScope();
- if (StyleEngine* styleEngine = document().styleEngine())
- styleEngine->removeStyleSheetCandidateNode(this, scopingNode, scope);
- }
-
if (m_sheet)
clearSheet();
}
@@ -77,10 +68,10 @@ void HTMLStyleElement::parseAttribute(const QualifiedName& name, const AtomicStr
void HTMLStyleElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
- if (inActiveDocument()) {
- document().styleEngine()->addStyleSheetCandidateNode(this, false);
- process();
- }
+ if (!inActiveDocument())
+ return;
+ treeScope().styleSheets().addStyleSheetCandidateNode(*this);
+ process();
}
void HTMLStyleElement::removedFrom(ContainerNode* insertionPoint)
@@ -90,14 +81,10 @@ void HTMLStyleElement::removedFrom(ContainerNode* insertionPoint)
if (!insertionPoint->inActiveDocument())
return;
- ShadowRoot* scopingNode = containingShadowRoot();
- if (!scopingNode)
- scopingNode = insertionPoint->containingShadowRoot();
-
TreeScope* containingScope = containingShadowRoot();
TreeScope& scope = containingScope ? *containingScope : insertionPoint->treeScope();
- document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNode, scope);
+ scope.styleSheets().removeStyleSheetCandidateNode(*this);
RefPtr<CSSStyleSheet> removedSheet = m_sheet.get();
« no previous file with comments | « sky/engine/core/dom/shadow/ShadowRoot.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698