Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1799253002: Stricter user gestures for touch - measure and warn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index 570f5228c838720a7c154fe9e0aa0375ffeb7fb3..d6fc782b72f5a838edbb895664ccd3f5d72ad20d 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -50,11 +50,13 @@
#include "core/events/TouchEvent.h"
#include "core/events/WheelEvent.h"
#include "core/fetch/ImageResource.h"
+#include "core/frame/Deprecation.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/frame/UseCounter.h"
#include "core/frame/VisualViewport.h"
#include "core/html/HTMLDialogElement.h"
#include "core/html/HTMLFrameElementBase.h"
@@ -978,7 +980,7 @@ WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
- m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.currentToken();
+ m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = UserGestureIndicator::currentToken();
cancelFakeMouseMoveEvent();
if (m_eventHandlerWillResetCapturingMouseEventsNode)
@@ -3733,15 +3735,6 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
m_touchSequenceUserGestureToken.clear();
}
- OwnPtr<UserGestureIndicator> gestureIndicator;
-
- if (m_touchSequenceUserGestureToken)
- gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUserGestureToken.release()));
- else
- gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
-
- m_touchSequenceUserGestureToken = gestureIndicator->currentToken();
-
ASSERT(m_frame->view());
if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touchSequenceDocument->frame()->view())) {
// If the active touch document has no frame or view, it's probably being destroyed
@@ -3812,6 +3805,25 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
return WebInputEventResult::NotHandled;
}
+ // Whether a touch should be considered a "user gesture" or not is a tricky question.
+ // XXX - link to doc,
+ // TODO(rbyers): Disable user gesture in some cases but retain logging for now (crbug.com/582140).
+ OwnPtr<UserGestureIndicator> gestureIndicator;
+ if (event.touchPoints().size() == 1
+ && event.touchPoints()[0].state() == PlatformTouchPoint::TouchReleased
+ && !event.causesScrollingIfUncanceled()) {
+ // This is a touchend corresponding to a tap, definitely a user gesture.
+ gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
+ } else {
+ // This is some other touch event that perhaps shouldn't be considered a user gesture.
+ if (m_touchSequenceUserGestureToken)
+ gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUserGestureToken.release(), &m_touchSequenceDocument->frame()->eventHandler()));
+ else
+ gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture, &m_touchSequenceDocument->frame()->eventHandler()));
+ m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken();
+ }
+
+
// Compute and store the common info used by both PointerEvent and TouchEvent.
WillBeHeapVector<TouchInfo> touchInfos(points.size());
@@ -3905,6 +3917,14 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
return eventResult;
}
+void EventHandler::userGestureUsed()
+{
+ // This is invoked UserGestureIndicators created in handleTouchEvent which perhaps represent
+ // touch actions which shouldn't be considered a user-gesture.
+ UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed);
+ Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDragUserGestureUsedCrossOrigin);
+}
+
void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
{
m_mousePositionIsUnknown = false;

Powered by Google App Engine
This is Rietveld 408576698