Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1426643008: Cleaning up PointerIdManager and add id re-mapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a link error in the shared_library case Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 sendMouseEventsForNodeTransition(lastNodeUnderMouse.get(), m_nodeUnderMo use.get(), mouseEvent); 1612 sendMouseEventsForNodeTransition(lastNodeUnderMouse.get(), m_nodeUnderMo use.get(), mouseEvent);
1613 } 1613 }
1614 1614
1615 bool EventHandler::dispatchPointerEvent(Node* target, const AtomicString& eventT ype, 1615 bool EventHandler::dispatchPointerEvent(Node* target, const AtomicString& eventT ype,
1616 const PlatformMouseEvent& mouseEvent, Node* relatedTarget) 1616 const PlatformMouseEvent& mouseEvent, Node* relatedTarget)
1617 { 1617 {
1618 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 1618 if (!RuntimeEnabledFeatures::pointerEventEnabled())
1619 return false; 1619 return false;
1620 1620
1621 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eventTy pe, true, 1621 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eventTy pe, true,
1622 mouseEvent, relatedTarget, m_frame->document()->domWindow()); 1622 mouseEvent, relatedTarget, m_frame->document()->domWindow(),
1623 m_pointerIdManager.getPrimaryId(WebPointerProperties::PointerType::Mouse ));
1623 target->dispatchEvent(pointerEvent.get()); 1624 target->dispatchEvent(pointerEvent.get());
1624 return pointerEvent->defaultPrevented() || pointerEvent->defaultHandled(); 1625 return pointerEvent->defaultPrevented() || pointerEvent->defaultHandled();
1625 } 1626 }
1626 1627
1627 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, 1628 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode,
1628 const PlatformMouseEvent& mouseEvent) 1629 const PlatformMouseEvent& mouseEvent)
1629 { 1630 {
1630 ASSERT(exitedNode != enteredNode); 1631 ASSERT(exitedNode != enteredNode);
1631 1632
1632 // Dispatch pointerout/mouseout events 1633 // Dispatch pointerout/mouseout events
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 3650 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3650 return; 3651 return;
3651 3652
3652 // Iterate through the touch points, sending PointerEvents to the targets as required. 3653 // Iterate through the touch points, sending PointerEvents to the targets as required.
3653 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3654 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3654 TouchInfo& touchInfo = touchInfos[i]; 3655 TouchInfo& touchInfo = touchInfos[i];
3655 const PlatformTouchPoint& touchPoint = touchInfo.point; 3656 const PlatformTouchPoint& touchPoint = touchInfo.point;
3656 const unsigned& pointerId = touchPoint.id(); 3657 const unsigned& pointerId = touchPoint.id();
3657 const PlatformTouchPoint::State pointState = touchPoint.state(); 3658 const PlatformTouchPoint::State pointState = touchPoint.state();
3658 3659
3660
3659 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget) 3661 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget)
3660 continue; 3662 continue;
3661 3663
3662 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased 3664 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased
3663 || pointState == PlatformTouchPoint::TouchCancelled; 3665 || pointState == PlatformTouchPoint::TouchCancelled;
3664 const WebPointerProperties::PointerType pointerType = touchPoint.pointer Properties().pointerType; 3666 const WebPointerProperties::PointerType pointerType = touchPoint.pointer Properties().pointerType;
3665 3667
3666 if (pointState == PlatformTouchPoint::TouchPressed) 3668 // The id gets added the first time we call add which should TouchPresse d
3667 m_pointerIdManager.add(pointerType, pointerId); 3669 // and the consecutive calls with the same GeneratedPointer will return the same MappedId.
3670 const PointerIdManager::MappedId mappedId = m_pointerIdManager.add(Point erIdManager::GeneratedPointer(pointerType, pointerId));
mustaq 2015/11/20 20:13:53 This looks good. One concern is that EventHandler
Navid Zolghadr 2015/11/20 20:32:22 Then maybe in this case we can change PointerIdMan
3668 3671
3669 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create( 3672 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(
3670 pointerEventNameForTouchPointState(pointState), 3673 pointerEventNameForTouchPointState(pointState),
3671 m_pointerIdManager.isPrimary(pointerType, pointerId), 3674 m_pointerIdManager.isPrimary(mappedId),
3672 touchPoint, event.modifiers(), 3675 touchPoint, event.modifiers(),
3673 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), 3676 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(),
3674 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); 3677 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y(),
3678 mappedId);
3675 3679
3676 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); 3680 touchInfo.touchTarget->dispatchEvent(pointerEvent.get());
3677 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled(); 3681 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled();
3678 3682
3679 // Remove the released/cancelled id at the end to correctly determine pr imary id above. 3683 // Remove the released/cancelled id at the end to correctly determine pr imary id above.
3680 if (pointerReleasedOrCancelled) 3684 if (pointerReleasedOrCancelled)
3681 m_pointerIdManager.remove(pointerType, pointerId); 3685 m_pointerIdManager.remove(mappedId);
3682 } 3686 }
3683 } 3687 }
3684 3688
3685 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) 3689 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos)
3686 { 3690 {
3687 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 3691 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3688 return; 3692 return;
3689 3693
3690 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3694 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3691 TouchInfo& touchInfo = touchInfos[i]; 3695 TouchInfo& touchInfo = touchInfos[i];
3692 const PlatformTouchPoint& point = touchInfo.point; 3696 const PlatformTouchPoint& point = touchInfo.point;
3693 const unsigned& pointerId = point.id(); 3697 const unsigned& pointerId = point.id();
3694 const PlatformTouchPoint::State pointState = point.state(); 3698 const PlatformTouchPoint::State pointState = point.state();
3695 3699
3696 if (pointState == PlatformTouchPoint::TouchReleased 3700 if (pointState == PlatformTouchPoint::TouchReleased
3697 || pointState == PlatformTouchPoint::TouchCancelled) 3701 || pointState == PlatformTouchPoint::TouchCancelled)
3698 continue; 3702 continue;
3699 3703
3700 PointerEventInit pointerEventInit; 3704 PointerEventInit pointerEventInit;
3701 pointerEventInit.setPointerId(pointerId); 3705 pointerEventInit.setPointerId(pointerId);
3702 pointerEventInit.setBubbles(true); 3706 pointerEventInit.setBubbles(true);
3703 pointerEventInit.setCancelable(false); 3707 pointerEventInit.setCancelable(false);
3704 3708
3705 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create( 3709 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(
3706 EventTypeNames::pointercancel, pointerEventInit); 3710 EventTypeNames::pointercancel, pointerEventInit);
3707 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); 3711 touchInfo.touchTarget->dispatchEvent(pointerEvent.get());
3708 3712
3709 m_pointerIdManager.remove(WebPointerProperties::PointerType::Touch, poin terId); 3713 m_pointerIdManager.remove(PointerIdManager::GeneratedPointer(WebPointerP roperties::PointerType::Touch, pointerId));
3710 } 3714 }
3711 } 3715 }
3712 3716
3713 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, 3717 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event,
3714 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc hReleased) 3718 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc hReleased)
3715 { 3719 {
3716 // Build up the lists to use for the 'touches', 'targetTouches' and 3720 // Build up the lists to use for the 'touches', 'targetTouches' and
3717 // 'changedTouches' attributes in the JS event. See 3721 // 'changedTouches' attributes in the JS event. See
3718 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these 3722 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
3719 // lists fit together. 3723 // lists fit together.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4076 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4073 { 4077 {
4074 #if OS(MACOSX) 4078 #if OS(MACOSX)
4075 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4079 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4076 #else 4080 #else
4077 return PlatformEvent::AltKey; 4081 return PlatformEvent::AltKey;
4078 #endif 4082 #endif
4079 } 4083 }
4080 4084
4081 } // namespace blink 4085 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698