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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/engine/core/dom/StyleEngine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // See fast/dom/early-frame-url.html 285 // See fast/dom/early-frame-url.html
286 // and fast/dom/location-new-window-no-crash.html, respectively. 286 // and fast/dom/location-new-window-no-crash.html, respectively.
287 // FIXME: Can/should we unify this behavior? 287 // FIXME: Can/should we unify this behavior?
288 if (initializer.shouldSetURL()) 288 if (initializer.shouldSetURL())
289 setURL(initializer.url()); 289 setURL(initializer.url());
290 290
291 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); 291 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter);
292 292
293 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); 293 m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
294 294
295 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
296 // CSSFontSelector, need to initialize m_styleEngine after initializing
297 // m_fetcher.
298 m_styleEngine = StyleEngine::create(*this);
299
300 #ifndef NDEBUG 295 #ifndef NDEBUG
301 liveDocumentSet().add(this); 296 liveDocumentSet().add(this);
302 #endif 297 #endif
303 } 298 }
304 299
305 Document::~Document() 300 Document::~Document()
306 { 301 {
307 ASSERT(!renderView()); 302 ASSERT(!renderView());
308 ASSERT(!parentTreeScope()); 303 ASSERT(!parentTreeScope());
309 #if !ENABLE(OILPAN) 304 #if !ENABLE(OILPAN)
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1218
1224 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element) 1219 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element)
1225 { 1220 {
1226 ASSERT_ARG(element, element->document() == this); 1221 ASSERT_ARG(element, element->document() == this);
1227 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); 1222 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get());
1228 return ensureStyleResolver().styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0); 1223 return ensureStyleResolver().styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0);
1229 } 1224 }
1230 1225
1231 StyleResolver* Document::styleResolver() const 1226 StyleResolver* Document::styleResolver() const
1232 { 1227 {
1228 if (!isActive())
1229 return 0;
1233 return m_styleEngine->resolver(); 1230 return m_styleEngine->resolver();
1234 } 1231 }
1235 1232
1236 StyleResolver& Document::ensureStyleResolver() const 1233 StyleResolver& Document::ensureStyleResolver() const
1237 { 1234 {
1235 ASSERT(isActive());
1238 return m_styleEngine->ensureResolver(); 1236 return m_styleEngine->ensureResolver();
1239 } 1237 }
1240 1238
1241 void Document::clearStyleResolver() 1239 void Document::clearStyleResolver()
1242 { 1240 {
1243 m_styleEngine->clearResolver(); 1241 m_styleEngine->clearResolver();
1244 } 1242 }
1245 1243
1246 void Document::attach(const AttachContext& context) 1244 void Document::attach(const AttachContext& context)
1247 { 1245 {
1248 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive); 1246 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive);
1249 1247
1248 m_styleEngine = StyleEngine::create(*this);
1249
1250 m_renderView = new RenderView(this); 1250 m_renderView = new RenderView(this);
1251 setRenderer(m_renderView); 1251 setRenderer(m_renderView);
1252 1252
1253 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); 1253 m_renderView->setStyle(StyleResolver::styleForDocument(*this));
1254 1254
1255 ContainerNode::attach(context); 1255 ContainerNode::attach(context);
1256 1256
1257 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); 1257 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean);
1258 } 1258 }
1259 1259
(...skipping 17 matching lines...) Expand all
1277 m_domWindow->clearEventQueue(); 1277 m_domWindow->clearEventQueue();
1278 1278
1279 m_hoverNode = nullptr; 1279 m_hoverNode = nullptr;
1280 m_focusedElement = nullptr; 1280 m_focusedElement = nullptr;
1281 m_activeHoverElement = nullptr; 1281 m_activeHoverElement = nullptr;
1282 1282
1283 m_renderView = 0; 1283 m_renderView = 0;
1284 ContainerNode::detach(context); 1284 ContainerNode::detach(context);
1285 1285
1286 m_styleEngine->didDetach(); 1286 m_styleEngine->didDetach();
1287 m_styleEngine = nullptr;
1287 1288
1288 // This is required, as our LocalFrame might delete itself as soon as it det aches 1289 // This is required, as our LocalFrame might delete itself as soon as it det aches
1289 // us. However, this violates Node::detach() semantics, as it's never 1290 // us. However, this violates Node::detach() semantics, as it's never
1290 // possible to re-attach. Eventually Document::detach() should be renamed, 1291 // possible to re-attach. Eventually Document::detach() should be renamed,
1291 // or this setting of the frame to 0 could be made explicit in each of the 1292 // or this setting of the frame to 0 could be made explicit in each of the
1292 // callers of Document::detach(). 1293 // callers of Document::detach().
1293 m_frame = 0; 1294 m_frame = 0;
1294 1295
1295 if (m_mediaQueryMatcher) 1296 if (m_mediaQueryMatcher)
1296 m_mediaQueryMatcher->documentDetached(); 1297 m_mediaQueryMatcher->documentDetached();
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2766 using namespace blink; 2767 using namespace blink;
2767 void showLiveDocumentInstances() 2768 void showLiveDocumentInstances()
2768 { 2769 {
2769 WeakDocumentSet& set = liveDocumentSet(); 2770 WeakDocumentSet& set = liveDocumentSet();
2770 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2771 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2771 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2772 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2772 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2773 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2773 } 2774 }
2774 } 2775 }
2775 #endif 2776 #endif
OLDNEW
« 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