Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 PassRefPtrWillBeRawPtr<GestureEvent> GestureEvent::create(PassRefPtrWillBeRawPtr <AbstractView> view, const PlatformGestureEvent& event) | 33 PassRefPtrWillBeRawPtr<GestureEvent> GestureEvent::create(PassRefPtrWillBeRawPtr <AbstractView> view, const 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; | 38 float velocityX = 0; |
| 39 float velocityY = 0; | 39 float velocityY = 0; |
| 40 bool inertial = false; | 40 bool inertial = false; |
| 41 | |
| 42 GestureSource source; | |
| 43 switch (event.source()) { | |
| 44 case PlatformGestureSourceTouchpad: | |
| 45 source = GestureSourceTouchpad; | |
| 46 break; | |
| 47 case PlatformGestureSourceTouchscreen: | |
| 48 source = GestureSourceTouchscreen; | |
| 49 break; | |
| 50 default: | |
| 51 source = GestureSourceUninitialized; | |
|
tdresser
2015/10/14 15:14:20
Should this case ever happen?
wjmaclean
2015/10/14 15:55:09
Done.
| |
| 52 } | |
| 53 | |
| 41 switch (event.type()) { | 54 switch (event.type()) { |
| 42 case PlatformEvent::GestureScrollBegin: | 55 case PlatformEvent::GestureScrollBegin: |
| 43 eventType = EventTypeNames::gesturescrollstart; break; | 56 eventType = EventTypeNames::gesturescrollstart; break; |
| 44 case PlatformEvent::GestureScrollEnd: | 57 case PlatformEvent::GestureScrollEnd: |
| 45 eventType = EventTypeNames::gesturescrollend; break; | 58 eventType = EventTypeNames::gesturescrollend; break; |
| 46 case PlatformEvent::GestureScrollUpdate: | 59 case PlatformEvent::GestureScrollUpdate: |
| 47 // Only deltaX/Y are used when converting this | 60 // Only deltaX/Y are used when converting this |
| 48 // back to a PlatformGestureEvent. | 61 // back to a PlatformGestureEvent. |
| 49 eventType = EventTypeNames::gesturescrollupdate; | 62 eventType = EventTypeNames::gesturescrollupdate; |
| 50 deltaX = event.deltaX(); | 63 deltaX = event.deltaX(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 67 velocityY = event.velocityY(); | 80 velocityY = event.velocityY(); |
| 68 break; | 81 break; |
| 69 case PlatformEvent::GestureTwoFingerTap: | 82 case PlatformEvent::GestureTwoFingerTap: |
| 70 case PlatformEvent::GesturePinchBegin: | 83 case PlatformEvent::GesturePinchBegin: |
| 71 case PlatformEvent::GesturePinchEnd: | 84 case PlatformEvent::GesturePinchEnd: |
| 72 case PlatformEvent::GesturePinchUpdate: | 85 case PlatformEvent::GesturePinchUpdate: |
| 73 case PlatformEvent::GestureTapDownCancel: | 86 case PlatformEvent::GestureTapDownCancel: |
| 74 default: | 87 default: |
| 75 return nullptr; | 88 return nullptr; |
| 76 } | 89 } |
| 77 return adoptRefWillBeNoop(new GestureEvent(eventType, view, event.globalPosi tion().x(), event.globalPosition().y(), event.position().x(), event.position().y (), event.modifiers(), deltaX, deltaY, velocityX, velocityY, inertial, event.tim estamp(), event.resendingPluginId())); | 90 return adoptRefWillBeNoop(new GestureEvent(eventType, view, event.globalPosi tion().x(), event.globalPosition().y(), event.position().x(), event.position().y (), event.modifiers(), deltaX, deltaY, velocityX, velocityY, inertial, event.tim estamp(), event.resendingPluginId(), source)); |
| 78 } | 91 } |
| 79 | 92 |
| 80 const AtomicString& GestureEvent::interfaceName() const | 93 const AtomicString& GestureEvent::interfaceName() const |
| 81 { | 94 { |
| 82 // FIXME: when a GestureEvent.idl interface is defined, return the string "G estureEvent". | 95 // FIXME: when a GestureEvent.idl interface is defined, return the string "G estureEvent". |
| 83 // Until that happens, do not advertise an interface that does not exist, si nce it will | 96 // Until that happens, do not advertise an interface that does not exist, si nce it will |
| 84 // trip up the bindings integrity checks. | 97 // trip up the bindings integrity checks. |
| 85 return UIEvent::interfaceName(); | 98 return UIEvent::interfaceName(); |
| 86 } | 99 } |
| 87 | 100 |
| 88 bool GestureEvent::isGestureEvent() const | 101 bool GestureEvent::isGestureEvent() const |
| 89 { | 102 { |
| 90 return true; | 103 return true; |
| 91 } | 104 } |
| 92 | 105 |
| 93 GestureEvent::GestureEvent() | 106 GestureEvent::GestureEvent() |
| 94 : m_deltaX(0) | 107 : m_deltaX(0) |
| 95 , m_deltaY(0) | 108 , m_deltaY(0) |
| 96 , m_velocityX(0) | 109 , m_velocityX(0) |
| 97 , m_velocityY(0) | 110 , m_velocityY(0) |
| 98 , m_inertial(false) | 111 , m_inertial(false) |
| 112 , m_source(GestureSourceUninitialized) | |
| 99 , m_resendingPluginId(-1) | 113 , m_resendingPluginId(-1) |
| 100 { | 114 { |
| 101 } | 115 } |
| 102 | 116 |
| 103 GestureEvent::GestureEvent(const AtomicString& type, PassRefPtrWillBeRawPtr<Abst ractView> view, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers, float deltaX, float deltaY, float velocityX, float veloc ityY, bool inertial, double timestamp, int resendingPluginId) | 117 GestureEvent::GestureEvent(const AtomicString& type, PassRefPtrWillBeRawPtr<Abst ractView> view, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers, float deltaX, float deltaY, float velocityX, float veloc ityY, bool inertial, double timestamp, int resendingPluginId, GestureSource sour ce) |
| 104 : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), I ntPoint(clientX, clientY), IntPoint(0, 0), modifiers, PositionType::Position) | 118 : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), I ntPoint(clientX, clientY), IntPoint(0, 0), modifiers, PositionType::Position) |
| 105 , m_deltaX(deltaX) | 119 , m_deltaX(deltaX) |
| 106 , m_deltaY(deltaY) | 120 , m_deltaY(deltaY) |
| 107 , m_velocityX(velocityX) | 121 , m_velocityX(velocityX) |
| 108 , m_velocityY(velocityY) | 122 , m_velocityY(velocityY) |
| 109 , m_inertial(inertial) | 123 , m_inertial(inertial) |
| 124 , m_source(source) | |
| 110 , m_resendingPluginId(resendingPluginId) | 125 , m_resendingPluginId(resendingPluginId) |
| 111 { | 126 { |
| 112 setPlatformTimeStamp(timestamp); | 127 setPlatformTimeStamp(timestamp); |
| 113 } | 128 } |
| 114 | 129 |
| 115 PassRefPtrWillBeRawPtr<EventDispatchMediator> GestureEvent::createMediator() | 130 PassRefPtrWillBeRawPtr<EventDispatchMediator> GestureEvent::createMediator() |
| 116 { | 131 { |
| 117 return GestureEventDispatchMediator::create(this); | 132 return GestureEventDispatchMediator::create(this); |
| 118 } | 133 } |
| 119 | 134 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 133 } | 148 } |
| 134 | 149 |
| 135 bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) co nst | 150 bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) co nst |
| 136 { | 151 { |
| 137 dispatcher.dispatch(); | 152 dispatcher.dispatch(); |
| 138 ASSERT(!event().defaultPrevented()); | 153 ASSERT(!event().defaultPrevented()); |
| 139 return event().defaultHandled() || event().defaultPrevented(); | 154 return event().defaultHandled() || event().defaultPrevented(); |
| 140 } | 155 } |
| 141 | 156 |
| 142 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |