WebCore: Let Page create the main Frame.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 17:54:33 +0000 (17:54 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 17:54:33 +0000 (17:54 +0000)
commit0f329f7a873444be14bb09a7718a7f4b547304ec
treee07a97bf0a9cf7638a7f7fa079a3d88e8d2bc624
parent1ba4891d0ef923913bf127f7266df15d1299fe76
WebCore: Let Page create the main Frame.
<https://webkit.org/b/119964>

Source/WebCore:

Reviewed by Anders Carlsson.

Previously, Frame::create() would call Page::setMainFrame() when constructing the
main Frame for a Page. Up until that point, Page had a null mainFrame().

To guarantee that Page::mainFrame() is never null, we re-order things so that
Page is responsible for creating its own main Frame. We do this at the earliest
possible point; in the Page constructor initializer list.

Constructing a Frame requires a FrameLoaderClient*, so I've added such a field to
the PageClients struct.

When creating a WebKit-layer frame, we now wrap the already-instantiated
Page::mainFrame() instead of creating a new Frame.

* loader/EmptyClients.cpp:
(WebCore::fillWithEmptyClients):

    Add an EmptyFrameLoaderClient to the PageClients constructed here.

* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::overlayPage):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):

    Updated to wrap Page::mainFrame() in a FrameView instead of creating their
    own Frame manually.

* page/Frame.cpp:
(WebCore::Frame::create):
* page/Page.h:

    Remove Page::setMainFrame() and the only call site.

* page/Page.cpp:
(WebCore::Page::Page):

    Construct Page::m_mainFrame in the initializer list.

(WebCore::Page::PageClients::PageClients):

    Add "FrameLoaderClient* loaderClientForMainFrame" to PageClients.

(WebCore::Page::setNeedsRecalcStyleInAllFrames):

    Null-check the Frame::document() before calling through on it. This would
    otherwise crash when changing font-related Settings before calling init() on
    the Frame (like InspectorOverlay does.)

Source/WebKit/gtk:

Tweak WebKit1/GTK for changes in WebCore.

Patch by Zan Dobersek <zdobersek@igalia.com>
Reviewed by Gustavo Noronha Silva.

* WebCoreSupport/FrameLoaderClientGtk.h:
(WebKit::FrameLoaderClient::setWebFrame):
* webkit/webkitwebframe.cpp:
(webkit_web_frame_new):
* webkit/webkitwebview.cpp:
(webkit_web_view_init):

Source/WebKit/mac:

Reviewed by Anders Carlsson.

* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient::setWebFrame):

    Make it possible to construct a WebFrameLoaderClient with a null WebFrame*.
    A WebFrame* is later hooked up with a call to setWebFrame().

* WebView/WebFrame.mm:
(+[WebFrame _createMainFrameWithPage:frameName:frameView:]):

    Customized this method to wrap the Page::mainFrame() instead of creating a
    new Frame.

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):

    Add a WebFrameLoaderClient to the PageClients passed to Page().

Source/WebKit2:

Reviewed by Anders Carlsson.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::WebFrameLoaderClient):

    This starts out with a null WebFrame* pointer now.

(WebKit::WebFrameLoaderClient::setWebFrame):

    WebFrame hooks itself up through this as soon as it's constructed.

(WebKit::WebFrameLoaderClient::frameLoaderDestroyed):

    Tweak an out-of-date comment. The ref() we're balancing out comes from
    WebFrame::create().

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createWithCoreMainFrame):

    Rewrote createMainFrame() as createWithCoreMainFrame(). The new method wraps
    an existing WebCore::Frame instead of creating a new one.

(WebKit::WebFrame::createSubframe):

    Merged WebFrame::init() into here since the logic isn't shared with main
    Frame creation anymore.

(WebKit::WebFrame::create):
(WebKit::WebFrame::WebFrame):

    Call WebFrameLoaderClient::setWebFrame(this).

* WebProcess/WebPage/WebFrame.h:

    WebFrame::m_frameLoaderClient is now an OwnPtr rather than an inline member.
    This way it can be created before the WebFrame.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):

    Set up a WebFrameLoaderClient and pass it to the Page constructor along with
    the other PageClients.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
Source/WebKit/gtk/webkit/webkitwebframe.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp