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

Side by Side Diff: Source/web/FrameLoaderClientImpl.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/web/FrameLoaderClientImpl.h ('k') | Source/web/WebFrameImpl.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) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame) 104 FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame)
105 : m_webFrame(frame) 105 : m_webFrame(frame)
106 { 106 {
107 } 107 }
108 108
109 FrameLoaderClientImpl::~FrameLoaderClientImpl() 109 FrameLoaderClientImpl::~FrameLoaderClientImpl()
110 { 110 {
111 } 111 }
112 112
113 void FrameLoaderClientImpl::frameLoaderDestroyed()
114 {
115 // When the WebFrame was created, it had an extra reference given to it on
116 // behalf of the Frame. Since the WebFrame owns us, this extra ref also
117 // serves to keep us alive until the FrameLoader is done with us. The
118 // FrameLoader calls this method when it's going away. Therefore, we balanc e
119 // out that extra reference, which may cause 'this' to be deleted.
120 ASSERT(!m_webFrame->frame());
121 m_webFrame->deref();
122 }
123
124 void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* ) 113 void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* )
125 { 114 {
126 if (m_webFrame->client()) { 115 if (m_webFrame->client()) {
127 m_webFrame->client()->didClearWindowObject(m_webFrame); 116 m_webFrame->client()->didClearWindowObject(m_webFrame);
128 Document* document = m_webFrame->frame()->document(); 117 Document* document = m_webFrame->frame()->document();
129 if (document) { 118 if (document) {
130 WheelController::from(document); 119 WheelController::from(document);
131 if (RuntimeEnabledFeatures::deviceMotionEnabled()) 120 if (RuntimeEnabledFeatures::deviceMotionEnabled())
132 DeviceMotionController::from(document); 121 DeviceMotionController::from(document);
133 if (RuntimeEnabledFeatures::deviceOrientationEnabled()) 122 if (RuntimeEnabledFeatures::deviceOrientationEnabled())
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 235 }
247 236
248 bool FrameLoaderClientImpl::hasFrameView() const 237 bool FrameLoaderClientImpl::hasFrameView() const
249 { 238 {
250 // The Mac port has this notion of a WebFrameView, which seems to be 239 // The Mac port has this notion of a WebFrameView, which seems to be
251 // some wrapper around an NSView. Since our equivalent is HWND, I guess 240 // some wrapper around an NSView. Since our equivalent is HWND, I guess
252 // we have a "frameview" whenever we have the toplevel HWND. 241 // we have a "frameview" whenever we have the toplevel HWND.
253 return m_webFrame->viewImpl(); 242 return m_webFrame->viewImpl();
254 } 243 }
255 244
245 void FrameLoaderClientImpl::willDetachParent()
246 {
247 m_webFrame->willDetachParent();
248 }
249
256 void FrameLoaderClientImpl::detachedFromParent() 250 void FrameLoaderClientImpl::detachedFromParent()
257 { 251 {
258 // Close down the proxy. The purpose of this change is to make the
259 // call to ScriptController::clearWindowShell a no-op when called from
260 // Frame::pageDestroyed. Without this change, this call to clearWindowShell
261 // will cause a crash. If you remove/modify this, just ensure that you can
262 // go to a page and then navigate to a new page without getting any asserts
263 // or crashes.
264 m_webFrame->frame()->script().clearForClose();
265
266 // Alert the client that the frame is being detached. This is the last 252 // Alert the client that the frame is being detached. This is the last
267 // chance we have to communicate with the client. 253 // chance we have to communicate with the client.
268 if (m_webFrame->client()) 254 m_webFrame->setWebCoreFrame(0);
269 m_webFrame->client()->frameDetached(m_webFrame);
270 255
271 // Stop communicating with the WebFrameClient at this point since we are no 256 // Signal that no further communication with WebFrameClient should take
272 // longer associated with the Page. 257 // place at this point since we are no longer associated with the Page.
258 WebFrameClient* client = m_webFrame->client();
273 m_webFrame->setClient(0); 259 m_webFrame->setClient(0);
260
261 // The call to WebFrameClient::frameDetached() is generally when the embedde r will release its
262 // reference to the WebFrame, which may trigger WebFrame destruction. Since WebFrame owns
263 // FrameLoaderClientImpl, we must not access any of our own members after th is call, since this
264 // object may have been destroyed.
265 WebFrame* webFrame = m_webFrame;
266 m_webFrame = 0;
267 client->frameDetached(webFrame);
274 } 268 }
275 269
276 void FrameLoaderClientImpl::dispatchWillRequestAfterPreconnect(ResourceRequest& request) 270 void FrameLoaderClientImpl::dispatchWillRequestAfterPreconnect(ResourceRequest& request)
277 { 271 {
278 if (m_webFrame->client()) { 272 if (m_webFrame->client()) {
279 WrappedResourceRequest webreq(request); 273 WrappedResourceRequest webreq(request);
280 m_webFrame->client()->willRequestAfterPreconnect(m_webFrame, webreq); 274 m_webFrame->client()->willRequestAfterPreconnect(m_webFrame, webreq);
281 } 275 }
282 } 276 }
283 277
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 return m_webFrame->sharedWorkerRepositoryClient(); 772 return m_webFrame->sharedWorkerRepositoryClient();
779 } 773 }
780 774
781 void FrameLoaderClientImpl::didStopAllLoaders() 775 void FrameLoaderClientImpl::didStopAllLoaders()
782 { 776 {
783 if (m_webFrame->client()) 777 if (m_webFrame->client())
784 m_webFrame->client()->didAbortLoading(m_webFrame); 778 m_webFrame->client()->didAbortLoading(m_webFrame);
785 } 779 }
786 780
787 } // namespace blink 781 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/FrameLoaderClientImpl.h ('k') | Source/web/WebFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698