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

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

Issue 2027473002: Deprecate use of user gestures during scroll-related touch events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
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
« no previous file with comments | « third_party/WebKit/Source/core/input/TouchEventManager.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3bcb2f3323c2ee01bb0514dbd17297f6f6cf220b..72dca58039c5dca773bda630cd77d96ded751611 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"
@@ -222,6 +223,10 @@ WebInputEventResult TouchEventManager::dispatchTouchEvents(
EventHandler::toWebInputEventResult(domDispatchResult));
}
}
+
+ if (allTouchesReleased)
+ m_touchScrollStarted = false;
+
return eventResult;
}
@@ -411,10 +416,31 @@ bool TouchEventManager::reHitTestTouchPointsIfNeeded(
return true;
}
+// TODO(rbyers): Replace with AutoReset as base/WTF unification permits.
+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());
+
if (!reHitTestTouchPointsIfNeeded(event, touchInfos))
return WebInputEventResult::NotHandled;
@@ -455,12 +481,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();
+ // These are cases we'd like to migrate to not hold a user gesture.
+ if (event.type() == PlatformEvent::TouchStart
+ || event.type() == PlatformEvent::TouchMove
+ || (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)) {
+ // Collect metrics in userGestureUtilized().
+ callback = this;
}
-
if (m_touchSequenceUserGestureToken)
gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUserGestureToken.release(), callback));
else
@@ -479,6 +506,8 @@ void TouchEventManager::clear()
m_regionForTouchID.clear();
m_touchPressed = false;
m_waitingForFirstTouchMove = false;
+ m_touchScrollStarted = false;
+ m_currentEvent = PlatformEvent::NoType;
}
bool TouchEventManager::isAnyTouchActive() const
@@ -493,4 +522,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
« no previous file with comments | « third_party/WebKit/Source/core/input/TouchEventManager.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698