summaryrefslogtreecommitdiffstats
path: root/WebCore/plugins
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-06-15 11:44:16 -0400
committerDerek Sollenberger <djsollen@google.com>2009-06-18 09:12:26 -0400
commit56ce2fa12f7492cf355cfb37b80b679d7921f6d4 (patch)
tree321bf366530c55cb9c87988390b0b5cefe4174df /WebCore/plugins
parent82ffe8c7d96e55d04747f3df250a7a8e5f7c54b8 (diff)
downloadexternal_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.zip
external_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.tar.gz
external_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.tar.bz2
Adding touch events for plugins.
Diffstat (limited to 'WebCore/plugins')
-rw-r--r--WebCore/plugins/PluginView.cpp8
-rw-r--r--WebCore/plugins/PluginView.h9
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp55
3 files changed, 61 insertions, 11 deletions
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index cdb8ca9..f32afb5 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -59,6 +59,9 @@
#include "RenderObject.h"
#include "npruntime_impl.h"
#include "Settings.h"
+#if defined(ANDROID_PLUGINS)
+#include "TouchEvent.h"
+#endif
#if USE(JSC)
#include "JSDOMWindow.h"
@@ -160,8 +163,13 @@ void PluginView::handleEvent(Event* event)
handleMouseEvent(static_cast<MouseEvent*>(event));
else if (event->isKeyboardEvent())
handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
+#if defined(ANDROID_PLUGINS)
+ else if (event->isTouchEvent())
+ handleTouchEvent(static_cast<TouchEvent*>(event));
+#endif
}
+
bool PluginView::start()
{
if (m_isStarted)
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index d007d64..8bd0641 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -73,6 +73,9 @@ namespace WebCore {
class Frame;
class KeyboardEvent;
class MouseEvent;
+#ifdef ANDROID_PLUGINS
+ class TouchEvent;
+#endif
class KURL;
#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
class PluginMessageThrottlerWin;
@@ -207,6 +210,11 @@ namespace WebCore {
static bool isCallingPlugin();
+#ifdef ANDROID_PLUGINS
+ Frame* getParentFrame() const { return m_parentFrame; }
+ Element* getElement() const { return m_element; }
+#endif
+
private:
PluginView(Frame* parentFrame, const IntSize&, PluginPackage*, Element*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
@@ -258,6 +266,7 @@ namespace WebCore {
void handleMouseEvent(MouseEvent*);
#ifdef ANDROID_PLUGINS
+ void handleTouchEvent(TouchEvent*);
// called at the end of the base constructor
void platformInit();
#endif
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index f10ac45..51dd4e9 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -50,6 +50,7 @@
#include "PlatformKeyboardEvent.h"
#include "PluginMainThreadScheduler.h"
#include "PluginPackage.h"
+#include "TouchEvent.h"
#include "android_graphics.h"
#include "SkCanvas.h"
#include "npruntime_impl.h"
@@ -203,25 +204,45 @@ void PluginView::init()
m_status = PluginStatusLoadedSuccessfully;
}
+void PluginView::handleTouchEvent(TouchEvent* event)
+{
+ if (!m_window->isAcceptingEvent(kTouch_ANPEventFlag))
+ return;
+
+ ANPEvent evt;
+ SkANP::InitEvent(&evt, kTouch_ANPEventType);
+
+ const AtomicString& type = event->type();
+ if (eventNames().touchstartEvent == type)
+ evt.data.touch.action = kDown_ANPTouchAction;
+ else if (eventNames().touchendEvent == type)
+ evt.data.touch.action = kUp_ANPTouchAction;
+ else if (eventNames().touchmoveEvent == type)
+ evt.data.touch.action = kMove_ANPTouchAction;
+ else if (eventNames().touchcancelEvent == type)
+ evt.data.touch.action = kCancel_ANPTouchAction;
+ else
+ return;
+
+ evt.data.touch.modifiers = 0; // todo
+ // these are relative to plugin
+ evt.data.touch.x = event->pageX() - m_npWindow.x;
+ evt.data.touch.y = event->pageY() - m_npWindow.y;
+
+ if (m_plugin->pluginFuncs()->event(m_instance, &evt)) {
+ event->setDefaultHandled();
+ }
+}
+
void PluginView::handleMouseEvent(MouseEvent* event)
{
const AtomicString& type = event->type();
- bool isDown = (eventNames().mousedownEvent == type);
- bool isUp = (eventNames().mouseupEvent == type);
bool isOver = (eventNames().mouseoverEvent == type);
bool isOut = (eventNames().mouseoutEvent == type);
ANPEvent evt;
- if (isDown || isUp) {
- SkANP::InitEvent(&evt, kTouch_ANPEventType);
- evt.data.touch.action = isDown ? kDown_ANPTouchAction : kUp_ANPTouchAction;
- evt.data.touch.modifiers = 0; // todo
- // these are relative to plugin
- evt.data.touch.x = event->pageX() - m_npWindow.x;
- evt.data.touch.y = event->pageY() - m_npWindow.y;
- }
- else if (isOver || isOut) {
+ if (isOver || isOut) {
SkANP::InitEvent(&evt, kLifecycle_ANPEventType);
evt.data.lifecycle.action = isOver ? kGainFocus_ANPLifecycleAction : kLooseFocus_ANPLifecycleAction;
}
@@ -247,6 +268,9 @@ static ANPKeyModifier make_modifiers(bool shift, bool alt) {
void PluginView::handleKeyboardEvent(KeyboardEvent* event)
{
+ if (!m_window->isAcceptingEvent(kKey_ANPEventFlag))
+ return;
+
const PlatformKeyboardEvent* pke = event->keyEvent();
if (NULL == pke) {
return;
@@ -487,6 +511,15 @@ NPError PluginView::platformSetValue(NPPVariable variable, void* value)
default:
break;
}
+ break;
+ }
+ case kAcceptEvents_ANPSetValue : {
+ if(value) {
+ ANPEventFlags flags = *reinterpret_cast<ANPEventFlags*>(value);
+ m_window->updateEventFlags(flags);
+ error = NPERR_NO_ERROR;
+ }
+ break;
}
default:
break;