Changeset 221887 in webkit


Ignore:
Timestamp:
Sep 11, 2017 3:51:18 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Modernize and make API::UIClient more asynchronous
https://bugs.webkit.org/show_bug.cgi?id=176583

Reviewed by Brian Burg.

API::UIClient calls that return values synchronously require synchronous APIs unnecessarily.
Having them call completion handlers with the results instead allows us to make asynchronous
APIs, and existing synchronous APIs can just call the completion handlers immediately.

Unfortunately an assumption that API::UIClient::windowFrame returns synchronously had worked
its way into the WebAutomationSession, which calls WebPageProxy::getWindowFrame. Making it
asynchronous required making some automation protocols asynchronous so they can send their
result once they have the resulting frames from the UIClient.

No change in behaviour.

  • UIProcess/API/APIUIClient.h:

(API::UIClient::setToolbarsAreVisible):
(API::UIClient::menuBarIsVisible):
(API::UIClient::setMenuBarIsVisible):
(API::UIClient::statusBarIsVisible):
(API::UIClient::setStatusBarIsVisible):
(API::UIClient::isResizable):
(API::UIClient::setIsResizable):
(API::UIClient::setWindowFrame):
(API::UIClient::windowFrame):
(API::UIClient::headerHeight):
(API::UIClient::footerHeight):
(API::UIClient::drawHeader):
(API::UIClient::drawFooter):
(API::UIClient::printFrame):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient):

  • UIProcess/Automation/Automation.json:
  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::buildBrowsingContextForPage):
(WebKit::WebAutomationSession::getNextContext):
(WebKit::WebAutomationSession::getBrowsingContexts):
(WebKit::WebAutomationSession::getBrowsingContext):
(WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
(WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
(WebKit::WebAutomationSession::performMouseInteraction):

  • UIProcess/Automation/WebAutomationSession.h:
  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::UIClient::printFrame):

  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::printOperationWithPrintInfo):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::runJavaScriptPrompt):
(WebKit::WebPageProxy::setToolbarsAreVisible):
(WebKit::WebPageProxy::setMenuBarIsVisible):
(WebKit::WebPageProxy::getMenuBarIsVisible):
(WebKit::WebPageProxy::setStatusBarIsVisible):
(WebKit::WebPageProxy::getStatusBarIsVisible):
(WebKit::WebPageProxy::setIsResizable):
(WebKit::WebPageProxy::getIsResizable):
(WebKit::WebPageProxy::setWindowFrame):
(WebKit::WebPageProxy::getWindowFrame):
(WebKit::WebPageProxy::getWindowFrameWithCompletionHandler):
(WebKit::WebPageProxy::screenToRootView):
(WebKit::WebPageProxy::rootViewToScreen):
(WebKit::WebPageProxy::printFrame):
(WebKit::WebPageProxy::headerHeight):
(WebKit::WebPageProxy::footerHeight):
(WebKit::WebPageProxy::drawHeader):
(WebKit::WebPageProxy::drawFooter):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/mac/WKPrintingView.h:
  • UIProcess/mac/WKPrintingView.mm:

(-[WKPrintingView initWithFrameProxy:view:]):
(-[WKPrintingView _adjustPrintingMarginsForHeaderAndFooter]):
(-[WKPrintingView drawPageBorderWithSize:]):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::windowAndViewFramesChanged):

Location:
trunk/Source/WebKit
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r221874 r221887  
     12017-09-11  Alex Christensen  <achristensen@webkit.org>
     2
     3        Modernize and make API::UIClient more asynchronous
     4        https://bugs.webkit.org/show_bug.cgi?id=176583
     5
     6        Reviewed by Brian Burg.
     7
     8        API::UIClient calls that return values synchronously require synchronous APIs unnecessarily.
     9        Having them call completion handlers with the results instead allows us to make asynchronous
     10        APIs, and existing synchronous APIs can just call the completion handlers immediately.
     11       
     12        Unfortunately an assumption that API::UIClient::windowFrame returns synchronously had worked
     13        its way into the WebAutomationSession, which calls WebPageProxy::getWindowFrame.  Making it
     14        asynchronous required making some automation protocols asynchronous so they can send their
     15        result once they have the resulting frames from the UIClient.
     16       
     17        No change in behaviour.
     18
     19        * UIProcess/API/APIUIClient.h:
     20        (API::UIClient::setToolbarsAreVisible):
     21        (API::UIClient::menuBarIsVisible):
     22        (API::UIClient::setMenuBarIsVisible):
     23        (API::UIClient::statusBarIsVisible):
     24        (API::UIClient::setStatusBarIsVisible):
     25        (API::UIClient::isResizable):
     26        (API::UIClient::setIsResizable):
     27        (API::UIClient::setWindowFrame):
     28        (API::UIClient::windowFrame):
     29        (API::UIClient::headerHeight):
     30        (API::UIClient::footerHeight):
     31        (API::UIClient::drawHeader):
     32        (API::UIClient::drawFooter):
     33        (API::UIClient::printFrame):
     34        * UIProcess/API/C/WKPage.cpp:
     35        (WKPageSetPageUIClient):
     36        * UIProcess/Automation/Automation.json:
     37        * UIProcess/Automation/WebAutomationSession.cpp:
     38        (WebKit::WebAutomationSession::buildBrowsingContextForPage):
     39        (WebKit::WebAutomationSession::getNextContext):
     40        (WebKit::WebAutomationSession::getBrowsingContexts):
     41        (WebKit::WebAutomationSession::getBrowsingContext):
     42        (WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
     43        (WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
     44        (WebKit::WebAutomationSession::performMouseInteraction):
     45        * UIProcess/Automation/WebAutomationSession.h:
     46        * UIProcess/Cocoa/UIDelegate.h:
     47        * UIProcess/Cocoa/UIDelegate.mm:
     48        (WebKit::UIDelegate::UIClient::printFrame):
     49        * UIProcess/Cocoa/WebViewImpl.mm:
     50        (WebKit::WebViewImpl::printOperationWithPrintInfo):
     51        * UIProcess/WebPageProxy.cpp:
     52        (WebKit::WebPageProxy::runJavaScriptPrompt):
     53        (WebKit::WebPageProxy::setToolbarsAreVisible):
     54        (WebKit::WebPageProxy::setMenuBarIsVisible):
     55        (WebKit::WebPageProxy::getMenuBarIsVisible):
     56        (WebKit::WebPageProxy::setStatusBarIsVisible):
     57        (WebKit::WebPageProxy::getStatusBarIsVisible):
     58        (WebKit::WebPageProxy::setIsResizable):
     59        (WebKit::WebPageProxy::getIsResizable):
     60        (WebKit::WebPageProxy::setWindowFrame):
     61        (WebKit::WebPageProxy::getWindowFrame):
     62        (WebKit::WebPageProxy::getWindowFrameWithCompletionHandler):
     63        (WebKit::WebPageProxy::screenToRootView):
     64        (WebKit::WebPageProxy::rootViewToScreen):
     65        (WebKit::WebPageProxy::printFrame):
     66        (WebKit::WebPageProxy::headerHeight):
     67        (WebKit::WebPageProxy::footerHeight):
     68        (WebKit::WebPageProxy::drawHeader):
     69        (WebKit::WebPageProxy::drawFooter):
     70        * UIProcess/WebPageProxy.h:
     71        * UIProcess/WebPageProxy.messages.in:
     72        * UIProcess/mac/WKPrintingView.h:
     73        * UIProcess/mac/WKPrintingView.mm:
     74        (-[WKPrintingView initWithFrameProxy:view:]):
     75        (-[WKPrintingView _adjustPrintingMarginsForHeaderAndFooter]):
     76        (-[WKPrintingView drawPageBorderWithSize:]):
     77        * UIProcess/mac/WebPageProxyMac.mm:
     78        (WebKit::WebPageProxy::windowAndViewFramesChanged):
     79
    1802017-09-11  Stephan Szabo  <stephan.szabo@sony.com>
    281
  • trunk/Source/WebKit/UIProcess/API/APIUIClient.h

    r221873 r221887  
    100100
    101101    virtual void toolbarsAreVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }
    102     virtual void setToolbarsAreVisible(WebKit::WebPageProxy*, bool) { }
    103     virtual bool menuBarIsVisible(WebKit::WebPageProxy*) { return true; }
    104     virtual void setMenuBarIsVisible(WebKit::WebPageProxy*, bool) { }
    105     virtual bool statusBarIsVisible(WebKit::WebPageProxy*) { return true; }
    106     virtual void setStatusBarIsVisible(WebKit::WebPageProxy*, bool) { }
    107     virtual bool isResizable(WebKit::WebPageProxy*) { return true; }
    108     virtual void setIsResizable(WebKit::WebPageProxy*, bool) { }
     102    virtual void setToolbarsAreVisible(WebKit::WebPageProxy&, bool) { }
     103    virtual void menuBarIsVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }
     104    virtual void setMenuBarIsVisible(WebKit::WebPageProxy&, bool) { }
     105    virtual void statusBarIsVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }
     106    virtual void setStatusBarIsVisible(WebKit::WebPageProxy&, bool) { }
     107    virtual void isResizable(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }
     108    virtual void setIsResizable(WebKit::WebPageProxy&, bool) { }
    109109
    110     virtual void setWindowFrame(WebKit::WebPageProxy*, const WebCore::FloatRect&) { }
    111     virtual WebCore::FloatRect windowFrame(WebKit::WebPageProxy*) { return WebCore::FloatRect(); }
     110    virtual void setWindowFrame(WebKit::WebPageProxy&, const WebCore::FloatRect&) { }
     111    virtual void windowFrame(WebKit::WebPageProxy&, Function<void(WebCore::FloatRect)>&& completionHandler) { completionHandler({ }); }
    112112
    113113    virtual bool canRunBeforeUnloadConfirmPanel() const { return false; }
     
    133133
    134134    // Printing.
    135     virtual float headerHeight(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { return 0; }
    136     virtual float footerHeight(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { return 0; }
    137     virtual void drawHeader(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
    138     virtual void drawFooter(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
    139     virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { }
     135    virtual float headerHeight(WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { return 0; }
     136    virtual float footerHeight(WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { return 0; }
     137    virtual void drawHeader(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::FloatRect&&) { }
     138    virtual void drawFooter(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::FloatRect&&) { }
     139    virtual void printFrame(WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { }
    140140
    141141    virtual bool canRunModal() const { return false; }
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r221873 r221887  
    18401840        }
    18411841
    1842         void setToolbarsAreVisible(WebPageProxy* page, bool visible) final
     1842        void setToolbarsAreVisible(WebPageProxy& page, bool visible) final
    18431843        {
    18441844            if (!m_client.setToolbarsAreVisible)
    18451845                return;
    1846             m_client.setToolbarsAreVisible(toAPI(page), visible, m_client.base.clientInfo);
    1847         }
    1848 
    1849         bool menuBarIsVisible(WebPageProxy* page) final
     1846            m_client.setToolbarsAreVisible(toAPI(&page), visible, m_client.base.clientInfo);
     1847        }
     1848
     1849        void menuBarIsVisible(WebPageProxy& page, Function<void(bool)>&& completionHandler) final
    18501850        {
    18511851            if (!m_client.menuBarIsVisible)
    1852                 return true;
    1853             return m_client.menuBarIsVisible(toAPI(page), m_client.base.clientInfo);
    1854         }
    1855 
    1856         void setMenuBarIsVisible(WebPageProxy* page, bool visible) final
     1852                return completionHandler(true);
     1853            completionHandler(m_client.menuBarIsVisible(toAPI(&page), m_client.base.clientInfo));
     1854        }
     1855
     1856        void setMenuBarIsVisible(WebPageProxy& page, bool visible) final
    18571857        {
    18581858            if (!m_client.setMenuBarIsVisible)
    18591859                return;
    1860             m_client.setMenuBarIsVisible(toAPI(page), visible, m_client.base.clientInfo);
    1861         }
    1862 
    1863         bool statusBarIsVisible(WebPageProxy* page) final
     1860            m_client.setMenuBarIsVisible(toAPI(&page), visible, m_client.base.clientInfo);
     1861        }
     1862
     1863        void statusBarIsVisible(WebPageProxy& page, Function<void(bool)>&& completionHandler) final
    18641864        {
    18651865            if (!m_client.statusBarIsVisible)
    1866                 return true;
    1867             return m_client.statusBarIsVisible(toAPI(page), m_client.base.clientInfo);
    1868         }
    1869 
    1870         void setStatusBarIsVisible(WebPageProxy* page, bool visible) final
     1866                return completionHandler(true);
     1867            completionHandler(m_client.statusBarIsVisible(toAPI(&page), m_client.base.clientInfo));
     1868        }
     1869
     1870        void setStatusBarIsVisible(WebPageProxy& page, bool visible) final
    18711871        {
    18721872            if (!m_client.setStatusBarIsVisible)
    18731873                return;
    1874             m_client.setStatusBarIsVisible(toAPI(page), visible, m_client.base.clientInfo);
    1875         }
    1876 
    1877         bool isResizable(WebPageProxy* page) final
     1874            m_client.setStatusBarIsVisible(toAPI(&page), visible, m_client.base.clientInfo);
     1875        }
     1876
     1877        void isResizable(WebPageProxy& page, Function<void(bool)>&& completionHandler) final
    18781878        {
    18791879            if (!m_client.isResizable)
    1880                 return true;
    1881             return m_client.isResizable(toAPI(page), m_client.base.clientInfo);
    1882         }
    1883 
    1884         void setIsResizable(WebPageProxy* page, bool resizable) final
     1880                return completionHandler(true);
     1881            completionHandler(m_client.isResizable(toAPI(&page), m_client.base.clientInfo));
     1882        }
     1883
     1884        void setIsResizable(WebPageProxy& page, bool resizable) final
    18851885        {
    18861886            if (!m_client.setIsResizable)
    18871887                return;
    1888             m_client.setIsResizable(toAPI(page), resizable, m_client.base.clientInfo);
    1889         }
    1890 
    1891         void setWindowFrame(WebPageProxy* page, const FloatRect& frame) final
     1888            m_client.setIsResizable(toAPI(&page), resizable, m_client.base.clientInfo);
     1889        }
     1890
     1891        void setWindowFrame(WebPageProxy& page, const FloatRect& frame) final
    18921892        {
    18931893            if (!m_client.setWindowFrame)
    18941894                return;
    18951895
    1896             m_client.setWindowFrame(toAPI(page), toAPI(frame), m_client.base.clientInfo);
    1897         }
    1898 
    1899         FloatRect windowFrame(WebPageProxy* page) final
     1896            m_client.setWindowFrame(toAPI(&page), toAPI(frame), m_client.base.clientInfo);
     1897        }
     1898
     1899        void windowFrame(WebPageProxy& page, Function<void(WebCore::FloatRect)>&& completionHandler) final
    19001900        {
    19011901            if (!m_client.getWindowFrame)
    1902                 return FloatRect();
    1903 
    1904             return toFloatRect(m_client.getWindowFrame(toAPI(page), m_client.base.clientInfo));
     1902                return completionHandler({ });
     1903
     1904            completionHandler(toFloatRect(m_client.getWindowFrame(toAPI(&page), m_client.base.clientInfo)));
    19051905        }
    19061906
     
    19901990
    19911991        // Printing.
    1992         float headerHeight(WebPageProxy* page, WebFrameProxy* frame) final
     1992        float headerHeight(WebPageProxy& page, WebFrameProxy& frame) final
    19931993        {
    19941994            if (!m_client.headerHeight)
    19951995                return 0;
    19961996
    1997             return m_client.headerHeight(toAPI(page), toAPI(frame), m_client.base.clientInfo);
    1998         }
    1999 
    2000         float footerHeight(WebPageProxy* page, WebFrameProxy* frame) final
     1997            return m_client.headerHeight(toAPI(&page), toAPI(&frame), m_client.base.clientInfo);
     1998        }
     1999
     2000        float footerHeight(WebPageProxy& page, WebFrameProxy& frame) final
    20012001        {
    20022002            if (!m_client.footerHeight)
    20032003                return 0;
    20042004
    2005             return m_client.footerHeight(toAPI(page), toAPI(frame), m_client.base.clientInfo);
    2006         }
    2007 
    2008         void drawHeader(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) final
     2005            return m_client.footerHeight(toAPI(&page), toAPI(&frame), m_client.base.clientInfo);
     2006        }
     2007
     2008        void drawHeader(WebPageProxy& page, WebFrameProxy& frame, WebCore::FloatRect&& rect) final
    20092009        {
    20102010            if (!m_client.drawHeader)
    20112011                return;
    20122012
    2013             m_client.drawHeader(toAPI(page), toAPI(frame), toAPI(rect), m_client.base.clientInfo);
    2014         }
    2015 
    2016         void drawFooter(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) final
     2013            m_client.drawHeader(toAPI(&page), toAPI(&frame), toAPI(rect), m_client.base.clientInfo);
     2014        }
     2015
     2016        void drawFooter(WebPageProxy& page, WebFrameProxy& frame, WebCore::FloatRect&& rect) final
    20172017        {
    20182018            if (!m_client.drawFooter)
    20192019                return;
    20202020
    2021             m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.base.clientInfo);
    2022         }
    2023 
    2024         void printFrame(WebPageProxy* page, WebFrameProxy* frame) final
     2021            m_client.drawFooter(toAPI(&page), toAPI(&frame), toAPI(rect), m_client.base.clientInfo);
     2022        }
     2023
     2024        void printFrame(WebPageProxy& page, WebFrameProxy& frame) final
    20252025        {
    20262026            if (!m_client.printFrame)
    20272027                return;
    20282028
    2029             m_client.printFrame(toAPI(page), toAPI(frame), m_client.base.clientInfo);
     2029            m_client.printFrame(toAPI(&page), toAPI(&frame), m_client.base.clientInfo);
    20302030        }
    20312031
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp

    r221873 r221887  
    5454    }
    5555
    56     void showPage(WebPageProxy*) override
     56    void showPage(WebPageProxy*) final
    5757    {
    5858        webkitWebViewReadyToShowPage(m_webView);
    5959    }
    6060
    61     void close(WebPageProxy*) override
     61    void close(WebPageProxy*) final
    6262    {
    6363        webkitWebViewClosePage(m_webView);
    6464    }
    6565
    66     void runJavaScriptAlert(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void ()>&& completionHandler) override
     66    void runJavaScriptAlert(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void()>&& completionHandler) final
    6767    {
    6868        webkitWebViewRunJavaScriptAlert(m_webView, message.utf8());
     
    7070    }
    7171
    72     void runJavaScriptConfirm(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (bool)>&& completionHandler) override
     72    void runJavaScriptConfirm(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void(bool)>&& completionHandler) final
    7373    {
    7474        completionHandler(webkitWebViewRunJavaScriptConfirm(m_webView, message.utf8()));
    7575    }
    7676
    77     void runJavaScriptPrompt(WebPageProxy*, const String& message, const String& defaultValue, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (const String&)>&& completionHandler) override
     77    void runJavaScriptPrompt(WebPageProxy*, const String& message, const String& defaultValue, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void(const String&)>&& completionHandler) final
    7878    {
    7979        CString result = webkitWebViewRunJavaScriptPrompt(m_webView, message.utf8(), defaultValue.utf8());
     
    8686    }
    8787
    88     bool canRunBeforeUnloadConfirmPanel() const override { return true; }
    89 
    90     void runBeforeUnloadConfirmPanel(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (bool)>&& completionHandler) override
     88    bool canRunBeforeUnloadConfirmPanel() const final { return true; }
     89
     90    void runBeforeUnloadConfirmPanel(WebPageProxy*, const String& message, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void(bool)>&& completionHandler) final
    9191    {
    9292        completionHandler(webkitWebViewRunJavaScriptBeforeUnloadConfirm(m_webView, message.utf8()));
     
    9898    }
    9999
    100     void toolbarsAreVisible(WebPageProxy&, Function<void(bool)>&& completionHandler) override
     100    void toolbarsAreVisible(WebPageProxy&, Function<void(bool)>&& completionHandler) final
    101101    {
    102102        completionHandler(webkit_window_properties_get_toolbar_visible(webkit_web_view_get_window_properties(m_webView)));
    103103    }
    104104
    105     void setToolbarsAreVisible(WebPageProxy*, bool visible) override
     105    void setToolbarsAreVisible(WebPageProxy&, bool visible) final
    106106    {
    107107        webkitWindowPropertiesSetToolbarVisible(webkit_web_view_get_window_properties(m_webView), visible);
    108108    }
    109109
    110     bool menuBarIsVisible(WebPageProxy*) override
    111     {
    112         return webkit_window_properties_get_menubar_visible(webkit_web_view_get_window_properties(m_webView));
    113     }
    114 
    115     void setMenuBarIsVisible(WebPageProxy*, bool visible) override
     110    void menuBarIsVisible(WebPageProxy&, Function<void(bool)>&& completionHandler) final
     111    {
     112        completionHandler(webkit_window_properties_get_menubar_visible(webkit_web_view_get_window_properties(m_webView)));
     113    }
     114
     115    void setMenuBarIsVisible(WebPageProxy&, bool visible) final
    116116    {
    117117        webkitWindowPropertiesSetToolbarVisible(webkit_web_view_get_window_properties(m_webView), visible);
    118118    }
    119119
    120     bool statusBarIsVisible(WebPageProxy*) override
    121     {
    122         return webkit_window_properties_get_statusbar_visible(webkit_web_view_get_window_properties(m_webView));
    123     }
    124 
    125     void setStatusBarIsVisible(WebPageProxy*, bool visible) override
     120    void statusBarIsVisible(WebPageProxy&, Function<void(bool)>&& completionHandler) final
     121    {
     122        completionHandler(webkit_window_properties_get_statusbar_visible(webkit_web_view_get_window_properties(m_webView)));
     123    }
     124
     125    void setStatusBarIsVisible(WebPageProxy&, bool visible) final
    126126    {
    127127        webkitWindowPropertiesSetStatusbarVisible(webkit_web_view_get_window_properties(m_webView), visible);
    128128    }
    129129
    130     bool isResizable(WebPageProxy*) override
    131     {
    132         return webkit_window_properties_get_resizable(webkit_web_view_get_window_properties(m_webView));
    133     }
    134 
    135     void setIsResizable(WebPageProxy*, bool resizable) override
     130    void isResizable(WebPageProxy&, Function<void(bool)>&& completionHandler) final
     131    {
     132        completionHandler(webkit_window_properties_get_resizable(webkit_web_view_get_window_properties(m_webView)));
     133    }
     134
     135    void setIsResizable(WebPageProxy&, bool resizable) final
    136136    {
    137137        webkitWindowPropertiesSetResizable(webkit_web_view_get_window_properties(m_webView), resizable);
    138138    }
    139139
    140     void setWindowFrame(WebPageProxy*, const WebCore::FloatRect& frame) override
     140    void setWindowFrame(WebPageProxy&, const WebCore::FloatRect& frame) final
    141141    {
    142142#if PLATFORM(GTK)
     
    153153    }
    154154
    155     WebCore::FloatRect windowFrame(WebPageProxy*) override
     155    void windowFrame(WebPageProxy&, Function<void(WebCore::FloatRect)>&& completionHandler) final
    156156    {
    157157#if PLATFORM(GTK)
     
    162162            gtk_window_get_size(GTK_WINDOW(window), &geometry.width, &geometry.height);
    163163        }
    164         return WebCore::FloatRect(geometry);
     164        completionHandler(WebCore::FloatRect(geometry));
    165165#elif PLATFORM(WPE)
    166166        // FIXME: I guess this is actually the view size in WPE. We need more refactoring here.
    167         return { };
    168 #endif
    169     }
    170 
    171     void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const String&, const String&, unsigned long long /*currentQuota*/, unsigned long long /*currentOriginUsage*/, unsigned long long /*currentDatabaseUsage*/, unsigned long long /*expectedUsage*/, Function<void (unsigned long long)>&& completionHandler) override
     167        completionHandler({ });
     168#endif
     169    }
     170
     171    void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const String&, const String&, unsigned long long /*currentQuota*/, unsigned long long /*currentOriginUsage*/, unsigned long long /*currentDatabaseUsage*/, unsigned long long /*expectedUsage*/, Function<void(unsigned long long)>&& completionHandler) final
    172172    {
    173173        static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB
     
    176176    }
    177177
    178     bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
     178    bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) final
    179179    {
    180180        GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener));
     
    189189    }
    190190
    191     bool decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) override
     191    bool decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final
    192192    {
    193193        GRefPtr<WebKitUserMediaPermissionRequest> userMediaPermissionRequest = adoptGRef(webkitUserMediaPermissionRequestCreate(permissionRequest, userMediaDocumentOrigin, topLevelDocumentOrigin));
     
    196196    }
    197197
    198     bool decidePolicyForNotificationPermissionRequest(WebPageProxy*, API::SecurityOrigin*, NotificationPermissionRequest* permissionRequest) override
     198    bool decidePolicyForNotificationPermissionRequest(WebPageProxy*, API::SecurityOrigin*, NotificationPermissionRequest* permissionRequest) final
    199199    {
    200200        GRefPtr<WebKitNotificationPermissionRequest> notificationPermissionRequest = adoptGRef(webkitNotificationPermissionRequestCreate(permissionRequest));
     
    204204
    205205#if PLATFORM(GTK)
    206     void printFrame(WebPageProxy*, WebFrameProxy* frame) override
    207     {
    208         webkitWebViewPrintFrame(m_webView, frame);
    209     }
    210 #endif
    211 
    212     bool canRunModal() const override { return true; }
    213 
    214     void runModal(WebPageProxy*) override
     206    void printFrame(WebPageProxy&, WebFrameProxy& frame) final
     207    {
     208        webkitWebViewPrintFrame(m_webView, &frame);
     209    }
     210#endif
     211
     212    bool canRunModal() const final { return true; }
     213
     214    void runModal(WebPageProxy*) final
    215215    {
    216216        webkitWebViewRunAsModal(m_webView);
  • trunk/Source/WebKit/UIProcess/Automation/Automation.json

    r221255 r221887  
    226226            "returns": [
    227227                { "name": "contexts", "type": "array", "items": { "$ref": "BrowsingContext" }, "description": "All known browsing contexts available to the session." }
    228             ]
     228            ],
     229            "async": true
    229230        },
    230231        {
     
    236237            "returns": [
    237238                { "name": "context", "$ref": "BrowsingContext", "description": "The browsing context available to the session." }
    238             ]
     239            ],
     240            "async": true
    239241        },
    240242        {
     
    266268                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be resized." },
    267269                { "name": "size", "$ref": "Size", "description": "The new size for the browsing context's window." }
    268             ]
     270            ],
     271            "async": true
    269272        },
    270273        {
     
    274277                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be moved." },
    275278                { "name": "origin", "$ref": "Point", "description": "The new origin for the browsing context's window. The position is interpreted in screen coordinate space, relative to the upper left corner of the screen." }
    276             ]
     279            ],
     280            "async": true
    277281        },
    278282        {
     
    366370            "returns": [
    367371                { "name": "position", "$ref": "Point", "description": "The updated position of the mouse cursor, specified in viewport coordinates." }
    368             ]
     372            ],
     373            "async": true
    369374        },
    370375        {
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r221255 r221887  
    208208}
    209209
    210 RefPtr<Inspector::Protocol::Automation::BrowsingContext> WebAutomationSession::buildBrowsingContextForPage(WebPageProxy& page)
    211 {
    212     WebCore::FloatRect windowFrame;
    213     page.getWindowFrame(windowFrame);
    214 
     210Ref<Inspector::Protocol::Automation::BrowsingContext> WebAutomationSession::buildBrowsingContextForPage(WebPageProxy& page, WebCore::FloatRect windowFrame)
     211{
    215212    auto originObject = Inspector::Protocol::Automation::Point::create()
    216213        .setX(windowFrame.x())
     
    236233// Platform-independent Commands.
    237234
    238 void WebAutomationSession::getBrowsingContexts(Inspector::ErrorString& errorString, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>& contexts)
    239 {
    240     contexts = Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>::create();
    241 
     235void WebAutomationSession::getNextContext(Ref<WebAutomationSession>&& protectedThis, Vector<Ref<WebPageProxy>>&& pages, Ref<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>> contexts, Ref<WebAutomationSession::GetBrowsingContextsCallback>&& callback)
     236{
     237    if (pages.isEmpty()) {
     238        callback->sendSuccess(WTFMove(contexts));
     239        return;
     240    }
     241    auto page = pages.takeLast();
     242    auto& webPageProxy = page.get();
     243    webPageProxy.getWindowFrameWithCallback([this, protectedThis = WTFMove(protectedThis), callback = WTFMove(callback), pages = WTFMove(pages), contexts = WTFMove(contexts), page = WTFMove(page)](WebCore::FloatRect windowFrame) mutable {
     244        contexts->addItem(protectedThis->buildBrowsingContextForPage(page.get(), windowFrame));
     245        getNextContext(WTFMove(protectedThis), WTFMove(pages), WTFMove(contexts), WTFMove(callback));
     246    });
     247}
     248   
     249void WebAutomationSession::getBrowsingContexts(Inspector::ErrorString& errorString, Ref<GetBrowsingContextsCallback>&& callback)
     250{
     251    Vector<Ref<WebPageProxy>> pages;
    242252    for (auto& process : m_processPool->processes()) {
    243253        for (auto* page : process->pages()) {
     
    245255            if (!page->isControlledByAutomation())
    246256                continue;
    247 
    248             contexts->addItem(buildBrowsingContextForPage(*page));
     257            pages.append(*page);
    249258        }
    250259    }
    251 }
    252 
    253 void WebAutomationSession::getBrowsingContext(Inspector::ErrorString& errorString, const String& handle, RefPtr<Inspector::Protocol::Automation::BrowsingContext>& context)
     260   
     261    getNextContext(makeRef(*this), WTFMove(pages), Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>::create(), WTFMove(callback));
     262}
     263
     264void WebAutomationSession::getBrowsingContext(Inspector::ErrorString& errorString, const String& handle, Ref<GetBrowsingContextCallback>&& callback)
    254265{
    255266    WebPageProxy* page = webPageProxyForHandle(handle);
     
    257268        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    258269
    259     context = buildBrowsingContextForPage(*page);
     270    page->getWindowFrameWithCallback([protectedThis = makeRef(*this), page = makeRef(*page), callback = WTFMove(callback)](WebCore::FloatRect windowFrame) mutable {
     271        callback->sendSuccess(protectedThis->buildBrowsingContextForPage(page.get(), windowFrame));
     272    });
    260273}
    261274
     
    302315}
    303316
    304 void WebAutomationSession::resizeWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& sizeObject)
     317void WebAutomationSession::resizeWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& sizeObject, Ref<ResizeWindowOfBrowsingContextCallback>&& callback)
    305318{
    306319#if PLATFORM(IOS)
     
    325338        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    326339
    327     WebCore::FloatRect originalFrame;
    328     page->getWindowFrame(originalFrame);
    329 
    330     WebCore::FloatRect newFrame = WebCore::FloatRect(originalFrame.location(), WebCore::FloatSize(width, height));
    331     if (newFrame == originalFrame)
    332         return;
    333 
    334     page->setWindowFrame(newFrame);
    335 
    336 #if !PLATFORM(GTK)
    337     // If nothing changed at all, it's probably fair to report that something went wrong.
    338     // (We can't assume that the requested frame size will be honored exactly, however.)
    339     WebCore::FloatRect updatedFrame;
    340     page->getWindowFrame(updatedFrame);
    341     if (originalFrame == updatedFrame)
    342         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window size was expected to have changed, but did not.");
     340    page->getWindowFrameWithCallback([callback = WTFMove(callback), page = makeRef(*page), width, height](WebCore::FloatRect originalFrame) mutable {
     341        WebCore::FloatRect newFrame = WebCore::FloatRect(originalFrame.location(), WebCore::FloatSize(width, height));
     342        if (newFrame == originalFrame)
     343            return callback->sendSuccess();
     344
     345        page->setWindowFrame(newFrame);
     346
     347#if PLATFORM(GTK)
     348        callback->sendSuccess();
     349#else
     350        // If nothing changed at all, it's probably fair to report that something went wrong.
     351        // (We can't assume that the requested frame size will be honored exactly, however.)
     352        page->getWindowFrameWithCallback([callback = WTFMove(callback), originalFrame](WebCore::FloatRect updatedFrame) {
     353            if (originalFrame == updatedFrame)
     354                callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME_AND_DETAILS(InternalError, "The window size was expected to have changed, but did not."));
     355            else
     356                callback->sendSuccess();
     357        });
    343358#endif
     359    });
    344360#endif
    345361}
    346362
    347 void WebAutomationSession::moveWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& positionObject)
     363void WebAutomationSession::moveWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& positionObject, Ref<MoveWindowOfBrowsingContextCallback>&& callback)
    348364{
    349365#if PLATFORM(IOS)
     
    369385
    370386    WebCore::FloatRect originalFrame;
    371     page->getWindowFrame(originalFrame);
    372 
    373     WebCore::FloatRect newFrame = WebCore::FloatRect(WebCore::FloatPoint(x, y), originalFrame.size());
    374     if (newFrame == originalFrame)
    375         return;
    376 
    377     page->setWindowFrame(newFrame);
    378 
    379 #if !PLATFORM(GTK)
    380     // If nothing changed at all, it's probably fair to report that something went wrong.
    381     // (We can't assume that the requested frame size will be honored exactly, however.)
    382     WebCore::FloatRect updatedFrame;
    383     page->getWindowFrame(updatedFrame);
    384     if (originalFrame == updatedFrame)
    385         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window position was expected to have changed, but did not.");
     387    page->getWindowFrameWithCallback([callback = WTFMove(callback), page = makeRef(*page), x, y](WebCore::FloatRect originalFrame) mutable {
     388
     389        WebCore::FloatRect newFrame = WebCore::FloatRect(WebCore::FloatPoint(x, y), originalFrame.size());
     390        if (newFrame == originalFrame)
     391            return callback->sendSuccess();
     392
     393        page->setWindowFrame(newFrame);
     394
     395#if PLATFORM(GTK)
     396        callback->sendSuccess();
     397#else
     398        // If nothing changed at all, it's probably fair to report that something went wrong.
     399        // (We can't assume that the requested frame size will be honored exactly, however.)
     400        page->getWindowFrameWithCallback([callback = WTFMove(callback), originalFrame](WebCore::FloatRect updatedFrame) {
     401            if (originalFrame == updatedFrame)
     402                callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME_AND_DETAILS(InternalError, "The window position was expected to have changed, but did not."));
     403            else
     404                callback->sendSuccess();
     405        });
    386406#endif
     407    });
    387408#endif
    388409}
     
    12221243#endif // USE(APPKIT)
    12231244
    1224 void WebAutomationSession::performMouseInteraction(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const Inspector::InspectorArray& keyModifierStrings, RefPtr<Inspector::Protocol::Automation::Point>& updatedPositionObject)
     1245void WebAutomationSession::performMouseInteraction(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const Inspector::InspectorArray& keyModifierStrings, Ref<PerformMouseInteractionCallback>&& callback)
    12251246{
    12261247#if !USE(APPKIT) && !PLATFORM(GTK)
     
    12381259    if (!requestedPositionObject.getDouble(WTF::ASCIILiteral("y"), y))
    12391260        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The parameter 'y' was not found.");
    1240 
    1241     WebCore::FloatRect windowFrame;
    1242     page->getWindowFrame(windowFrame);
    1243 
    1244     x = std::min(std::max(0.0f, x), windowFrame.size().width());
    1245     y = std::min(std::max(0.0f, y + page->topContentInset()), windowFrame.size().height());
    1246 
    1247     WebCore::IntPoint viewPosition = WebCore::IntPoint(static_cast<int>(x), static_cast<int>(y));
    1248 
    1249     auto parsedInteraction = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseInteraction>(mouseInteractionString);
    1250     if (!parsedInteraction)
    1251         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'interaction' is invalid.");
    1252 
    1253     auto parsedButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(mouseButtonString);
    1254     if (!parsedButton)
    1255         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'button' is invalid.");
    12561261
    12571262    WebEvent::Modifiers keyModifiers = (WebEvent::Modifiers)0;
     
    12671272        keyModifiers = (WebEvent::Modifiers)(enumValue | keyModifiers);
    12681273    }
    1269 
    1270     platformSimulateMouseInteraction(*page, viewPosition, parsedInteraction.value(), parsedButton.value(), keyModifiers);
    1271 
    1272     updatedPositionObject = Inspector::Protocol::Automation::Point::create()
    1273         .setX(x)
    1274         .setY(y - page->topContentInset())
    1275         .release();
     1274   
     1275    page->getWindowFrameWithCallback([this, protectedThis = makeRef(*this), callback = WTFMove(callback), page = makeRef(*page), x, y, mouseInteractionString, mouseButtonString, keyModifiers](WebCore::FloatRect windowFrame) mutable {
     1276
     1277        x = std::min(std::max(0.0f, x), windowFrame.size().width());
     1278        y = std::min(std::max(0.0f, y + page->topContentInset()), windowFrame.size().height());
     1279
     1280        WebCore::IntPoint viewPosition = WebCore::IntPoint(static_cast<int>(x), static_cast<int>(y));
     1281
     1282        auto parsedInteraction = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseInteraction>(mouseInteractionString);
     1283        if (!parsedInteraction)
     1284            return callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME_AND_DETAILS(InvalidParameter, "The parameter 'interaction' is invalid."));
     1285
     1286        auto parsedButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(mouseButtonString);
     1287        if (!parsedButton)
     1288            return callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME_AND_DETAILS(InvalidParameter, "The parameter 'button' is invalid."));
     1289
     1290        platformSimulateMouseInteraction(page, viewPosition, parsedInteraction.value(), parsedButton.value(), keyModifiers);
     1291
     1292        callback->sendSuccess(Inspector::Protocol::Automation::Point::create()
     1293            .setX(x)
     1294            .setY(y - page->topContentInset())
     1295            .release());
     1296    });
    12761297#endif // USE(APPKIT)
    12771298}
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h

    r221255 r221887  
    116116
    117117    // Platform: Generic
    118     void getBrowsingContexts(Inspector::ErrorString&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>&) override;
    119     void getBrowsingContext(Inspector::ErrorString&, const String&, RefPtr<Inspector::Protocol::Automation::BrowsingContext>&) override;
     118    void getBrowsingContexts(Inspector::ErrorString&, Ref<GetBrowsingContextsCallback>&&) final;
     119    void getBrowsingContext(Inspector::ErrorString&, const String&, Ref<GetBrowsingContextCallback>&&) final;
    120120    void createBrowsingContext(Inspector::ErrorString&, String*) override;
    121121    void closeBrowsingContext(Inspector::ErrorString&, const String&) override;
    122122    void switchToBrowsingContext(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle) override;
    123     void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size) override;
    124     void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position) override;
     123    void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size, Ref<ResizeWindowOfBrowsingContextCallback>&&) final;
     124    void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position, Ref<MoveWindowOfBrowsingContextCallback>&&) final;
    125125    void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<NavigateBrowsingContextCallback>&&) override;
    126126    void goBackInBrowsingContext(Inspector::ErrorString&, const String&, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<GoBackInBrowsingContextCallback>&&) override;
     
    129129    void waitForNavigationToComplete(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&&) override;
    130130    void evaluateJavaScriptFunction(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const Inspector::InspectorArray& arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
    131     void performMouseInteraction(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& requestedPosition, const String& mouseButton, const String& mouseInteraction, const Inspector::InspectorArray& keyModifiers, RefPtr<Inspector::Protocol::Automation::Point>& updatedPosition) override;
     131    void performMouseInteraction(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& requestedPosition, const String& mouseButton, const String& mouseInteraction, const Inspector::InspectorArray& keyModifiers, Ref<PerformMouseInteractionCallback>&&) final;
    132132    void performKeyboardInteractions(Inspector::ErrorString&, const String& handle, const Inspector::InspectorArray& interactions, Ref<PerformKeyboardInteractionsCallback>&&) override;
    133133    void takeScreenshot(Inspector::ErrorString&, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, Ref<TakeScreenshotCallback>&&) override;
     
    161161    WebPageProxy* webPageProxyForHandle(const String&);
    162162    String handleForWebPageProxy(const WebPageProxy&);
    163     RefPtr<Inspector::Protocol::Automation::BrowsingContext> buildBrowsingContextForPage(WebPageProxy&);
     163    Ref<Inspector::Protocol::Automation::BrowsingContext> buildBrowsingContextForPage(WebPageProxy&, WebCore::FloatRect windowFrame);
     164    void getNextContext(Ref<WebAutomationSession>&&, Vector<Ref<WebPageProxy>>&&, Ref<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>, Ref<WebAutomationSession::GetBrowsingContextsCallback>&&);
    164165
    165166    std::optional<uint64_t> webFrameIDForHandle(const String&);
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r221873 r221887  
    116116        bool checkUserMediaPermissionForOrigin(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionCheckProxy&) final;
    117117        void mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags) final;
    118         void printFrame(WebPageProxy*, WebFrameProxy*) final;
     118        void printFrame(WebPageProxy&, WebFrameProxy&) final;
    119119#if PLATFORM(IOS)
    120120#if HAVE(APP_LINKS)
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r221873 r221887  
    852852}
    853853
    854 void UIDelegate::UIClient::printFrame(WebPageProxy*, WebFrameProxy* webFrameProxy)
    855 {
    856     ASSERT_ARG(webFrameProxy, webFrameProxy);
    857 
     854void UIDelegate::UIClient::printFrame(WebPageProxy&, WebFrameProxy& webFrameProxy)
     855{
    858856    if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame)
    859857        return;
     
    863861        return;
    864862
    865     [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
     863    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy.frameID()))];
    866864}
    867865
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r221707 r221887  
    16291629    // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows
    16301630    // printing), this function should return nil.
    1631     RetainPtr<WKPrintingView> printingView = adoptNS([[WKPrintingView alloc] initWithFrameProxy:&frame view:m_view.getAutoreleased()]);
     1631    RetainPtr<WKPrintingView> printingView = adoptNS([[WKPrintingView alloc] initWithFrameProxy:frame view:m_view.getAutoreleased()]);
    16321632    // NSPrintOperation takes ownership of the view.
    16331633    NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get() printInfo:printInfo];
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r221873 r221887  
    39603960}
    39613961
    3962 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const SecurityOriginData& securityOrigin, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
     3962void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const SecurityOriginData& securityOrigin, const String& message, const String& defaultValue, Ref<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply>&& reply)
    39633963{
    39643964    WebFrameProxy* frame = m_process->webFrame(frameID);
     
    39733973    }
    39743974
    3975     m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, securityOrigin, [reply](const String& result) { reply->send(result); });
     3975    m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, securityOrigin, [reply = WTFMove(reply)](const String& result) {
     3976        reply->send(result);
     3977    });
    39763978}
    39773979
     
    40634065void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
    40644066{
    4065     m_uiClient->setToolbarsAreVisible(this, toolbarsAreVisible);
     4067    m_uiClient->setToolbarsAreVisible(*this, toolbarsAreVisible);
    40664068}
    40674069
     
    40754077void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
    40764078{
    4077     m_uiClient->setMenuBarIsVisible(this, menuBarIsVisible);
    4078 }
    4079 
    4080 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
    4081 {
    4082     menuBarIsVisible = m_uiClient->menuBarIsVisible(this);
     4079    m_uiClient->setMenuBarIsVisible(*this, menuBarIsVisible);
     4080}
     4081
     4082void WebPageProxy::getMenuBarIsVisible(Ref<Messages::WebPageProxy::GetMenuBarIsVisible::DelayedReply>&& reply)
     4083{
     4084    m_uiClient->menuBarIsVisible(*this, [reply = WTFMove(reply)] (bool visible) {
     4085        reply->send(visible);
     4086    });
    40834087}
    40844088
    40854089void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
    40864090{
    4087     m_uiClient->setStatusBarIsVisible(this, statusBarIsVisible);
    4088 }
    4089 
    4090 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
    4091 {
    4092     statusBarIsVisible = m_uiClient->statusBarIsVisible(this);
     4091    m_uiClient->setStatusBarIsVisible(*this, statusBarIsVisible);
     4092}
     4093
     4094void WebPageProxy::getStatusBarIsVisible(Ref<Messages::WebPageProxy::GetStatusBarIsVisible::DelayedReply>&& reply)
     4095{
     4096    m_uiClient->statusBarIsVisible(*this, [reply = WTFMove(reply)] (bool visible) {
     4097        reply->send(visible);
     4098    });
    40934099}
    40944100
    40954101void WebPageProxy::setIsResizable(bool isResizable)
    40964102{
    4097     m_uiClient->setIsResizable(this, isResizable);
    4098 }
    4099 
    4100 void WebPageProxy::getIsResizable(bool& isResizable)
    4101 {
    4102     isResizable = m_uiClient->isResizable(this);
     4103    m_uiClient->setIsResizable(*this, isResizable);
     4104}
     4105
     4106void WebPageProxy::getIsResizable(Ref<Messages::WebPageProxy::GetIsResizable::DelayedReply>&& reply)
     4107{
     4108    m_uiClient->isResizable(*this, [reply = WTFMove(reply)] (bool resizable) {
     4109        reply->send(resizable);
     4110    });
    41034111}
    41044112
    41054113void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
    41064114{
    4107     m_uiClient->setWindowFrame(this, m_pageClient.convertToDeviceSpace(newWindowFrame));
    4108 }
    4109 
    4110 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
    4111 {
    4112     newWindowFrame = m_pageClient.convertToUserSpace(m_uiClient->windowFrame(this));
     4115    m_uiClient->setWindowFrame(*this, m_pageClient.convertToDeviceSpace(newWindowFrame));
     4116}
     4117
     4118void WebPageProxy::getWindowFrame(Ref<Messages::WebPageProxy::GetWindowFrame::DelayedReply>&& reply)
     4119{
     4120    m_uiClient->windowFrame(*this, [this, protectedThis = makeRef(*this), reply = WTFMove(reply)] (FloatRect frame) {
     4121        reply->send(m_pageClient.convertToUserSpace(frame));
     4122    });
     4123}
     4124
     4125void WebPageProxy::getWindowFrameWithCallback(Function<void(FloatRect)>&& completionHandler)
     4126{
     4127    m_uiClient->windowFrame(*this, WTFMove(completionHandler));
     4128}
     4129
     4130void WebPageProxy::screenToRootView(const IntPoint& screenPoint, Ref<Messages::WebPageProxy::ScreenToRootView::DelayedReply>&& reply)
     4131{
     4132    reply->send(m_pageClient.screenToRootView(screenPoint));
    41134133}
    41144134   
    4115 void WebPageProxy::screenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
    4116 {
    4117     windowPoint = m_pageClient.screenToRootView(screenPoint);
    4118 }
    4119    
    4120 void WebPageProxy::rootViewToScreen(const IntRect& viewRect, IntRect& result)
    4121 {
    4122     result = m_pageClient.rootViewToScreen(viewRect);
     4135void WebPageProxy::rootViewToScreen(const IntRect& viewRect, Ref<Messages::WebPageProxy::RootViewToScreen::DelayedReply>&& reply)
     4136{
     4137    reply->send(m_pageClient.rootViewToScreen(viewRect));
    41234138}
    41244139   
     
    42064221    MESSAGE_CHECK(frame);
    42074222
    4208     m_uiClient->printFrame(this, frame);
     4223    m_uiClient->printFrame(*this, *frame);
    42094224
    42104225    endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
     
    59135928}
    59145929
    5915 float WebPageProxy::headerHeight(WebFrameProxy* frame)
    5916 {
    5917     if (frame->isDisplayingPDFDocument())
     5930float WebPageProxy::headerHeight(WebFrameProxy& frame)
     5931{
     5932    if (frame.isDisplayingPDFDocument())
    59185933        return 0;
    5919     return m_uiClient->headerHeight(this, frame);
    5920 }
    5921 
    5922 float WebPageProxy::footerHeight(WebFrameProxy* frame)
    5923 {
    5924     if (frame->isDisplayingPDFDocument())
     5934    return m_uiClient->headerHeight(*this, frame);
     5935}
     5936
     5937float WebPageProxy::footerHeight(WebFrameProxy& frame)
     5938{
     5939    if (frame.isDisplayingPDFDocument())
    59255940        return 0;
    5926     return m_uiClient->footerHeight(this, frame);
    5927 }
    5928 
    5929 void WebPageProxy::drawHeader(WebFrameProxy* frame, const FloatRect& rect)
    5930 {
    5931     if (frame->isDisplayingPDFDocument())
    5932         return;
    5933     m_uiClient->drawHeader(this, frame, rect);
    5934 }
    5935 
    5936 void WebPageProxy::drawFooter(WebFrameProxy* frame, const FloatRect& rect)
    5937 {
    5938     if (frame->isDisplayingPDFDocument())
    5939         return;
    5940     m_uiClient->drawFooter(this, frame, rect);
     5941    return m_uiClient->footerHeight(*this, frame);
     5942}
     5943
     5944void WebPageProxy::drawHeader(WebFrameProxy& frame, FloatRect&& rect)
     5945{
     5946    if (frame.isDisplayingPDFDocument())
     5947        return;
     5948    m_uiClient->drawHeader(*this, frame, WTFMove(rect));
     5949}
     5950
     5951void WebPageProxy::drawFooter(WebFrameProxy& frame, FloatRect&& rect)
     5952{
     5953    if (frame.isDisplayingPDFDocument())
     5954        return;
     5955    m_uiClient->drawFooter(*this, frame, WTFMove(rect));
    59415956}
    59425957
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r221866 r221887  
    809809    void forceRepaint(RefPtr<VoidCallback>&&);
    810810
    811     float headerHeight(WebFrameProxy*);
    812     float footerHeight(WebFrameProxy*);
    813     void drawHeader(WebFrameProxy*, const WebCore::FloatRect&);
    814     void drawFooter(WebFrameProxy*, const WebCore::FloatRect&);
     811    float headerHeight(WebFrameProxy&);
     812    float footerHeight(WebFrameProxy&);
     813    void drawHeader(WebFrameProxy&, WebCore::FloatRect&&);
     814    void drawFooter(WebFrameProxy&, WebCore::FloatRect&&);
    815815
    816816#if PLATFORM(COCOA)
     
    11691169    void setFocus(bool focused);
    11701170    void setWindowFrame(const WebCore::FloatRect&);
    1171     void getWindowFrame(WebCore::FloatRect&);
     1171    void getWindowFrame(Ref<Messages::WebPageProxy::GetWindowFrame::DelayedReply>&&);
     1172    void getWindowFrameWithCallback(Function<void(WebCore::FloatRect)>&&);
    11721173
    11731174    bool isResourceCachingDisabled() const { return m_isResourceCachingDisabled; }
     
    12971298    void runJavaScriptAlert(uint64_t frameID, const WebCore::SecurityOriginData&, const String&, Ref<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>&&);
    12981299    void runJavaScriptConfirm(uint64_t frameID, const WebCore::SecurityOriginData&, const String&, Ref<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply>&&);
    1299     void runJavaScriptPrompt(uint64_t frameID, const WebCore::SecurityOriginData&, const String&, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply>);
     1300    void runJavaScriptPrompt(uint64_t frameID, const WebCore::SecurityOriginData&, const String&, const String&, Ref<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply>&&);
    13001301    void setStatusText(const String&);
    13011302    void mouseDidMoveOverElement(WebHitTestResultData&&, uint32_t modifiers, UserData&&);
     
    13111312    void getToolbarsAreVisible(Ref<Messages::WebPageProxy::GetToolbarsAreVisible::DelayedReply>&&);
    13121313    void setMenuBarIsVisible(bool menuBarIsVisible);
    1313     void getMenuBarIsVisible(bool& menuBarIsVisible);
     1314    void getMenuBarIsVisible(Ref<Messages::WebPageProxy::GetMenuBarIsVisible::DelayedReply>&&);
    13141315    void setStatusBarIsVisible(bool statusBarIsVisible);
    1315     void getStatusBarIsVisible(bool& statusBarIsVisible);
     1316    void getStatusBarIsVisible(Ref<Messages::WebPageProxy::GetStatusBarIsVisible::DelayedReply>&&);
    13161317    void setIsResizable(bool isResizable);
    1317     void getIsResizable(bool& isResizable);
    1318     void screenToRootView(const WebCore::IntPoint& screenPoint, WebCore::IntPoint& windowPoint);
    1319     void rootViewToScreen(const WebCore::IntRect& viewRect, WebCore::IntRect& result);
     1318    void getIsResizable(Ref<Messages::WebPageProxy::GetIsResizable::DelayedReply>&&);
     1319    void screenToRootView(const WebCore::IntPoint& screenPoint, Ref<Messages::WebPageProxy::ScreenToRootView::DelayedReply>&&);
     1320    void rootViewToScreen(const WebCore::IntRect& viewRect, Ref<Messages::WebPageProxy::RootViewToScreen::DelayedReply>&&);
    13201321#if PLATFORM(IOS)
    13211322    void accessibilityScreenToRootView(const WebCore::IntPoint& screenPoint, WebCore::IntPoint& windowPoint);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r221866 r221887  
    5353    SetToolbarsAreVisible(bool toolbarsAreVisible)
    5454    GetToolbarsAreVisible() -> (bool toolbarsAreVisible) Delayed
    55     SetMenuBarIsVisible(bool menuBarIsVisible);
    56     GetMenuBarIsVisible() -> (bool menuBarIsVisible);
     55    SetMenuBarIsVisible(bool menuBarIsVisible)
     56    GetMenuBarIsVisible() -> (bool menuBarIsVisible) Delayed
    5757    SetStatusBarIsVisible(bool statusBarIsVisible)
    58     GetStatusBarIsVisible() -> (bool statusBarIsVisible)
     58    GetStatusBarIsVisible() -> (bool statusBarIsVisible) Delayed
    5959    SetIsResizable(bool isResizable)
    60     GetIsResizable() -> (bool isResizable)
     60    GetIsResizable() -> (bool isResizable) Delayed
    6161    SetWindowFrame(WebCore::FloatRect windowFrame)
    62     GetWindowFrame() -> (WebCore::FloatRect windowFrame)
    63     ScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint)
    64     RootViewToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame)
     62    GetWindowFrame() -> (WebCore::FloatRect windowFrame) Delayed
     63    ScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint) Delayed
     64    RootViewToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame) Delayed
    6565
    6666#if PLATFORM(COCOA)
  • trunk/Source/WebKit/UIProcess/mac/WKPrintingView.h

    r218799 r221887  
    6969}
    7070
    71 - (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView;
     71- (id)initWithFrameProxy:(WebKit::WebFrameProxy&)frame view:(NSView *)wkView;
    7272
    7373@end
  • trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm

    r218985 r221887  
    5252@implementation WKPrintingView
    5353
    54 - (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView
     54- (id)initWithFrameProxy:(WebKit::WebFrameProxy&)frame view:(NSView *)wkView
    5555{
    5656    self = [super init]; // No frame rect to pass to NSView.
     
    5858        return nil;
    5959
    60     _webFrame = frame;
     60    _webFrame = &frame;
    6161    _wkView = wkView;
    6262
     
    152152   
    153153    CGFloat scale = [info scalingFactor];
    154     [info setTopMargin:originalTopMargin + _webFrame->page()->headerHeight(_webFrame.get()) * scale];
    155     [info setBottomMargin:originalBottomMargin + _webFrame->page()->footerHeight(_webFrame.get()) * scale];
     154    [info setTopMargin:originalTopMargin + _webFrame->page()->headerHeight(*_webFrame) * scale];
     155    [info setBottomMargin:originalBottomMargin + _webFrame->page()->footerHeight(*_webFrame) * scale];
    156156}
    157157
     
    638638    CGFloat headerFooterLeft = [printInfo leftMargin] / scale;
    639639    CGFloat headerFooterWidth = (paperSize.width - ([printInfo leftMargin] + [printInfo rightMargin])) / scale;
    640     NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin] / scale - _webFrame->page()->footerHeight(_webFrame.get()), headerFooterWidth, _webFrame->page()->footerHeight(_webFrame.get()));
    641     NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin]) / scale, headerFooterWidth, _webFrame->page()->headerHeight(_webFrame.get()));
     640    NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin] / scale - _webFrame->page()->footerHeight(*_webFrame), headerFooterWidth, _webFrame->page()->footerHeight(*_webFrame));
     641    NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin]) / scale, headerFooterWidth, _webFrame->page()->headerHeight(*_webFrame));
    642642
    643643    NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
    644644    [currentContext saveGraphicsState];
    645645    NSRectClip(headerRect);
    646     _webFrame->page()->drawHeader(_webFrame.get(), headerRect);
     646    _webFrame->page()->drawHeader(*_webFrame, headerRect);
    647647    [currentContext restoreGraphicsState];
    648648
    649649    [currentContext saveGraphicsState];
    650650    NSRectClip(footerRect);
    651     _webFrame->page()->drawFooter(_webFrame.get(), footerRect);
     651    _webFrame->page()->drawFooter(*_webFrame, footerRect);
    652652    [currentContext restoreGraphicsState];
    653653}
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r221502 r221887  
    137137
    138138    // In case the UI client overrides getWindowFrame(), we call it here to make sure we send the appropriate window frame.
    139     FloatRect windowFrameInScreenCoordinates = m_uiClient->windowFrame(this);
    140     FloatRect windowFrameInUnflippedScreenCoordinates = m_pageClient.convertToUserSpace(windowFrameInScreenCoordinates);
    141 
    142     process().send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, windowFrameInUnflippedScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
     139    m_uiClient->windowFrame(*this, [this, protectedThis = makeRef(*this), viewFrameInWindowCoordinates, accessibilityViewCoordinates] (FloatRect windowFrameInScreenCoordinates) {
     140        FloatRect windowFrameInUnflippedScreenCoordinates = m_pageClient.convertToUserSpace(windowFrameInScreenCoordinates);
     141        process().send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, windowFrameInUnflippedScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
     142    });
    143143}
    144144
Note: See TracChangeset for help on using the changeset viewer.