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

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

Issue 813493003: Only the main document should have a StyleEngine. (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 | « no previous file | sky/engine/core/dom/StyleEngine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/Document.cpp
diff --git a/sky/engine/core/dom/Document.cpp b/sky/engine/core/dom/Document.cpp
index feeb3005d64b6b024c63803de5856549bf596ecf..3180121284874de48220308615a4f88f2c79f538 100644
--- a/sky/engine/core/dom/Document.cpp
+++ b/sky/engine/core/dom/Document.cpp
@@ -292,11 +292,6 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
- // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
- // CSSFontSelector, need to initialize m_styleEngine after initializing
- // m_fetcher.
- m_styleEngine = StyleEngine::create(*this);
-
#ifndef NDEBUG
liveDocumentSet().add(this);
#endif
@@ -1230,11 +1225,14 @@ PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
StyleResolver* Document::styleResolver() const
{
+ if (!isActive())
+ return 0;
return m_styleEngine->resolver();
}
StyleResolver& Document::ensureStyleResolver() const
{
+ ASSERT(isActive());
return m_styleEngine->ensureResolver();
}
@@ -1247,6 +1245,8 @@ void Document::attach(const AttachContext& context)
{
ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive);
+ m_styleEngine = StyleEngine::create(*this);
+
m_renderView = new RenderView(this);
setRenderer(m_renderView);
@@ -1284,6 +1284,7 @@ void Document::detach(const AttachContext& context)
ContainerNode::detach(context);
m_styleEngine->didDetach();
+ m_styleEngine = nullptr;
// This is required, as our LocalFrame might delete itself as soon as it detaches
// us. However, this violates Node::detach() semantics, as it's never
« no previous file with comments | « no previous file | sky/engine/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698