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

Side by Side Diff: third_party/WebKit/Source/core/input/TouchEventManager.cpp

Issue 2007733003: Add UMA metric for tracking root level listeners for blocking touch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/TouchEventManager.h" 5 #include "core/input/TouchEventManager.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/events/TouchEvent.h" 8 #include "core/events/TouchEvent.h"
9 #include "core/frame/EventHandlerRegistry.h" 9 #include "core/frame/EventHandlerRegistry.h"
10 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 case PlatformTouchPoint::TouchMoved: 43 case PlatformTouchPoint::TouchMoved:
44 return EventTypeNames::touchmove; 44 return EventTypeNames::touchmove;
45 case PlatformTouchPoint::TouchStationary: 45 case PlatformTouchPoint::TouchStationary:
46 // Fall through to default 46 // Fall through to default
47 default: 47 default:
48 ASSERT_NOT_REACHED(); 48 ASSERT_NOT_REACHED();
49 return emptyAtom; 49 return emptyAtom;
50 } 50 }
51 } 51 }
52 52
53 // These offsets change indicies into the ListenerHistogram
54 // enumeration. The addition of a series of offsets then
55 // produces the resulting ListenerHistogram value.
56 const size_t kTouchTargetHistogramRootScrollerOffset = 4;
57 const size_t kTouchTargetHistogramScrollableDocumentOffset = 2;
58 const size_t kTouchTargetHistogramHandledOffset = 1;
59
60 enum TouchTargetAndDispatchResultType {
61 NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled.
62 NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable do cument, handled application.
63 NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollabl e document, not handled.
64 NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable d ocument, handled application.
65 RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable docume nt, not handled.
66 RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled.
67 RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable docum ent, not handled.
68 RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document , handled.
69 TouchTargetAndDispatchResultTypeMax,
70 };
71
72 TouchTargetAndDispatchResultType toTouchTargetHistogramValue(EventTarget* eventT arget, DispatchEventResult dispatchResult)
73 {
74 int result = 0;
75 Document* document = nullptr;
76
77 if (const LocalDOMWindow* domWindow = eventTarget->toLocalDOMWindow()) {
78 // Treat the window as a root scroller as well.
79 document = domWindow->document();
80 result += kTouchTargetHistogramRootScrollerOffset;
81 } else if (Node* node = eventTarget->toNode()) {
82 // Report if the target node is the document or body.
83 if (node->isDocumentNode() || static_cast<Node*>(node->document().docume ntElement()) == node || static_cast<Node*>(node->document().body()) == node) {
84 result += kTouchTargetHistogramRootScrollerOffset;
85 }
86 document = &node->document();
87 }
88
89 if (document) {
90 FrameView* view = document->view();
91 if (view && view->isScrollable())
92 result += kTouchTargetHistogramScrollableDocumentOffset;
93 }
94
95 if (dispatchResult != DispatchEventResult::NotCanceled)
96 result += kTouchTargetHistogramHandledOffset;
97 return static_cast<TouchTargetAndDispatchResultType>(result);
98 }
99
100 enum TouchEventDispatchResultType { 53 enum TouchEventDispatchResultType {
101 UnhandledTouches, // Unhandled touch events. 54 UnhandledTouches, // Unhandled touch events.
102 HandledTouches, // Handled touch events. 55 HandledTouches, // Handled touch events.
103 TouchEventDispatchResultTypeMax, 56 TouchEventDispatchResultTypeMax,
104 }; 57 };
105 58
106 // Defining this class type local to dispatchTouchEvents() and annotating 59 // Defining this class type local to dispatchTouchEvents() and annotating
107 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning 60 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning
108 // that the local class doesn't provide a local definition for 'operator new'. 61 // that the local class doesn't provide a local definition for 'operator new'.
109 // Which it intentionally doesn't and shouldn't. 62 // Which it intentionally doesn't and shouldn't.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { 176 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) {
224 if (!changedTouches[state].m_touches) 177 if (!changedTouches[state].m_touches)
225 continue; 178 continue;
226 179
227 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); 180 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state)));
228 for (const auto& eventTarget : changedTouches[state].m_targets) { 181 for (const auto& eventTarget : changedTouches[state].m_targets) {
229 EventTarget* touchEventTarget = eventTarget; 182 EventTarget* touchEventTarget = eventTarget;
230 TouchEvent* touchEvent = TouchEvent::create( 183 TouchEvent* touchEvent = TouchEvent::create(
231 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), 184 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(),
232 eventName, touchEventTarget->toNode()->document().domWindow(), 185 eventName, touchEventTarget->toNode()->document().domWindow(),
233 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); 186 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), touchStartOrFirstTouchMove, event.timestamp());
234 187
235 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); 188 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent);
236 189
237 // Only report for top level documents with a single touch on 190 // Only report for top level documents with a single touch on
238 // touch-start or the first touch-move. 191 // touch-start or the first touch-move.
239 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) { 192 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) {
240 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax));
241 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult));
242 193
243 // Record the disposition and latency of touch starts and first touch moves before and after the page is fully loaded respectively. 194 // Record the disposition and latency of touch starts and first touch moves before and after the page is fully loaded respectively.
244 int64_t latencyInMicros = static_cast<int64_t>((currentTime() - event.timestamp()) * 1000000.0); 195 int64_t latencyInMicros = static_cast<int64_t>((currentTime() - event.timestamp()) * 1000000.0);
245 if (m_frame->document()->isLoadCompleted()) { 196 if (m_frame->document()->isLoadCompleted()) {
246 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); 197 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax));
247 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); 198 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches);
248 199
249 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyAfterP ageLoadHistogram, ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50)); 200 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyAfterP ageLoadHistogram, ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50));
250 eventLatencyAfterPageLoadHistogram.count(latencyInMicros); 201 eventLatencyAfterPageLoadHistogram.count(latencyInMicros);
251 } else { 202 } else {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 487 }
537 488
538 DEFINE_TRACE(TouchEventManager) 489 DEFINE_TRACE(TouchEventManager)
539 { 490 {
540 visitor->trace(m_frame); 491 visitor->trace(m_frame);
541 visitor->trace(m_touchSequenceDocument); 492 visitor->trace(m_touchSequenceDocument);
542 visitor->trace(m_targetForTouchID); 493 visitor->trace(m_targetForTouchID);
543 } 494 }
544 495
545 } // namespace blink 496 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698