| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "sky/engine/core/events/GestureEvent.h" | 28 #include "sky/engine/core/events/GestureEvent.h" |
| 29 #include "sky/engine/wtf/text/AtomicString.h" | 29 #include "sky/engine/wtf/text/AtomicString.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 PassRefPtr<GestureEvent> GestureEvent::create(PassRefPtr<AbstractView> view, con
st PlatformGestureEvent& event) | 33 PassRefPtr<GestureEvent> GestureEvent::create(PassRefPtr<AbstractView> view, con
st PlatformGestureEvent& event) |
| 34 { | 34 { |
| 35 AtomicString eventType; | 35 AtomicString eventType; |
| 36 float deltaX = 0; | 36 float deltaX = 0; |
| 37 float deltaY = 0; | 37 float deltaY = 0; |
| 38 float velocityX = 0; |
| 39 float velocityY = 0; |
| 38 switch (event.type()) { | 40 switch (event.type()) { |
| 39 case PlatformEvent::GestureScrollBegin: | 41 case PlatformEvent::GestureScrollBegin: |
| 40 eventType = EventTypeNames::gesturescrollstart; break; | 42 eventType = EventTypeNames::gesturescrollstart; |
| 43 break; |
| 41 case PlatformEvent::GestureScrollEnd: | 44 case PlatformEvent::GestureScrollEnd: |
| 42 eventType = EventTypeNames::gesturescrollend; break; | 45 eventType = EventTypeNames::gesturescrollend; |
| 46 break; |
| 43 case PlatformEvent::GestureScrollUpdate: | 47 case PlatformEvent::GestureScrollUpdate: |
| 44 case PlatformEvent::GestureScrollUpdateWithoutPropagation: | 48 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
| 45 // Only deltaX/Y are used when converting this | 49 // Only deltaX/Y are used when converting this |
| 46 // back to a PlatformGestureEvent. | 50 // back to a PlatformGestureEvent. |
| 47 eventType = EventTypeNames::gesturescrollupdate; | 51 eventType = EventTypeNames::gesturescrollupdate; |
| 48 deltaX = event.deltaX(); | 52 deltaX = event.deltaX(); |
| 49 deltaY = event.deltaY(); | 53 deltaY = event.deltaY(); |
| 54 velocityX = event.velocityX(); |
| 55 velocityY = event.velocityY(); |
| 50 break; | 56 break; |
| 51 case PlatformEvent::GestureTap: | 57 case PlatformEvent::GestureTap: |
| 52 eventType = EventTypeNames::gesturetap; break; | 58 eventType = EventTypeNames::gesturetap; |
| 59 break; |
| 53 case PlatformEvent::GestureTapUnconfirmed: | 60 case PlatformEvent::GestureTapUnconfirmed: |
| 54 eventType = EventTypeNames::gesturetapunconfirmed; break; | 61 eventType = EventTypeNames::gesturetapunconfirmed; |
| 62 break; |
| 55 case PlatformEvent::GestureTapDown: | 63 case PlatformEvent::GestureTapDown: |
| 56 eventType = EventTypeNames::gesturetapdown; break; | 64 eventType = EventTypeNames::gesturetapdown; |
| 65 break; |
| 57 case PlatformEvent::GestureShowPress: | 66 case PlatformEvent::GestureShowPress: |
| 58 eventType = EventTypeNames::gestureshowpress; break; | 67 eventType = EventTypeNames::gestureshowpress; |
| 68 break; |
| 59 case PlatformEvent::GestureTwoFingerTap: | 69 case PlatformEvent::GestureTwoFingerTap: |
| 60 case PlatformEvent::GestureLongPress: | 70 case PlatformEvent::GestureLongPress: |
| 61 case PlatformEvent::GesturePinchBegin: | 71 case PlatformEvent::GesturePinchBegin: |
| 62 case PlatformEvent::GesturePinchEnd: | 72 case PlatformEvent::GesturePinchEnd: |
| 63 case PlatformEvent::GesturePinchUpdate: | 73 case PlatformEvent::GesturePinchUpdate: |
| 64 case PlatformEvent::GestureTapDownCancel: | 74 case PlatformEvent::GestureTapDownCancel: |
| 65 default: | 75 default: |
| 66 return nullptr; | 76 return nullptr; |
| 67 } | 77 } |
| 68 return adoptRef(new GestureEvent(eventType, view, event.globalPosition().x()
, event.globalPosition().y(), event.position().x(), event.position().y(), event.
ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), deltaX, deltaY)); | 78 return adoptRef(new GestureEvent(eventType, view, event.globalPosition().x()
, event.globalPosition().y(), event.position().x(), event.position().y(), event.
ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), deltaX, deltaY, ve
locityX, velocityY)); |
| 79 } |
| 80 |
| 81 PassRefPtr<GestureEvent> GestureEvent::create(const AtomicString& type, const Ge
stureEventInit& initializer) |
| 82 { |
| 83 return adoptRef(new GestureEvent(type, initializer)); |
| 69 } | 84 } |
| 70 | 85 |
| 71 const AtomicString& GestureEvent::interfaceName() const | 86 const AtomicString& GestureEvent::interfaceName() const |
| 72 { | 87 { |
| 73 // FIXME: when a GestureEvent.idl interface is defined, return the string "G
estureEvent". | 88 return EventNames::GestureEvent; |
| 74 // Until that happens, do not advertise an interface that does not exist, si
nce it will | |
| 75 // trip up the bindings integrity checks. | |
| 76 return UIEvent::interfaceName(); | |
| 77 } | 89 } |
| 78 | 90 |
| 79 bool GestureEvent::isGestureEvent() const | 91 bool GestureEvent::isGestureEvent() const |
| 80 { | 92 { |
| 81 return true; | 93 return true; |
| 82 } | 94 } |
| 83 | 95 |
| 84 GestureEvent::GestureEvent() | 96 GestureEvent::GestureEvent() |
| 85 : m_deltaX(0) | 97 : m_deltaX(0) |
| 86 , m_deltaY(0) | 98 , m_deltaY(0) |
| 99 , m_velocityX(0) |
| 100 , m_velocityY(0) |
| 87 { | 101 { |
| 88 } | 102 } |
| 89 | 103 |
| 90 GestureEvent::GestureEvent(const AtomicString& type, PassRefPtr<AbstractView> vi
ew, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKe
y, bool shiftKey, bool metaKey, float deltaX, float deltaY) | 104 GestureEvent::GestureEvent(const AtomicString& type, const GestureEventInit& ini
tializer) |
| 105 : MouseRelatedEvent(type, initializer.bubbles, initializer.cancelable, initi
alizer.view, initializer.detail, IntPoint(initializer.screenX, initializer.scree
nY), |
| 106 IntPoint(0 /* pageX */, 0 /* pageY */), |
| 107 IntPoint(0 /* movementX */, 0 /* movementY */), |
| 108 initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializ
er.metaKey, false /* isSimulated */) |
| 109 , m_deltaX(initializer.deltaX) |
| 110 , m_deltaY(initializer.deltaY) |
| 111 , m_velocityX(initializer.velocityX) |
| 112 , m_velocityY(initializer.velocityY) |
| 113 { |
| 114 } |
| 115 |
| 116 GestureEvent::GestureEvent(const AtomicString& type, PassRefPtr<AbstractView> vi
ew, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKe
y, bool shiftKey, bool metaKey, float deltaX, float deltaY, float velocityX, flo
at velocityY) |
| 91 : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), I
ntPoint(clientX, clientY), IntPoint(0, 0), ctrlKey, altKey, shiftKey, metaKey) | 117 : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), I
ntPoint(clientX, clientY), IntPoint(0, 0), ctrlKey, altKey, shiftKey, metaKey) |
| 92 , m_deltaX(deltaX) | 118 , m_deltaX(deltaX) |
| 93 , m_deltaY(deltaY) | 119 , m_deltaY(deltaY) |
| 120 , m_velocityX(velocityX) |
| 121 , m_velocityY(velocityY) |
| 94 { | 122 { |
| 95 } | 123 } |
| 96 | 124 |
| 97 GestureEventDispatchMediator::GestureEventDispatchMediator(PassRefPtr<GestureEve
nt> gestureEvent) | 125 GestureEventDispatchMediator::GestureEventDispatchMediator(PassRefPtr<GestureEve
nt> gestureEvent) |
| 98 : EventDispatchMediator(gestureEvent) | 126 : EventDispatchMediator(gestureEvent) |
| 99 { | 127 { |
| 100 } | 128 } |
| 101 | 129 |
| 102 GestureEvent* GestureEventDispatchMediator::event() const | 130 GestureEvent* GestureEventDispatchMediator::event() const |
| 103 { | 131 { |
| 104 return toGestureEvent(EventDispatchMediator::event()); | 132 return toGestureEvent(EventDispatchMediator::event()); |
| 105 } | 133 } |
| 106 | 134 |
| 107 bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) co
nst | 135 bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) co
nst |
| 108 { | 136 { |
| 109 dispatcher->dispatch(); | 137 dispatcher->dispatch(); |
| 110 ASSERT(!event()->defaultPrevented()); | 138 ASSERT(!event()->defaultPrevented()); |
| 111 return event()->defaultHandled() || event()->defaultPrevented(); | 139 return event()->defaultHandled() || event()->defaultPrevented(); |
| 112 } | 140 } |
| 113 | 141 |
| 114 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |