Title: [159198] trunk/Source/WebCore
Revision
159198
Author
[email protected]
Date
2013-11-13 08:23:14 -0800 (Wed, 13 Nov 2013)

Log Message

Restrict UserGestureIndicator to main thread
https://bugs.webkit.org/show_bug.cgi?id=124277

Reviewed by Andreas Kling.

Certain classes that interact with UserGestureIndicators, e.g.
the DOMTimer, can also live on worker threads. Since a
background thread cannot possible get a user gesture in the
first place, and to avoid races, we turn a UserGestureIndicator
on a background thread into a no-op.

* dom/UserGestureIndicator.cpp:
(WebCore::UserGestureIndicator::UserGestureIndicator):
(WebCore::UserGestureIndicator::~UserGestureIndicator):
(WebCore::UserGestureIndicator::processingUserGesture):
* dom/UserGestureIndicator.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159197 => 159198)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 16:19:55 UTC (rev 159197)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 16:23:14 UTC (rev 159198)
@@ -1,3 +1,22 @@
+2013-11-13  Jochen Eisinger  <[email protected]>
+
+        Restrict UserGestureIndicator to main thread
+        https://bugs.webkit.org/show_bug.cgi?id=124277
+
+        Reviewed by Andreas Kling.
+
+        Certain classes that interact with UserGestureIndicators, e.g.
+        the DOMTimer, can also live on worker threads. Since a
+        background thread cannot possible get a user gesture in the
+        first place, and to avoid races, we turn a UserGestureIndicator
+        on a background thread into a no-op.
+
+        * dom/UserGestureIndicator.cpp:
+        (WebCore::UserGestureIndicator::UserGestureIndicator):
+        (WebCore::UserGestureIndicator::~UserGestureIndicator):
+        (WebCore::UserGestureIndicator::processingUserGesture):
+        * dom/UserGestureIndicator.h:
+
 2013-11-13  Antti Koivisto  <[email protected]>
 
         Factor simple line creation loop to function

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.cpp (159197 => 159198)


--- trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-11-13 16:19:55 UTC (rev 159197)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-11-13 16:23:14 UTC (rev 159198)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "UserGestureIndicator.h"
 
+#include <wtf/MainThread.h>
+
 namespace WebCore {
 
 static bool isDefinite(ProcessingUserGestureState state)
@@ -38,6 +40,9 @@
 UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
     : m_previousState(s_state)
 {
+    // Silently ignore UserGestureIndicators on non main threads.
+    if (!isMainThread())
+        return;
     // We overwrite s_state only if the caller is definite about the gesture state.
     if (isDefinite(state))
         s_state = state;
@@ -46,8 +51,15 @@
 
 UserGestureIndicator::~UserGestureIndicator()
 {
+    if (!isMainThread())
+        return;
     s_state = m_previousState;
     ASSERT(isDefinite(s_state));
 }
 
+bool UserGestureIndicator::processingUserGesture()
+{
+    return isMainThread() ? s_state == DefinitelyProcessingUserGesture : false;
 }
+
+}

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (159197 => 159198)


--- trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-11-13 16:19:55 UTC (rev 159197)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-11-13 16:23:14 UTC (rev 159198)
@@ -39,7 +39,7 @@
 class UserGestureIndicator {
     WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
 public:
-    static bool processingUserGesture() { return s_state == DefinitelyProcessingUserGesture; }
+    static bool processingUserGesture();
 
     explicit UserGestureIndicator(ProcessingUserGestureState);
     ~UserGestureIndicator();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to