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/Deprecation.h" | 9 #include "core/frame/Deprecation.h" |
10 #include "core/frame/EventHandlerRegistry.h" | 10 #include "core/frame/EventHandlerRegistry.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 88 |
89 TouchEventManager::~TouchEventManager() | 89 TouchEventManager::~TouchEventManager() |
90 { | 90 { |
91 } | 91 } |
92 | 92 |
93 WebInputEventResult TouchEventManager::dispatchTouchEvents( | 93 WebInputEventResult TouchEventManager::dispatchTouchEvents( |
94 const PlatformTouchEvent& event, | 94 const PlatformTouchEvent& event, |
95 const HeapVector<TouchInfo>& touchInfos, | 95 const HeapVector<TouchInfo>& touchInfos, |
96 bool allTouchesReleased) | 96 bool allTouchesReleased) |
97 { | 97 { |
98 bool touchStartOrFirstTouchMove = false; | |
99 if (event.type() == PlatformEvent::TouchStart) { | |
100 m_waitingForFirstTouchMove = true; | |
dtapuska
2016/08/15 14:41:29
Can the class variable now be removed?
lanwei
2016/08/17 01:22:35
Done.
| |
101 touchStartOrFirstTouchMove = true; | |
102 } else if (event.type() == PlatformEvent::TouchMove) { | |
103 touchStartOrFirstTouchMove = m_waitingForFirstTouchMove; | |
104 m_waitingForFirstTouchMove = false; | |
105 } | |
106 | |
107 // Build up the lists to use for the |touches|, |targetTouches| and | 98 // Build up the lists to use for the |touches|, |targetTouches| and |
108 // |changedTouches| attributes in the JS event. See | 99 // |changedTouches| attributes in the JS event. See |
109 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 100 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
110 // lists fit together. | 101 // lists fit together. |
111 | 102 |
112 // Holds the complete set of touches on the screen. | 103 // Holds the complete set of touches on the screen. |
113 TouchList* touches = TouchList::create(); | 104 TouchList* touches = TouchList::create(); |
114 | 105 |
115 // A different view on the 'touches' list above, filtered and grouped by | 106 // A different view on the 'touches' list above, filtered and grouped by |
116 // event target. Used for the |targetTouches| list in the JS event. | 107 // event target. Used for the |targetTouches| list in the JS event. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { | 170 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { |
180 if (!changedTouches[state].m_touches) | 171 if (!changedTouches[state].m_touches) |
181 continue; | 172 continue; |
182 | 173 |
183 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); | 174 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); |
184 for (const auto& eventTarget : changedTouches[state].m_targets) { | 175 for (const auto& eventTarget : changedTouches[state].m_targets) { |
185 EventTarget* touchEventTarget = eventTarget; | 176 EventTarget* touchEventTarget = eventTarget; |
186 TouchEvent* touchEvent = TouchEvent::create( | 177 TouchEvent* touchEvent = TouchEvent::create( |
187 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), | 178 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), |
188 eventName, touchEventTarget->toNode()->document().domWindow(), | 179 eventName, touchEventTarget->toNode()->document().domWindow(), |
189 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), touchStartOrFirstTouchMove, event.timestamp()); | 180 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.touchStartOrFirstTouchMove(), event.timestamp()); |
190 | 181 |
191 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); | 182 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); |
192 | 183 |
193 // Only report for top level documents with a single touch on | 184 // Only report for top level documents with a single touch on |
194 // touch-start or the first touch-move. | 185 // touch-start or the first touch-move. |
195 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) { | 186 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && m_frame->isMainFrame()) { |
196 | 187 |
197 // Record the disposition and latency of touch starts and first touch moves before and after the page is fully loaded respectively. | 188 // Record the disposition and latency of touch starts and first touch moves before and after the page is fully loaded respectively. |
198 int64_t latencyInMicros = static_cast<int64_t>((monotonicallyInc reasingTime() - event.timestamp()) * 1000000.0); | 189 int64_t latencyInMicros = static_cast<int64_t>((monotonicallyInc reasingTime() - event.timestamp()) * 1000000.0); |
199 if (m_frame->document()->isLoadCompleted()) { | 190 if (event.cancelable()) { |
200 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); | 191 if (m_frame->document()->isLoadCompleted()) { |
201 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 192 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsAfterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchE ventDispatchResultTypeMax)); |
193 touchDispositionsAfterPageLoadHistogram.count((domDispat chResult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouche s); | |
202 | 194 |
203 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyAfterP ageLoadHistogram, ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50)); | 195 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyAf terPageLoadHistogram, ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50 )); |
204 eventLatencyAfterPageLoadHistogram.count(latencyInMicros); | 196 eventLatencyAfterPageLoadHistogram.count(latencyInMicros ); |
205 } else { | 197 } else { |
206 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsB eforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", TouchEve ntDispatchResultTypeMax)); | 198 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsBeforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", Touc hEventDispatchResultTypeMax)); |
207 touchDispositionsBeforePageLoadHistogram.count((domDispatchR esult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 199 touchDispositionsBeforePageLoadHistogram.count((domDispa tchResult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouch es); |
208 | 200 |
209 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyBefore PageLoadHistogram, ("Event.Touch.TouchLatencyBeforePageLoad", 1, 100000000, 50)) ; | 201 DEFINE_STATIC_LOCAL(CustomCountHistogram, eventLatencyBe forePageLoadHistogram, ("Event.Touch.TouchLatencyBeforePageLoad", 1, 100000000, 50)); |
210 eventLatencyBeforePageLoadHistogram.count(latencyInMicros); | 202 eventLatencyBeforePageLoadHistogram.count(latencyInMicro s); |
203 } | |
211 } | 204 } |
212 | 205 |
213 // Report the touch disposition, split by whether there is an ac tive fling animation. | 206 // Report the touch disposition, split by whether there is an ac tive fling animation. |
214 if (event.type() == PlatformEvent::TouchStart) { | 207 if (event.dispatchedDuringFling()) { |
215 if (event.dispatchedDuringFling()) { | 208 if (event.dispatchType() == PlatformEvent::ListenersForcedNo nBlockingPassiveDueToFling) { |
216 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsDuringFlingHistogram, ("Event.Touch.TouchDispositionsDuringFling", TouchEvent DispatchResultTypeMax)); | 209 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsDuringFlingHistogram, ("Event.Touch.TouchDispositionsDuringFling2", TouchEven tDispatchResultTypeMax)); |
217 touchDispositionsDuringFlingHistogram.count((domDispatch Result != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches) ; | 210 touchDispositionsDuringFlingHistogram.count(touchEvent-> preventDefaultCalledOnUncancelableEvent() ? HandledTouches : UnhandledTouches); |
218 } else { | 211 } |
219 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsOutsideFlingHistogram, ("Event.Touch.TouchDispositionsOutsideFling", TouchEve ntDispatchResultTypeMax)); | 212 } else { |
213 if (event.cancelable()) { | |
214 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositi onsOutsideFlingHistogram, ("Event.Touch.TouchDispositionsOutsideFling2", TouchEv entDispatchResultTypeMax)); | |
220 touchDispositionsOutsideFlingHistogram.count((domDispatc hResult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches ); | 215 touchDispositionsOutsideFlingHistogram.count((domDispatc hResult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches ); |
221 } | 216 } |
222 } | 217 } |
223 } | 218 } |
224 eventResult = EventHandler::mergeEventResult(eventResult, | 219 eventResult = EventHandler::mergeEventResult(eventResult, |
225 EventHandler::toWebInputEventResult(domDispatchResult)); | 220 EventHandler::toWebInputEventResult(domDispatchResult)); |
226 } | 221 } |
227 } | 222 } |
228 | 223 |
229 if (allTouchesReleased) | 224 if (allTouchesReleased) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; | 528 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; |
534 break; | 529 break; |
535 default: | 530 default: |
536 NOTREACHED(); | 531 NOTREACHED(); |
537 return; | 532 return; |
538 } | 533 } |
539 Deprecation::countDeprecation(m_frame, feature); | 534 Deprecation::countDeprecation(m_frame, feature); |
540 } | 535 } |
541 | 536 |
542 } // namespace blink | 537 } // namespace blink |
OLD | NEW |