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

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: Comment clarity? Created 7 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 | Annotate | Revision Log
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 252 // Close down the proxy. The purpose of this change is to make the
259 // call to ScriptController::clearWindowShell a no-op when called from 253 // call to ScriptController::clearWindowShell a no-op when called from
260 // Frame::pageDestroyed. Without this change, this call to clearWindowShell 254 // Frame::pageDestroyed. Without this change, this call to clearWindowShell
261 // will cause a crash. If you remove/modify this, just ensure that you can 255 // 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 256 // go to a page and then navigate to a new page without getting any asserts
263 // or crashes. 257 // or crashes.
264 m_webFrame->frame()->script().clearForClose(); 258 m_webFrame->frame()->script().clearForClose();
265 259
266 // Alert the client that the frame is being detached. This is the last 260 // Now alert the client that the frame is being detached. This is the last
267 // chance we have to communicate with the client. 261 // chance we have to communicate with the client.
268 if (m_webFrame->client()) 262 m_webFrame->setWebCoreFrame(0);
269 m_webFrame->client()->frameDetached(m_webFrame);
270 263
271 // Stop communicating with the WebFrameClient at this point since we are no 264 // Signal that no further communication with WebFrameClient should take
272 // longer associated with the Page. 265 // place at this point since we are no longer associated with the Page.
266 WebFrameClient* client = m_webFrame->client();
273 m_webFrame->setClient(0); 267 m_webFrame->setClient(0);
268
269 // frameDetached() may release the final reference to WebFrame. Since we are
270 // owned by WebFrame, we can't reference any members after this point, so
271 // clear WebFrame now.
272 WebFrame* webFrame = m_webFrame;
273 m_webFrame = 0;
274 client->frameDetached(webFrame);
274 } 275 }
275 276
276 void FrameLoaderClientImpl::dispatchWillRequestAfterPreconnect(ResourceRequest& request) 277 void FrameLoaderClientImpl::dispatchWillRequestAfterPreconnect(ResourceRequest& request)
277 { 278 {
278 if (m_webFrame->client()) { 279 if (m_webFrame->client()) {
279 WrappedResourceRequest webreq(request); 280 WrappedResourceRequest webreq(request);
280 m_webFrame->client()->willRequestAfterPreconnect(m_webFrame, webreq); 281 m_webFrame->client()->willRequestAfterPreconnect(m_webFrame, webreq);
281 } 282 }
282 } 283 }
283 284
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 return m_webFrame->sharedWorkerRepositoryClient(); 779 return m_webFrame->sharedWorkerRepositoryClient();
779 } 780 }
780 781
781 void FrameLoaderClientImpl::didStopAllLoaders() 782 void FrameLoaderClientImpl::didStopAllLoaders()
782 { 783 {
783 if (m_webFrame->client()) 784 if (m_webFrame->client())
784 m_webFrame->client()->didAbortLoading(m_webFrame); 785 m_webFrame->client()->didAbortLoading(m_webFrame);
785 } 786 }
786 787
787 } // namespace blink 788 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698