| 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" |
| 11 #include "core/frame/FrameHost.h" | 11 #include "core/frame/FrameHost.h" |
| 12 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
| 13 #include "core/html/HTMLCanvasElement.h" | 13 #include "core/html/HTMLCanvasElement.h" |
| 14 #include "core/input/EventHandler.h" | 14 #include "core/input/EventHandler.h" |
| 15 #include "core/input/TouchActionUtil.h" | 15 #include "core/input/TouchActionUtil.h" |
| 16 #include "core/page/ChromeClient.h" | 16 #include "core/page/ChromeClient.h" |
| 17 #include "core/page/Page.h" | 17 #include "core/page/Page.h" |
| 18 #include "platform/Histogram.h" | 18 #include "platform/Histogram.h" |
| 19 #include "platform/PlatformTouchEvent.h" | 19 #include "platform/PlatformTouchEvent.h" |
| 20 #include "wtf/CurrentTime.h" | 20 #include "wtf/CurrentTime.h" |
| 21 #include "wtf/PtrUtil.h" |
| 22 #include <memory> |
| 21 | 23 |
| 22 | 24 |
| 23 namespace blink { | 25 namespace blink { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 bool hasTouchHandlers(const EventHandlerRegistry& registry) | 29 bool hasTouchHandlers(const EventHandlerRegistry& registry) |
| 28 { | 30 { |
| 29 return registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent
Blocking) | 31 return registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent
Blocking) |
| 30 || registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent
Passive) | 32 || registry.hasEventHandlers(EventHandlerRegistry::TouchStartOrMoveEvent
Passive) |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // For now, disallow dragging as a user gesture when the events are being se
nt to a | 464 // For now, disallow dragging as a user gesture when the events are being se
nt to a |
| 463 // cross-origin iframe (crbug.com/582140). | 465 // cross-origin iframe (crbug.com/582140). |
| 464 bool isSameOrigin = false; | 466 bool isSameOrigin = false; |
| 465 if (m_touchSequenceDocument && m_touchSequenceDocument->frame()) { | 467 if (m_touchSequenceDocument && m_touchSequenceDocument->frame()) { |
| 466 SecurityOrigin* securityOrigin = m_touchSequenceDocument->frame()->secur
ityContext()->getSecurityOrigin(); | 468 SecurityOrigin* securityOrigin = m_touchSequenceDocument->frame()->secur
ityContext()->getSecurityOrigin(); |
| 467 Frame* top = m_frame->tree().top(); | 469 Frame* top = m_frame->tree().top(); |
| 468 if (top && securityOrigin->canAccess(top->securityContext()->getSecurity
Origin())) | 470 if (top && securityOrigin->canAccess(top->securityContext()->getSecurity
Origin())) |
| 469 isSameOrigin = true; | 471 isSameOrigin = true; |
| 470 } | 472 } |
| 471 | 473 |
| 472 OwnPtr<UserGestureIndicator> gestureIndicator; | 474 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 473 if (isTap || isSameOrigin) { | 475 if (isTap || isSameOrigin) { |
| 474 UserGestureUtilizedCallback* callback = 0; | 476 UserGestureUtilizedCallback* callback = 0; |
| 475 // These are cases we'd like to migrate to not hold a user gesture. | 477 // These are cases we'd like to migrate to not hold a user gesture. |
| 476 if (event.type() == PlatformEvent::TouchStart | 478 if (event.type() == PlatformEvent::TouchStart |
| 477 || event.type() == PlatformEvent::TouchMove | 479 || event.type() == PlatformEvent::TouchMove |
| 478 || (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)
) { | 480 || (event.type() == PlatformEvent::TouchEnd && m_touchScrollStarted)
) { |
| 479 // Collect metrics in userGestureUtilized(). | 481 // Collect metrics in userGestureUtilized(). |
| 480 callback = this; | 482 callback = this; |
| 481 } | 483 } |
| 482 if (m_touchSequenceUserGestureToken) | 484 if (m_touchSequenceUserGestureToken) |
| 483 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequence
UserGestureToken.release(), callback)); | 485 gestureIndicator = wrapUnique(new UserGestureIndicator(m_touchSequen
ceUserGestureToken.release(), callback)); |
| 484 else | 486 else |
| 485 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProce
ssingUserGesture, callback)); | 487 gestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyPro
cessingUserGesture, callback)); |
| 486 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); | 488 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); |
| 487 } | 489 } |
| 488 | 490 |
| 489 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); | 491 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); |
| 490 } | 492 } |
| 491 | 493 |
| 492 void TouchEventManager::clear() | 494 void TouchEventManager::clear() |
| 493 { | 495 { |
| 494 m_touchSequenceDocument.clear(); | 496 m_touchSequenceDocument.clear(); |
| 495 m_touchSequenceUserGestureToken.clear(); | 497 m_touchSequenceUserGestureToken.clear(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; | 533 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; |
| 532 break; | 534 break; |
| 533 default: | 535 default: |
| 534 NOTREACHED(); | 536 NOTREACHED(); |
| 535 return; | 537 return; |
| 536 } | 538 } |
| 537 Deprecation::countDeprecation(m_frame, feature); | 539 Deprecation::countDeprecation(m_frame, feature); |
| 538 } | 540 } |
| 539 | 541 |
| 540 } // namespace blink | 542 } // namespace blink |
| OLD | NEW |