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 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3703 pointerEventInit.setCancelable(false); | 3703 pointerEventInit.setCancelable(false); |
3704 | 3704 |
3705 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create( | 3705 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create( |
3706 EventTypeNames::pointercancel, pointerEventInit); | 3706 EventTypeNames::pointercancel, pointerEventInit); |
3707 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); | 3707 touchInfo.touchTarget->dispatchEvent(pointerEvent.get()); |
3708 | 3708 |
3709 m_pointerIdManager.remove(WebPointerProperties::PointerType::Touch, poin
terId); | 3709 m_pointerIdManager.remove(WebPointerProperties::PointerType::Touch, poin
terId); |
3710 } | 3710 } |
3711 } | 3711 } |
3712 | 3712 |
| 3713 namespace { |
| 3714 |
| 3715 // Defining this class type local to dispatchTouchEvents() and annotating |
| 3716 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning |
| 3717 // that the local class doesn't provide a local definition for 'operator new'. |
| 3718 // Which it intentionally doesn't and shouldn't. |
| 3719 // |
| 3720 // Work around such toolchain bugginess by lifting out the type, thereby |
| 3721 // taking it out of C4822's reach. |
| 3722 class ChangedTouches final { |
| 3723 STACK_ALLOCATED(); |
| 3724 public: |
| 3725 // The touches corresponding to the particular change state this struct |
| 3726 // instance represents. |
| 3727 RefPtrWillBeMember<TouchList> m_touches; |
| 3728 |
| 3729 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; |
| 3730 // Set of targets involved in m_touches. |
| 3731 EventTargetSet m_targets; |
| 3732 }; |
| 3733 |
| 3734 } // namespace |
| 3735 |
3713 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, | 3736 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, |
3714 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc
hReleased) | 3737 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc
hReleased) |
3715 { | 3738 { |
3716 // Build up the lists to use for the 'touches', 'targetTouches' and | 3739 // Build up the lists to use for the 'touches', 'targetTouches' and |
3717 // 'changedTouches' attributes in the JS event. See | 3740 // 'changedTouches' attributes in the JS event. See |
3718 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3741 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
3719 // lists fit together. | 3742 // lists fit together. |
3720 | 3743 |
3721 // Holds the complete set of touches on the screen. | 3744 // Holds the complete set of touches on the screen. |
3722 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); | 3745 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); |
3723 | 3746 |
3724 // A different view on the 'touches' list above, filtered and grouped by | 3747 // A different view on the 'touches' list above, filtered and grouped by |
3725 // event target. Used for the 'targetTouches' list in the JS event. | 3748 // event target. Used for the 'targetTouches' list in the JS event. |
3726 using TargetTouchesHeapMap = WillBeHeapHashMap<EventTarget*, RefPtrWillBeMem
ber<TouchList>>; | 3749 using TargetTouchesHeapMap = WillBeHeapHashMap<EventTarget*, RefPtrWillBeMem
ber<TouchList>>; |
3727 TargetTouchesHeapMap touchesByTarget; | 3750 TargetTouchesHeapMap touchesByTarget; |
3728 | 3751 |
3729 // Array of touches per state, used to assemble the 'changedTouches' list. | 3752 // Array of touches per state, used to assemble the 'changedTouches' list. |
3730 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; | 3753 ChangedTouches changedTouches[PlatformTouchPoint::TouchStateEnd]; |
3731 struct { | |
3732 // The touches corresponding to the particular change state this struct | |
3733 // instance represents. | |
3734 RefPtrWillBeMember<TouchList> m_touches; | |
3735 // Set of targets involved in m_touches. | |
3736 EventTargetSet m_targets; | |
3737 } changedTouches[PlatformTouchPoint::TouchStateEnd]; | |
3738 | 3754 |
3739 for (unsigned i = 0; i < touchInfos.size(); ++i) { | 3755 for (unsigned i = 0; i < touchInfos.size(); ++i) { |
3740 const TouchInfo& touchInfo = touchInfos[i]; | 3756 const TouchInfo& touchInfo = touchInfos[i]; |
3741 const PlatformTouchPoint& point = touchInfo.point; | 3757 const PlatformTouchPoint& point = touchInfo.point; |
3742 PlatformTouchPoint::State pointState = point.state(); | 3758 PlatformTouchPoint::State pointState = point.state(); |
3743 | 3759 |
3744 if (touchInfo.consumed) | 3760 if (touchInfo.consumed) |
3745 continue; | 3761 continue; |
3746 | 3762 |
3747 RefPtrWillBeRawPtr<Touch> touch = Touch::create( | 3763 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 | 3807 |
3792 bool swallowedEvent = false; | 3808 bool swallowedEvent = false; |
3793 | 3809 |
3794 // Now iterate through the changedTouches list and m_targets within it, send
ing | 3810 // Now iterate through the changedTouches list and m_targets within it, send
ing |
3795 // TouchEvents to the targets as required. | 3811 // TouchEvents to the targets as required. |
3796 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { | 3812 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { |
3797 if (!changedTouches[state].m_touches) | 3813 if (!changedTouches[state].m_touches) |
3798 continue; | 3814 continue; |
3799 | 3815 |
3800 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca
st<PlatformTouchPoint::State>(state))); | 3816 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca
st<PlatformTouchPoint::State>(state))); |
3801 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 3817 for (const auto& eventTarget : changedTouches[state].m_targets) { |
3802 for (const RefPtrWillBeMember<EventTarget>& eventTarget : targetsForStat
e) { | |
3803 EventTarget* touchEventTarget = eventTarget.get(); | 3818 EventTarget* touchEventTarget = eventTarget.get(); |
3804 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( | 3819 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( |
3805 touches.get(), touchesByTarget.get(touchEventTarget), changedTou
ches[state].m_touches.get(), | 3820 touches.get(), touchesByTarget.get(touchEventTarget), changedTou
ches[state].m_touches.get(), |
3806 eventName, touchEventTarget->toNode()->document().domWindow(), | 3821 eventName, touchEventTarget->toNode()->document().domWindow(), |
3807 event.modifiers(), event.cancelable(), event.causesScrollingIfUn
canceled(), event.timestamp()); | 3822 event.modifiers(), event.cancelable(), event.causesScrollingIfUn
canceled(), event.timestamp()); |
3808 | 3823 |
3809 touchEventTarget->dispatchEvent(touchEvent.get()); | 3824 touchEventTarget->dispatchEvent(touchEvent.get()); |
3810 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); | 3825 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); |
3811 } | 3826 } |
3812 } | 3827 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4072 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4087 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
4073 { | 4088 { |
4074 #if OS(MACOSX) | 4089 #if OS(MACOSX) |
4075 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4090 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
4076 #else | 4091 #else |
4077 return PlatformEvent::AltKey; | 4092 return PlatformEvent::AltKey; |
4078 #endif | 4093 #endif |
4079 } | 4094 } |
4080 | 4095 |
4081 } // namespace blink | 4096 } // namespace blink |
OLD | NEW |