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

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2783233004: Refine tap disambiguation UMA to track same-node/different-node. (Closed)
Patch Set: Deprecate existing field Created 3 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebView.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index cd796ba53c2654ab0fea667de05b153925d3df33..d141eaf977374b7c04531293d7668bb66b2ed68e 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -856,6 +856,12 @@ WebInputEventResult WebViewImpl::handleGestureEvent(
if (goodTargets.size() >= 2 && m_client &&
m_client->didTapMultipleTargets(visualViewportOffset, boundingBox,
goodTargets)) {
+ // Stash the position of the node that would've been used absent
+ // disambiguation, for UMA purposes.
+ m_lastTapDisambiguationBestCandidatePosition =
+ targetedEvent.hitTestResult().roundedPointInMainFrame() -
+ roundedIntSize(targetedEvent.hitTestResult().localPoint());
+
enableTapHighlights(highlightNodes);
for (size_t i = 0; i < m_linkHighlights.size(); ++i)
m_linkHighlights[i]->startHighlightAnimationIfNeeded();
@@ -931,6 +937,59 @@ WebInputEventResult WebViewImpl::handleGestureEvent(
return eventResult;
}
+namespace {
+// This enum is used to back a histogram, and should therefore be treated as
+// append-only.
+enum TapDisambiguationResult {
+ UmaTapDisambiguationOther = 0,
+ UmaTapDisambiguationBackButton = 1,
+ UmaTapDisambiguationTappedOutside = 2,
+ UmaTapDisambiguationTappedInsideDeprecated = 3,
+ UmaTapDisambiguationTappedInsideSameNode = 4,
+ UmaTapDisambiguationTappedInsideDifferentNode = 5,
+ UmaTapDisambiguationCount = 6,
+};
+
+void RecordTapDisambiguation(TapDisambiguationResult result) {
+ UMA_HISTOGRAM_ENUMERATION("Touchscreen.TapDisambiguation", result,
+ UmaTapDisambiguationCount);
+}
+
+} // namespace
+
+void WebViewImpl::resolveTapDisambiguation(double timestampSeconds,
+ WebPoint tapViewportOffset,
+ bool isLongPress) {
+ WebGestureEvent event(
+ isLongPress ? WebInputEvent::GestureLongPress : WebInputEvent::GestureTap,
+ WebInputEvent::NoModifiers, timestampSeconds);
+
+ event.x = tapViewportOffset.x;
+ event.y = tapViewportOffset.y;
+ event.sourceDevice = blink::WebGestureDeviceTouchscreen;
+
+ {
+ // Compute UMA stat about whether the node selected by disambiguation UI was
+ // different from the one preferred by the regular hit-testing + adjustment
+ // logic.
+ WebGestureEvent scaledEvent =
+ TransformWebGestureEvent(mainFrameImpl()->frameView(), event);
+ GestureEventWithHitTestResults targetedEvent =
+ m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(
+ scaledEvent);
+ WebPoint nodePosition =
+ targetedEvent.hitTestResult().roundedPointInMainFrame() -
+ roundedIntSize(targetedEvent.hitTestResult().localPoint());
+ TapDisambiguationResult result =
+ (nodePosition == m_lastTapDisambiguationBestCandidatePosition)
+ ? UmaTapDisambiguationTappedInsideSameNode
+ : UmaTapDisambiguationTappedInsideDifferentNode;
+ RecordTapDisambiguation(result);
+ }
+
+ handleGestureEvent(event);
+}
+
WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(
const WebGestureEvent& pinchEvent) {
DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate);
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698