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

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

Issue 2233543002: Make first TouchStart and first TouchMove events on a flinging layer non-blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fling intervetion Created 4 years, 4 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/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
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;
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
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); 486 return dispatchTouchEvents(event, touchInfos, allTouchesReleased);
492 } 487 }
493 488
494 void TouchEventManager::clear() 489 void TouchEventManager::clear()
495 { 490 {
496 m_touchSequenceDocument.clear(); 491 m_touchSequenceDocument.clear();
497 m_touchSequenceUserGestureToken.clear(); 492 m_touchSequenceUserGestureToken.clear();
498 m_targetForTouchID.clear(); 493 m_targetForTouchID.clear();
499 m_regionForTouchID.clear(); 494 m_regionForTouchID.clear();
500 m_touchPressed = false; 495 m_touchPressed = false;
501 m_waitingForFirstTouchMove = false;
502 m_touchScrollStarted = false; 496 m_touchScrollStarted = false;
503 m_currentEvent = PlatformEvent::NoType; 497 m_currentEvent = PlatformEvent::NoType;
504 } 498 }
505 499
506 bool TouchEventManager::isAnyTouchActive() const 500 bool TouchEventManager::isAnyTouchActive() const
507 { 501 {
508 return m_touchPressed; 502 return m_touchPressed;
509 } 503 }
510 504
511 DEFINE_TRACE(TouchEventManager) 505 DEFINE_TRACE(TouchEventManager)
(...skipping 21 matching lines...) Expand all
533 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; 527 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized;
534 break; 528 break;
535 default: 529 default:
536 NOTREACHED(); 530 NOTREACHED();
537 return; 531 return;
538 } 532 }
539 Deprecation::countDeprecation(m_frame, feature); 533 Deprecation::countDeprecation(m_frame, feature);
540 } 534 }
541 535
542 } // namespace blink 536 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698