When a live iframe element is moved between pages, it still depends on the old page.
authordimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Feb 2010 07:55:06 +0000 (07:55 +0000)
committerdimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Feb 2010 07:55:06 +0000 (07:55 +0000)
commit1f7efaac469e366b21c3934673e0aaf2d80939ce
treef2c8e2f882f8897e97248928d1b1cca8e5eae488
parent6177f7390ee991c2cadb7b09b7dd6d05d6197697
When a live iframe element is moved between pages, it still depends on the old page.
https://bugs.webkit.org/show_bug.cgi?id=34382

Reviewed by David Levin, Darin Fisher, Simon Hausmann.

WebCore:

Test: fast/frames/iframe-reparenting-new-page.html

* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::setName):
Move the code setting the frame name into a separate function.

(WebCore::HTMLFrameElementBase::setNameAndOpenURL):
(WebCore::HTMLFrameElementBase::updateOnReparenting):
Called on the frame that was just re-parented and inserted into another Document.
Simply invoke Frame::transferChildFrameToNewDocument(...);

(WebCore::HTMLFrameElementBase::insertedIntoDocument):
* html/HTMLFrameElementBase.h:
* html/HTMLFrameOwnerElement.h:
(WebCore::HTMLFrameOwnerElement::setName):
Make this a virtual function, to be able to reach it via Frame::m_ownerElement.

* loader/EmptyClients.h:
(WebCore::EmptyFrameLoaderClient::adoptFrame):
* loader/FrameLoaderClient.h:
Add a new method, didTransferChildFrameToNewDocument().
It compliments createFrame() in that a frame which was re-parented
in DOM and potentially changes Page, should notify the WebKit
implementation about potential ownership change.
Many embedders assume that Page owns all the Frames, or at least
all Frames are destroyed before 'their' Page is destroyed. Obviously, if Frame
can be transferred to another Page, the embedders should be notified.

* page/Frame.cpp:
(WebCore::Frame::transferChildFrameToNewDocument):
Added, makes actual adjustments for Frame - resets the Page,
updates the frame tree and frame name, calls to FrameLoaderClient
to update external objects and recurses into children.
Can only be used on child frames.

* page/Frame.h:

WebKit/chromium:

* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::detachedFromParent3):
(WebKit::FrameLoaderClientImpl::didTransferChildFrameToNewDocument):
Since Chromium's WebFrameClient is destroyed once a window is closed,
if Frame moves between Pages, the client of corresponding WebFrame
should be replaced as well.

* src/FrameLoaderClientImpl.h:
* src/WebFrameImpl.h:
(WebKit::WebFrameImpl::setClient):

WebKit/gtk:

* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::didTransferChildFrameToNewDocument):
Added empty implementation of a new virtual method.

* WebCoreSupport/FrameLoaderClientGtk.h:

WebKit/haiku:

* WebCoreSupport/FrameLoaderClientHaiku.cpp:
(WebCore::FrameLoaderClientHaiku::didTransferChildFrameToNewDocument):
Added empty implementation of a new virtual method.

* WebCoreSupport/FrameLoaderClientHaiku.h:

WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
Added empty implementation of a new virtual method.

(WebFrameLoaderClient::didTransferChildFrameToNewDocument):

WebKit/qt:

* Api/qwebframe_p.h:
(QWebFramePrivate::setPage): Added.
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::didTransferChildFrameToNewDocument):
The QWebFrame caches a QWebPage which should be replaced when Frame is re-parented.
Also, the QWebFrame is a child (in QT terms) of QWebPage - so update that relationship as well.
Emit a signal that QWebFrame moved to a different QWebPage.

* WebCoreSupport/FrameLoaderClientQt.h:

WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::didTransferChildFrameToNewDocument):
Added empty implementation of a new virtual method.

* WebCoreSupport/WebFrameLoaderClient.h:

WebKit/wx:

* WebKitSupport/FrameLoaderClientWx.cpp:
(WebCore::FrameLoaderClientWx::didTransferChildFrameToNewDocument):
Added empty implementation of a new virtual method.

* WebKitSupport/FrameLoaderClientWx.h:

LayoutTests:

* fast/frames/iframe-reparenting-new-page-expected.txt: Added.
* fast/frames/iframe-reparenting-new-page.html: Added.
* fast/frames/resources/iframe-reparenting-new-page-1.html: Added.
* fast/frames/resources/iframe-reparenting-new-page-2.html: Added.
* fast/frames/resources/iframe-reparenting-new-page-iframe.html: Added.
* fast/frames/script-tests/TEMPLATE.html: Copied from LayoutTests/fast/canvas/script-tests/TEMPLATE.html.
* fast/frames/script-tests/iframe-reparenting-new-page.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@54938 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/frames/iframe-reparenting-new-page-expected.txt [new file with mode: 0644]
LayoutTests/fast/frames/iframe-reparenting-new-page.html [new file with mode: 0644]
LayoutTests/fast/frames/resources/iframe-reparenting-new-page-1.html [new file with mode: 0644]
LayoutTests/fast/frames/resources/iframe-reparenting-new-page-2.html [new file with mode: 0644]
LayoutTests/fast/frames/resources/iframe-reparenting-new-page-iframe.html [new file with mode: 0644]
LayoutTests/fast/frames/script-tests/TEMPLATE.html [new file with mode: 0644]
LayoutTests/fast/frames/script-tests/iframe-reparenting-new-page.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLFrameElementBase.cpp
WebCore/html/HTMLFrameElementBase.h
WebCore/html/HTMLFrameOwnerElement.h
WebCore/loader/EmptyClients.h
WebCore/loader/FrameLoaderClient.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/chromium/ChangeLog
WebKit/chromium/src/FrameLoaderClientImpl.cpp
WebKit/chromium/src/FrameLoaderClientImpl.h
WebKit/chromium/src/WebFrameImpl.h
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
WebKit/haiku/ChangeLog
WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
WebKit/qt/Api/qwebframe.cpp
WebKit/qt/Api/qwebframe.h
WebKit/qt/Api/qwebframe_p.h
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
WebKit/wx/ChangeLog
WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
WebKit/wx/WebKitSupport/FrameLoaderClientWx.h