Changeset 164450 in webkit


Ignore:
Timestamp:
Feb 20, 2014 3:04:31 PM (10 years ago)
Author:
andersca@apple.com
Message:

Make it possible to reply asynchronously to JavaScript panels and alerts
https://bugs.webkit.org/show_bug.cgi?id=129116

Reviewed by Dan Bernstein.

  • Scripts/webkit2/LegacyMessageReceiver-expected.cpp:

(Messages::WebPage::GetPluginProcessConnection::DelayedReply::send):
(Messages::WebPage::TestMultipleAttributes::DelayedReply::send):

  • Scripts/webkit2/MessageReceiver-expected.cpp:

(Messages::WebPage::GetPluginProcessConnection::DelayedReply::send):
(Messages::WebPage::TestMultipleAttributes::DelayedReply::send):

  • Scripts/webkit2/messages.py:

(generate_message_handler):

  • UIProcess/API/APIUIClient.h:

(API::UIClient::runJavaScriptAlert):
(API::UIClient::runJavaScriptConfirm):
(API::UIClient::runJavaScriptPrompt):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::runJavaScriptAlert):
(WebKit::WebPageProxy::runJavaScriptConfirm):
(WebKit::WebPageProxy::runJavaScriptPrompt):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r164438 r164450  
     12014-02-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Make it possible to reply asynchronously to JavaScript panels and alerts
     4        https://bugs.webkit.org/show_bug.cgi?id=129116
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * Scripts/webkit2/LegacyMessageReceiver-expected.cpp:
     9        (Messages::WebPage::GetPluginProcessConnection::DelayedReply::send):
     10        (Messages::WebPage::TestMultipleAttributes::DelayedReply::send):
     11        * Scripts/webkit2/MessageReceiver-expected.cpp:
     12        (Messages::WebPage::GetPluginProcessConnection::DelayedReply::send):
     13        (Messages::WebPage::TestMultipleAttributes::DelayedReply::send):
     14        * Scripts/webkit2/messages.py:
     15        (generate_message_handler):
     16        * UIProcess/API/APIUIClient.h:
     17        (API::UIClient::runJavaScriptAlert):
     18        (API::UIClient::runJavaScriptConfirm):
     19        (API::UIClient::runJavaScriptPrompt):
     20        * UIProcess/API/C/WKPage.cpp:
     21        (WKPageSetPageUIClient):
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::runJavaScriptAlert):
     24        (WebKit::WebPageProxy::runJavaScriptConfirm):
     25        (WebKit::WebPageProxy::runJavaScriptPrompt):
     26        * UIProcess/WebPageProxy.h:
     27        * UIProcess/WebPageProxy.messages.in:
     28
    1292014-02-20  Enrique Ocaña González  <eocanha@igalia.com>
    230
  • trunk/Source/WebKit2/Scripts/webkit2/LegacyMessageReceiver-expected.cpp

    r164171 r164450  
    7575    ASSERT(m_encoder);
    7676    *m_encoder << connectionHandle;
    77     bool result = m_connection->sendSyncReply(std::move(m_encoder));
     77    bool _result = m_connection->sendSyncReply(std::move(m_encoder));
    7878    m_connection = nullptr;
    79     return result;
     79    return _result;
    8080}
    8181
     
    9494{
    9595    ASSERT(m_encoder);
    96     bool result = m_connection->sendSyncReply(std::move(m_encoder));
     96    bool _result = m_connection->sendSyncReply(std::move(m_encoder));
    9797    m_connection = nullptr;
    98     return result;
     98    return _result;
    9999}
    100100
  • trunk/Source/WebKit2/Scripts/webkit2/MessageReceiver-expected.cpp

    r164171 r164450  
    7575    ASSERT(m_encoder);
    7676    *m_encoder << connectionHandle;
    77     bool result = m_connection->sendSyncReply(std::move(m_encoder));
     77    bool _result = m_connection->sendSyncReply(std::move(m_encoder));
    7878    m_connection = nullptr;
    79     return result;
     79    return _result;
    8080}
    8181
     
    9494{
    9595    ASSERT(m_encoder);
    96     bool result = m_connection->sendSyncReply(std::move(m_encoder));
     96    bool _result = m_connection->sendSyncReply(std::move(m_encoder));
    9797    m_connection = nullptr;
    98     return result;
     98    return _result;
    9999}
    100100
  • trunk/Source/WebKit2/Scripts/webkit2/messages.py

    r164171 r164450  
    574574            result.append('    ASSERT(m_encoder);\n')
    575575            result += ['    *m_encoder << %s;\n' % x.name for x in message.reply_parameters]
    576             result.append('    bool result = m_connection->sendSyncReply(std::move(m_encoder));\n')
     576            result.append('    bool _result = m_connection->sendSyncReply(std::move(m_encoder));\n')
    577577            result.append('    m_connection = nullptr;\n')
    578             result.append('    return result;\n')
     578            result.append('    return _result;\n')
    579579            result.append('}\n')
    580580            result.append('\n')
  • trunk/Source/WebKit2/UIProcess/API/APIUIClient.h

    r164271 r164450  
    3131#include "WebHitTestResult.h"
    3232#include <WebCore/FloatRect.h>
     33#include <functional>
    3334#include <wtf/PassRefPtr.h>
    3435
     
    6970    virtual void unfocus(WebKit::WebPageProxy*) { }
    7071
    71     virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*) { }
    72     virtual bool runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*) { return false; }
    73     virtual WTF::String runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*) { return WTF::String(); }
     72    virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void ()> completionHandler) { completionHandler(); }
     73    virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (bool)> completionHandler) { completionHandler(false); }
     74    virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (const WTF::String&)> completionHandler) { completionHandler(WTF::String()); }
    7475
    7576    virtual void setStatusText(WebKit::WebPageProxy*, const WTF::String&) { }
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r164410 r164450  
    11491149        }
    11501150
    1151         virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame) override
    1152         {
    1153             if (!m_client.runJavaScriptAlert)
    1154                 return;
     1151        virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame, std::function<void ()> completionHandler) override
     1152        {
     1153            if (!m_client.runJavaScriptAlert) {
     1154                completionHandler();
     1155                return;
     1156            }
    11551157
    11561158            m_client.runJavaScriptAlert(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
    11571159        }
    11581160
    1159         virtual bool runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame) override
    1160         {
    1161             if (!m_client.runJavaScriptConfirm)
    1162                 return false;
    1163 
    1164             return m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
    1165         }
    1166 
    1167         virtual String runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame) override
    1168         {
    1169             if (!m_client.runJavaScriptPrompt)
    1170                 return String();
    1171 
    1172             API::String* string = toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo));
    1173             if (!string)
    1174                 return String();
    1175 
    1176             String result = string->string();
    1177             string->deref();
    1178 
    1179             return result;
     1161        virtual void runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame, std::function<void (bool)> completionHandler) override
     1162        {
     1163            if (!m_client.runJavaScriptConfirm) {
     1164                completionHandler(false);
     1165                return;
     1166            }
     1167
     1168            bool result = m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
     1169            completionHandler(result);
     1170        }
     1171
     1172        virtual void runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame, std::function<void (const String&)> completionHandler) override
     1173        {
     1174            if (!m_client.runJavaScriptPrompt) {
     1175                completionHandler(String());
     1176                return;
     1177            }
     1178
     1179            RefPtr<API::String> string = adoptRef(toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo)));
     1180            if (!string) {
     1181                completionHandler(String());
     1182                return;
     1183            }
     1184
     1185            completionHandler(string->string());
    11801186        }
    11811187
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r164398 r164450  
    26432643}
    26442644
    2645 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
     2645void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
    26462646{
    26472647    WebFrameProxy* frame = m_process->webFrame(frameID);
     
    26512651    m_process->responsivenessTimer()->stop();
    26522652
    2653     m_uiClient->runJavaScriptAlert(this, message, frame);
    2654 }
    2655 
    2656 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
     2653    m_uiClient->runJavaScriptAlert(this, message, frame, [reply]{ reply->send(); });
     2654}
     2655
     2656void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
    26572657{
    26582658    WebFrameProxy* frame = m_process->webFrame(frameID);
     
    26622662    m_process->responsivenessTimer()->stop();
    26632663
    2664     result = m_uiClient->runJavaScriptConfirm(this, message, frame);
    2665 }
    2666 
    2667 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
     2664    m_uiClient->runJavaScriptConfirm(this, message, frame, [reply](bool result) { reply->send(result); });
     2665}
     2666
     2667void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
    26682668{
    26692669    WebFrameProxy* frame = m_process->webFrame(frameID);
     
    26732673    m_process->responsivenessTimer()->stop();
    26742674
    2675     result = m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame);
     2675    m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, [reply](const String& result) { reply->send(result); });
    26762676}
    26772677
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r164409 r164450  
    957957    void showPage();
    958958    void closePage(bool stopResponsivenessTimer);
    959     void runJavaScriptAlert(uint64_t frameID, const String&);
    960     void runJavaScriptConfirm(uint64_t frameID, const String&, bool& result);
    961     void runJavaScriptPrompt(uint64_t frameID, const String&, const String&, String& result);
     959    void runJavaScriptAlert(uint64_t frameID, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>);
     960    void runJavaScriptConfirm(uint64_t frameID, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply>);
     961    void runJavaScriptPrompt(uint64_t frameID, const String&, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply>);
    962962    void shouldInterruptJavaScript(bool& result);
    963963    void setStatusText(const String&);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r164382 r164450  
    2626    ShowPage()
    2727    ClosePage(bool stopResponsivenessTimer)
    28     RunJavaScriptAlert(uint64_t frameID, String message) -> ()
    29     RunJavaScriptConfirm(uint64_t frameID, String message) -> (bool result)
    30     RunJavaScriptPrompt(uint64_t frameID, String message, String defaultValue) -> (String result)
     28    RunJavaScriptAlert(uint64_t frameID, String message) -> () Delayed
     29    RunJavaScriptConfirm(uint64_t frameID, String message) -> (bool result) Delayed
     30    RunJavaScriptPrompt(uint64_t frameID, String message, String defaultValue) -> (String result) Delayed
    3131    ShouldInterruptJavaScript() -> (bool shouldInterupt)
    3232    MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
Note: See TracChangeset for help on using the changeset viewer.