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 1956493002: Remove user gestures on touches other than tap in cross-origin iframes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt to harden the test Created 4 years, 7 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/EventHandlerRegistry.h" 9 #include "core/frame/EventHandlerRegistry.h"
10 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 bool allTouchesReleased = true; 461 bool allTouchesReleased = true;
462 for (const auto& point : event.touchPoints()) { 462 for (const auto& point : event.touchPoints()) {
463 if (point.state() != PlatformTouchPoint::TouchReleased 463 if (point.state() != PlatformTouchPoint::TouchReleased
464 && point.state() != PlatformTouchPoint::TouchCancelled) 464 && point.state() != PlatformTouchPoint::TouchCancelled)
465 allTouchesReleased = false; 465 allTouchesReleased = false;
466 } 466 }
467 467
468 // Whether a touch should be considered a "user gesture" or not is a tricky question. 468 // Whether a touch should be considered a "user gesture" or not is a tricky question.
469 // https://docs.google.com/document/d/1oF1T3O7_E4t1PYHV6gyCwHxOi3ystm0eSL5xZ u7nvOg/edit# 469 // https://docs.google.com/document/d/1oF1T3O7_E4t1PYHV6gyCwHxOi3ystm0eSL5xZ u7nvOg/edit#
470 // TODO(rbyers): Disable user gesture in some cases but retain logging for n ow (crbug.com/582140). 470 bool takeUserGesture = false;
471
dtapuska 2016/05/12 00:29:47 I think this might be a little more readable if we
Rick Byers 2016/05/12 03:20:45 Yeah, as long as I don't worry about trying to ski
472 // The touchend corresponding to a tap is always a user gesture.
473 bool isTap = event.touchPoints().size() == 1
474 && event.touchPoints()[0].state() == PlatformTouchPoint::TouchReleased
475 && !event.causesScrollingIfUncanceled();
476 if (isTap)
477 takeUserGesture = true;
478
479 // For now, disallow dragging as a user gesture when the events are being se nt to a
480 // cross-origin iframe (crbug.com/582140).
481 if (!takeUserGesture && m_touchSequenceDocument && m_touchSequenceDocument-> frame()) {
482 SecurityOrigin* securityOrigin = m_touchSequenceDocument->frame()->secur ityContext()->getSecurityOrigin();
483 Frame* top = m_frame->tree().top();
484 if (top && securityOrigin->canAccess(top->securityContext()->getSecurity Origin()))
485 takeUserGesture = true;
486 }
487
471 OwnPtr<UserGestureIndicator> gestureIndicator; 488 OwnPtr<UserGestureIndicator> gestureIndicator;
472 if (event.touchPoints().size() == 1 489 if (takeUserGesture) {
473 && event.touchPoints()[0].state() == PlatformTouchPoint::TouchReleased 490 UserGestureUtilizedCallback* callback = 0;
474 && !event.causesScrollingIfUncanceled()) { 491 if (!isTap) {
475 // This is a touchend corresponding to a tap, definitely a user gesture. So don't supply 492 // This is some other touch event that we currently consider a user gesture. So
476 // a UserGestureUtilizedCallback. 493 // use a UserGestureUtilizedCallback to get metrics.
477 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture)); 494 callback = &m_touchSequenceDocument->frame()->eventHandler();
478 } else { 495 }
479 // This is some other touch event that perhaps shouldn't be considered a user gesture. So 496
480 // use a UserGestureUtilizedCallback to get metrics / deprecation warnin gs.
481 if (m_touchSequenceUserGestureToken) 497 if (m_touchSequenceUserGestureToken)
482 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequence UserGestureToken.release(), &m_touchSequenceDocument->frame()->eventHandler())); 498 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequence UserGestureToken.release(), callback));
483 else 499 else
484 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProce ssingUserGesture, &m_touchSequenceDocument->frame()->eventHandler())); 500 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProce ssingUserGesture, callback));
485 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); 501 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken();
486 } 502 }
487 503
488 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); 504 return dispatchTouchEvents(event, touchInfos, allTouchesReleased);
489 } 505 }
490 506
491 void TouchEventManager::clear() 507 void TouchEventManager::clear()
492 { 508 {
493 m_touchSequenceDocument.clear(); 509 m_touchSequenceDocument.clear();
494 m_touchSequenceUserGestureToken.clear(); 510 m_touchSequenceUserGestureToken.clear();
495 m_targetForTouchID.clear(); 511 m_targetForTouchID.clear();
496 m_regionForTouchID.clear(); 512 m_regionForTouchID.clear();
497 m_touchPressed = false; 513 m_touchPressed = false;
498 m_waitingForFirstTouchMove = false; 514 m_waitingForFirstTouchMove = false;
499 } 515 }
500 516
501 bool TouchEventManager::isAnyTouchActive() const 517 bool TouchEventManager::isAnyTouchActive() const
502 { 518 {
503 return m_touchPressed; 519 return m_touchPressed;
504 } 520 }
505 521
506 DEFINE_TRACE(TouchEventManager) 522 DEFINE_TRACE(TouchEventManager)
507 { 523 {
508 visitor->trace(m_frame); 524 visitor->trace(m_frame);
509 visitor->trace(m_touchSequenceDocument); 525 visitor->trace(m_touchSequenceDocument);
510 visitor->trace(m_targetForTouchID); 526 visitor->trace(m_targetForTouchID);
511 } 527 }
512 528
513 } // namespace blink 529 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698