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

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

Issue 2401123002: UserGestureIndicator is a mess. Clean it up. (Closed)
Patch Set: Callback cleanup, comments Created 4 years, 2 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 ->securityContext() 517 ->securityContext()
518 ->getSecurityOrigin(); 518 ->getSecurityOrigin();
519 Frame* top = m_frame->tree().top(); 519 Frame* top = m_frame->tree().top();
520 if (top && 520 if (top &&
521 securityOrigin->canAccess(top->securityContext()->getSecurityOrigin())) 521 securityOrigin->canAccess(top->securityContext()->getSecurityOrigin()))
522 isSameOrigin = true; 522 isSameOrigin = true;
523 } 523 }
524 524
525 std::unique_ptr<UserGestureIndicator> gestureIndicator; 525 std::unique_ptr<UserGestureIndicator> gestureIndicator;
526 if (isTap || isSameOrigin) { 526 if (isTap || isSameOrigin) {
527 UserGestureUtilizedCallback* callback = 0; 527 gestureIndicator = wrapUnique(
528 new UserGestureIndicator(m_touchSequenceUserGestureToken
529 ? m_touchSequenceUserGestureToken.release()
530 : UserGestureToken::create()));
531
532 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken();
528 // These are cases we'd like to migrate to not hold a user gesture. 533 // These are cases we'd like to migrate to not hold a user gesture.
529 if (event.type() == PlatformEvent::TouchStart || 534 if (event.type() == PlatformEvent::TouchStart ||
530 event.type() == PlatformEvent::TouchMove || 535 event.type() == PlatformEvent::TouchMove ||
531 (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)) { 536 (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)) {
532 // Collect metrics in userGestureUtilized(). 537 // Collect metrics in userGestureUtilized().
533 callback = this; 538 m_touchSequenceUserGestureToken->setUserGestureUtilizedCallback(this);
534 } 539 }
535 if (m_touchSequenceUserGestureToken)
536 gestureIndicator = wrapUnique(new UserGestureIndicator(
537 m_touchSequenceUserGestureToken.release(), callback));
538 else
539 gestureIndicator = wrapUnique(
540 new UserGestureIndicator(DefinitelyProcessingUserGesture, callback));
541 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken();
542 } 540 }
543 541
544 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); 542 return dispatchTouchEvents(event, touchInfos, allTouchesReleased);
545 } 543 }
546 544
547 bool TouchEventManager::isAnyTouchActive() const { 545 bool TouchEventManager::isAnyTouchActive() const {
548 return m_touchPressed; 546 return m_touchPressed;
549 } 547 }
550 548
551 void TouchEventManager::userGestureUtilized() { 549 void TouchEventManager::userGestureUtilized() {
(...skipping 14 matching lines...) Expand all
566 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; 564 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized;
567 break; 565 break;
568 default: 566 default:
569 NOTREACHED(); 567 NOTREACHED();
570 return; 568 return;
571 } 569 }
572 Deprecation::countDeprecation(m_frame, feature); 570 Deprecation::countDeprecation(m_frame, feature);
573 } 571 }
574 572
575 } // namespace blink 573 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698