Skip to content
  • akling@apple.com's avatar
    WebCore: Let Page create the main Frame. · 8e830e40
    akling@apple.com authored
    <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: http://svn.webkit.org/repository/webkit/trunk@154616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    8e830e40