Chromium Code Reviews| 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/EventHandlingUtil.h" | 14 #include "core/input/EventHandlingUtil.h" |
| 15 #include "core/input/TouchActionUtil.h" | 15 #include "core/input/TouchActionUtil.h" |
| 16 #include "core/layout/HitTestCanvasResult.h" | 16 #include "core/layout/HitTestCanvasResult.h" |
| 17 #include "core/page/ChromeClient.h" | 17 #include "core/page/ChromeClient.h" |
| 18 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
| 19 #include "platform/Histogram.h" | 19 #include "platform/Histogram.h" |
| 20 #include "platform/PlatformTouchEvent.h" | 20 #include "platform/PlatformTouchEvent.h" |
| 21 #include "platform/RuntimeEnabledFeatures.h" | |
| 22 #include "wtf/CurrentTime.h" | 21 #include "wtf/CurrentTime.h" |
| 23 #include "wtf/PtrUtil.h" | 22 #include "wtf/PtrUtil.h" |
| 24 #include <memory> | 23 #include <memory> |
| 25 | 24 |
| 26 namespace blink { | 25 namespace blink { |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 bool hasTouchHandlers(const EventHandlerRegistry& registry) { | 29 bool hasTouchHandlers(const EventHandlerRegistry& registry) { |
| 31 return registry.hasEventHandlers( | 30 return registry.hasEventHandlers( |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 } | 482 } |
| 484 ~CurrentEventHolder() { m_target = PlatformEvent::NoType; } | 483 ~CurrentEventHolder() { m_target = PlatformEvent::NoType; } |
| 485 | 484 |
| 486 private: | 485 private: |
| 487 PlatformEvent::EventType& m_target; | 486 PlatformEvent::EventType& m_target; |
| 488 }; | 487 }; |
| 489 | 488 |
| 490 WebInputEventResult TouchEventManager::handleTouchEvent( | 489 WebInputEventResult TouchEventManager::handleTouchEvent( |
| 491 const PlatformTouchEvent& event, | 490 const PlatformTouchEvent& event, |
| 492 HeapVector<TouchInfo>& touchInfos) { | 491 HeapVector<TouchInfo>& touchInfos) { |
| 493 if (!RuntimeEnabledFeatures::touchEventAPIEnabled()) | 492 // We ideally want to suppress TouchEvent firing when touch detection is |
|
Rick Byers
2016/12/01 21:40:16
FWIW I don't agree with this comment. We'd "ideal
| |
| 494 return WebInputEventResult::HandledSuppressed; | 493 // disabled but we need to support dev-tools emulation and "some" dynamic |
| 494 // cases. | |
| 495 | 495 |
| 496 // Track the current event for the scope of this function. | 496 // Track the current event for the scope of this function. |
| 497 CurrentEventHolder holder(m_currentEvent, event.type()); | 497 CurrentEventHolder holder(m_currentEvent, event.type()); |
| 498 | 498 |
| 499 if (!reHitTestTouchPointsIfNeeded(event, touchInfos)) | 499 if (!reHitTestTouchPointsIfNeeded(event, touchInfos)) |
| 500 return WebInputEventResult::NotHandled; | 500 return WebInputEventResult::NotHandled; |
| 501 | 501 |
| 502 bool allTouchesReleased = true; | 502 bool allTouchesReleased = true; |
| 503 for (const auto& point : event.touchPoints()) { | 503 for (const auto& point : event.touchPoints()) { |
| 504 if (point.state() != PlatformTouchPoint::TouchReleased && | 504 if (point.state() != PlatformTouchPoint::TouchReleased && |
| 505 point.state() != PlatformTouchPoint::TouchCancelled) | 505 point.state() != PlatformTouchPoint::TouchCancelled) |
| 506 allTouchesReleased = false; | 506 allTouchesReleased = false; |
| 507 } | 507 } |
| 508 | 508 |
| 509 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); | 509 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); |
| 510 } | 510 } |
| 511 | 511 |
| 512 bool TouchEventManager::isAnyTouchActive() const { | 512 bool TouchEventManager::isAnyTouchActive() const { |
| 513 return m_touchPressed; | 513 return m_touchPressed; |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // namespace blink | 516 } // namespace blink |
| OLD | NEW |