[webkit-changes] [WebKit/WebKit] b87d18: Remove Frame::setOpener

Alex Christensen noreply at github.com
Fri Aug 30 12:24:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b87d18215a73f63b17fc05ca68ad57d8a04646e4
      https://github.com/WebKit/WebKit/commit/b87d18215a73f63b17fc05ca68ad57d8a04646e4
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2024-08-30 (Fri, 30 Aug 2024)

  Changed paths:
    M Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/FrameLoader.h
    M Source/WebCore/page/Frame.cpp
    M Source/WebCore/page/Frame.h
    M Source/WebCore/page/LocalDOMWindow.cpp
    M Source/WebCore/page/RemoteDOMWindow.cpp
    M Source/WebCore/page/RemoteDOMWindow.h
    M Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
    M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
    M Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm
    M Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
    M Source/WebKitLegacy/mac/WebView/WebFrame.mm
    M Source/WebKitLegacy/mac/WebView/WebView.mm
    M Tools/TestWebKitAPI/Tests/WebKit/CloseFromWithinCreatePage.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/ModalAlertsSPI.cpp

  Log Message:
  -----------
  Remove Frame::setOpener
https://bugs.webkit.org/show_bug.cgi?id=278592
rdar://134596394

Reviewed by Charlie Wolfe.

This PR untangles the different cases where we need to set
the opener of a frame.  Most commonly we only want to remove
the opener.  A frame can usually only get an opener if it is
created with one, which I moved to the UI process in
274396 at main but it can also be given an opener later if
window.open is called with an existing frame as the target.
We also need a setter upon Page construction in
WebKitLegacy because the delegate callback doesn't have a
configuration object and when switching between a LocalFrame
and RemoteFrame.

This is step 1 of turning FrameLoaderClient::dispatchCreatePage
inside out and making it send the request and other parameters
for the UI process to decide to make a page in whatever process
it decides to.  This is needed for implementing window.open
with noopener with site isolation enabled.

In order for this new way of setting the opener to work,
users of WKPageSetPageUIClient need to be updated to v6
to get the createNewPage callback with a configuration where
we can preserve the opener info like we do with WKUIDelegate.
I've gone through the users of WKPageSetPageUIClient and made
sure this won't break any current use.  There is one current
use and it always returns nil, so there is no compatibility
concern there.

WebCore::createWindow had an issue that had been covered up for
many years.  It takes two LocalFrame parameters, but when it is
called from LocalDOMWindow::createWindow the parameter order was
switched, and we used to just call Frame::setOpener to cover it
up and make sure the frame had the correct opener when we were
done.  With this new flow of giving the Frame the correct opener
in its constructor then never changing it unless we call open
with a named existing frame, we need to use the correct frame as
the opener.  Since we were already using the opener as the lookup
frame, I simplified it to only take one frame as a parameter,
the correct opener frame.

* Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::openURLExternally):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::~FrameLoader):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
(WebCore::FrameLoader::switchBrowsingContextsGroup):
* Source/WebCore/page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::takeWindowProxyAndOpenerFrom):
(WebCore::Frame::disownOpener):
(WebCore::Frame::setOpenerForWebKitLegacy):
(WebCore::Frame::detachFromAllOpenedFrames):
(WebCore::Frame::takeWindowProxyFrom): Deleted.
(WebCore::Frame::setOpener): Deleted.
(WebCore::Frame::openedFrames): Deleted.
* Source/WebCore/page/Frame.h:
(WebCore::Frame::opener):
* Source/WebCore/page/LocalDOMWindow.cpp:
(WebCore::LocalDOMWindow::disownOpener):
(WebCore::LocalDOMWindow::createWindow):
* Source/WebCore/page/RemoteDOMWindow.cpp:
(WebCore::RemoteDOMWindow::setOpener): Deleted.
* Source/WebCore/page/RemoteDOMWindow.h:
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameClearOpener):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::loadDidCommitInAnotherProcess):
(WebKit::WebFrame::commitProvisionalFrame):
* Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchCreatePage):
* Source/WebKitLegacy/mac/WebView/WebFrame.mm:
(-[WebFrame _clearOpener]):
* Source/WebKitLegacy/mac/WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Canonical link: https://commits.webkit.org/282987@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list