| 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/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 "wtf/CurrentTime.h" | 21 #include "wtf/CurrentTime.h" |
| 22 #include "wtf/PtrUtil.h" | 22 #include "wtf/PtrUtil.h" |
| 23 #include <memory> | 23 #include <memory> |
| 24 | 24 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 TouchEventManager::TouchEventManager(LocalFrame* frame) | 84 TouchEventManager::TouchEventManager(LocalFrame* frame) |
| 85 : m_frame(frame) | 85 : m_frame(frame) |
| 86 { | 86 { |
| 87 clear(); | 87 clear(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TouchEventManager::~TouchEventManager() | |
| 91 { | |
| 92 } | |
| 93 | |
| 94 WebInputEventResult TouchEventManager::dispatchTouchEvents( | 90 WebInputEventResult TouchEventManager::dispatchTouchEvents( |
| 95 const PlatformTouchEvent& event, | 91 const PlatformTouchEvent& event, |
| 96 const HeapVector<TouchInfo>& touchInfos, | 92 const HeapVector<TouchInfo>& touchInfos, |
| 97 bool allTouchesReleased) | 93 bool allTouchesReleased) |
| 98 { | 94 { |
| 99 // Build up the lists to use for the |touches|, |targetTouches| and | 95 // Build up the lists to use for the |touches|, |targetTouches| and |
| 100 // |changedTouches| attributes in the JS event. See | 96 // |changedTouches| attributes in the JS event. See |
| 101 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 97 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 102 // lists fit together. | 98 // lists fit together. |
| 103 | 99 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsO
utsideFlingHistogram, ("Event.Touch.TouchDispositionsOutsideFling2", TouchEventD
ispatchResultTypeMax)); | 202 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsO
utsideFlingHistogram, ("Event.Touch.TouchDispositionsOutsideFling2", TouchEventD
ispatchResultTypeMax)); |
| 207 touchDispositionsOutsideFlingHistogram.count((domDispatchRes
ult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 203 touchDispositionsOutsideFlingHistogram.count((domDispatchRes
ult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); |
| 208 } | 204 } |
| 209 | 205 |
| 210 // Report the touch disposition when there is an active fling an
imation. | 206 // Report the touch disposition when there is an active fling an
imation. |
| 211 if (event.dispatchType() == PlatformEvent::ListenersForcedNonBlo
ckingDueToFling) { | 207 if (event.dispatchType() == PlatformEvent::ListenersForcedNonBlo
ckingDueToFling) { |
| 212 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsD
uringFlingHistogram, ("Event.Touch.TouchDispositionsDuringFling2", TouchEventDis
patchResultTypeMax)); | 208 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsD
uringFlingHistogram, ("Event.Touch.TouchDispositionsDuringFling2", TouchEventDis
patchResultTypeMax)); |
| 213 touchDispositionsDuringFlingHistogram.count(touchEvent->prev
entDefaultCalledOnUncancelableEvent() ? HandledTouches : UnhandledTouches); | 209 touchDispositionsDuringFlingHistogram.count(touchEvent->prev
entDefaultCalledOnUncancelableEvent() ? HandledTouches : UnhandledTouches); |
| 214 } | 210 } |
| 215 } | 211 } |
| 216 eventResult = EventHandler::mergeEventResult(eventResult, | 212 eventResult = EventHandlingUtil::mergeEventResult(eventResult, |
| 217 EventHandler::toWebInputEventResult(domDispatchResult)); | 213 EventHandlingUtil::toWebInputEventResult(domDispatchResult)); |
| 218 } | 214 } |
| 219 } | 215 } |
| 220 | 216 |
| 221 if (allTouchesReleased) | 217 if (allTouchesReleased) |
| 222 m_touchScrollStarted = false; | 218 m_touchScrollStarted = false; |
| 223 | 219 |
| 224 return eventResult; | 220 return eventResult; |
| 225 } | 221 } |
| 226 | 222 |
| 227 void TouchEventManager::updateTargetAndRegionMapsForTouchStarts( | 223 void TouchEventManager::updateTargetAndRegionMapsForTouchStarts( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 239 // PointerEventManager. If it was the second touch there is a | 235 // PointerEventManager. If it was the second touch there is a |
| 240 // capturing documents for the touch and |m_touchSequenceDocument| | 236 // capturing documents for the touch and |m_touchSequenceDocument| |
| 241 // is not null. So if PointerEventManager should hit-test again | 237 // is not null. So if PointerEventManager should hit-test again |
| 242 // against |m_touchSequenceDocument| if the target set by | 238 // against |m_touchSequenceDocument| if the target set by |
| 243 // PointerEventManager was either null or not in | 239 // PointerEventManager was either null or not in |
| 244 // |m_touchSequenceDocument|. | 240 // |m_touchSequenceDocument|. |
| 245 if (m_touchSequenceDocument && (!touchInfo.touchNode | 241 if (m_touchSequenceDocument && (!touchInfo.touchNode |
| 246 || &touchInfo.touchNode->document() != m_touchSequenceDocument))
{ | 242 || &touchInfo.touchNode->document() != m_touchSequenceDocument))
{ |
| 247 if (m_touchSequenceDocument->frame()) { | 243 if (m_touchSequenceDocument->frame()) { |
| 248 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceD
ocument->frame()->view()->rootFrameToContents(touchInfo.point.pos())); | 244 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceD
ocument->frame()->view()->rootFrameToContents(touchInfo.point.pos())); |
| 249 result = EventHandler::hitTestResultInFrame(m_touchSequenceD
ocument->frame(), framePoint, hitType); | 245 result = EventHandlingUtil::hitTestResultInFrame(m_touchSequ
enceDocument->frame(), framePoint, hitType); |
| 250 Node* node = result.innerNode(); | 246 Node* node = result.innerNode(); |
| 251 if (!node) | 247 if (!node) |
| 252 continue; | 248 continue; |
| 253 if (isHTMLCanvasElement(node)) { | 249 if (isHTMLCanvasElement(node)) { |
| 254 HitTestCanvasResult* hitTestCanvasResult = toHTMLCanvasE
lement(node)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame()); | 250 HitTestCanvasResult* hitTestCanvasResult = toHTMLCanvasE
lement(node)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame()); |
| 255 if (hitTestCanvasResult->getControl()) | 251 if (hitTestCanvasResult->getControl()) |
| 256 node = hitTestCanvasResult->getControl(); | 252 node = hitTestCanvasResult->getControl(); |
| 257 touchInfo.region = hitTestCanvasResult->getId(); | 253 touchInfo.region = hitTestCanvasResult->getId(); |
| 258 } | 254 } |
| 259 // Touch events should not go to text nodes. | 255 // Touch events should not go to text nodes. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; | 520 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; |
| 525 break; | 521 break; |
| 526 default: | 522 default: |
| 527 NOTREACHED(); | 523 NOTREACHED(); |
| 528 return; | 524 return; |
| 529 } | 525 } |
| 530 Deprecation::countDeprecation(m_frame, feature); | 526 Deprecation::countDeprecation(m_frame, feature); |
| 531 } | 527 } |
| 532 | 528 |
| 533 } // namespace blink | 529 } // namespace blink |
| OLD | NEW |