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

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

Issue 1864523004: Add UMA metric for tracking root level listeners for blocking touch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra classification 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "core/page/DragState.h" 80 #include "core/page/DragState.h"
81 #include "core/page/FocusController.h" 81 #include "core/page/FocusController.h"
82 #include "core/page/FrameTree.h" 82 #include "core/page/FrameTree.h"
83 #include "core/page/Page.h" 83 #include "core/page/Page.h"
84 #include "core/page/SpatialNavigation.h" 84 #include "core/page/SpatialNavigation.h"
85 #include "core/page/TouchAdjustment.h" 85 #include "core/page/TouchAdjustment.h"
86 #include "core/page/scrolling/ScrollState.h" 86 #include "core/page/scrolling/ScrollState.h"
87 #include "core/paint/PaintLayer.h" 87 #include "core/paint/PaintLayer.h"
88 #include "core/style/ComputedStyle.h" 88 #include "core/style/ComputedStyle.h"
89 #include "core/svg/SVGDocumentExtensions.h" 89 #include "core/svg/SVGDocumentExtensions.h"
90 #include "platform/Histogram.h"
90 #include "platform/PlatformGestureEvent.h" 91 #include "platform/PlatformGestureEvent.h"
91 #include "platform/PlatformKeyboardEvent.h" 92 #include "platform/PlatformKeyboardEvent.h"
92 #include "platform/PlatformTouchEvent.h" 93 #include "platform/PlatformTouchEvent.h"
93 #include "platform/PlatformWheelEvent.h" 94 #include "platform/PlatformWheelEvent.h"
94 #include "platform/RuntimeEnabledFeatures.h" 95 #include "platform/RuntimeEnabledFeatures.h"
95 #include "platform/TraceEvent.h" 96 #include "platform/TraceEvent.h"
96 #include "platform/WindowsKeyboardCodes.h" 97 #include "platform/WindowsKeyboardCodes.h"
97 #include "platform/geometry/FloatPoint.h" 98 #include "platform/geometry/FloatPoint.h"
98 #include "platform/graphics/Image.h" 99 #include "platform/graphics/Image.h"
99 #include "platform/heap/Handle.h" 100 #include "platform/heap/Handle.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 202 }
202 // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/4 10974. 203 // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/4 10974.
203 // We need to ensure that the scrollingElement is always part of 204 // We need to ensure that the scrollingElement is always part of
204 // the scroll chain. In quirks mode, when the scrollingElement is 205 // the scroll chain. In quirks mode, when the scrollingElement is
205 // the body, some elements may use the documentElement as their 206 // the body, some elements may use the documentElement as their
206 // containingBlock, so we ensure the scrollingElement is added 207 // containingBlock, so we ensure the scrollingElement is added
207 // here. 208 // here.
208 scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElem ent())); 209 scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElem ent()));
209 } 210 }
210 211
212 // These offsets change indicies into the ListenerHistogram
213 // enumeration. The addition of a series of offsets then
214 // produces the resulting ListenerHistogram value.
215 const size_t kTouchTargetHistogramRootScrollerOffset = 4;
216 const size_t kTouchTargetHistogramScrollableDocumentOffset = 2;
217 const size_t kTouchTargetHistogramHandledOffset = 1;
218
219 enum TouchTargetAndDispatchResultType {
220 NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled.
221 NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable do cument, handled application.
222 NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollabl e document, not handled.
223 NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable d ocument, handled application.
224 RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable docume nt, not handled.
225 RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled.
226 RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable docum ent, not handled.
227 RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document , handled.
228 TouchTargetAndDispatchResultTypeMax,
229 };
230
231 TouchTargetAndDispatchResultType toTouchTargetHistogramValue(EventTarget* eventT arget, DispatchEventResult dispatchResult)
232 {
233 int result = 0;
234 Document* document = nullptr;
235
236 if (const LocalDOMWindow* domWindow = eventTarget->toLocalDOMWindow()) {
237 // Treat the window as a root scroller as well.
238 document = domWindow->document();
239 result += kTouchTargetHistogramRootScrollerOffset;
240 } else if (Node* node = eventTarget->toNode()) {
241 // Report if the target node is the document or body.
242 if (node->isDocumentNode() || static_cast<Node*>(node->document().docume ntElement()) == node || static_cast<Node*>(node->document().body()) == node) {
243 result += kTouchTargetHistogramRootScrollerOffset;
244 }
245 document = &node->document();
246 }
247
248 if (document) {
249 FrameView* view = document->view();
250 if (view && view->isScrollable())
251 result += kTouchTargetHistogramScrollableDocumentOffset;
252 }
253
254 if (dispatchResult != DispatchEventResult::NotCanceled)
255 result += kTouchTargetHistogramHandledOffset;
256 return static_cast<TouchTargetAndDispatchResultType>(result);
257 }
258
211 } // namespace 259 } // namespace
212 260
213 using namespace HTMLNames; 261 using namespace HTMLNames;
214 262
215 // The link drag hysteresis is much larger than the others because there 263 // The link drag hysteresis is much larger than the others because there
216 // needs to be enough space to cancel the link press without starting a link dra g, 264 // needs to be enough space to cancel the link press without starting a link dra g,
217 // and because dragging links is rare. 265 // and because dragging links is rare.
218 static const int LinkDragHysteresis = 40; 266 static const int LinkDragHysteresis = 40;
219 static const int ImageDragHysteresis = 5; 267 static const int ImageDragHysteresis = 5;
220 static const int TextDragHysteresis = 3; 268 static const int TextDragHysteresis = 3;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 , m_accumulatedRootOverscroll(FloatSize()) 332 , m_accumulatedRootOverscroll(FloatSize())
285 , m_mousePositionIsUnknown(true) 333 , m_mousePositionIsUnknown(true)
286 , m_mouseDownTimestamp(0) 334 , m_mouseDownTimestamp(0)
287 , m_touchPressed(false) 335 , m_touchPressed(false)
288 , m_scrollGestureHandlingNode(nullptr) 336 , m_scrollGestureHandlingNode(nullptr)
289 , m_lastGestureScrollOverWidget(false) 337 , m_lastGestureScrollOverWidget(false)
290 , m_longTapShouldInvokeContextMenu(false) 338 , m_longTapShouldInvokeContextMenu(false)
291 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 339 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
292 , m_lastShowPressTimestamp(0) 340 , m_lastShowPressTimestamp(0)
293 , m_deltaConsumedForScrollSequence(false) 341 , m_deltaConsumedForScrollSequence(false)
342 , m_waitingForFirstTouchMove(false)
294 { 343 {
295 } 344 }
296 345
297 EventHandler::~EventHandler() 346 EventHandler::~EventHandler()
298 { 347 {
299 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); 348 ASSERT(!m_fakeMouseMoveEventTimer.isActive());
300 } 349 }
301 350
302 DEFINE_TRACE(EventHandler) 351 DEFINE_TRACE(EventHandler)
303 { 352 {
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 using EventTargetSet = HeapHashSet<Member<EventTarget>>; 3784 using EventTargetSet = HeapHashSet<Member<EventTarget>>;
3736 // Set of targets involved in m_touches. 3785 // Set of targets involved in m_touches.
3737 EventTargetSet m_targets; 3786 EventTargetSet m_targets;
3738 }; 3787 };
3739 3788
3740 } // namespace 3789 } // namespace
3741 3790
3742 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, 3791 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event,
3743 HeapVector<TouchInfo>& touchInfos, bool allTouchReleased) 3792 HeapVector<TouchInfo>& touchInfos, bool allTouchReleased)
3744 { 3793 {
3794 bool touchStartOrFirstTouchMove = false;
3795 if (event.type() == PlatformEvent::TouchStart) {
3796 m_waitingForFirstTouchMove = true;
3797 touchStartOrFirstTouchMove = true;
3798 } else if (event.type() == PlatformEvent::TouchMove) {
3799 touchStartOrFirstTouchMove = m_waitingForFirstTouchMove;
3800 m_waitingForFirstTouchMove = false;
3801 }
3802
3745 // Build up the lists to use for the 'touches', 'targetTouches' and 3803 // Build up the lists to use for the 'touches', 'targetTouches' and
3746 // 'changedTouches' attributes in the JS event. See 3804 // 'changedTouches' attributes in the JS event. See
3747 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these 3805 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
3748 // lists fit together. 3806 // lists fit together.
3749 3807
3750 // Holds the complete set of touches on the screen. 3808 // Holds the complete set of touches on the screen.
3751 TouchList* touches = TouchList::create(); 3809 TouchList* touches = TouchList::create();
3752 3810
3753 // A different view on the 'touches' list above, filtered and grouped by 3811 // A different view on the 'touches' list above, filtered and grouped by
3754 // event target. Used for the 'targetTouches' list in the JS event. 3812 // event target. Used for the 'targetTouches' list in the JS event.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 continue; 3879 continue;
3822 3880
3823 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); 3881 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state)));
3824 for (const auto& eventTarget : changedTouches[state].m_targets) { 3882 for (const auto& eventTarget : changedTouches[state].m_targets) {
3825 EventTarget* touchEventTarget = eventTarget; 3883 EventTarget* touchEventTarget = eventTarget;
3826 TouchEvent* touchEvent = TouchEvent::create( 3884 TouchEvent* touchEvent = TouchEvent::create(
3827 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), 3885 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(),
3828 eventName, touchEventTarget->toNode()->document().domWindow(), 3886 eventName, touchEventTarget->toNode()->document().domWindow(),
3829 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); 3887 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp());
3830 3888
3831 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent))); 3889 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent);
3890
3891 // Only report for top level documents with a single touch on
3892 // touch-start or the first touch-move.
3893 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && !m_frame->document()->ownerElement()) {
3894 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax));
3895 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult));
3896 }
3897 eventResult = mergeEventResult(eventResult, toWebInputEventResult(do mDispatchResult));
3832 } 3898 }
3833 } 3899 }
3834 3900
3835 return eventResult; 3901 return eventResult;
3836 } 3902 }
3837 3903
3838 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3904 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3839 { 3905 {
3840 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3906 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3841 3907
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4170 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4105 { 4171 {
4106 #if OS(MACOSX) 4172 #if OS(MACOSX)
4107 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4173 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4108 #else 4174 #else
4109 return PlatformEvent::AltKey; 4175 return PlatformEvent::AltKey;
4110 #endif 4176 #endif
4111 } 4177 }
4112 4178
4113 } // namespace blink 4179 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698