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

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: Fix EXPECT_EQ compilation error on Android Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 m_capturesDragging = false; 367 m_capturesDragging = false;
368 m_capturingMouseEventsNode = nullptr; 368 m_capturingMouseEventsNode = nullptr;
369 m_previousWheelScrolledNode = nullptr; 369 m_previousWheelScrolledNode = nullptr;
370 m_targetForTouchID.clear(); 370 m_targetForTouchID.clear();
371 m_touchSequenceDocument.clear(); 371 m_touchSequenceDocument.clear();
372 m_touchSequenceUserGestureToken.clear(); 372 m_touchSequenceUserGestureToken.clear();
373 clearGestureScrollState(); 373 clearGestureScrollState();
374 m_lastGestureScrollOverWidget = false; 374 m_lastGestureScrollOverWidget = false;
375 m_scrollbarHandlingScrollGesture = nullptr; 375 m_scrollbarHandlingScrollGesture = nullptr;
376 m_touchPressed = false; 376 m_touchPressed = false;
377 m_pointerIdManager.clear(); 377 m_pointerEventFactory.clear();
378 m_preventMouseEventForPointerTypeMouse = false; 378 m_preventMouseEventForPointerTypeMouse = false;
379 m_inPointerCanceledState = false; 379 m_inPointerCanceledState = false;
380 m_mouseDownMayStartDrag = false; 380 m_mouseDownMayStartDrag = false;
381 m_lastShowPressTimestamp = 0; 381 m_lastShowPressTimestamp = 0;
382 m_lastDeferredTapElement = nullptr; 382 m_lastDeferredTapElement = nullptr;
383 m_eventHandlerWillResetCapturingMouseEventsNode = false; 383 m_eventHandlerWillResetCapturingMouseEventsNode = false;
384 m_mouseDownMayStartAutoscroll = false; 384 m_mouseDownMayStartAutoscroll = false;
385 m_svgPan = false; 385 m_svgPan = false;
386 m_mouseDownPos = IntPoint(); 386 m_mouseDownPos = IntPoint();
387 m_mouseDownTimestamp = 0; 387 m_mouseDownTimestamp = 0;
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 if (lastNodeUnderMouse != m_nodeUnderMouse) 1611 if (lastNodeUnderMouse != m_nodeUnderMouse)
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 = m_pointerEventFactory.create (eventType,
1622 mouseEvent, relatedTarget, m_frame->document()->domWindow()); 1622 mouseEvent, relatedTarget, m_frame->document()->domWindow());
1623 target->dispatchEvent(pointerEvent.get()); 1623 target->dispatchEvent(pointerEvent.get());
1624 return pointerEvent->defaultPrevented() || pointerEvent->defaultHandled(); 1624 return pointerEvent->defaultPrevented() || pointerEvent->defaultHandled();
1625 } 1625 }
1626 1626
1627 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, 1627 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode,
1628 const PlatformMouseEvent& mouseEvent) 1628 const PlatformMouseEvent& mouseEvent)
1629 { 1629 {
1630 ASSERT(exitedNode != enteredNode); 1630 ASSERT(exitedNode != enteredNode);
1631 1631
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 void EventHandler::dispatchPointerEvents(const PlatformTouchEvent& event, 3647 void EventHandler::dispatchPointerEvents(const PlatformTouchEvent& event,
3648 WillBeHeapVector<TouchInfo>& touchInfos) 3648 WillBeHeapVector<TouchInfo>& touchInfos)
3649 { 3649 {
3650 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 3650 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3651 return; 3651 return;
3652 3652
3653 // 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.
3654 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3654 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3655 TouchInfo& touchInfo = touchInfos[i]; 3655 TouchInfo& touchInfo = touchInfos[i];
3656 const PlatformTouchPoint& touchPoint = touchInfo.point; 3656 const PlatformTouchPoint& touchPoint = touchInfo.point;
3657 const unsigned& pointerId = touchPoint.id();
3658 const PlatformTouchPoint::State pointState = touchPoint.state(); 3657 const PlatformTouchPoint::State pointState = touchPoint.state();
3659 3658
3659
3660 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget) 3660 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know nTarget)
3661 continue; 3661 continue;
3662 3662
3663 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased 3663 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc hReleased
3664 || pointState == PlatformTouchPoint::TouchCancelled; 3664 || pointState == PlatformTouchPoint::TouchCancelled;
3665 const WebPointerProperties::PointerType pointerType = touchPoint.pointer Properties().pointerType;
3666 3665
3667 if (pointState == PlatformTouchPoint::TouchPressed) 3666 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.cr eate(
3668 m_pointerIdManager.add(pointerType, pointerId);
3669
3670 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(
3671 pointerEventNameForTouchPointState(pointState), 3667 pointerEventNameForTouchPointState(pointState),
3672 m_pointerIdManager.isPrimary(pointerType, pointerId),
3673 touchPoint, event.modifiers(), 3668 touchPoint, event.modifiers(),
3674 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), 3669 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(),
3675 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); 3670 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y());
3676 3671
3677 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); 3672 touchInfo.touchTarget->dispatchEvent(pointerEvent.get());
3678 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled(); 3673 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d efaultHandled();
3679 3674
3680 // Remove the released/cancelled id at the end to correctly determine pr imary id above. 3675 // Remove the released/cancelled id at the end to correctly determine pr imary id above.
3681 if (pointerReleasedOrCancelled) 3676 if (pointerReleasedOrCancelled)
3682 m_pointerIdManager.remove(pointerType, pointerId); 3677 m_pointerEventFactory.remove(pointerEvent);
3683 } 3678 }
3684 } 3679 }
3685 3680
3686 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) 3681 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos)
3687 { 3682 {
3688 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 3683 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3689 return; 3684 return;
3690 3685
3691 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3686 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3692 TouchInfo& touchInfo = touchInfos[i]; 3687 TouchInfo& touchInfo = touchInfos[i];
3693 const PlatformTouchPoint& point = touchInfo.point; 3688 const PlatformTouchPoint& point = touchInfo.point;
3694 const unsigned& pointerId = point.id();
3695 const PlatformTouchPoint::State pointState = point.state(); 3689 const PlatformTouchPoint::State pointState = point.state();
3696 3690
3697 if (pointState == PlatformTouchPoint::TouchReleased 3691 if (pointState == PlatformTouchPoint::TouchReleased
3698 || pointState == PlatformTouchPoint::TouchCancelled) 3692 || pointState == PlatformTouchPoint::TouchCancelled)
3699 continue; 3693 continue;
3700 3694
3701 PointerEventInit pointerEventInit; 3695 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.cr eatePointerCancel(point);
3702 pointerEventInit.setPointerId(pointerId);
3703 pointerEventInit.setBubbles(true);
3704 pointerEventInit.setCancelable(false);
3705
3706 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(
3707 EventTypeNames::pointercancel, pointerEventInit);
3708 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); 3696 touchInfo.touchTarget->dispatchEvent(pointerEvent.get());
3709 3697
3710 m_pointerIdManager.remove(WebPointerProperties::PointerType::Touch, poin terId); 3698 m_pointerEventFactory.remove(pointerEvent);
3711 } 3699 }
3712 } 3700 }
3713 3701
3714 namespace { 3702 namespace {
3715 3703
3716 // Defining this class type local to dispatchTouchEvents() and annotating 3704 // Defining this class type local to dispatchTouchEvents() and annotating
3717 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning 3705 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning
3718 // that the local class doesn't provide a local definition for 'operator new'. 3706 // that the local class doesn't provide a local definition for 'operator new'.
3719 // Which it intentionally doesn't and shouldn't. 3707 // Which it intentionally doesn't and shouldn't.
3720 // 3708 //
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4076 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4089 { 4077 {
4090 #if OS(MACOSX) 4078 #if OS(MACOSX)
4091 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4079 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4092 #else 4080 #else
4093 return PlatformEvent::AltKey; 4081 return PlatformEvent::AltKey;
4094 #endif 4082 #endif
4095 } 4083 }
4096 4084
4097 } // namespace blink 4085 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698