Title: [145481] trunk
Revision
145481
Author
[email protected]
Date
2013-03-11 22:45:19 -0700 (Mon, 11 Mar 2013)

Log Message

Don't create multiple user gesture indicators when forwarding events to sub frames
https://bugs.webkit.org/show_bug.cgi?id=111923

Reviewed by Adam Barth.

Ports that implement consumable user gestures depend on a single user
gesture indicator being created in response to a single user gesture.

Source/WebCore:

Test: platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html

* dom/UserGestureIndicator.cpp:
(WebCore::isDefinite):
(WebCore::UserGestureIndicator::UserGestureIndicator):
(WebCore::UserGestureIndicator::processingUserGesture):
* dom/UserGestureIndicator.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::keyEvent):
(WebCore::EventHandler::handleTouchEvent):

LayoutTests:

* platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes-expected.txt: Added.
* platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (145480 => 145481)


--- trunk/LayoutTests/ChangeLog	2013-03-12 05:37:50 UTC (rev 145480)
+++ trunk/LayoutTests/ChangeLog	2013-03-12 05:45:19 UTC (rev 145481)
@@ -1,3 +1,16 @@
+2013-03-11  Jochen Eisinger  <[email protected]>
+
+        Don't create multiple user gesture indicators when forwarding events to sub frames
+        https://bugs.webkit.org/show_bug.cgi?id=111923
+
+        Reviewed by Adam Barth.
+
+        Ports that implement consumable user gestures depend on a single user
+        gesture indicator being created in response to a single user gesture.
+
+        * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes-expected.txt: Added.
+        * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html: Added.
+
 2013-03-11  Pavel Feldman  <[email protected]>
 
         Not reviewed: Chromium expectations updated.

Added: trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes-expected.txt (0 => 145481)


--- trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes-expected.txt	2013-03-12 05:45:19 UTC (rev 145481)
@@ -0,0 +1,6 @@
+Test that we don't create a new user gesture indicator every time an event is passed to an iframe.
+
+To run, click on the iframe. The test passes, if only one window is opened in response to the click.
+
+
+PASSED

Added: trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html (0 => 145481)


--- trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html	2013-03-12 05:45:19 UTC (rev 145481)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html> 
+    <body>
+        <p>
+            Test that we don't create a new user gesture indicator every time
+            an event is passed to an iframe.
+        </p>
+        <p>
+            To run, click on the iframe. The test passes, if only one window
+            is opened in response to the click.
+        </p>
+        <iframe id="iframe" src=""
+        <div id="console"></div>
+        <script>
+            var iframe = document.getElementById("iframe");
+            iframe.contentDocument.body._onclick_ = function() {
+                window.open("about:blank", "window1");
+                window.open("about:blank", "window2");
+                if (window.testRunner) {
+                    if (testRunner.windowCount() == windowCount + 1)
+                        document.getElementById("console").innerText = "PASSED";
+                    else
+                        document.getElementById("console").innerText = "FAILED";
+                    testRunner.notifyDone();
+                }
+            }
+
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                testRunner.setCanOpenWindows();
+                testRunner.setPopupBlockingEnabled(true);
+                testRunner.setCloseRemainingWindowsWhenComplete(true);
+                testRunner.waitUntilDone();
+                windowCount = testRunner.windowCount();
+
+                var frame = document.getElementById("iframe");
+
+                if (window.eventSender) {
+                    eventSender.mouseMoveTo(frame.offsetLeft + frame.offsetWidth / 2, frame.offsetTop + frame.offsetHeight / 2);
+                    eventSender.mouseDown();
+                    eventSender.mouseUp();
+                }
+            }
+        </script>
+    </body>
+  </html>

Modified: trunk/Source/WebCore/ChangeLog (145480 => 145481)


--- trunk/Source/WebCore/ChangeLog	2013-03-12 05:37:50 UTC (rev 145480)
+++ trunk/Source/WebCore/ChangeLog	2013-03-12 05:45:19 UTC (rev 145481)
@@ -1,3 +1,27 @@
+2013-03-11  Jochen Eisinger  <[email protected]>
+
+        Don't create multiple user gesture indicators when forwarding events to sub frames
+        https://bugs.webkit.org/show_bug.cgi?id=111923
+
+        Reviewed by Adam Barth.
+
+        Ports that implement consumable user gestures depend on a single user
+        gesture indicator being created in response to a single user gesture.
+
+        Test: platform/chromium/fast/events/popup-allowed-from-gesture-only-once-iframes.html
+
+        * dom/UserGestureIndicator.cpp:
+        (WebCore::isDefinite):
+        (WebCore::UserGestureIndicator::UserGestureIndicator):
+        (WebCore::UserGestureIndicator::processingUserGesture):
+        * dom/UserGestureIndicator.h:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::handleMouseDoubleClickEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        (WebCore::EventHandler::keyEvent):
+        (WebCore::EventHandler::handleTouchEvent):
+
 2013-03-11  Simon Fraser  <[email protected]>
 
         Fix Windows build.

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.cpp (145480 => 145481)


--- trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-03-12 05:37:50 UTC (rev 145480)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-03-12 05:45:19 UTC (rev 145481)
@@ -59,7 +59,7 @@
 
 static bool isDefinite(ProcessingUserGestureState state)
 {
-    return state == DefinitelyProcessingNewUserGesture || state == DefinitelyNotProcessingUserGesture;
+    return state == DefinitelyProcessingNewUserGesture || state == DefinitelyProcessingUserGesture || state == DefinitelyNotProcessingUserGesture;
 }
 
 ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture;
@@ -80,6 +80,8 @@
 
     if (state == DefinitelyProcessingNewUserGesture)
         static_cast<GestureToken*>(m_token.get())->addGesture();
+    else if (state == DefinitelyProcessingUserGesture && s_topmostIndicator == this)
+        static_cast<GestureToken*>(m_token.get())->addGesture();
     ASSERT(isDefinite(s_state));
 }
 
@@ -95,7 +97,7 @@
             static_cast<GestureToken*>(m_token.get())->addGesture();
             static_cast<GestureToken*>(token.get())->consumeGesture();
         }
-        s_state = DefinitelyProcessingNewUserGesture;
+        s_state = DefinitelyProcessingUserGesture;
     }
 
     ASSERT(isDefinite(s_state));
@@ -111,7 +113,7 @@
 
 bool UserGestureIndicator::processingUserGesture()
 {
-    return s_topmostIndicator && static_cast<GestureToken*>(s_topmostIndicator->currentToken())->hasGestures() && s_state == DefinitelyProcessingNewUserGesture;
+    return s_topmostIndicator && static_cast<GestureToken*>(s_topmostIndicator->currentToken())->hasGestures() && (s_state == DefinitelyProcessingNewUserGesture || s_state == DefinitelyProcessingUserGesture);
 }
 
 bool UserGestureIndicator::consumeUserGesture()

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (145480 => 145481)


--- trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-03-12 05:37:50 UTC (rev 145480)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-03-12 05:45:19 UTC (rev 145481)
@@ -34,6 +34,7 @@
 
 enum ProcessingUserGestureState {
     DefinitelyProcessingNewUserGesture,
+    DefinitelyProcessingUserGesture,
     PossiblyProcessingUserGesture,
     DefinitelyNotProcessingUserGesture
 };

Modified: trunk/Source/WebCore/page/EventHandler.cpp (145480 => 145481)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-03-12 05:37:50 UTC (rev 145480)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-03-12 05:45:19 UTC (rev 145481)
@@ -1454,7 +1454,7 @@
         return true;
 #endif
 
-    UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
     m_lastMouseDownUserGestureToken = gestureIndicator.currentToken();
 
     // FIXME (bug 68185): this call should be made at another abstraction layer
@@ -1588,7 +1588,7 @@
 
     m_frame->selection()->setCaretBlinkingSuspended(false);
 
-    UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
 
     // We get this instead of a second mouse-up 
     m_mousePressed = false;
@@ -1831,7 +1831,7 @@
     if (m_lastMouseDownUserGestureToken)
         gestureIndicator = adoptPtr(new UserGestureIndicator(m_lastMouseDownUserGestureToken.release()));
     else
-        gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingNewUserGesture));
+        gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
 
 #if ENABLE(PAN_SCROLLING)
     m_autoscrollController->handleMouseReleaseEvent(mouseEvent);
@@ -3156,7 +3156,7 @@
     if (!node)
         return false;
 
-    UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
     UserTypingGestureIndicator typingGestureIndicator(m_frame);
 
     if (FrameView* view = m_frame->view())
@@ -3853,7 +3853,7 @@
 
     const Vector<PlatformTouchPoint>& points = event.touchPoints();
 
-    UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
 
     unsigned i;
     bool freshTouchEvents = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to