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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2547843002: Refactor setImportsController() to clarify invariants (Closed)
Patch Set: Rebase Created 4 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
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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 return constructorBuilder.bindingsReturnValue(); 897 return constructorBuilder.bindingsReturnValue();
898 } 898 }
899 899
900 V0CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue() { 900 V0CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue() {
901 if (!m_customElementMicrotaskRunQueue) 901 if (!m_customElementMicrotaskRunQueue)
902 m_customElementMicrotaskRunQueue = 902 m_customElementMicrotaskRunQueue =
903 V0CustomElementMicrotaskRunQueue::create(); 903 V0CustomElementMicrotaskRunQueue::create();
904 return m_customElementMicrotaskRunQueue.get(); 904 return m_customElementMicrotaskRunQueue.get();
905 } 905 }
906 906
907 void Document::setImportsController(HTMLImportsController* controller) { 907 void Document::clearImportsController() {
908 DCHECK(!m_importsController || !controller); 908 m_importsController = nullptr;
909 m_importsController = controller; 909 if (!loader())
910 if (!m_importsController && !loader())
911 m_fetcher->clearContext(); 910 m_fetcher->clearContext();
912 } 911 }
913 912
913 void Document::createImportsController() {
914 DCHECK(!m_importsController);
915 m_importsController = HTMLImportsController::create(*this);
916 }
917
914 HTMLImportLoader* Document::importLoader() const { 918 HTMLImportLoader* Document::importLoader() const {
915 if (!m_importsController) 919 if (!m_importsController)
916 return 0; 920 return 0;
917 return m_importsController->loaderFor(*this); 921 return m_importsController->loaderFor(*this);
918 } 922 }
919 923
920 bool Document::haveImportsLoaded() const { 924 bool Document::haveImportsLoaded() const {
921 if (!m_importsController) 925 if (!m_importsController)
922 return true; 926 return true;
923 return !m_importsController->shouldBlockScriptExecution(*this); 927 return !m_importsController->shouldBlockScriptExecution(*this);
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 // to the DocumentLoader when possible also prevents prematurely clearing 2477 // to the DocumentLoader when possible also prevents prematurely clearing
2474 // the context in the case where multiple Documents end up associated with 2478 // the context in the case where multiple Documents end up associated with
2475 // a single DocumentLoader (e.g., navigating to a javascript: url). 2479 // a single DocumentLoader (e.g., navigating to a javascript: url).
2476 if (!loader()) 2480 if (!loader())
2477 m_fetcher->clearContext(); 2481 m_fetcher->clearContext();
2478 // If this document is the master for an HTMLImportsController, sever that 2482 // If this document is the master for an HTMLImportsController, sever that
2479 // relationship. This ensures that we don't leave import loads in flight, 2483 // relationship. This ensures that we don't leave import loads in flight,
2480 // thinking they should have access to a valid frame when they don't. 2484 // thinking they should have access to a valid frame when they don't.
2481 if (m_importsController) { 2485 if (m_importsController) {
2482 m_importsController->dispose(); 2486 m_importsController->dispose();
2483 setImportsController(nullptr); 2487 clearImportsController();
2484 } 2488 }
2485 2489
2486 m_timers.setTimerTaskRunner(Platform::current() 2490 m_timers.setTimerTaskRunner(Platform::current()
2487 ->currentThread() 2491 ->currentThread()
2488 ->scheduler() 2492 ->scheduler()
2489 ->timerTaskRunner() 2493 ->timerTaskRunner()
2490 ->clone()); 2494 ->clone());
2491 2495
2492 if (m_mediaQueryMatcher) 2496 if (m_mediaQueryMatcher)
2493 m_mediaQueryMatcher->documentDetached(); 2497 m_mediaQueryMatcher->documentDetached();
(...skipping 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after
6571 } 6575 }
6572 6576
6573 void showLiveDocumentInstances() { 6577 void showLiveDocumentInstances() {
6574 WeakDocumentSet& set = liveDocumentSet(); 6578 WeakDocumentSet& set = liveDocumentSet();
6575 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6579 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6576 for (Document* document : set) 6580 for (Document* document : set)
6577 fprintf(stderr, "- Document %p URL: %s\n", document, 6581 fprintf(stderr, "- Document %p URL: %s\n", document,
6578 document->url().getString().utf8().data()); 6582 document->url().getString().utf8().data());
6579 } 6583 }
6580 #endif 6584 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/html/imports/HTMLImportLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698