| OLD | NEW |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 case PlatformTouchPoint::TouchMoved: | 151 case PlatformTouchPoint::TouchMoved: |
| 152 return EventTypeNames::touchmove; | 152 return EventTypeNames::touchmove; |
| 153 case PlatformTouchPoint::TouchStationary: | 153 case PlatformTouchPoint::TouchStationary: |
| 154 // Fall through to default | 154 // Fall through to default |
| 155 default: | 155 default: |
| 156 ASSERT_NOT_REACHED(); | 156 ASSERT_NOT_REACHED(); |
| 157 return emptyAtom; | 157 return emptyAtom; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint::State
state) | |
| 162 { | |
| 163 switch (state) { | |
| 164 case PlatformTouchPoint::TouchReleased: | |
| 165 return EventTypeNames::pointerup; | |
| 166 case PlatformTouchPoint::TouchCancelled: | |
| 167 return EventTypeNames::pointercancel; | |
| 168 case PlatformTouchPoint::TouchPressed: | |
| 169 return EventTypeNames::pointerdown; | |
| 170 case PlatformTouchPoint::TouchMoved: | |
| 171 return EventTypeNames::pointermove; | |
| 172 case PlatformTouchPoint::TouchStationary: | |
| 173 // Fall through to default | |
| 174 default: | |
| 175 ASSERT_NOT_REACHED(); | |
| 176 return emptyAtom; | |
| 177 } | |
| 178 } | |
| 179 | |
| 180 const AtomicString& pointerEventNameForMouseEventName(const AtomicString& mouseE
ventName) | 161 const AtomicString& pointerEventNameForMouseEventName(const AtomicString& mouseE
ventName) |
| 181 { | 162 { |
| 182 #define RETURN_CORRESPONDING_PE_NAME(eventSuffix) \ | 163 #define RETURN_CORRESPONDING_PE_NAME(eventSuffix) \ |
| 183 if (mouseEventName == EventTypeNames::mouse##eventSuffix) {\ | 164 if (mouseEventName == EventTypeNames::mouse##eventSuffix) {\ |
| 184 return EventTypeNames::pointer##eventSuffix;\ | 165 return EventTypeNames::pointer##eventSuffix;\ |
| 185 } | 166 } |
| 186 | 167 |
| 187 RETURN_CORRESPONDING_PE_NAME(down); | 168 RETURN_CORRESPONDING_PE_NAME(down); |
| 188 RETURN_CORRESPONDING_PE_NAME(enter); | 169 RETURN_CORRESPONDING_PE_NAME(enter); |
| 189 RETURN_CORRESPONDING_PE_NAME(leave); | 170 RETURN_CORRESPONDING_PE_NAME(leave); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 visitor->trace(m_dragTarget); | 338 visitor->trace(m_dragTarget); |
| 358 visitor->trace(m_frameSetBeingResized); | 339 visitor->trace(m_frameSetBeingResized); |
| 359 visitor->trace(m_previousWheelScrolledNode); | 340 visitor->trace(m_previousWheelScrolledNode); |
| 360 visitor->trace(m_scrollbarHandlingScrollGesture); | 341 visitor->trace(m_scrollbarHandlingScrollGesture); |
| 361 visitor->trace(m_targetForTouchID); | 342 visitor->trace(m_targetForTouchID); |
| 362 visitor->trace(m_touchSequenceDocument); | 343 visitor->trace(m_touchSequenceDocument); |
| 363 visitor->trace(m_scrollGestureHandlingNode); | 344 visitor->trace(m_scrollGestureHandlingNode); |
| 364 visitor->trace(m_previousGestureScrolledNode); | 345 visitor->trace(m_previousGestureScrolledNode); |
| 365 visitor->trace(m_lastDeferredTapElement); | 346 visitor->trace(m_lastDeferredTapElement); |
| 366 visitor->trace(m_selectionController); | 347 visitor->trace(m_selectionController); |
| 348 visitor->trace(m_pointerEventManager); |
| 367 #endif | 349 #endif |
| 368 } | 350 } |
| 369 | 351 |
| 370 DragState& EventHandler::dragState() | 352 DragState& EventHandler::dragState() |
| 371 { | 353 { |
| 372 DEFINE_STATIC_LOCAL(Persistent<DragState>, state, (new DragState())); | 354 DEFINE_STATIC_LOCAL(Persistent<DragState>, state, (new DragState())); |
| 373 return *state; | 355 return *state; |
| 374 } | 356 } |
| 375 | 357 |
| 376 void EventHandler::clear() | 358 void EventHandler::clear() |
| (...skipping 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3730 void EventHandler::dispatchPointerEvents(const PlatformTouchEvent& event, | 3712 void EventHandler::dispatchPointerEvents(const PlatformTouchEvent& event, |
| 3731 WillBeHeapVector<TouchInfo>& touchInfos) | 3713 WillBeHeapVector<TouchInfo>& touchInfos) |
| 3732 { | 3714 { |
| 3733 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | 3715 if (!RuntimeEnabledFeatures::pointerEventEnabled()) |
| 3734 return; | 3716 return; |
| 3735 | 3717 |
| 3736 // Iterate through the touch points, sending PointerEvents to the targets as
required. | 3718 // Iterate through the touch points, sending PointerEvents to the targets as
required. |
| 3737 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3719 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3738 TouchInfo& touchInfo = touchInfos[i]; | 3720 TouchInfo& touchInfo = touchInfos[i]; |
| 3739 const PlatformTouchPoint& touchPoint = touchInfo.point; | 3721 const PlatformTouchPoint& touchPoint = touchInfo.point; |
| 3740 const PlatformTouchPoint::State pointState = touchPoint.state(); | |
| 3741 | 3722 |
| 3742 | 3723 |
| 3743 if (pointState == PlatformTouchPoint::TouchStationary || !touchInfo.know
nTarget) | 3724 if (touchPoint.state() == PlatformTouchPoint::TouchStationary |
| 3725 || !touchInfo.knownTarget) |
| 3744 continue; | 3726 continue; |
| 3745 | 3727 |
| 3746 bool pointerReleasedOrCancelled = pointState == PlatformTouchPoint::Touc
hReleased | 3728 touchInfo.consumed = m_pointerEventManager.sendTouchPointerEvent( |
| 3747 || pointState == PlatformTouchPoint::TouchCancelled; | 3729 touchInfo.touchTarget, |
| 3748 | |
| 3749 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventManager.cr
eate( | |
| 3750 pointerEventNameForTouchPointState(pointState), | |
| 3751 touchPoint, event.modifiers(), | 3730 touchPoint, event.modifiers(), |
| 3752 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), | 3731 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), |
| 3753 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); | 3732 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); |
| 3754 | |
| 3755 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturi
ng vs pointer event capturing | |
| 3756 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); | |
| 3757 | |
| 3758 touchInfo.consumed = pointerEvent->defaultPrevented() || pointerEvent->d
efaultHandled(); | |
| 3759 | |
| 3760 // Remove the released/cancelled id at the end to correctly determine pr
imary id above. | |
| 3761 if (pointerReleasedOrCancelled) | |
| 3762 m_pointerEventManager.remove(pointerEvent); | |
| 3763 } | 3733 } |
| 3764 } | 3734 } |
| 3765 | 3735 |
| 3766 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) | 3736 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) |
| 3767 { | 3737 { |
| 3768 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | 3738 if (!RuntimeEnabledFeatures::pointerEventEnabled()) |
| 3769 return; | 3739 return; |
| 3770 | 3740 |
| 3771 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3741 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
| 3772 TouchInfo& touchInfo = touchInfos[i]; | 3742 TouchInfo& touchInfo = touchInfos[i]; |
| 3773 const PlatformTouchPoint& point = touchInfo.point; | 3743 const PlatformTouchPoint& point = touchInfo.point; |
| 3774 const PlatformTouchPoint::State pointState = point.state(); | 3744 const PlatformTouchPoint::State pointState = point.state(); |
| 3775 | 3745 |
| 3776 if (pointState == PlatformTouchPoint::TouchReleased | 3746 if (pointState == PlatformTouchPoint::TouchReleased |
| 3777 || pointState == PlatformTouchPoint::TouchCancelled) | 3747 || pointState == PlatformTouchPoint::TouchCancelled) |
| 3778 continue; | 3748 continue; |
| 3779 | 3749 |
| 3780 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventManager.cr
eatePointerCancel(point); | 3750 m_pointerEventManager.sendTouchCancelPointerEvent( |
| 3781 | 3751 touchInfo.touchTarget, |
| 3782 // TODO(nzolghadr): crbug.com/579553 dealing with implicit touch capturi
ng vs pointer event capturing | 3752 point); |
| 3783 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); | |
| 3784 | |
| 3785 m_pointerEventManager.remove(pointerEvent); | |
| 3786 } | 3753 } |
| 3787 } | 3754 } |
| 3788 | 3755 |
| 3789 namespace { | 3756 namespace { |
| 3790 | 3757 |
| 3791 // Defining this class type local to dispatchTouchEvents() and annotating | 3758 // Defining this class type local to dispatchTouchEvents() and annotating |
| 3792 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning | 3759 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning |
| 3793 // that the local class doesn't provide a local definition for 'operator new'. | 3760 // that the local class doesn't provide a local definition for 'operator new'. |
| 3794 // Which it intentionally doesn't and shouldn't. | 3761 // Which it intentionally doesn't and shouldn't. |
| 3795 // | 3762 // |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4136 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4170 { | 4137 { |
| 4171 #if OS(MACOSX) | 4138 #if OS(MACOSX) |
| 4172 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4139 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 4173 #else | 4140 #else |
| 4174 return PlatformEvent::AltKey; | 4141 return PlatformEvent::AltKey; |
| 4175 #endif | 4142 #endif |
| 4176 } | 4143 } |
| 4177 | 4144 |
| 4178 } // namespace blink | 4145 } // namespace blink |
| OLD | NEW |