Title: [139843] branches/chromium/1364
- Revision
- 139843
- Author
- [email protected]
- Date
- 2013-01-16 00:23:43 -0800 (Wed, 16 Jan 2013)
Log Message
Merge 139419
> Connect UserGestureIndicator for mousedown and mouseup events
> https://bugs.webkit.org/show_bug.cgi?id=105138
>
> Reviewed by Adam Barth.
>
> Source/WebCore:
>
> Ports that consume user gestures to prevent certain types of pop-ups
> need to be able to connect mousedown and mouseup events, otherwise, a
> single mouse click will allow for opening multiple pop-ups.
>
> Note that a mousedown is not always followed by a mouseup and vice
> versa, e.g. when the mousedown results in a context menu being shown, or
> something is dragged into the page.
>
> Test: platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html
>
> * page/EventHandler.cpp:
> (WebCore::EventHandler::clear):
> (WebCore::EventHandler::handleMousePressEvent):
> (WebCore::EventHandler::handleMouseReleaseEvent):
> * page/EventHandler.h:
>
> LayoutTests:
>
> * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt: Added.
> * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html: Added.
>
[email protected]
Review URL: https://codereview.chromium.org/11975006
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt (from rev 139419, trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt) (0 => 139843)
--- branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt (rev 0)
+++ branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt 2013-01-16 08:23:43 UTC (rev 139843)
@@ -0,0 +1,4 @@
+Test that only a single popup is allowed in response to a single user action, even if the the user action triggers multiple events. The test passes if only one popup is created.
+
+Click Here
+PASSED
Copied: branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html (from rev 139419, trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html) (0 => 139843)
--- branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html (rev 0)
+++ branches/chromium/1364/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html 2013-01-16 08:23:43 UTC (rev 139843)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <p>
+ Test that only a single popup is allowed in response to a single
+ user action, even if the the user action triggers multiple events.
+ The test passes if only one popup is created.
+ </p>
+ <button id="button" _onmousedown_="popup1()" _onmouseup_="popup2()">Click Here</button>
+ <div id="console"></div>
+ <script>
+ function popup1() {
+ window.open("about:blank", "window1");
+ }
+
+ function popup2() {
+ 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 button = document.getElementById("button");
+
+ if (window.eventSender) {
+ eventSender.mouseMoveTo(button.offsetLeft + button.offsetWidth / 2, button.offsetTop + button.offsetHeight / 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+ }
+ </script>
+ </body>
+ </html>
Modified: branches/chromium/1364/Source/WebCore/page/EventHandler.cpp (139842 => 139843)
--- branches/chromium/1364/Source/WebCore/page/EventHandler.cpp 2013-01-16 08:05:55 UTC (rev 139842)
+++ branches/chromium/1364/Source/WebCore/page/EventHandler.cpp 2013-01-16 08:23:43 UTC (rev 139843)
@@ -82,7 +82,6 @@
#include "StyleCachedImage.h"
#include "TextEvent.h"
#include "TextIterator.h"
-#include "UserGestureIndicator.h"
#include "UserTypingGestureIndicator.h"
#include "WheelEvent.h"
#include "WindowsKeyboardCodes.h"
@@ -383,6 +382,7 @@
m_mousePositionIsUnknown = true;
m_lastKnownMousePosition = IntPoint();
m_lastKnownMouseGlobalPosition = IntPoint();
+ m_lastMouseDownUserGestureToken.clear();
m_mousePressNode = 0;
m_mousePressed = false;
m_capturesDragging = false;
@@ -1422,6 +1422,7 @@
#endif
UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+ m_lastMouseDownUserGestureToken = gestureIndicator.currentToken();
// FIXME (bug 68185): this call should be made at another abstraction layer
m_frame->loader()->resetMultipleFormSubmissionProtection();
@@ -1766,8 +1767,13 @@
return true;
#endif
- UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+ OwnPtr<UserGestureIndicator> gestureIndicator;
+ if (m_lastMouseDownUserGestureToken)
+ gestureIndicator = adoptPtr(new UserGestureIndicator(m_lastMouseDownUserGestureToken.release()));
+ else
+ gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
+
#if ENABLE(PAN_SCROLLING)
m_autoscrollController->handleMouseReleaseEvent(mouseEvent);
#endif
Modified: branches/chromium/1364/Source/WebCore/page/EventHandler.h (139842 => 139843)
--- branches/chromium/1364/Source/WebCore/page/EventHandler.h 2013-01-16 08:05:55 UTC (rev 139842)
+++ branches/chromium/1364/Source/WebCore/page/EventHandler.h 2013-01-16 08:23:43 UTC (rev 139843)
@@ -37,6 +37,7 @@
#include "TextEventInputType.h"
#include "TextGranularity.h"
#include "Timer.h"
+#include "UserGestureIndicator.h"
#include <wtf/Forward.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
@@ -445,6 +446,7 @@
IntPoint m_mouseDownPos; // In our view's coords.
double m_mouseDownTimestamp;
PlatformMouseEvent m_mouseDown;
+ RefPtr<UserGestureIndicator::Token> m_lastMouseDownUserGestureToken;
RefPtr<Node> m_latchedWheelEventNode;
bool m_widgetIsLatched;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes