Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 12 #include "core/html/HTMLCanvasElement.h" | 12 #include "core/html/HTMLCanvasElement.h" |
| 13 #include "core/input/EventHandler.h" | 13 #include "core/input/EventHandler.h" |
| 14 #include "core/input/TouchActionUtil.h" | 14 #include "core/input/TouchActionUtil.h" |
| 15 #include "core/page/ChromeClient.h" | 15 #include "core/page/ChromeClient.h" |
| 16 #include "core/page/Page.h" | 16 #include "core/page/Page.h" |
| 17 #include "platform/Histogram.h" | 17 #include "platform/Histogram.h" |
| 18 #include "platform/PlatformTouchEvent.h" | 18 #include "platform/PlatformTouchEvent.h" |
| 19 | 19 #include "wtf/CurrentTime.h" |
| 20 | 20 |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 bool hasTouchHandlers(const EventHandlerRegistry& registry) | 26 bool hasTouchHandlers(const EventHandlerRegistry& registry) |
| 27 { | 27 { |
| 28 return registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent Blocking) | 28 return registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent Blocking) |
| 29 || registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent Passive) | 29 || registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent Passive) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); | 236 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); |
| 237 | 237 |
| 238 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); | 238 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); |
| 239 | 239 |
| 240 // Only report for top level documents with a single touch on | 240 // Only report for top level documents with a single touch on |
| 241 // touch-start or the first touch-move. | 241 // touch-start or the first touch-move. |
| 242 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) { | 242 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) { |
| 243 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax)); | 243 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax)); |
| 244 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult)); | 244 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult)); |
| 245 | 245 |
| 246 // Count the handled touch starts and first touch moves before a nd after the page is fully loaded respectively. | 246 // Count the handled touch starts and first touch moves before a nd after the page is fully loaded respectively and also their latency. |
|
tdresser
2016/05/16 17:13:55
Record the disposition and latency of touch starts
lanwei
2016/05/16 20:23:09
Done.
| |
| 247 int64_t latencyInMicros = static_cast<int64_t>((currentTime() - event.timestamp()) * 1000000.0); | |
| 247 if (m_frame->document()->isLoadCompleted()) { | 248 if (m_frame->document()->isLoadCompleted()) { |
| 248 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); | 249 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); |
| 249 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 250 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); |
| 251 | |
| 252 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyAfterP ageLoadHistogram, ("Event.Touch.TouchesAfterPageLoadLatency", 1, 10000000, 100)) ; | |
|
tdresser
2016/05/16 17:13:55
Let's bump up the maximum by a factor of 10. Right
lanwei
2016/05/16 20:23:09
Done.
| |
| 253 eventLatencyAfterPageLoadHistogram.count(latencyInMicros); | |
| 250 } else { | 254 } else { |
| 251 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsB eforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", TouchEve ntDispatchResultTypeMax)); | 255 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsB eforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", TouchEve ntDispatchResultTypeMax)); |
| 252 touchDispositionsBeforePageLoadHistogram.count((domDispatchR esult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 256 touchDispositionsBeforePageLoadHistogram.count((domDispatchR esult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); |
| 257 | |
| 258 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyBefore PageLoadHistogram, ("Event.Touch.TouchesBeforePageLoadLatency", 1, 10000000, 100 )); | |
| 259 eventLatencyBeforePageLoadHistogram.count(latencyInMicros); | |
| 253 } | 260 } |
| 254 } | 261 } |
| 255 eventResult = EventHandler::mergeEventResult(eventResult, | 262 eventResult = EventHandler::mergeEventResult(eventResult, |
| 256 EventHandler::toWebInputEventResult(domDispatchResult)); | 263 EventHandler::toWebInputEventResult(domDispatchResult)); |
| 257 } | 264 } |
| 258 } | 265 } |
| 259 return eventResult; | 266 return eventResult; |
| 260 } | 267 } |
| 261 | 268 |
| 262 void TouchEventManager::updateTargetAndRegionMapsForTouchStarts( | 269 void TouchEventManager::updateTargetAndRegionMapsForTouchStarts( |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 } | 525 } |
| 519 | 526 |
| 520 DEFINE_TRACE(TouchEventManager) | 527 DEFINE_TRACE(TouchEventManager) |
| 521 { | 528 { |
| 522 visitor->trace(m_frame); | 529 visitor->trace(m_frame); |
| 523 visitor->trace(m_touchSequenceDocument); | 530 visitor->trace(m_touchSequenceDocument); |
| 524 visitor->trace(m_targetForTouchID); | 531 visitor->trace(m_targetForTouchID); |
| 525 } | 532 } |
| 526 | 533 |
| 527 } // namespace blink | 534 } // namespace blink |
| OLD | NEW |