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/DocumentUserGestureToken.h" | 7 #include "core/dom/DocumentUserGestureToken.h" |
| 8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 return pointerCaptureTargetTemp != pendingPointercaptureTargetTemp; | 551 return pointerCaptureTargetTemp != pendingPointercaptureTargetTemp; |
| 552 } | 552 } |
| 553 | 553 |
| 554 EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( | 554 EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| 555 PointerEvent* pointerEvent, | 555 PointerEvent* pointerEvent, |
| 556 EventTarget* hitTestTarget, | 556 EventTarget* hitTestTarget, |
| 557 const PlatformMouseEvent& mouseEvent, | 557 const PlatformMouseEvent& mouseEvent, |
| 558 bool sendMouseEvent) { | 558 bool sendMouseEvent) { |
| 559 processPendingPointerCapture(pointerEvent); | 559 processPendingPointerCapture(pointerEvent); |
| 560 | 560 |
| 561 if (!RuntimeEnabledFeatures::pointerEventV1SpecCapturingEnabled()) { | 561 if (!RuntimeEnabledFeatures::pointerEventV1SpecCapturingEnabled()) { |
|
mustaq
2016/11/22 21:46:36
Wait...one last thing:
- With pointerEventV1SpecC
Navid Zolghadr
2016/11/22 21:58:11
- I noticed this problem before actually. I could
mustaq
2016/11/23 15:38:47
I vote for #3.
Navid Zolghadr
2016/11/23 15:59:39
Alright. I work on this before this lands. This ch
| |
| 562 PointerCapturingMap::const_iterator it = | 562 PointerCapturingMap::const_iterator it = |
| 563 m_pointerCaptureTarget.find(pointerEvent->pointerId()); | 563 m_pointerCaptureTarget.find(pointerEvent->pointerId()); |
| 564 if (EventTarget* pointercaptureTarget = | 564 if (EventTarget* pointercaptureTarget = |
| 565 (it != m_pointerCaptureTarget.end()) ? it->value : nullptr) | 565 (it != m_pointerCaptureTarget.end()) ? it->value : nullptr) |
| 566 hitTestTarget = pointercaptureTarget; | 566 hitTestTarget = pointercaptureTarget; |
| 567 } | 567 } |
| 568 | 568 |
| 569 setNodeUnderPointer(pointerEvent, hitTestTarget); | 569 setNodeUnderPointer(pointerEvent, hitTestTarget); |
| 570 if (sendMouseEvent) { | 570 if (sendMouseEvent) { |
| 571 m_mouseEventManager->setNodeUnderMouse( | 571 m_mouseEventManager->setNodeUnderMouse( |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 591 // Re-target lostpointercapture to the document when the element is | 591 // Re-target lostpointercapture to the document when the element is |
| 592 // no longer participating in the tree. | 592 // no longer participating in the tree. |
| 593 EventTarget* target = pointerCaptureTarget; | 593 EventTarget* target = pointerCaptureTarget; |
| 594 if (target->toNode() && !target->toNode()->isConnected()) { | 594 if (target->toNode() && !target->toNode()->isConnected()) { |
| 595 target = target->toNode()->ownerDocument(); | 595 target = target->toNode()->ownerDocument(); |
| 596 } | 596 } |
| 597 dispatchPointerEvent(target, | 597 dispatchPointerEvent(target, |
| 598 m_pointerEventFactory.createPointerCaptureEvent( | 598 m_pointerEventFactory.createPointerCaptureEvent( |
| 599 pointerEvent, EventTypeNames::lostpointercapture)); | 599 pointerEvent, EventTypeNames::lostpointercapture)); |
| 600 } | 600 } |
| 601 // Note that If pendingPointerCaptureTarget is null dispatchPointerEvent | |
| 602 // automatically does nothing. | |
| 603 dispatchPointerEvent(pendingPointerCaptureTarget, | |
| 604 m_pointerEventFactory.createPointerCaptureEvent( | |
| 605 pointerEvent, EventTypeNames::gotpointercapture)); | |
| 606 | 601 |
| 607 if (pendingPointerCaptureTarget) | 602 if (pendingPointerCaptureTarget) { |
| 603 setNodeUnderPointer(pointerEvent, pendingPointerCaptureTarget); | |
| 604 dispatchPointerEvent(pendingPointerCaptureTarget, | |
| 605 m_pointerEventFactory.createPointerCaptureEvent( | |
| 606 pointerEvent, EventTypeNames::gotpointercapture)); | |
| 608 m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); | 607 m_pointerCaptureTarget.set(pointerId, pendingPointerCaptureTarget); |
| 609 else | 608 } else { |
| 610 m_pointerCaptureTarget.remove(pointerId); | 609 m_pointerCaptureTarget.remove(pointerId); |
| 610 } | |
| 611 } | 611 } |
| 612 | 612 |
| 613 void PointerEventManager::removeTargetFromPointerCapturingMapping( | 613 void PointerEventManager::removeTargetFromPointerCapturingMapping( |
| 614 PointerCapturingMap& map, | 614 PointerCapturingMap& map, |
| 615 const EventTarget* target) { | 615 const EventTarget* target) { |
| 616 // We could have kept a reverse mapping to make this deletion possibly | 616 // We could have kept a reverse mapping to make this deletion possibly |
| 617 // faster but it adds some code complication which might not be worth of | 617 // faster but it adds some code complication which might not be worth of |
| 618 // the performance improvement considering there might not be a lot of | 618 // the performance improvement considering there might not be a lot of |
| 619 // active pointer or pointer captures at the same time. | 619 // active pointer or pointer captures at the same time. |
| 620 PointerCapturingMap tmp = map; | 620 PointerCapturingMap tmp = map; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 return true; | 719 return true; |
| 720 } | 720 } |
| 721 return false; | 721 return false; |
| 722 } | 722 } |
| 723 | 723 |
| 724 EventTarget* PointerEventManager::getMouseCapturingNode() { | 724 EventTarget* PointerEventManager::getMouseCapturingNode() { |
| 725 return getCapturingNode(PointerEventFactory::s_mouseId); | 725 return getCapturingNode(PointerEventFactory::s_mouseId); |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace blink | 728 } // namespace blink |
| OLD | NEW |