| 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/ElementTraversal.h" | 7 #include "core/dom/ElementTraversal.h" |
| 8 #include "core/dom/shadow/FlatTreeTraversal.h" | 8 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 9 #include "core/events/MouseEvent.h" | 9 #include "core/events/MouseEvent.h" |
| 10 #include "core/html/HTMLCanvasElement.h" | 10 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 if (sendEvent) | 304 if (sendEvent) |
| 305 sendNodeTransitionEvents(node.target, target, pointerEvent); | 305 sendNodeTransitionEvents(node.target, target, pointerEvent); |
| 306 } else if (target) { | 306 } else if (target) { |
| 307 m_nodeUnderPointer.add(pointerEvent->pointerId(), | 307 m_nodeUnderPointer.add(pointerEvent->pointerId(), |
| 308 EventTargetAttributes(target, false)); | 308 EventTargetAttributes(target, false)); |
| 309 if (sendEvent) | 309 if (sendEvent) |
| 310 sendNodeTransitionEvents(nullptr, target, pointerEvent); | 310 sendNodeTransitionEvents(nullptr, target, pointerEvent); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 void PointerEventManager::sendTouchCancelPointerEvent(EventTarget* target, const
PlatformTouchPoint& point) | 314 void PointerEventManager::blockTouchPointers() |
| 315 { | 315 { |
| 316 PointerEvent* pointerEvent = m_pointerEventFactory.createPointerCancelEvent(
point); | 316 if (m_inCanceledStateForPointerTypeTouch) |
| 317 return; |
| 318 m_inCanceledStateForPointerTypeTouch = true; |
| 317 | 319 |
| 320 HeapVector<int> touchPointerIds |
| 321 = m_pointerEventFactory.getPointerIdsOfType(WebPointerProperties::Pointe
rType::Touch); |
| 318 | 322 |
| 319 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 323 for (int pointerId : touchPointerIds) { |
| 324 PointerEvent* pointerEvent |
| 325 = m_pointerEventFactory.createPointerCancelEvent( |
| 326 pointerId, WebPointerProperties::PointerType::Touch); |
| 320 | 327 |
| 321 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 328 ASSERT(m_nodeUnderPointer.contains(pointerId)); |
| 322 dispatchPointerEvent( | 329 EventTarget* target = m_nodeUnderPointer.get(pointerId).target; |
| 323 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | |
| 324 pointerEvent); | |
| 325 | 330 |
| 326 releasePointerCapture(pointerEvent->pointerId()); | 331 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| 327 | 332 |
| 328 // Sending the leave/out events and lostpointercapture | 333 // TODO(nzolghadr): This event follows implicit TE capture. The actual t
arget |
| 329 // because the next touch event will have a different id. So delayed | 334 // would depend on PE capturing. Perhaps need to split TE/PE event path
upstream? |
| 330 // sending of lostpointercapture won't work here. | 335 // crbug.com/579553. |
| 331 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); | 336 dispatchPointerEvent( |
| 337 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId())
, |
| 338 pointerEvent); |
| 332 | 339 |
| 333 removePointer(pointerEvent); | 340 releasePointerCapture(pointerEvent->pointerId()); |
| 341 |
| 342 // Sending the leave/out events and lostpointercapture |
| 343 // because the next touch event will have a different id. So delayed |
| 344 // sending of lostpointercapture won't work here. |
| 345 processCaptureAndPositionOfPointerEvent(pointerEvent, nullptr); |
| 346 |
| 347 removePointer(pointerEvent); |
| 348 } |
| 349 } |
| 350 |
| 351 void PointerEventManager::unblockTouchPointers() |
| 352 { |
| 353 m_inCanceledStateForPointerTypeTouch = false; |
| 334 } | 354 } |
| 335 | 355 |
| 336 WebInputEventResult PointerEventManager::sendTouchPointerEvent( | 356 WebInputEventResult PointerEventManager::sendTouchPointerEvent( |
| 337 EventTarget* target, | 357 EventTarget* target, |
| 338 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, | 358 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, |
| 339 const double width, const double height, | 359 const double width, const double height, |
| 340 const double clientX, const double clientY) | 360 const double clientX, const double clientY) |
| 341 { | 361 { |
| 362 if (m_inCanceledStateForPointerTypeTouch) |
| 363 return WebInputEventResult::NotHandled; |
| 364 |
| 342 PointerEvent* pointerEvent = | 365 PointerEvent* pointerEvent = |
| 343 m_pointerEventFactory.create( | 366 m_pointerEventFactory.create( |
| 344 pointerEventNameForTouchPointState(touchPoint.state()), | 367 pointerEventNameForTouchPointState(touchPoint.state()), |
| 345 touchPoint, modifiers, width, height, clientX, clientY); | 368 touchPoint, modifiers, width, height, clientX, clientY); |
| 346 | 369 |
| 347 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 370 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| 348 | 371 |
| 349 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing | 372 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturing v
s pointer event capturing |
| 350 WebInputEventResult result = dispatchPointerEvent( | 373 WebInputEventResult result = dispatchPointerEvent( |
| 351 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), | 374 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 452 } |
| 430 | 453 |
| 431 PointerEventManager::~PointerEventManager() | 454 PointerEventManager::~PointerEventManager() |
| 432 { | 455 { |
| 433 } | 456 } |
| 434 | 457 |
| 435 void PointerEventManager::clear() | 458 void PointerEventManager::clear() |
| 436 { | 459 { |
| 437 for (auto& entry : m_preventMouseEventForPointerType) | 460 for (auto& entry : m_preventMouseEventForPointerType) |
| 438 entry = false; | 461 entry = false; |
| 462 m_inCanceledStateForPointerTypeTouch = false; |
| 439 m_pointerEventFactory.clear(); | 463 m_pointerEventFactory.clear(); |
| 440 m_nodeUnderPointer.clear(); | 464 m_nodeUnderPointer.clear(); |
| 441 m_pointerCaptureTarget.clear(); | 465 m_pointerCaptureTarget.clear(); |
| 442 m_pendingPointerCaptureTarget.clear(); | 466 m_pendingPointerCaptureTarget.clear(); |
| 443 } | 467 } |
| 444 | 468 |
| 445 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 469 void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| 446 PointerEvent* pointerEvent, | 470 PointerEvent* pointerEvent, |
| 447 EventTarget* hitTestTarget, | 471 EventTarget* hitTestTarget, |
| 448 EventTarget* lastNodeUnderMouse, | 472 EventTarget* lastNodeUnderMouse, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 EventTarget* PointerEventManager::getCapturingNode(int pointerId) | 582 EventTarget* PointerEventManager::getCapturingNode(int pointerId) |
| 559 { | 583 { |
| 560 if (m_pointerCaptureTarget.contains(pointerId)) | 584 if (m_pointerCaptureTarget.contains(pointerId)) |
| 561 return m_pointerCaptureTarget.get(pointerId); | 585 return m_pointerCaptureTarget.get(pointerId); |
| 562 return nullptr; | 586 return nullptr; |
| 563 } | 587 } |
| 564 | 588 |
| 565 void PointerEventManager::removePointer( | 589 void PointerEventManager::removePointer( |
| 566 PointerEvent* pointerEvent) | 590 PointerEvent* pointerEvent) |
| 567 { | 591 { |
| 568 if (m_pointerEventFactory.remove(pointerEvent)) { | 592 int pointerId = pointerEvent->pointerId(); |
| 569 int pointerId = pointerEvent->pointerId(); | 593 if (m_pointerEventFactory.remove(pointerId)) { |
| 570 m_pendingPointerCaptureTarget.remove(pointerId); | 594 m_pendingPointerCaptureTarget.remove(pointerId); |
| 571 m_pointerCaptureTarget.remove(pointerId); | 595 m_pointerCaptureTarget.remove(pointerId); |
| 572 m_nodeUnderPointer.remove(pointerId); | 596 m_nodeUnderPointer.remove(pointerId); |
| 573 } | 597 } |
| 574 } | 598 } |
| 575 | 599 |
| 576 void PointerEventManager::elementRemoved(EventTarget* target) | 600 void PointerEventManager::elementRemoved(EventTarget* target) |
| 577 { | 601 { |
| 578 removeTargetFromPointerCapturingMapping(m_pendingPointerCaptureTarget, targe
t); | 602 removeTargetFromPointerCapturingMapping(m_pendingPointerCaptureTarget, targe
t); |
| 579 } | 603 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 608 | 632 |
| 609 DEFINE_TRACE(PointerEventManager) | 633 DEFINE_TRACE(PointerEventManager) |
| 610 { | 634 { |
| 611 visitor->trace(m_nodeUnderPointer); | 635 visitor->trace(m_nodeUnderPointer); |
| 612 visitor->trace(m_pointerCaptureTarget); | 636 visitor->trace(m_pointerCaptureTarget); |
| 613 visitor->trace(m_pendingPointerCaptureTarget); | 637 visitor->trace(m_pendingPointerCaptureTarget); |
| 614 } | 638 } |
| 615 | 639 |
| 616 | 640 |
| 617 } // namespace blink | 641 } // namespace blink |
| OLD | NEW |