summaryrefslogtreecommitdiffstats
path: root/WebKit/android
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 /WebKit/android
parent82ffe8c7d96e55d04747f3df250a7a8e5f7c54b8 (diff)
downloadexternal_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.zip
external_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.tar.gz
external_webkit-56ce2fa12f7492cf355cfb37b80b679d7921f6d4.tar.bz2
Adding touch events for plugins.
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp25
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h17
-rw-r--r--WebKit/android/plugins/android_npapi.h28
3 files changed, 63 insertions, 7 deletions
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 350243e..ddb07bf 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -25,6 +25,9 @@
#include "config.h"
#include "android_graphics.h"
+#include "Document.h"
+#include "Element.h"
+#include "Frame.h"
#include "PluginPackage.h"
#include "PluginView.h"
#include "PluginWidgetAndroid.h"
@@ -37,6 +40,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_flipPixelRef = NULL;
m_core = NULL;
m_drawingModel = kBitmap_ANPDrawingModel;
+ m_eventFlags = 0;
m_x = m_y = 0;
}
@@ -156,3 +160,24 @@ bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) {
return false;
}
+void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) {
+
+ // if there are no differences then immediately return
+ if (m_eventFlags == flags) {
+ return;
+ }
+
+ Document* doc = m_pluginView->getParentFrame()->document();
+ if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) {
+ if(flags & kTouch_ANPEventFlag)
+ doc->addTouchEventListener(m_pluginView->getElement());
+ else
+ doc->removeTouchEventListener(m_pluginView->getElement());
+ }
+
+ m_eventFlags = flags;
+}
+
+bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) {
+ return m_eventFlags & flag;
+}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 157651c..1b0cfa9 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -62,7 +62,7 @@ struct PluginWidgetAndroid {
/* Called whenever the plugin itself requests a new drawing model
*/
void setDrawingModel(ANPDrawingModel);
-
+
/* Utility method to convert from local (plugin) coordinates to docuemnt
coordinates. Needed (for instance) to convert the dirty rectangle into
document coordinates to inturn inval the screen.
@@ -78,22 +78,33 @@ struct PluginWidgetAndroid {
a subsequent call to draw(NULL).
*/
void inval(const WebCore::IntRect&, bool signalRedraw);
-
+
/* Called to draw into the plugin's bitmap. If canvas is non-null, the
bitmap itself is then drawn into the canvas.
*/
void draw(SkCanvas* canvas = NULL);
-
+
/* Send this event to the plugin instance, and return true if the plugin
handled it.
*/
bool sendEvent(const ANPEvent&);
+ /* Update the plugins event flags. If a flag is set to true then the plugin
+ wants to be notified of events of this type.
+ */
+ void updateEventFlags(ANPEventFlags);
+
+ /* Called to check if a plugin wants to accept a given event type. It
+ returns true if the plugin wants the events and false otherwise.
+ */
+ bool isAcceptingEvent(ANPEventFlag);
+
private:
WebCore::PluginView* m_pluginView;
android::WebViewCore* m_core;
SkFlipPixelRef* m_flipPixelRef;
ANPDrawingModel m_drawingModel;
+ ANPEventFlags m_eventFlags;
int m_x;
int m_y;
};
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 596d2ac..32fa1c0 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -126,9 +126,9 @@ typedef uint32_t ANPMatrixFlag;
#define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000)
///////////////////////////////////////////////////////////////////////////////
-// NPN_GetValue
+// NPN_SetValue
-/** Reqeust to set the drawing model.
+/** Request to set the drawing model.
NPN_SetValue(inst, ANPRequestDrawingModel_EnumValue, (void*)foo_DrawingModel)
*/
@@ -147,6 +147,24 @@ enum ANPDrawingModels {
};
typedef int32_t ANPDrawingModel;
+/** Request to receive/disable events. If the pointer is NULL then all input will
+ be disabled. Otherwise, the input type will be enabled iff its corresponding
+ bit in the EventFlags bit field is set.
+
+ NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags)
+ */
+#define kAcceptEvents_ANPSetValue ((NPPVariable)1001)
+
+/* The EventFlags are a set of bits used to determine which types of input the
+ plugin wishes to receive. For example, if the value is 0x03 then both key
+ and touch events will be provided to the plugin.
+ */
+enum ANPEventFlag {
+ kKey_ANPEventFlag = 0x01,
+ kTouch_ANPEventFlag = 0x02,
+};
+typedef uint32_t ANPEventFlags;
+
/* Interfaces provide additional functionality to the plugin via function ptrs.
Once an interface is retrived, it is valid for the lifetime of the plugin
(just like browserfuncs).
@@ -699,8 +717,10 @@ enum ANPKeyModifiers {
typedef uint32_t ANPKeyModifier;
enum ANPTouchActions {
- kDown_ANPTouchAction = 0,
- kUp_ANPTouchAction = 1,
+ kDown_ANPTouchAction = 0,
+ kUp_ANPTouchAction = 1,
+ kMove_ANPTouchAction = 2,
+ kCancel_ANPTouchAction = 3,
};
typedef int32_t ANPTouchAction;