Title: [91939] trunk/Source/WebKit2
Revision
91939
Author
[email protected]
Date
2011-07-28 10:38:03 -0700 (Thu, 28 Jul 2011)

Log Message

REGRESSION (Safari 5.1): _javascript_ dialogs not usable with VoiceOver
https://bugs.webkit.org/show_bug.cgi?id=65214

Reviewed by Anders Carlsson.

Allow the ability to spin the run loop while WebProcess is waiting for a synchronous reply.
This allows it to continue to serve accessibility requests while waiting and basically
restores the behavior WK1 was presenting. This patch only enables this mode when accessibility is on.

* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::sendSyncMessage):
(CoreIPC::Connection::waitForSyncReply):
* Platform/CoreIPC/Connection.h:
(CoreIPC::Connection::sendSync):
* Platform/RunLoop.h:
* Platform/mac/RunLoopMac.mm:
(RunLoop::runForDuration):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::runJavaScriptAlert):
(WebKit::WebChromeClient::runJavaScriptConfirm):
(WebKit::WebChromeClient::runJavaScriptPrompt):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (91938 => 91939)


--- trunk/Source/WebKit2/ChangeLog	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-28 17:38:03 UTC (rev 91939)
@@ -1,3 +1,27 @@
+2011-07-26  Chris Fleizach  <[email protected]>
+
+        REGRESSION (Safari 5.1): _javascript_ dialogs not usable with VoiceOver
+        https://bugs.webkit.org/show_bug.cgi?id=65214
+
+        Reviewed by Anders Carlsson.
+
+        Allow the ability to spin the run loop while WebProcess is waiting for a synchronous reply.
+        This allows it to continue to serve accessibility requests while waiting and basically
+        restores the behavior WK1 was presenting. This patch only enables this mode when accessibility is on.
+
+        * Platform/CoreIPC/Connection.cpp:
+        (CoreIPC::Connection::sendSyncMessage):
+        (CoreIPC::Connection::waitForSyncReply):
+        * Platform/CoreIPC/Connection.h:
+        (CoreIPC::Connection::sendSync):
+        * Platform/RunLoop.h:
+        * Platform/mac/RunLoopMac.mm:
+        (RunLoop::runForDuration):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runJavaScriptAlert):
+        (WebKit::WebChromeClient::runJavaScriptConfirm):
+        (WebKit::WebChromeClient::runJavaScriptPrompt):
+
 2011-07-28  Ravi Phaneendra Kasibhatla  <[email protected]>
 
         Pass the key_press_event or key_release_event to parent widget when it is not handled by Web Process.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp (91938 => 91939)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2011-07-28 17:38:03 UTC (rev 91939)
@@ -384,7 +384,7 @@
     return nullptr;
 }
 
-PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uint64_t syncRequestID, PassOwnPtr<ArgumentEncoder> encoder, double timeout)
+PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uint64_t syncRequestID, PassOwnPtr<ArgumentEncoder> encoder, double timeout, unsigned syncSendFlags)
 {
     // We only allow sending sync messages from the client run loop.
     ASSERT(RunLoop::current() == m_clientRunLoop);
@@ -411,7 +411,7 @@
     // Then wait for a reply. Waiting for a reply could involve dispatching incoming sync messages, so
     // keep an extra reference to the connection here in case it's invalidated.
     RefPtr<Connection> protect(this);
-    OwnPtr<ArgumentDecoder> reply = waitForSyncReply(syncRequestID, timeout);
+    OwnPtr<ArgumentDecoder> reply = waitForSyncReply(syncRequestID, timeout, syncSendFlags);
 
     // Finally, pop the pending sync reply information.
     {
@@ -426,7 +426,7 @@
     return reply.release();
 }
 
-PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, double timeout)
+PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags)
 {
     if (timeout == DefaultTimeout)
         timeout = m_defaultSyncMessageTimeout;
@@ -467,8 +467,20 @@
 #if PLATFORM(WIN)
         timedOut = !m_syncMessageState->waitWhileDispatchingSentWin32Messages(absoluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply());
 #else
-        timedOut = !m_syncMessageState->wait(absoluteTime);
+
+        // This allows the WebProcess to still serve clients while waiting for the message to return. 
+        // Notably, it can continue to process accessibility requests, which are on the main thread.
+        if (syncSendFlags & SpinRunLoopWhileWaitingForReply) {
+#if PLATFORM(MAC)
+            // FIXME: Although we run forever, any events incoming will cause us to drop out and exit out. This however doesn't
+            // account for a timeout value passed in. Timeout is always NoTimeout in these cases, but that could change.
+            RunLoop::current()->runForDuration(1e10);
+            timeout = currentTime() >= absoluteTime;
 #endif
+        } else
+            timedOut = !m_syncMessageState->wait(absoluteTime);
+#endif
+        
     }
 
     // We timed out.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (91938 => 91939)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2011-07-28 17:38:03 UTC (rev 91939)
@@ -62,6 +62,11 @@
     DispatchMessageEvenWhenWaitingForSyncReply = 1 << 0,
 };
 
+enum SyncMessageSendFlags {
+    // Will allow events to continue being handled while waiting for the synch reply.
+    SpinRunLoopWhileWaitingForReply = 1 << 0,
+};
+    
 #define MESSAGE_CHECK_BASE(assertion, connection) do \
     if (!(assertion)) { \
         ASSERT(assertion); \
@@ -148,7 +153,7 @@
     static const int NoTimeout = -1;
 
     template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0);
-    template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = DefaultTimeout);
+    template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = DefaultTimeout, unsigned syncSendFlags = 0);
     template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout);
 
     PassOwnPtr<ArgumentEncoder> createSyncMessageArgumentEncoder(uint64_t destinationID, uint64_t& syncRequestID);
@@ -209,8 +214,8 @@
     
     PassOwnPtr<ArgumentDecoder> waitForMessage(MessageID, uint64_t destinationID, double timeout);
     
-    PassOwnPtr<ArgumentDecoder> sendSyncMessage(MessageID, uint64_t syncRequestID, PassOwnPtr<ArgumentEncoder>, double timeout);
-    PassOwnPtr<ArgumentDecoder> waitForSyncReply(uint64_t syncRequestID, double timeout);
+    PassOwnPtr<ArgumentDecoder> sendSyncMessage(MessageID, uint64_t syncRequestID, PassOwnPtr<ArgumentEncoder>, double timeout, unsigned syncSendFlags = 0);
+    PassOwnPtr<ArgumentDecoder> waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags);
 
     // Called on the connection work queue.
     void processIncomingMessage(MessageID, PassOwnPtr<ArgumentDecoder>);
@@ -360,7 +365,7 @@
     return sendMessage(MessageID(T::messageID), argumentEncoder.release(), messageSendFlags);
 }
 
-template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout)
+template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
 {
     uint64_t syncRequestID = 0;
     OwnPtr<ArgumentEncoder> argumentEncoder = createSyncMessageArgumentEncoder(destinationID, syncRequestID);
@@ -369,7 +374,7 @@
     argumentEncoder->encode(message);
 
     // Now send the message and wait for a reply.
-    OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID), syncRequestID, argumentEncoder.release(), timeout);
+    OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID), syncRequestID, argumentEncoder.release(), timeout, syncSendFlags);
     if (!replyDecoder)
         return false;
 

Modified: trunk/Source/WebKit2/Platform/RunLoop.h (91938 => 91939)


--- trunk/Source/WebKit2/Platform/RunLoop.h	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/Platform/RunLoop.h	2011-07-28 17:38:03 UTC (rev 91939)
@@ -68,6 +68,10 @@
     static void run();
     void stop();
 
+#if PLATFORM(MAC)
+    void runForDuration(double duration);
+#endif
+    
     class TimerBase {
         friend class RunLoop;
     public:

Modified: trunk/Source/WebKit2/Platform/mac/RunLoopMac.mm (91938 => 91939)


--- trunk/Source/WebKit2/Platform/mac/RunLoopMac.mm	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/Platform/mac/RunLoopMac.mm	2011-07-28 17:38:03 UTC (rev 91939)
@@ -67,6 +67,11 @@
     }        
 }
 
+void RunLoop::runForDuration(double duration)
+{
+    CFRunLoopRunInMode(kCFRunLoopDefaultMode, duration, true);
+}
+
 void RunLoop::stop()
 {
     ASSERT(m_runLoop == CFRunLoopGetCurrent());

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (91938 => 91939)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-07-28 17:32:40 UTC (rev 91938)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-07-28 17:38:03 UTC (rev 91939)
@@ -44,6 +44,7 @@
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
 #include "WebSearchPopupMenu.h"
+#include <WebCore/AXObjectCache.h>
 #include <WebCore/DatabaseTracker.h>
 #include <WebCore/FileChooser.h>
 #include <WebCore/FileIconLoader.h>
@@ -312,7 +313,8 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame);
 
-    WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID());
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags);
 }
 
 bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
@@ -322,8 +324,9 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
 
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
     bool result = false;
-    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID()))
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
         return false;
 
     return result;
@@ -336,7 +339,8 @@
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
 
-    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID()))
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
         return false;
 
     return !result.isNull();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to