Chromium Code Reviews| Index: third_party/WebKit/Source/core/events/TouchEvent.cpp |
| diff --git a/third_party/WebKit/Source/core/events/TouchEvent.cpp b/third_party/WebKit/Source/core/events/TouchEvent.cpp |
| index 721ec81f34e7ac66bfebdc6348c896a6b6a0f4ac..8a31f4f2142c39c8996628ef9425c912c6f10ee4 100644 |
| --- a/third_party/WebKit/Source/core/events/TouchEvent.cpp |
| +++ b/third_party/WebKit/Source/core/events/TouchEvent.cpp |
| @@ -30,11 +30,123 @@ |
| #include "bindings/core/v8/ScriptState.h" |
| #include "core/events/EventDispatcher.h" |
| #include "core/frame/FrameConsole.h" |
| +#include "core/frame/FrameView.h" |
| #include "core/frame/LocalDOMWindow.h" |
| #include "core/inspector/ConsoleMessage.h" |
| +#include "platform/Histogram.h" |
| namespace blink { |
| +namespace { |
| + |
| +// These offsets change indicies into the ListenerHistogram |
|
Rick Byers
2016/05/18 18:37:18
this is quite a lot of complexity / details. Talk
dtapuska
2016/05/19 16:11:21
Done.
|
| +// enumeration. The addition of a series of offsets then |
| +// produces the resulting ListenerHistogram value. |
| +const size_t kTouchTargetHistogramRootScrollerOffset = 6; |
| +const size_t kTouchTargetHistogramScrollableDocumentOffset = 3; |
| +const size_t kTouchTargetHistogramAlreadyHandledOffset = 0; |
| +const size_t kTouchTargetHistogramNotHandledOffset = 1; |
| +const size_t kTouchTargetHistogramHandledOffset = 2; |
| +const size_t kCapturingOffset = 0; |
| +const size_t kAtTargetOffset = 12; |
| +const size_t kBubblingOffset = 24; |
| + |
| +enum TouchTargetAndDispatchResultType { |
| + // The following enums represent state captured during the CAPTURING_PHASE. |
| + CapturingNonRootScrollerNonScrollableAlreadyHandled, // Non-root-scroller, non-scrollable document, already handled. |
| + CapturingNonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled. |
| + CapturingNonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable document, handled application. |
| + CapturingNonRootScrollerScrollableDocumentAlreadyHandled, // Non-root-scroller, scrollable document, already handled. |
| + CapturingNonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollable document, not handled. |
| + CapturingNonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable document, handled application. |
| + CapturingRootScrollerNonScrollableAlreadyHandled, // Root-scroller, non-scrollable document, already handled. |
| + CapturingRootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable document, not handled. |
| + CapturingRootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled. |
| + CapturingRootScrollerScrollableDocumentAlreadyHandled, // Root-scroller, scrollable document, already handled. |
| + CapturingRootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable document, not handled. |
| + CapturingRootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document, handled. |
| + |
| + // The following enums represent state captured during the AT_TARGET phase. |
| + NonRootScrollerNonScrollableAlreadyHandled, // Non-root-scroller, non-scrollable document, already handled. |
| + NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled. |
| + NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable document, handled application. |
| + NonRootScrollerScrollableDocumentAlreadyHandled, // Non-root-scroller, scrollable document, already handled. |
| + NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollable document, not handled. |
| + NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable document, handled application. |
| + RootScrollerNonScrollableAlreadyHandled, // Root-scroller, non-scrollable document, already handled. |
| + RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable document, not handled. |
| + RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled. |
| + RootScrollerScrollableDocumentAlreadyHandled, // Root-scroller, scrollable document, already handled. |
| + RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable document, not handled. |
| + RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document, handled. |
| + |
| + // The following enums represent state captured during the BUBBLING_PHASE. |
| + BubblingNonRootScrollerNonScrollableAlreadyHandled, // Non-root-scroller, non-scrollable document, already handled. |
| + BubblingNonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled. |
| + BubblingNonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable document, handled application. |
| + BubblingNonRootScrollerScrollableDocumentAlreadyHandled, // Non-root-scroller, scrollable document, already handled. |
| + BubblingNonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollable document, not handled. |
| + BubblingNonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable document, handled application. |
| + BubblingRootScrollerNonScrollableAlreadyHandled, // Root-scroller, non-scrollable document, already handled. |
| + BubblingRootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable document, not handled. |
| + BubblingRootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled. |
| + BubblingRootScrollerScrollableDocumentAlreadyHandled, // Root-scroller, scrollable document, already handled. |
| + BubblingRootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable document, not handled. |
| + BubblingRootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document, handled. |
| + TouchTargetAndDispatchResultTypeMax, |
| +}; |
| + |
| +void logTouchTargetHistogram(EventTarget* eventTarget, unsigned short phase, bool defaultPreventedBeforeCurrentTarget, bool defaultPrevented) |
| +{ |
| + int result = 0; |
| + Document* document = nullptr; |
| + |
| + switch (phase) { |
| + default: |
| + case Event::NONE: |
| + return; |
| + case Event::CAPTURING_PHASE: |
| + result += kCapturingOffset; |
| + break; |
| + case Event::AT_TARGET: |
| + result += kAtTargetOffset; |
| + break; |
| + case Event::BUBBLING_PHASE: |
| + result += kBubblingOffset; |
| + break; |
| + } |
| + |
| + if (const LocalDOMWindow* domWindow = eventTarget->toLocalDOMWindow()) { |
| + // Treat the window as a root scroller as well. |
| + document = domWindow->document(); |
| + result += kTouchTargetHistogramRootScrollerOffset; |
| + } else if (Node* node = eventTarget->toNode()) { |
| + // Report if the target node is the document or body. |
| + if (node->isDocumentNode() || node->document().documentElement() == node || node->document().body() == node) { |
| + result += kTouchTargetHistogramRootScrollerOffset; |
| + } |
| + document = &node->document(); |
| + } |
| + |
| + if (document) { |
| + FrameView* view = document->view(); |
| + if (view && view->isScrollable()) |
| + result += kTouchTargetHistogramScrollableDocumentOffset; |
| + } |
| + |
| + if (defaultPreventedBeforeCurrentTarget) |
| + result += kTouchTargetHistogramAlreadyHandledOffset; |
| + else if (defaultPrevented) |
| + result += kTouchTargetHistogramHandledOffset; |
| + else |
| + result += kTouchTargetHistogramNotHandledOffset; |
| + |
| + DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHistogram, ("Event.Touch.TargetAndDispatchResult2", TouchTargetAndDispatchResultTypeMax)); |
| + rootDocumentListenerHistogram.count(static_cast<TouchTargetAndDispatchResultType>(result)); |
| +} |
| + |
| +} // namespace |
| + |
| TouchEvent::TouchEvent() |
| { |
| } |
| @@ -46,7 +158,11 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, |
| double platformTimeStamp) |
| // Pass a sourceCapabilities including the ability to fire touchevents when creating this touchevent, which is always created from input device capabilities from EventHandler. |
| : UIEventWithKeyState(type, true, cancelable, view, 0, modifiers, platformTimeStamp, InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), |
| - m_touches(touches), m_targetTouches(targetTouches), m_changedTouches(changedTouches), m_causesScrollingIfUncanceled(causesScrollingIfUncanceled) |
| + m_touches(touches), |
| + m_targetTouches(targetTouches), |
| + m_changedTouches(changedTouches), |
| + m_causesScrollingIfUncanceled(causesScrollingIfUncanceled), |
| + m_defaultPreventedBeforeCurrentTarget(false) |
| { |
| } |
| @@ -109,6 +225,15 @@ void TouchEvent::preventDefault() |
| } |
| } |
| +void TouchEvent::doneDispatchingEventAtCurrentTarget() |
| +{ |
| + if (!cancelable()) |
|
Rick Byers
2016/05/18 18:37:18
This histogram is going to be swamped out by the (
tdresser
2016/05/18 18:57:12
+1, thanks.
dtapuska
2016/05/19 16:11:21
Done.
|
| + return; |
| + bool canceled = defaultPrevented(); |
| + logTouchTargetHistogram(currentTarget(), eventPhase(), m_defaultPreventedBeforeCurrentTarget, canceled); |
| + m_defaultPreventedBeforeCurrentTarget = canceled; |
| +} |
| + |
| EventDispatchMediator* TouchEvent::createMediator() |
| { |
| return TouchEventDispatchMediator::create(this); |