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

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: Tweaks Created 4 years, 8 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 e3cfaf7cb01c70fbe6631718c17cf2e5526dab3c..5b7ed7dfc68046ac58b729f32052fe092f95fcc0 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/HTMLCanvasElement.h"
#include "core/html/HTMLDialogElement.h"
@@ -994,7 +996,7 @@ WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
RawPtr<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)
@@ -3773,15 +3775,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
@@ -3859,6 +3852,26 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
return WebInputEventResult::NotHandled;
}
+ // Whether a touch should be considered a "user gesture" or not is a tricky question.
+ // https://docs.google.com/document/d/1oF1T3O7_E4t1PYHV6gyCwHxOi3ystm0eSL5xZu7nvOg/edit#
+ // 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. So don't supply
+ // a UserGestureUtilizedCallback.
+ gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
+ } else {
+ // This is some other touch event that perhaps shouldn't be considered a user gesture. So
+ // use a UserGestureUtilizedCallback to get metrics / deprecation warnings.
+ 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.
HeapVector<TouchInfo> touchInfos(points.size());
@@ -3956,6 +3969,14 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
return eventResult;
}
+void EventHandler::userGestureUtilized()
+{
+ // This is invoked for 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;
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698