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

Unified Diff: sky/engine/core/html/HTMLStyleElement.cpp

Issue 798563005: Simplify the internals of HTMLStyleElement. (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/html/HTMLStyleElement.h ('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 cfa8c56bdca0a07e90bb01fd3a11a808757e06ec..d7ce4d9f59580423597ba489eddf23c6cd39ae95 100644
--- a/sky/engine/core/html/HTMLStyleElement.cpp
+++ b/sky/engine/core/html/HTMLStyleElement.cpp
@@ -43,7 +43,17 @@ inline HTMLStyleElement::HTMLStyleElement(Document& document)
HTMLStyleElement::~HTMLStyleElement()
{
- clearDocumentData();
+ 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();
+ document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNode, scope);
+ }
+
if (m_sheet)
clearSheet();
}
@@ -66,11 +76,8 @@ void HTMLStyleElement::parseAttribute(const QualifiedName& name, const AtomicStr
void HTMLStyleElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
-
- if (!inDocument())
- return;
-
- processStyleSheet();
+ document().styleEngine()->addStyleSheetCandidateNode(this, false);
+ process();
}
void HTMLStyleElement::removedFrom(ContainerNode* insertionPoint)
@@ -119,22 +126,18 @@ ContainerNode* HTMLStyleElement::scopingNode()
return &document();
}
-void HTMLStyleElement::process()
-{
- if (!inDocument())
- return;
- createSheet();
-}
-
void HTMLStyleElement::clearSheet()
{
ASSERT(m_sheet);
m_sheet.release()->clearOwnerNode();
}
-void HTMLStyleElement::createSheet()
+void HTMLStyleElement::process()
{
- ASSERT(inDocument());
+ if (!inDocument())
+ return;
+
+ TRACE_EVENT0("blink", "StyleElement::process");
if (m_sheet)
clearSheet();
@@ -142,8 +145,7 @@ void HTMLStyleElement::createSheet()
RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media());
MediaQueryEvaluator screenEval("screen", true);
- MediaQueryEvaluator printEval("print", true);
- if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get())) {
+ if (screenEval.eval(mediaQueries.get())) {
const String& text = textFromChildren();
m_sheet = document().styleEngine()->createSheet(this, text);
m_sheet->setMediaQueries(mediaQueries.release());
@@ -152,26 +154,4 @@ void HTMLStyleElement::createSheet()
document().styleResolverChanged();
}
-void HTMLStyleElement::clearDocumentData()
-{
- if (m_sheet)
- m_sheet->clearOwnerNode();
-
- if (inDocument()) {
- ContainerNode* scopingNode = this->scopingNode();
- TreeScope& scope = scopingNode ? scopingNode->treeScope() : treeScope();
- document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNode, scope);
- }
-}
-
-void HTMLStyleElement::processStyleSheet()
-{
- TRACE_EVENT0("blink", "StyleElement::processStyleSheet");
-
- ASSERT(inDocument());
-
- document().styleEngine()->addStyleSheetCandidateNode(this, false);
- process();
-}
-
}
« no previous file with comments | « sky/engine/core/html/HTMLStyleElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698