| 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/PointerEventManager.h" | 5 #include "core/input/PointerEventManager.h" |
| 6 | 6 |
| 7 #include "core/dom/shadow/FlatTreeTraversal.h" | 7 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 8 #include "core/events/MouseEvent.h" | 8 #include "core/events/MouseEvent.h" |
| 9 #include "core/input/EventHandler.h" | 9 #include "core/input/EventHandler.h" |
| 10 | 10 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if (sendEvent) | 276 if (sendEvent) |
| 277 sendNodeTransitionEvents(node.target, target, pointerEvent); | 277 sendNodeTransitionEvents(node.target, target, pointerEvent); |
| 278 } else if (target) { | 278 } else if (target) { |
| 279 m_nodeUnderPointer.add(pointerEvent->pointerId(), | 279 m_nodeUnderPointer.add(pointerEvent->pointerId(), |
| 280 EventTargetAttributes(target, false)); | 280 EventTargetAttributes(target, false)); |
| 281 if (sendEvent) | 281 if (sendEvent) |
| 282 sendNodeTransitionEvents(nullptr, target, pointerEvent); | 282 sendNodeTransitionEvents(nullptr, target, pointerEvent); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 void PointerEventManager::sendTouchCancelPointerEvent(EventTarget* target, const
PlatformTouchPoint& point) | 286 void PointerEventManager::blockTouchPointers() |
| 287 { | 287 { |
| 288 PointerEvent* pointerEvent = m_pointerEventFactory.createPointerCancelEvent(
point); | 288 if (m_inCanceledStateForPointerTypeTouch) |
| 289 return; |
| 290 m_inCanceledStateForPointerTypeTouch = true; |
| 289 | 291 |
| 292 HeapVector<int> touchPointerIds |
| 293 = m_pointerEventFactory.getPointerIdsOfType(WebPointerProperties::Pointe
rType::Touch); |
| 290 | 294 |
| 291 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 295 for (int pointerId : touchPointerIds) { |
| 296 PointerEvent* pointerEvent |
| 297 = m_pointerEventFactory.createPointerCancelEvent( |
| 298 pointerId, WebPointerProperties::PointerType::Touch); |
| 292 | 299 |
| 293 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 300 ASSERT(m_nodeUnderPointer.contains(pointerId)); |
| 294 dispatchPointerEvent( | 301 EventTarget* target = m_nodeUnderPointer.get(pointerId).target; |
| 295 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | |
| 296 pointerEvent); | |
| 297 | 302 |
| 298 releasePointerCapture(pointerEvent->pointerId()); | 303 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| 299 | 304 |
| 300 // Sending the leave/out events and lostpointercapture | 305 // TODO(nzolghadr): This event follows implicit TE capture. The actual t
arget |
| 301 // because the next touch event will have a different id. So delayed | 306 // would depend on PE capturing. Perhaps need to split TE/PE event path
upstream? |
| 302 // sending of lostpointercapture won't work here. | 307 // crbug.com/579553. |
| 303 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); | 308 dispatchPointerEvent( |
| 309 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId())
, |
| 310 pointerEvent); |
| 304 | 311 |
| 305 removePointer(pointerEvent); | 312 releasePointerCapture(pointerEvent->pointerId()); |
| 313 |
| 314 // Sending the leave/out events and lostpointercapture |
| 315 // because the next touch event will have a different id. So delayed |
| 316 // sending of lostpointercapture won't work here. |
| 317 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); |
| 318 |
| 319 removePointer(pointerEvent); |
| 320 } |
| 321 } |
| 322 |
| 323 void PointerEventManager::unblockTouchPointers() |
| 324 { |
| 325 m_inCanceledStateForPointerTypeTouch = false; |
| 306 } | 326 } |
| 307 | 327 |
| 308 WebInputEventResult PointerEventManager::sendTouchPointerEvent( | 328 WebInputEventResult PointerEventManager::sendTouchPointerEvent( |
| 309 EventTarget* target, | 329 EventTarget* target, |
| 310 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, | 330 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, |
| 311 const double width, const double height, | 331 const double width, const double height, |
| 312 const double clientX, const double clientY) | 332 const double clientX, const double clientY) |
| 313 { | 333 { |
| 334 if (m_inCanceledStateForPointerTypeTouch) |
| 335 return WebInputEventResult::NotHandled; |
| 336 |
| 314 PointerEvent* pointerEvent = | 337 PointerEvent* pointerEvent = |
| 315 m_pointerEventFactory.create( | 338 m_pointerEventFactory.create( |
| 316 pointerEventNameForTouchPointState(touchPoint.state()), | 339 pointerEventNameForTouchPointState(touchPoint.state()), |
| 317 touchPoint, modifiers, width, height, clientX, clientY); | 340 touchPoint, modifiers, width, height, clientX, clientY); |
| 318 | 341 |
| 319 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 342 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| 320 | 343 |
| 321 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 344 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing |
| 322 WebInputEventResult result = dispatchPointerEvent( | 345 WebInputEventResult result = dispatchPointerEvent( |
| 323 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | 346 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 clear(); | 414 clear(); |
| 392 } | 415 } |
| 393 | 416 |
| 394 PointerEventManager::~PointerEventManager() | 417 PointerEventManager::~PointerEventManager() |
| 395 { | 418 { |
| 396 } | 419 } |
| 397 | 420 |
| 398 void PointerEventManager::clear() | 421 void PointerEventManager::clear() |
| 399 { | 422 { |
| 400 m_preventMouseEventForPointerTypeMouse = false; | 423 m_preventMouseEventForPointerTypeMouse = false; |
| 424 m_inCanceledStateForPointerTypeTouch = false; |
| 401 m_pointerEventFactory.clear(); | 425 m_pointerEventFactory.clear(); |
| 402 m_nodeUnderPointer.clear(); | 426 m_nodeUnderPointer.clear(); |
| 403 m_pointerCaptureTarget.clear(); | 427 m_pointerCaptureTarget.clear(); |
| 404 m_pendingPointerCaptureTarget.clear(); | 428 m_pendingPointerCaptureTarget.clear(); |
| 405 } | 429 } |
| 406 | 430 |
| 407 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 431 void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| 408 PointerEvent* pointerEvent, | 432 PointerEvent* pointerEvent, |
| 409 EventTarget* hitTestTarget, | 433 EventTarget* hitTestTarget, |
| 410 EventTarget* lastNodeUnderMouse, | 434 EventTarget* lastNodeUnderMouse, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 EventTarget* PointerEventManager::getCapturingNode(int pointerId) | 544 EventTarget* PointerEventManager::getCapturingNode(int pointerId) |
| 521 { | 545 { |
| 522 if (m_pointerCaptureTarget.contains(pointerId)) | 546 if (m_pointerCaptureTarget.contains(pointerId)) |
| 523 return m_pointerCaptureTarget.get(pointerId); | 547 return m_pointerCaptureTarget.get(pointerId); |
| 524 return nullptr; | 548 return nullptr; |
| 525 } | 549 } |
| 526 | 550 |
| 527 void PointerEventManager::removePointer( | 551 void PointerEventManager::removePointer( |
| 528 PointerEvent* pointerEvent) | 552 PointerEvent* pointerEvent) |
| 529 { | 553 { |
| 530 if (m_pointerEventFactory.remove(pointerEvent)) { | 554 int pointerId = pointerEvent->pointerId(); |
| 531 int pointerId = pointerEvent->pointerId(); | 555 if (m_pointerEventFactory.remove(pointerId)) { |
| 532 m_pendingPointerCaptureTarget.remove(pointerId); | 556 m_pendingPointerCaptureTarget.remove(pointerId); |
| 533 m_pointerCaptureTarget.remove(pointerId); | 557 m_pointerCaptureTarget.remove(pointerId); |
| 534 m_nodeUnderPointer.remove(pointerId); | 558 m_nodeUnderPointer.remove(pointerId); |
| 535 } | 559 } |
| 536 } | 560 } |
| 537 | 561 |
| 538 void PointerEventManager::elementRemoved(EventTarget* target) | 562 void PointerEventManager::elementRemoved(EventTarget* target) |
| 539 { | 563 { |
| 540 removeTargetFromPointerCapturingMapping(m_pendingPointerCaptureTarget, targe
t); | 564 removeTargetFromPointerCapturingMapping(m_pendingPointerCaptureTarget, targe
t); |
| 541 } | 565 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 570 | 594 |
| 571 DEFINE_TRACE(PointerEventManager) | 595 DEFINE_TRACE(PointerEventManager) |
| 572 { | 596 { |
| 573 visitor->trace(m_nodeUnderPointer); | 597 visitor->trace(m_nodeUnderPointer); |
| 574 visitor->trace(m_pointerCaptureTarget); | 598 visitor->trace(m_pointerCaptureTarget); |
| 575 visitor->trace(m_pendingPointerCaptureTarget); | 599 visitor->trace(m_pendingPointerCaptureTarget); |
| 576 } | 600 } |
| 577 | 601 |
| 578 | 602 |
| 579 } // namespace blink | 603 } // namespace blink |
| OLD | NEW |