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

Unified Diff: Source/core/dom/Document.cpp

Issue 1063913002: Revert of Remove ResourceFetcher's access to a real FetchContext at frame detach time (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | « no previous file | Source/core/fetch/FetchContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 63b4370f8d4f1162b4f6e1580327a29d0ac32455..6e1fa9a68d6010ed66d30b819750ce188235a70d 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -481,13 +481,11 @@
provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
m_fetcher = m_frame->loader().documentLoader()->fetcher();
- FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
- } else if (m_importsController) {
+ }
+
+ if (!m_fetcher)
m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr);
- FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
- } else {
- m_fetcher = ResourceFetcher::create(nullptr);
- }
+ static_cast<FrameFetchContext&>(m_fetcher->context()).setDocument(this);
// We depend on the url getting immediately set in subframes, but we
// also depend on the url NOT getting immediately set in opened windows.
@@ -532,7 +530,6 @@
#if !ENABLE(OILPAN)
ASSERT(m_ranges.isEmpty());
ASSERT(!hasGuardRefCount());
- ASSERT(!m_importsController);
// With Oilpan, either the document outlives the visibility observers
// or the visibility observers and the document die in the same GC round.
// When they die in the same GC round, the list of visibility observers
@@ -567,6 +564,9 @@
if (m_styleSheetList)
m_styleSheetList->detachFromDocument();
+ if (m_importsController)
+ HTMLImportsController::removeFrom(*this);
+
m_timeline->detachFromDocument();
// We need to destroy CSSFontSelector before destroying m_fetcher.
@@ -574,6 +574,13 @@
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
+
+ // It's possible for multiple Documents to end up referencing the same ResourceFetcher (e.g., SVGImages
+ // load the initial empty document and the SVGDocument with the same DocumentLoader).
+ FrameFetchContext& context = static_cast<FrameFetchContext&>(m_fetcher->context());
+ if (context.document() == this)
+ context.setDocument(nullptr);
+ m_fetcher.clear();
// We must call clearRareData() here since a Document class inherits TreeScope
// as well as Node. See a comment on TreeScope.h for the reason.
@@ -614,6 +621,9 @@
m_registrationContext.clear();
+ if (m_importsController)
+ HTMLImportsController::removeFrom(*this);
+
// removeDetachedChildren() doesn't always unregister IDs,
// so tear down scope information upfront to avoid having stale references in the map.
destroyTreeScopeData();
@@ -822,8 +832,6 @@
{
ASSERT(!m_importsController || !controller);
m_importsController = controller;
- if (!m_importsController)
- m_fetcher->clearContext();
}
HTMLImportLoader* Document::importLoader() const
@@ -2127,19 +2135,6 @@
styleEngine().didDetach();
frameHost()->eventHandlerRegistry().documentDetached(*this);
-
- // If this Document is associated with a live DocumentLoader, the
- // DocumentLoader will take care of clearing the FetchContext. Deferring
- // to the DocumentLoader when possible also prevents prematurely clearing
- // the context in the case where multiple Documents end up associated with
- // a single DocumentLoader (e.g., navigating to a javascript: url).
- if (!loader())
- m_fetcher->clearContext();
- // If this document is the master for an HTMLImportsController, sever that
- // relationship. This ensures that we don't leave import loads in flight,
- // thinking they should have access to a valid frame when they don't.
- if (m_importsController)
- HTMLImportsController::removeFrom(*this);
// 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 | Source/core/fetch/FetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698