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/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/ExecutionContextTask.h" | 8 #include "core/dom/ExecutionContextTask.h" |
| 9 #include "core/dom/shadow/FlatTreeTraversal.h" | 9 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 10 #include "core/events/MouseEvent.h" | 10 #include "core/events/MouseEvent.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 return EventTypeNames::pointerup; | 30 return EventTypeNames::pointerup; |
| 31 case PlatformTouchPoint::TouchCancelled: | 31 case PlatformTouchPoint::TouchCancelled: |
| 32 return EventTypeNames::pointercancel; | 32 return EventTypeNames::pointercancel; |
| 33 case PlatformTouchPoint::TouchPressed: | 33 case PlatformTouchPoint::TouchPressed: |
| 34 return EventTypeNames::pointerdown; | 34 return EventTypeNames::pointerdown; |
| 35 case PlatformTouchPoint::TouchMoved: | 35 case PlatformTouchPoint::TouchMoved: |
| 36 return EventTypeNames::pointermove; | 36 return EventTypeNames::pointermove; |
| 37 case PlatformTouchPoint::TouchStationary: | 37 case PlatformTouchPoint::TouchStationary: |
| 38 // Fall through to default | 38 // Fall through to default |
| 39 default: | 39 default: |
| 40 ASSERT_NOT_REACHED(); | 40 NOTREACHED(); |
| 41 return emptyAtom; | 41 return emptyAtom; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool isInDocument(EventTarget* n) | 45 bool isInDocument(EventTarget* n) |
| 46 { | 46 { |
| 47 return n && n->toNode() && n->toNode()->isConnected(); | 47 return n && n->toNode() && n->toNode()->isConnected(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebInputEventResult dispatchMouseEvent( | 50 WebInputEventResult dispatchMouseEvent( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 204 |
| 205 void PointerEventManager::sendBoundaryEvents( | 205 void PointerEventManager::sendBoundaryEvents( |
| 206 EventTarget* exitedTarget, | 206 EventTarget* exitedTarget, |
| 207 EventTarget* enteredTarget, | 207 EventTarget* enteredTarget, |
| 208 PointerEvent* pointerEvent, | 208 PointerEvent* pointerEvent, |
| 209 const PlatformMouseEvent& mouseEvent, bool sendMouseEvent) | 209 const PlatformMouseEvent& mouseEvent, bool sendMouseEvent) |
| 210 { | 210 { |
| 211 if (exitedTarget == enteredTarget) | 211 if (exitedTarget == enteredTarget) |
| 212 return; | 212 return; |
| 213 | 213 |
| 214 if (EventTarget* capturingTarget = getCapturingNode(pointerEvent->pointerId( ))) { | |
| 215 if (capturingTarget == exitedTarget) | |
| 216 enteredTarget = nullptr; | |
| 217 else if (capturingTarget == enteredTarget) | |
| 218 exitedTarget = nullptr; | |
| 219 else | |
| 220 return; | |
| 221 } | |
| 222 | |
| 223 // Dispatch pointerout/mouseout events | 214 // Dispatch pointerout/mouseout events |
| 224 if (isInDocument(exitedTarget)) { | 215 if (isInDocument(exitedTarget)) { |
| 225 if (!sendMouseEvent) { | 216 if (!sendMouseEvent) { |
| 226 dispatchPointerEvent(exitedTarget, m_pointerEventFactory.createPoint erBoundaryEvent( | 217 dispatchPointerEvent(exitedTarget, m_pointerEventFactory.createPoint erBoundaryEvent( |
| 227 pointerEvent, EventTypeNames::pointerout, enteredTarget)); | 218 pointerEvent, EventTypeNames::pointerout, enteredTarget)); |
| 228 } else { | 219 } else { |
| 229 dispatchMouseEvent(exitedTarget, | 220 dispatchMouseEvent(exitedTarget, |
| 230 EventTypeNames::mouseout, | 221 EventTypeNames::mouseout, |
| 231 mouseEventWithRegion(exitedTarget->toNode(), mouseEvent), | 222 mouseEventWithRegion(exitedTarget->toNode(), mouseEvent), |
| 232 enteredTarget); | 223 enteredTarget); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 } else { | 305 } else { |
| 315 dispatchMouseEvent(enteredAncestors[i-1].get(), | 306 dispatchMouseEvent(enteredAncestors[i-1].get(), |
| 316 EventTypeNames::mouseenter, mouseEvent, exitedTarget, | 307 EventTypeNames::mouseenter, mouseEvent, exitedTarget, |
| 317 0, !enteredNodeHasCapturingAncestor); | 308 0, !enteredNodeHasCapturingAncestor); |
| 318 } | 309 } |
| 319 } | 310 } |
| 320 } | 311 } |
| 321 | 312 |
| 322 void PointerEventManager::setNodeUnderPointer( | 313 void PointerEventManager::setNodeUnderPointer( |
| 323 PointerEvent* pointerEvent, | 314 PointerEvent* pointerEvent, |
| 324 EventTarget* target, | 315 EventTarget* target) |
| 325 bool sendEvent) | |
| 326 { | 316 { |
| 327 if (m_nodeUnderPointer.contains(pointerEvent->pointerId())) { | 317 if (m_nodeUnderPointer.contains(pointerEvent->pointerId())) { |
| 328 EventTargetAttributes node = m_nodeUnderPointer.get( | 318 EventTargetAttributes node = m_nodeUnderPointer.get( |
| 329 pointerEvent->pointerId()); | 319 pointerEvent->pointerId()); |
| 330 if (!target) { | 320 if (!target) { |
| 331 m_nodeUnderPointer.remove(pointerEvent->pointerId()); | 321 m_nodeUnderPointer.remove(pointerEvent->pointerId()); |
| 332 } else if (target | 322 } else if (target |
| 333 != m_nodeUnderPointer.get(pointerEvent->pointerId()).target) { | 323 != m_nodeUnderPointer.get(pointerEvent->pointerId()).target) { |
| 334 m_nodeUnderPointer.set(pointerEvent->pointerId(), | 324 m_nodeUnderPointer.set(pointerEvent->pointerId(), |
| 335 EventTargetAttributes(target, false)); | 325 EventTargetAttributes(target, false)); |
| 336 } | 326 } |
| 337 if (sendEvent) | 327 sendBoundaryEvents(node.target, target, pointerEvent); |
| 338 sendBoundaryEvents(node.target, target, pointerEvent); | |
| 339 } else if (target) { | 328 } else if (target) { |
| 340 m_nodeUnderPointer.add(pointerEvent->pointerId(), | 329 m_nodeUnderPointer.add(pointerEvent->pointerId(), |
| 341 EventTargetAttributes(target, false)); | 330 EventTargetAttributes(target, false)); |
| 342 if (sendEvent) | 331 sendBoundaryEvents(nullptr, target, pointerEvent); |
| 343 sendBoundaryEvents(nullptr, target, pointerEvent); | |
| 344 } | 332 } |
| 345 } | 333 } |
| 346 | 334 |
| 347 void PointerEventManager::blockTouchPointers() | 335 void PointerEventManager::blockTouchPointers() |
| 348 { | 336 { |
| 349 if (m_inCanceledStateForPointerTypeTouch) | 337 if (m_inCanceledStateForPointerTypeTouch) |
| 350 return; | 338 return; |
| 351 m_inCanceledStateForPointerTypeTouch = true; | 339 m_inCanceledStateForPointerTypeTouch = true; |
| 352 | 340 |
| 353 Vector<int> touchPointerIds | 341 Vector<int> touchPointerIds |
| 354 = m_pointerEventFactory.getPointerIdsOfType(WebPointerProperties::Pointe rType::Touch); | 342 = m_pointerEventFactory.getPointerIdsOfType(WebPointerProperties::Pointe rType::Touch); |
| 355 | 343 |
| 356 for (int pointerId : touchPointerIds) { | 344 for (int pointerId : touchPointerIds) { |
| 357 PointerEvent* pointerEvent | 345 PointerEvent* pointerEvent |
| 358 = m_pointerEventFactory.createPointerCancelEvent( | 346 = m_pointerEventFactory.createPointerCancelEvent( |
| 359 pointerId, WebPointerProperties::PointerType::Touch); | 347 pointerId, WebPointerProperties::PointerType::Touch); |
| 360 | 348 |
| 361 ASSERT(m_nodeUnderPointer.contains(pointerId)); | 349 DCHECK(m_nodeUnderPointer.contains(pointerId)); |
| 362 EventTarget* target = m_nodeUnderPointer.get(pointerId).target; | 350 EventTarget* target = m_nodeUnderPointer.get(pointerId).target; |
| 363 | 351 |
| 364 processCaptureAndPositionOfPointerEvent(pointerEvent, target); | 352 processCaptureAndPositionOfPointerEvent(pointerEvent, target); |
| 365 | 353 |
| 366 // TODO(nzolghadr): This event follows implicit TE capture. The actual t arget | 354 // TODO(nzolghadr): This event follows implicit TE capture. The actual t arget |
| 367 // would depend on PE capturing. Perhaps need to split TE/PE event path upstream? | 355 // would depend on PE capturing. Perhaps need to split TE/PE event path upstream? |
| 368 // crbug.com/579553. | 356 // crbug.com/579553. |
| 369 dispatchPointerEvent( | 357 dispatchPointerEvent( |
| 370 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()) , | 358 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()) , |
| 371 pointerEvent); | 359 pointerEvent); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 relatedTarget, m_frame->document()->domWindow()); | 528 relatedTarget, m_frame->document()->domWindow()); |
| 541 | 529 |
| 542 // This is for when the mouse is released outside of the page. | 530 // This is for when the mouse is released outside of the page. |
| 543 if (pointerEvent->type() == EventTypeNames::pointermove | 531 if (pointerEvent->type() == EventTypeNames::pointermove |
| 544 && !pointerEvent->buttons() | 532 && !pointerEvent->buttons() |
| 545 && pointerEvent->isPrimary()) { | 533 && pointerEvent->isPrimary()) { |
| 546 m_preventMouseEventForPointerType[toPointerTypeIndex( | 534 m_preventMouseEventForPointerType[toPointerTypeIndex( |
| 547 mouseEvent.pointerProperties().pointerType)] = false; | 535 mouseEvent.pointerProperties().pointerType)] = false; |
| 548 } | 536 } |
| 549 | 537 |
| 550 processCaptureAndPositionOfPointerEvent(pointerEvent, target, | 538 EventTarget* pointerEventTarget = processCaptureAndPositionOfPointerEvent(po interEvent, target, |
| 551 lastNodeUnderMouse, mouseEvent, true, true); | 539 lastNodeUnderMouse, mouseEvent, true, true); |
| 552 | 540 |
| 553 EventTarget* effectiveTarget = | 541 EventTarget* effectiveTarget = |
| 554 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()); | 542 getEffectiveTargetForPointerEvent(pointerEventTarget, pointerEvent->poin terId()); |
| 555 | 543 |
| 556 WebInputEventResult result = | 544 WebInputEventResult result = |
| 557 dispatchPointerEvent(effectiveTarget, pointerEvent); | 545 dispatchPointerEvent(effectiveTarget, pointerEvent); |
| 558 | 546 |
| 559 if (result != WebInputEventResult::NotHandled | 547 if (result != WebInputEventResult::NotHandled |
| 560 && pointerEvent->type() == EventTypeNames::pointerdown | 548 && pointerEvent->type() == EventTypeNames::pointerdown |
| 561 && pointerEvent->isPrimary()) { | 549 && pointerEvent->isPrimary()) { |
| 562 m_preventMouseEventForPointerType[toPointerTypeIndex( | 550 m_preventMouseEventForPointerType[toPointerTypeIndex( |
| 563 mouseEvent.pointerProperties().pointerType)] = true; | 551 mouseEvent.pointerProperties().pointerType)] = true; |
| 564 } | 552 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 m_touchIdsForCanceledPointerdowns.clear(); | 601 m_touchIdsForCanceledPointerdowns.clear(); |
| 614 m_nodeUnderPointer.clear(); | 602 m_nodeUnderPointer.clear(); |
| 615 m_pointerCaptureTarget.clear(); | 603 m_pointerCaptureTarget.clear(); |
| 616 m_pendingPointerCaptureTarget.clear(); | 604 m_pendingPointerCaptureTarget.clear(); |
| 617 } | 605 } |
| 618 | 606 |
| 619 bool PointerEventManager::getPointerCaptureState(int pointerId, | 607 bool PointerEventManager::getPointerCaptureState(int pointerId, |
| 620 EventTarget** pointerCaptureTarget, | 608 EventTarget** pointerCaptureTarget, |
| 621 EventTarget** pendingPointerCaptureTarget) | 609 EventTarget** pendingPointerCaptureTarget) |
| 622 { | 610 { |
| 623 PointerCapturingMap::iterator it; | 611 PointerCapturingMap::const_iterator it; |
| 624 | 612 |
| 625 it = m_pointerCaptureTarget.find(pointerId); | 613 it = m_pointerCaptureTarget.find(pointerId); |
| 626 EventTarget* pointercaptureTargetTemp = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; | 614 EventTarget* pointerCaptureTargetTemp = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; |
| 627 it = m_pendingPointerCaptureTarget.find(pointerId); | 615 it = m_pendingPointerCaptureTarget.find(pointerId); |
| 628 EventTarget* pendingPointercaptureTargetTemp = (it != m_pendingPointerCaptur eTarget.end()) ? it->value : nullptr; | 616 EventTarget* pendingPointercaptureTargetTemp = (it != m_pendingPointerCaptur eTarget.end()) ? it->value : nullptr; |
| 629 | 617 |
| 630 if (pointerCaptureTarget) | 618 if (pointerCaptureTarget) |
| 631 *pointerCaptureTarget = pointercaptureTargetTemp; | 619 *pointerCaptureTarget = pointerCaptureTargetTemp; |
| 632 if (pendingPointerCaptureTarget) | 620 if (pendingPointerCaptureTarget) |
| 633 *pendingPointerCaptureTarget = pendingPointercaptureTargetTemp; | 621 *pendingPointerCaptureTarget = pendingPointercaptureTargetTemp; |
| 634 | 622 |
| 635 return pointercaptureTargetTemp != pendingPointercaptureTargetTemp; | 623 return pointerCaptureTargetTemp != pendingPointercaptureTargetTemp; |
| 636 } | 624 } |
| 637 | 625 |
| 638 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 626 EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| 639 PointerEvent* pointerEvent, | 627 PointerEvent* pointerEvent, |
| 640 EventTarget* hitTestTarget, | 628 EventTarget* hitTestTarget, |
| 641 EventTarget* lastNodeUnderMouse, | 629 EventTarget* lastNodeUnderMouse, |
| 642 const PlatformMouseEvent& mouseEvent, | 630 const PlatformMouseEvent& mouseEvent, |
| 643 bool sendMouseEvent, bool setPointerPosition) | 631 bool sendMouseEvent, bool setPointerPosition) |
| 644 { | 632 { |
| 645 bool isCaptureChanged = false; | 633 if (setPointerPosition) { |
| 634 processPendingPointerCapture(pointerEvent->pointerId()); | |
| 646 | 635 |
| 647 if (setPointerPosition) { | 636 PointerCapturingMap::const_iterator it = m_pointerCaptureTarget.find(poi nterEvent->pointerId()); |
| 648 isCaptureChanged = processPendingPointerCapture(pointerEvent, | 637 EventTarget* pointercaptureTarget = (it != m_pointerCaptureTarget.end()) ? it->value : nullptr; |
|
dtapuska
2016/07/22 15:57:39
collapse this into the if;
like if(EventTarget* p
Navid Zolghadr
2016/07/22 16:39:24
Done.
| |
| 649 hitTestTarget, mouseEvent, sendMouseEvent); | 638 if (pointercaptureTarget) |
| 650 // If there was a change in capturing processPendingPointerCapture has | 639 hitTestTarget = pointercaptureTarget; |
| 651 // already taken care of transition events. So we don't need to send the | 640 |
| 652 // transition events here. | 641 setNodeUnderPointer(pointerEvent, hitTestTarget); |
| 653 setNodeUnderPointer(pointerEvent, hitTestTarget, !isCaptureChanged); | |
| 654 } | 642 } |
| 655 if (sendMouseEvent && !isCaptureChanged) { | 643 if (sendMouseEvent) { |
| 656 // lastNodeUnderMouse is needed here because it is still stored in Event Handler. | 644 // lastNodeUnderMouse is needed here because it is still stored in Event Handler. |
| 657 sendBoundaryEvents(lastNodeUnderMouse, hitTestTarget, | 645 sendBoundaryEvents(lastNodeUnderMouse, hitTestTarget, |
| 658 pointerEvent, mouseEvent, true); | 646 pointerEvent, mouseEvent, true); |
| 659 } | 647 } |
| 648 return hitTestTarget; | |
| 660 } | 649 } |
| 661 | 650 |
| 662 void PointerEventManager::immediatelyProcessPendingPointerCapture(int pointerId) | 651 void PointerEventManager::processPendingPointerCapture(int pointerId) |
| 663 { | 652 { |
| 664 EventTarget* pointerCaptureTarget; | 653 EventTarget* pointerCaptureTarget; |
| 665 EventTarget* pendingPointerCaptureTarget; | 654 EventTarget* pendingPointerCaptureTarget; |
| 666 const bool isCaptureChanged = getPointerCaptureState(pointerId, | 655 const bool isCaptureChanged = getPointerCaptureState(pointerId, |
| 667 &pointerCaptureTarget, &pendingPointerCaptureTarget); | 656 &pointerCaptureTarget, &pendingPointerCaptureTarget); |
| 668 | 657 |
| 669 if (!isCaptureChanged) | 658 if (!isCaptureChanged) |
| 670 return; | 659 return; |
| 671 | 660 |
| 672 if (pointerCaptureTarget) { | 661 if (pointerCaptureTarget) { |
| 673 // Re-target lostpointercapture to the document when the element is | 662 // Re-target lostpointercapture to the document when the element is |
| 674 // no longer participating in the tree. | 663 // no longer participating in the tree. |
| 675 EventTarget* target = pointerCaptureTarget; | 664 EventTarget* target = pointerCaptureTarget; |
| 676 if (target->toNode() | 665 if (target->toNode() |
| 677 && !target->toNode()->isConnected()) { | 666 && !target->toNode()->isConnected()) { |
| 678 target = target->toNode()->ownerDocument(); | 667 target = target->toNode()->ownerDocument(); |
| 679 } | 668 } |
| 680 dispatchPointerEvent(target, | 669 dispatchPointerEvent(target, |
| 681 m_pointerEventFactory.createPointerCaptureEvent( | 670 m_pointerEventFactory.createPointerCaptureEvent( |
| 682 pointerId, EventTypeNames::lostpointercapture)); | 671 pointerId, EventTypeNames::lostpointercapture)); |
| 683 } | 672 } |
| 684 dispatchPointerEvent(pendingPointerCaptureTarget, | 673 dispatchPointerEvent(pendingPointerCaptureTarget, |
|
mustaq
2016/07/22 16:01:01
Caught here again, sorry. Please add a comment why
Navid Zolghadr
2016/07/22 16:39:24
Done.
| |
| 685 m_pointerEventFactory.createPointerCaptureEvent( | 674 m_pointerEventFactory.createPointerCaptureEvent( |
| 686 pointerId, EventTypeNames::gotpointercapture)); | 675 pointerId, EventTypeNames::gotpointercapture)); |
| 687 | 676 |
| 688 // Setting |m_pointerCaptureTarget| comes at the end to prevent the infinite | 677 // Setting |m_pointerCaptureTarget| comes at the end to prevent the infinite |
| 689 // loop if js calls set/releasepointercapture in got/lostpointercapture | 678 // loop if js calls set/releasepointercapture in got/lostpointercapture |
| 690 // handlers. | 679 // handlers. |
| 691 if (pendingPointerCaptureTarget) | 680 if (pendingPointerCaptureTarget) |
| 692 m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); | 681 m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); |
| 693 else | 682 else |
| 694 m_pointerCaptureTarget.remove(pointerId); | 683 m_pointerCaptureTarget.remove(pointerId); |
| 695 } | 684 } |
| 696 | 685 |
| 697 // TODO(crbug.com/629921): This function should be merged with |immediatelyProce ssPendingPointerCapture| | |
| 698 // when we stop hit-testing while a pointer is captured. | |
| 699 bool PointerEventManager::processPendingPointerCapture( | |
| 700 PointerEvent* pointerEvent, | |
| 701 EventTarget* hitTestTarget, | |
| 702 const PlatformMouseEvent& mouseEvent, bool sendMouseEvent) | |
| 703 { | |
| 704 int pointerId = pointerEvent->pointerId(); | |
| 705 EventTarget* pointerCaptureTarget; | |
| 706 EventTarget* pendingPointerCaptureTarget; | |
| 707 const bool isCaptureChanged = getPointerCaptureState(pointerId, | |
| 708 &pointerCaptureTarget, &pendingPointerCaptureTarget); | |
| 709 const EventTargetAttributes &nodeUnderPointerAtt = | |
| 710 m_nodeUnderPointer.contains(pointerId) | |
| 711 ? m_nodeUnderPointer.get(pointerId) : EventTargetAttributes(); | |
| 712 | |
| 713 if (isCaptureChanged) { | |
| 714 if ((hitTestTarget != nodeUnderPointerAtt.target | |
| 715 || (pendingPointerCaptureTarget | |
| 716 && pendingPointerCaptureTarget != nodeUnderPointerAtt.target)) | |
| 717 && nodeUnderPointerAtt.hasRecievedOverEvent) { | |
| 718 if (sendMouseEvent) { | |
| 719 // Send pointer event transitions as the line after this if | |
| 720 // block sends the mouse events | |
| 721 sendBoundaryEvents(nodeUnderPointerAtt.target, nullptr, | |
| 722 pointerEvent); | |
| 723 } | |
| 724 sendBoundaryEvents(nodeUnderPointerAtt.target, nullptr, | |
| 725 pointerEvent, mouseEvent, sendMouseEvent); | |
| 726 } | |
| 727 if (pointerCaptureTarget) { | |
| 728 // Re-target lostpointercapture to the document when the element is | |
| 729 // no longer participating in the tree. | |
| 730 EventTarget* target = pointerCaptureTarget; | |
| 731 if (target->toNode() | |
| 732 && !target->toNode()->isConnected()) { | |
| 733 target = target->toNode()->ownerDocument(); | |
| 734 } | |
| 735 dispatchPointerEvent(target, | |
| 736 m_pointerEventFactory.createPointerCaptureEvent( | |
| 737 pointerId, EventTypeNames::lostpointercapture)); | |
| 738 } | |
| 739 } | |
| 740 | |
| 741 // Set pointerCaptureTarget from pendingPointerCaptureTarget. This does | |
| 742 // affect the behavior of sendBoundaryEvents function. So the | |
| 743 // ordering of the surrounding blocks of code for sending transition events | |
| 744 // are important. | |
| 745 if (pendingPointerCaptureTarget) | |
| 746 m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); | |
| 747 else | |
| 748 m_pointerCaptureTarget.remove(pointerId); | |
| 749 | |
| 750 if (isCaptureChanged) { | |
| 751 dispatchPointerEvent(pendingPointerCaptureTarget, | |
| 752 m_pointerEventFactory.createPointerCaptureEvent( | |
| 753 pointerId, EventTypeNames::gotpointercapture)); | |
| 754 if ((pendingPointerCaptureTarget == hitTestTarget | |
| 755 || !pendingPointerCaptureTarget) | |
| 756 && (nodeUnderPointerAtt.target != hitTestTarget | |
| 757 || !nodeUnderPointerAtt.hasRecievedOverEvent)) { | |
| 758 if (sendMouseEvent) { | |
| 759 // Send pointer event transitions as the line after this if | |
| 760 // block sends the mouse events | |
| 761 sendBoundaryEvents(nullptr, hitTestTarget, pointerEvent); | |
| 762 } | |
| 763 sendBoundaryEvents(nullptr, hitTestTarget, pointerEvent, | |
| 764 mouseEvent, sendMouseEvent); | |
| 765 } | |
| 766 } | |
| 767 return isCaptureChanged; | |
| 768 } | |
| 769 | |
| 770 void PointerEventManager::removeTargetFromPointerCapturingMapping( | 686 void PointerEventManager::removeTargetFromPointerCapturingMapping( |
| 771 PointerCapturingMap& map, const EventTarget* target) | 687 PointerCapturingMap& map, const EventTarget* target) |
| 772 { | 688 { |
| 773 // We could have kept a reverse mapping to make this deletion possibly | 689 // We could have kept a reverse mapping to make this deletion possibly |
| 774 // faster but it adds some code complication which might not be worth of | 690 // faster but it adds some code complication which might not be worth of |
| 775 // the performance improvement considering there might not be a lot of | 691 // the performance improvement considering there might not be a lot of |
| 776 // active pointer or pointer captures at the same time. | 692 // active pointer or pointer captures at the same time. |
| 777 PointerCapturingMap tmp = map; | 693 PointerCapturingMap tmp = map; |
| 778 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { | 694 for (PointerCapturingMap::iterator it = tmp.begin(); it != tmp.end(); ++it) { |
| 779 if (it->value == target) | 695 if (it->value == target) |
| 780 map.remove(it->key); | 696 map.remove(it->key); |
| 781 } | 697 } |
| 782 } | 698 } |
| 783 | 699 |
| 784 EventTarget* PointerEventManager::getCapturingNode(int pointerId) | 700 EventTarget* PointerEventManager::getCapturingNode(int pointerId) const |
| 785 { | 701 { |
| 786 if (m_pointerCaptureTarget.contains(pointerId)) | 702 if (m_pointerCaptureTarget.contains(pointerId)) |
| 787 return m_pointerCaptureTarget.get(pointerId); | 703 return m_pointerCaptureTarget.get(pointerId); |
| 788 return nullptr; | 704 return nullptr; |
| 789 } | 705 } |
| 790 | 706 |
| 791 void PointerEventManager::removePointer( | 707 void PointerEventManager::removePointer( |
| 792 PointerEvent* pointerEvent) | 708 PointerEvent* pointerEvent) |
| 793 { | 709 { |
| 794 int pointerId = pointerEvent->pointerId(); | 710 int pointerId = pointerEvent->pointerId(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 uint32_t firstId = m_touchIdsForCanceledPointerdowns.first(); | 783 uint32_t firstId = m_touchIdsForCanceledPointerdowns.first(); |
| 868 if (firstId > uniqueTouchEventId) | 784 if (firstId > uniqueTouchEventId) |
| 869 return false; | 785 return false; |
| 870 m_touchIdsForCanceledPointerdowns.takeFirst(); | 786 m_touchIdsForCanceledPointerdowns.takeFirst(); |
| 871 if (firstId == uniqueTouchEventId) | 787 if (firstId == uniqueTouchEventId) |
| 872 return true; | 788 return true; |
| 873 } | 789 } |
| 874 return false; | 790 return false; |
| 875 } | 791 } |
| 876 | 792 |
| 793 EventTarget* PointerEventManager::getMouseCapturingNode() const | |
| 794 { | |
| 795 return getCapturingNode(1); | |
|
dtapuska
2016/07/22 15:57:39
This is an odd little constant. Can we name it for
mustaq
2016/07/22 16:01:01
May be reuse the constant from PE factory?
Navid Zolghadr
2016/07/22 16:39:24
:) yeah. I was trying to avoid making that constan
| |
| 796 } | |
| 797 | |
| 877 DEFINE_TRACE(PointerEventManager) | 798 DEFINE_TRACE(PointerEventManager) |
| 878 { | 799 { |
| 879 visitor->trace(m_frame); | 800 visitor->trace(m_frame); |
| 880 visitor->trace(m_nodeUnderPointer); | 801 visitor->trace(m_nodeUnderPointer); |
| 881 visitor->trace(m_pointerCaptureTarget); | 802 visitor->trace(m_pointerCaptureTarget); |
| 882 visitor->trace(m_pendingPointerCaptureTarget); | 803 visitor->trace(m_pendingPointerCaptureTarget); |
| 883 visitor->trace(m_touchEventManager); | 804 visitor->trace(m_touchEventManager); |
| 884 } | 805 } |
| 885 | 806 |
| 886 | 807 |
| 887 } // namespace blink | 808 } // namespace blink |
| OLD | NEW |