summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2013-11-13 18:11:38 -0800
committerSelim Gurun <sgurun@google.com>2013-11-13 18:19:15 -0800
commit29cbcb0f746cb081dea0e1d0ff911e3d67adf878 (patch)
tree32df8b7c93a9b69053af201848c2674feeed5e29
parent070b047c9a75d418df397df222b35beacf212a9c (diff)
downloadWebKit-29cbcb0f746cb081dea0e1d0ff911e3d67adf878.tar.gz
Fix badcast in event::isGestureEvent
Bug: 11676314 Cherry pick https://codereview.chromium.org/35153013. Change-Id: I141d6fe56410e2c44631b17e537f52ab7a75d3d6
-rw-r--r--Source/core/dom/Event.cpp5
-rw-r--r--Source/core/dom/Event.h1
-rw-r--r--Source/core/dom/GestureEvent.cpp7
-rw-r--r--Source/core/dom/GestureEvent.h8
-rw-r--r--Source/web/WebPluginContainerImpl.cpp4
5 files changed, 22 insertions, 3 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
diff --git a/Source/web/WebPluginContainerImpl.cpp b/Source/web/WebPluginContainerImpl.cpp
index 65d50f581..e24241076 100644
--- a/Source/web/WebPluginContainerImpl.cpp
+++ b/Source/web/WebPluginContainerImpl.cpp
@@ -194,8 +194,8 @@ void WebPluginContainerImpl::handleEvent(Event* event)
handleKeyboardEvent(toKeyboardEvent(event));
else if (eventNames().isTouchEventType(event->type()))
handleTouchEvent(static_cast<TouchEvent*>(event));
- else if (eventNames().isGestureEventType(event->type()))
- handleGestureEvent(static_cast<GestureEvent*>(event));
+ else if (event->isGestureEvent())
+ handleGestureEvent(toGestureEvent(event));
// FIXME: it would be cleaner if Widget::handleEvent returned true/false and
// HTMLPluginElement called setDefaultHandled or defaultEventHandler.