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

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

Issue 1996143002: Deprecate use of user gestures during scroll-related touch events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/TouchEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/TouchEventManager.cpp b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
index 548fa615cf7a2ee0c74e9e536516c4eea546552b..82798cf17270c5125d953b3ba208d0f0729fb523 100644
--- a/third_party/WebKit/Source/core/input/TouchEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
@@ -6,6 +6,7 @@
#include "core/dom/Document.h"
#include "core/events/TouchEvent.h"
+#include "core/frame/Deprecation.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
@@ -271,6 +272,10 @@ WebInputEventResult TouchEventManager::dispatchTouchEvents(
EventHandler::toWebInputEventResult(domDispatchResult));
}
}
+
+ if (allTouchesReleased)
+ m_touchScrollStarted = false;
+
return eventResult;
}
@@ -460,10 +465,30 @@ bool TouchEventManager::reHitTestTouchPointsIfNeeded(
return true;
}
+class CurrentEventHolder {
+ // Always stack allocated to ensure lifetime doesn't exceed that of target
+ DISALLOW_NEW();
+public:
+ CurrentEventHolder(PlatformEvent::EventType& target, PlatformEvent::EventType value)
+ : m_target(target)
+ {
+ m_target = value;
+ }
+ ~CurrentEventHolder()
+ {
+ m_target = PlatformEvent::NoType;
+ }
+private:
+ PlatformEvent::EventType& m_target;
+};
+
WebInputEventResult TouchEventManager::handleTouchEvent(
const PlatformTouchEvent& event,
HeapVector<TouchInfo>& touchInfos)
{
+ // Track the current event for the scope of this function.
+ CurrentEventHolder holder(m_currentEvent, event.type());
dtapuska 2016/05/24 14:54:27 Can we not use base/auto_reset.h ? base/macros.h i
Rick Byers 2016/05/24 20:29:21 macros.h is the only include from base we currentl
+
if (!reHitTestTouchPointsIfNeeded(event, touchInfos))
return WebInputEventResult::NotHandled;
@@ -504,12 +529,13 @@ WebInputEventResult TouchEventManager::handleTouchEvent(
OwnPtr<UserGestureIndicator> gestureIndicator;
if (isTap || isSameOrigin) {
UserGestureUtilizedCallback* callback = 0;
- if (!isTap) {
- // This is some other touch event that we currently consider a user gesture. So
- // use a UserGestureUtilizedCallback to get metrics.
- callback = &m_touchSequenceDocument->frame()->eventHandler();
+ if (event.type() == PlatformEvent::TouchStart
+ || event.type() == PlatformEvent::TouchMove
+ || (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)) {
+ // These are cases we'd like to migrate to not hold a user gesture.
mustaq 2016/05/24 15:54:06 The two comment lines seem to describe separate po
Rick Byers 2016/05/24 20:29:21 Done.
+ // Collect metrics in userGestureUtilized().
+ callback = this;
}
-
if (m_touchSequenceUserGestureToken)
gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUserGestureToken.release(), callback));
else
@@ -528,6 +554,8 @@ void TouchEventManager::clear()
m_regionForTouchID.clear();
m_touchPressed = false;
m_waitingForFirstTouchMove = false;
+ m_touchScrollStarted = false;
+ m_currentEvent = PlatformEvent::NoType;
}
bool TouchEventManager::isAnyTouchActive() const
@@ -542,4 +570,28 @@ DEFINE_TRACE(TouchEventManager)
visitor->trace(m_targetForTouchID);
}
+void TouchEventManager::userGestureUtilized()
+{
+ // This is invoked for UserGestureIndicators created in TouchEventManger::handleTouchEvent which perhaps
+ // represent touch actions which shouldn't be considered a user-gesture. Trigger a UseCounter based
+ // on the touch event that's currently being dispatched.
+ UseCounter::Feature feature;
+
+ switch (m_currentEvent) {
+ case PlatformEvent::TouchStart:
+ feature = UseCounter::TouchStartUserGestureUtilized;
+ break;
+ case PlatformEvent::TouchMove:
+ feature = UseCounter::TouchMoveUserGestureUtilized;
+ break;
+ case PlatformEvent::TouchEnd:
+ feature = UseCounter::TouchEndDuringScrollUserGestureUtilized;
+ break;
+ default:
+ NOTREACHED();
+ return;
+ }
+ Deprecation::countDeprecation(m_frame, feature);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698