diff options
Diffstat (limited to 'Source/core')
-rw-r--r-- | Source/core/dom/Event.cpp | 5 | ||||
-rw-r--r-- | Source/core/dom/Event.h | 1 | ||||
-rw-r--r-- | Source/core/dom/GestureEvent.cpp | 7 | ||||
-rw-r--r-- | Source/core/dom/GestureEvent.h | 8 |
4 files changed, 20 insertions, 1 deletions
diff --git a/Source/core/dom/Event.cpp b/Source/core/dom/Event.cpp index 1b714f753..f066f56c6 100644 --- a/Source/core/dom/Event.cpp +++ b/Source/core/dom/Event.cpp @@ -138,6 +138,11 @@ bool Event::isTouchEvent() const return false; } +bool Event::isGestureEvent() const +{ + return false; +} + bool Event::isDragEvent() const { return false; diff --git a/Source/core/dom/Event.h b/Source/core/dom/Event.h index 7875b1e23..3d4695fd9 100644 --- a/Source/core/dom/Event.h +++ b/Source/core/dom/Event.h @@ -126,6 +126,7 @@ public: virtual bool isFocusEvent() const; virtual bool isKeyboardEvent() const; virtual bool isTouchEvent() const; + virtual bool isGestureEvent() const; // Drag events are a subset of mouse events. virtual bool isDragEvent() const; diff --git a/Source/core/dom/GestureEvent.cpp b/Source/core/dom/GestureEvent.cpp index a4f5cf8f5..735036eaf 100644 --- a/Source/core/dom/GestureEvent.cpp +++ b/Source/core/dom/GestureEvent.cpp @@ -90,6 +90,11 @@ const AtomicString& GestureEvent::interfaceName() const return UIEvent::interfaceName(); } +bool GestureEvent::isGestureEvent() const +{ + return true; +} + GestureEvent::GestureEvent() : m_deltaX(0) , m_deltaY(0) @@ -110,7 +115,7 @@ GestureEventDispatchMediator::GestureEventDispatchMediator(PassRefPtr<GestureEve GestureEvent* GestureEventDispatchMediator::event() const { - return static_cast<GestureEvent*>(EventDispatchMediator::event()); + return toGestureEvent(EventDispatchMediator::event()); } bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const diff --git a/Source/core/dom/GestureEvent.h b/Source/core/dom/GestureEvent.h index a0d6f2edd..b630ae934 100644 --- a/Source/core/dom/GestureEvent.h +++ b/Source/core/dom/GestureEvent.h @@ -41,6 +41,8 @@ public: void initGestureEvent(const AtomicString& type, PassRefPtr<AbstractView>, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY); + virtual bool isGestureEvent() const OVERRIDE; + virtual const AtomicString& interfaceName() const; float deltaX() const { return m_deltaX; } @@ -69,6 +71,12 @@ private: virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; }; +inline GestureEvent* toGestureEvent(Event* event) +{ + ASSERT(event && event->isGestureEvent()); + return static_cast<GestureEvent*>(event); +} + } // namespace WebCore #endif // GestureEvent_h |