Changeset 221922 in webkit


Ignore:
Timestamp:
Sep 12, 2017, 9:37:04 AM (7 years ago)
Author:
achristensen@apple.com
Message:

Add WKUIDelegatePrivate equivalent of WKPageUIClient's runModal
https://bugs.webkit.org/show_bug.cgi?id=176728
<rdar://problem/29270035>
Source/WebKit:


Covered by a new API test.

Reviewed by Tim Horton.

  • UIProcess/API/APIUIClient.h:

(API::UIClient::runModal):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient):

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::canRunModal const):
(WebKit::UIDelegate::UIClient::runModal):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::runModal):

Tools:

Reviewed by Tim Horton.

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:

(-[ModalDelegate _webViewRunModal:]):
(-[ModalDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(TEST):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r221920 r221922  
     12017-09-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's runModal
     4        https://bugs.webkit.org/show_bug.cgi?id=176728
     5        <rdar://problem/29270035>
     6       
     7        Covered by a new API test.
     8
     9        Reviewed by Tim Horton.
     10
     11        * UIProcess/API/APIUIClient.h:
     12        (API::UIClient::runModal):
     13        * UIProcess/API/C/WKPage.cpp:
     14        (WKPageSetPageUIClient):
     15        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     16        * UIProcess/Cocoa/UIDelegate.h:
     17        * UIProcess/Cocoa/UIDelegate.mm:
     18        (WebKit::UIDelegate::setDelegate):
     19        (WebKit::UIDelegate::UIClient::canRunModal const):
     20        (WebKit::UIDelegate::UIClient::runModal):
     21        * UIProcess/WebPageProxy.cpp:
     22        (WebKit::WebPageProxy::runModal):
     23
    1242017-09-12  Alex Christensen  <achristensen@webkit.org>
    225
  • trunk/Source/WebKit/UIProcess/API/APIUIClient.h

    r221899 r221922  
    138138
    139139    virtual bool canRunModal() const { return false; }
    140     virtual void runModal(WebKit::WebPageProxy*) { }
     140    virtual void runModal(WebKit::WebPageProxy&) { }
    141141
    142142    virtual void saveDataToFileInDownloadsFolder(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, const WebCore::URL&, Data&) { }
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r221899 r221922  
    20342034        }
    20352035
    2036         void runModal(WebPageProxy* page) final
     2036        void runModal(WebPageProxy& page) final
    20372037        {
    20382038            if (!m_client.runModal)
    20392039                return;
    20402040
    2041             m_client.runModal(toAPI(page), m_client.base.clientInfo);
     2041            m_client.runModal(toAPI(&page), m_client.base.clientInfo);
    20422042        }
    20432043
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r221920 r221922  
    155155- (void)_unfocusWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    156156- (void)_webViewDidScroll:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     157- (void)_webViewRunModal:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    157158- (void)_webView:(WKWebView *)webView takeFocus:(_WKFocusDirection)direction WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    158159- (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macosx(WK_MAC_TBA));
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp

    r221899 r221922  
    211211    bool canRunModal() const final { return true; }
    212212
    213     void runModal(WebPageProxy*) final
     213    void runModal(WebPageProxy&) final
    214214    {
    215215        webkitWebViewRunAsModal(m_webView);
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r221920 r221922  
    9999        void focus(WebPageProxy*) final;
    100100        void unfocus(WebPageProxy*) final;
     101        bool canRunModal() const final;
     102        void runModal(WebPageProxy&) final;
    101103        void pageDidScroll(WebPageProxy*) final;
    102104        void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final;
     
    153155        bool focusWebView : 1;
    154156        bool unfocusWebView : 1;
     157        bool webViewRunModal : 1;
    155158        bool webViewTakeFocus : 1;
    156159        bool webViewDidScroll : 1;
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r221920 r221922  
    111111    m_delegateMethods.unfocusWebView = [delegate respondsToSelector:@selector(_unfocusWebView:)];
    112112    m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)];
     113    m_delegateMethods.webViewRunModal = [delegate respondsToSelector:@selector(_webViewRunModal:)];
    113114    m_delegateMethods.webViewDidScroll = [delegate respondsToSelector:@selector(_webViewDidScroll:)];
    114115    m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getToolbarsAreVisibleWithCompletionHandler:)];
     
    401402   
    402403    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView takeFocus:toWKFocusDirection(direction)];
     404}
     405
     406bool UIDelegate::UIClient::canRunModal() const
     407{
     408    return m_uiDelegate.m_delegateMethods.webViewRunModal;
     409}
     410
     411void UIDelegate::UIClient::runModal(WebPageProxy&)
     412{
     413    if (!m_uiDelegate.m_delegateMethods.webViewRunModal)
     414        return;
     415   
     416    auto delegate = m_uiDelegate.m_delegate.get();
     417    if (!delegate)
     418        return;
     419
     420    [(id <WKUIDelegatePrivate>)delegate _webViewRunModal:m_uiDelegate.m_webView];
    403421}
    404422
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r221899 r221922  
    59605960    m_process->connection()->wakeUpRunLoop();
    59615961
    5962     m_uiClient->runModal(this);
     5962    m_uiClient->runModal(*this);
    59635963}
    59645964
  • trunk/Tools/ChangeLog

    r221921 r221922  
     12017-09-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's runModal
     4        https://bugs.webkit.org/show_bug.cgi?id=176728
     5        <rdar://problem/29270035>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     10        (-[ModalDelegate _webViewRunModal:]):
     11        (-[ModalDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
     12        (TEST):
     13
    1142017-09-12  Daniel Bates  <dabates@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r221920 r221922  
    149149}
    150150
     151@interface ModalDelegate : NSObject <WKUIDelegatePrivate>
     152@end
     153
     154@implementation ModalDelegate
     155
     156- (void)_webViewRunModal:(WKWebView *)webView
     157{
     158    EXPECT_EQ(webView, createdWebView.get());
     159    done = true;
     160}
     161
     162- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
     163{
     164    createdWebView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease];
     165    [createdWebView setUIDelegate:self];
     166    return createdWebView.get();
     167}
     168
     169@end
     170
     171TEST(WebKit, RunModal)
     172{
     173    auto delegate = adoptNS([[ModalDelegate alloc] init]);
     174    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     175    [webView setUIDelegate:delegate.get()];
     176    NSURL *url = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     177    NSString *html = [NSString stringWithFormat:@"%@%@%@", @"<script> function openModal() { window.showModalDialog('", url, @"'); } </script> <input type='button' value='Click to open modal' onclick='openModal();'>"];
     178    [webView synchronouslyLoadHTMLString:html];
     179    [webView sendClicksAtPoint:NSMakePoint(20, 600 - 20) numberOfClicks:1];
     180    TestWebKitAPI::Util::run(&done);
     181}
    151182
    152183#if PLATFORM(MAC)
Note: See TracChangeset for help on using the changeset viewer.