Diff
Modified: trunk/Source/WebKit2/ChangeLog (164449 => 164450)
--- trunk/Source/WebKit2/ChangeLog 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-20 23:04:31 UTC (rev 164450)
@@ -1,3 +1,31 @@
+2014-02-20 Anders Carlsson <[email protected]>
+
+ 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:
+
2014-02-20 Enrique Ocaña González <[email protected]>
WebKitGTK+ should stop using COMPILE_ASSERT_MATCHING_ENUM macros
Modified: trunk/Source/WebKit2/Scripts/webkit2/LegacyMessageReceiver-expected.cpp (164449 => 164450)
--- trunk/Source/WebKit2/Scripts/webkit2/LegacyMessageReceiver-expected.cpp 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/Scripts/webkit2/LegacyMessageReceiver-expected.cpp 2014-02-20 23:04:31 UTC (rev 164450)
@@ -74,9 +74,9 @@
{
ASSERT(m_encoder);
*m_encoder << connectionHandle;
- bool result = m_connection->sendSyncReply(std::move(m_encoder));
+ bool _result = m_connection->sendSyncReply(std::move(m_encoder));
m_connection = nullptr;
- return result;
+ return _result;
}
TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::MessageEncoder> encoder)
@@ -93,9 +93,9 @@
bool TestMultipleAttributes::DelayedReply::send()
{
ASSERT(m_encoder);
- bool result = m_connection->sendSyncReply(std::move(m_encoder));
+ bool _result = m_connection->sendSyncReply(std::move(m_encoder));
m_connection = nullptr;
- return result;
+ return _result;
}
} // namespace WebPage
Modified: trunk/Source/WebKit2/Scripts/webkit2/MessageReceiver-expected.cpp (164449 => 164450)
--- trunk/Source/WebKit2/Scripts/webkit2/MessageReceiver-expected.cpp 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/Scripts/webkit2/MessageReceiver-expected.cpp 2014-02-20 23:04:31 UTC (rev 164450)
@@ -74,9 +74,9 @@
{
ASSERT(m_encoder);
*m_encoder << connectionHandle;
- bool result = m_connection->sendSyncReply(std::move(m_encoder));
+ bool _result = m_connection->sendSyncReply(std::move(m_encoder));
m_connection = nullptr;
- return result;
+ return _result;
}
TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<IPC::Connection> connection, std::unique_ptr<IPC::MessageEncoder> encoder)
@@ -93,9 +93,9 @@
bool TestMultipleAttributes::DelayedReply::send()
{
ASSERT(m_encoder);
- bool result = m_connection->sendSyncReply(std::move(m_encoder));
+ bool _result = m_connection->sendSyncReply(std::move(m_encoder));
m_connection = nullptr;
- return result;
+ return _result;
}
} // namespace WebPage
Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (164449 => 164450)
--- trunk/Source/WebKit2/Scripts/webkit2/messages.py 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py 2014-02-20 23:04:31 UTC (rev 164450)
@@ -573,9 +573,9 @@
result.append('{\n')
result.append(' ASSERT(m_encoder);\n')
result += [' *m_encoder << %s;\n' % x.name for x in message.reply_parameters]
- result.append(' bool result = m_connection->sendSyncReply(std::move(m_encoder));\n')
+ result.append(' bool _result = m_connection->sendSyncReply(std::move(m_encoder));\n')
result.append(' m_connection = nullptr;\n')
- result.append(' return result;\n')
+ result.append(' return _result;\n')
result.append('}\n')
result.append('\n')
Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (164449 => 164450)
--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2014-02-20 23:04:31 UTC (rev 164450)
@@ -30,6 +30,7 @@
#include "WebEvent.h"
#include "WebHitTestResult.h"
#include <WebCore/FloatRect.h>
+#include <functional>
#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -68,9 +69,9 @@
virtual void focus(WebKit::WebPageProxy*) { }
virtual void unfocus(WebKit::WebPageProxy*) { }
- virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*) { }
- virtual bool runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*) { return false; }
- virtual WTF::String runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*) { return WTF::String(); }
+ virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void ()> completionHandler) { completionHandler(); }
+ virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (bool)> completionHandler) { completionHandler(false); }
+ virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (const WTF::String&)> completionHandler) { completionHandler(WTF::String()); }
virtual void setStatusText(WebKit::WebPageProxy*, const WTF::String&) { }
virtual void mouseDidMoveOverElement(WebKit::WebPageProxy*, const WebKit::WebHitTestResult::Data&, WebKit::WebEvent::Modifiers, API::Object*) { }
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (164449 => 164450)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2014-02-20 23:04:31 UTC (rev 164450)
@@ -1148,35 +1148,41 @@
m_client.unfocus(toAPI(page), m_client.base.clientInfo);
}
- virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame) override
+ virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame, std::function<void ()> completionHandler) override
{
- if (!m_client.runJavaScriptAlert)
+ if (!m_client.runJavaScriptAlert) {
+ completionHandler();
return;
+ }
m_client.runJavaScriptAlert(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
}
- virtual bool runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame) override
+ virtual void runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame, std::function<void (bool)> completionHandler) override
{
- if (!m_client.runJavaScriptConfirm)
- return false;
+ if (!m_client.runJavaScriptConfirm) {
+ completionHandler(false);
+ return;
+ }
- return m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+ bool result = m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+ completionHandler(result);
}
- virtual String runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame) override
+ virtual void runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame, std::function<void (const String&)> completionHandler) override
{
- if (!m_client.runJavaScriptPrompt)
- return String();
+ if (!m_client.runJavaScriptPrompt) {
+ completionHandler(String());
+ return;
+ }
- API::String* string = toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo));
- if (!string)
- return String();
+ RefPtr<API::String> string = adoptRef(toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo)));
+ if (!string) {
+ completionHandler(String());
+ return;
+ }
- String result = string->string();
- string->deref();
-
- return result;
+ completionHandler(string->string());
}
virtual void setStatusText(WebPageProxy* page, const String& text) override
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (164449 => 164450)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-20 23:04:31 UTC (rev 164450)
@@ -2642,7 +2642,7 @@
m_uiClient->close(this);
}
-void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
+void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
{
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);
@@ -2650,10 +2650,10 @@
// Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
m_process->responsivenessTimer()->stop();
- m_uiClient->runJavaScriptAlert(this, message, frame);
+ m_uiClient->runJavaScriptAlert(this, message, frame, [reply]{ reply->send(); });
}
-void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
+void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
{
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);
@@ -2661,10 +2661,10 @@
// Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
m_process->responsivenessTimer()->stop();
- result = m_uiClient->runJavaScriptConfirm(this, message, frame);
+ m_uiClient->runJavaScriptConfirm(this, message, frame, [reply](bool result) { reply->send(result); });
}
-void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
+void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
{
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);
@@ -2672,7 +2672,7 @@
// Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
m_process->responsivenessTimer()->stop();
- result = m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame);
+ m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, [reply](const String& result) { reply->send(result); });
}
void WebPageProxy::shouldInterruptJavaScript(bool& result)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (164449 => 164450)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-20 23:04:31 UTC (rev 164450)
@@ -956,9 +956,9 @@
void createNewPage(const WebCore::ResourceRequest&, const WebCore::WindowFeatures&, uint32_t modifiers, int32_t mouseButton, uint64_t& newPageID, WebPageCreationParameters&);
void showPage();
void closePage(bool stopResponsivenessTimer);
- void runJavaScriptAlert(uint64_t frameID, const String&);
- void runJavaScriptConfirm(uint64_t frameID, const String&, bool& result);
- void runJavaScriptPrompt(uint64_t frameID, const String&, const String&, String& result);
+ void runJavaScriptAlert(uint64_t frameID, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>);
+ void runJavaScriptConfirm(uint64_t frameID, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply>);
+ void runJavaScriptPrompt(uint64_t frameID, const String&, const String&, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply>);
void shouldInterruptJavaScript(bool& result);
void setStatusText(const String&);
void mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t modifiers, IPC::MessageDecoder&);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (164449 => 164450)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2014-02-20 23:04:20 UTC (rev 164449)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2014-02-20 23:04:31 UTC (rev 164450)
@@ -25,9 +25,9 @@
CreateNewPage(WebCore::ResourceRequest request, WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters)
ShowPage()
ClosePage(bool stopResponsivenessTimer)
- RunJavaScriptAlert(uint64_t frameID, String message) -> ()
- RunJavaScriptConfirm(uint64_t frameID, String message) -> (bool result)
- RunJavaScriptPrompt(uint64_t frameID, String message, String defaultValue) -> (String result)
+ RunJavaScriptAlert(uint64_t frameID, String message) -> () Delayed
+ RunJavaScriptConfirm(uint64_t frameID, String message) -> (bool result) Delayed
+ RunJavaScriptPrompt(uint64_t frameID, String message, String defaultValue) -> (String result) Delayed
ShouldInterruptJavaScript() -> (bool shouldInterupt)
MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
#if ENABLE(NETSCAPE_PLUGIN_API)