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

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 117493002: Invert the owning relationship between WebFrame and Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/EmptyClients.h ('k') | Source/core/loader/FrameLoaderClient.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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 , m_shouldCallCheckCompleted(false) 152 , m_shouldCallCheckCompleted(false)
153 , m_opener(0) 153 , m_opener(0)
154 , m_didAccessInitialDocument(false) 154 , m_didAccessInitialDocument(false)
155 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 155 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
156 , m_forcedSandboxFlags(SandboxNone) 156 , m_forcedSandboxFlags(SandboxNone)
157 { 157 {
158 } 158 }
159 159
160 FrameLoader::~FrameLoader() 160 FrameLoader::~FrameLoader()
161 { 161 {
162 setOpener(0);
163
164 HashSet<Frame*>::iterator end = m_openedFrames.end(); 162 HashSet<Frame*>::iterator end = m_openedFrames.end();
165 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it) 163 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it)
166 (*it)->loader().m_opener = 0; 164 (*it)->loader().m_opener = 0;
167
168 m_client->frameLoaderDestroyed();
169 } 165 }
170 166
171 void FrameLoader::init() 167 void FrameLoader::init()
172 { 168 {
173 // This somewhat odd set of steps gives the frame an initial empty document. 169 // This somewhat odd set of steps gives the frame an initial empty document.
174 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest (KURL(ParsedURLString, emptyString())), SubstituteData()); 170 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest (KURL(ParsedURLString, emptyString())), SubstituteData());
175 m_provisionalDocumentLoader->setFrame(m_frame); 171 m_provisionalDocumentLoader->setFrame(m_frame);
176 m_provisionalDocumentLoader->startLoadingMainResource(); 172 m_provisionalDocumentLoader->startLoadingMainResource();
177 m_frame->document()->cancelParsing(); 173 m_frame->document()->cancelParsing();
178 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment); 174 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 void FrameLoader::finishedParsing() 407 void FrameLoader::finishedParsing()
412 { 408 {
413 if (m_stateMachine.creatingInitialEmptyDocument()) 409 if (m_stateMachine.creatingInitialEmptyDocument())
414 return; 410 return;
415 411
416 // This can be called from the Frame's destructor, in which case we shouldn' t protect ourselves 412 // This can be called from the Frame's destructor, in which case we shouldn' t protect ourselves
417 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 413 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
418 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 414 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
419 RefPtr<Frame> protector = m_frame->view() ? m_frame : 0; 415 RefPtr<Frame> protector = m_frame->view() ? m_frame : 0;
420 416
421 m_client->dispatchDidFinishDocumentLoad(); 417 if (m_client)
418 m_client->dispatchDidFinishDocumentLoad();
422 419
423 checkCompleted(); 420 checkCompleted();
424 421
425 if (!m_frame->view()) 422 if (!m_frame->view())
426 return; // We are being destroyed by something checkCompleted called. 423 return; // We are being destroyed by something checkCompleted called.
427 424
428 // Check if the scrollbars are really needed for the content. 425 // Check if the scrollbars are really needed for the content.
429 // If not, remove them, relayout, and repaint. 426 // If not, remove them, relayout, and repaint.
430 m_frame->view()->restoreScrollbar(); 427 m_frame->view()->restoreScrollbar();
431 scrollToFragmentWithParentBoundary(m_frame->document()->url()); 428 scrollToFragmentWithParentBoundary(m_frame->document()->url());
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 m_documentLoader->stopLoading(); 813 m_documentLoader->stopLoading();
817 814
818 if (m_provisionalDocumentLoader) 815 if (m_provisionalDocumentLoader)
819 m_provisionalDocumentLoader->detachFromFrame(); 816 m_provisionalDocumentLoader->detachFromFrame();
820 m_provisionalDocumentLoader = 0; 817 m_provisionalDocumentLoader = 0;
821 818
822 m_checkTimer.stop(); 819 m_checkTimer.stop();
823 820
824 m_inStopAllLoaders = false; 821 m_inStopAllLoaders = false;
825 822
826 m_client->didStopAllLoaders(); 823 // detachFromParent() can be called multiple times on same Frame, which
824 // means we may no longer have a FrameLoaderClient to talk to.
825 if (m_client)
826 m_client->didStopAllLoaders();
827 } 827 }
828 828
829 DocumentLoader* FrameLoader::activeDocumentLoader() const 829 DocumentLoader* FrameLoader::activeDocumentLoader() const
830 { 830 {
831 if (m_state == FrameStateProvisional) 831 if (m_state == FrameStateProvisional)
832 return m_provisionalDocumentLoader.get(); 832 return m_provisionalDocumentLoader.get();
833 return m_documentLoader.get(); 833 return m_documentLoader.get();
834 } 834 }
835 835
836 void FrameLoader::didAccessInitialDocument() 836 void FrameLoader::didAccessInitialDocument()
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren() 1118 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren()
1119 // will trigger the unload event handlers of any child frames, and those eve nt 1119 // will trigger the unload event handlers of any child frames, and those eve nt
1120 // handlers might start a new subresource load in this frame. 1120 // handlers might start a new subresource load in this frame.
1121 stopAllLoaders(); 1121 stopAllLoaders();
1122 1122
1123 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1123 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1124 1124
1125 if (m_documentLoader) 1125 if (m_documentLoader)
1126 m_documentLoader->detachFromFrame(); 1126 m_documentLoader->detachFromFrame();
1127 m_documentLoader = 0; 1127 m_documentLoader = 0;
1128 m_client->detachedFromParent();
1129 1128
1130 m_progressTracker.clear(); 1129 m_progressTracker.clear();
1131 1130
1131 if (m_client)
1132 m_client->willDetachParent();
1133
1132 // FIXME: All this code belongs up in Page. 1134 // FIXME: All this code belongs up in Page.
1133 if (Frame* parent = m_frame->tree().parent()) { 1135 if (Frame* parent = m_frame->tree().parent()) {
1134 parent->loader().closeAndRemoveChild(m_frame); 1136 parent->loader().closeAndRemoveChild(m_frame);
1135 parent->loader().scheduleCheckCompleted(); 1137 parent->loader().scheduleCheckCompleted();
1136 } else { 1138 } else {
1137 m_frame->setView(0); 1139 m_frame->setView(0);
1138 m_frame->willDetachFrameHost(); 1140 m_frame->willDetachFrameHost();
1139 m_frame->detachFromFrameHost(); 1141 m_frame->detachFromFrameHost();
1140 } 1142 }
1143
1144 if (m_client) {
1145 setOpener(0);
1146
1147 // Notify ScriptController that the frame is closing, since its cleanup ends up calling
1148 // back to FrameLoaderClient via V8WindowShell.
1149 m_frame->script().clearForClose();
1150
1151 // After this, we must no longer talk to the client since this clears
1152 // its owning reference back to us.
1153 m_client->detachedFromParent();
1154 m_client = 0;
1155 }
1141 } 1156 }
1142 1157
1143 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt ring& origin) 1158 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt ring& origin)
1144 { 1159 {
1145 if (!request.httpOrigin().isEmpty()) 1160 if (!request.httpOrigin().isEmpty())
1146 return; // Request already has an Origin header. 1161 return; // Request already has an Origin header.
1147 1162
1148 // Don't send an Origin header for GET or HEAD to avoid privacy issues. 1163 // Don't send an Origin header for GET or HEAD to avoid privacy issues.
1149 // For example, if an intranet page has a hyperlink to an external web 1164 // For example, if an intranet page has a hyperlink to an external web
1150 // site, we don't want to include the Origin of the request because it 1165 // site, we don't want to include the Origin of the request because it
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 return; 1298 return;
1284 1299
1285 // We skip dispatching the beforeload event on the frame owner if we've alre ady committed a real 1300 // We skip dispatching the beforeload event on the frame owner if we've alre ady committed a real
1286 // document load because the event would leak subsequent activity by the fra me which the parent 1301 // document load because the event would leak subsequent activity by the fra me which the parent
1287 // frame isn't supposed to learn. For example, if the child frame navigated to a new URL, the 1302 // frame isn't supposed to learn. For example, if the child frame navigated to a new URL, the
1288 // parent frame shouldn't learn the URL. 1303 // parent frame shouldn't learn the URL.
1289 const ResourceRequest& request = action.resourceRequest(); 1304 const ResourceRequest& request = action.resourceRequest();
1290 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string()) ) 1305 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string()) )
1291 return; 1306 return;
1292 1307
1308 // Dispatching the beforeload event could have blown away the frame.
1309 if (!m_client)
1310 return;
1311
1293 if (!m_stateMachine.startedFirstRealLoad()) 1312 if (!m_stateMachine.startedFirstRealLoad())
1294 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad); 1313 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad);
1295 1314
1296 // The current load should replace the history item if it is the first real 1315 // The current load should replace the history item if it is the first real
1297 // load of the frame. 1316 // load of the frame.
1298 bool replacesCurrentHistoryItem = false; 1317 bool replacesCurrentHistoryItem = false;
1299 if (type == FrameLoadTypeRedirectWithLockedBackForwardList 1318 if (type == FrameLoadTypeRedirectWithLockedBackForwardList
1300 || !m_stateMachine.committedFirstRealDocumentLoad()) { 1319 || !m_stateMachine.committedFirstRealDocumentLoad()) {
1301 replacesCurrentHistoryItem = true; 1320 replacesCurrentHistoryItem = true;
1302 } 1321 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 { 1521 {
1503 SandboxFlags flags = m_forcedSandboxFlags; 1522 SandboxFlags flags = m_forcedSandboxFlags;
1504 if (Frame* parentFrame = m_frame->tree().parent()) 1523 if (Frame* parentFrame = m_frame->tree().parent())
1505 flags |= parentFrame->document()->sandboxFlags(); 1524 flags |= parentFrame->document()->sandboxFlags();
1506 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1525 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1507 flags |= ownerElement->sandboxFlags(); 1526 flags |= ownerElement->sandboxFlags();
1508 return flags; 1527 return flags;
1509 } 1528 }
1510 1529
1511 } // namespace WebCore 1530 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/EmptyClients.h ('k') | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698