diff options
Diffstat (limited to 'WebKit/android/plugins')
26 files changed, 572 insertions, 238 deletions
diff --git a/WebKit/android/plugins/ANPBitmapInterface.cpp b/WebKit/android/plugins/ANPBitmapInterface.cpp index 25d1e97..4c6ad7c 100644 --- a/WebKit/android/plugins/ANPBitmapInterface.cpp +++ b/WebKit/android/plugins/ANPBitmapInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -69,4 +69,3 @@ void ANPBitmapInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, getPixelPacking); } - diff --git a/WebKit/android/plugins/ANPCanvasInterface.cpp b/WebKit/android/plugins/ANPCanvasInterface.cpp index c985f64..d6d89ff 100644 --- a/WebKit/android/plugins/ANPCanvasInterface.cpp +++ b/WebKit/android/plugins/ANPCanvasInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -195,4 +195,3 @@ void ANPCanvasInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, drawBitmap); ASSIGN(i, drawBitmapRect); } - diff --git a/WebKit/android/plugins/ANPEventInterface.cpp b/WebKit/android/plugins/ANPEventInterface.cpp new file mode 100644 index 0000000..2fdf159 --- /dev/null +++ b/WebKit/android/plugins/ANPEventInterface.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "config.h" +#include "SkANP.h" +#include "WebViewCore.h" +#include "PluginView.h" +#include "PluginWidgetAndroid.h" + +#include "JavaSharedClient.h" + +using namespace android; + +struct WrappedANPEvent { + WebViewCore* fWVC; + PluginWidgetAndroid* fPWA; + ANPEvent fEvent; +}; + +/* Its possible we may be called after the plugin that initiated the event + has been torn-down. Thus we check that the assicated webviewcore and + pluginwidget are still active before dispatching the event. + */ +static void send_anpevent(void* data) { + WrappedANPEvent* wrapper = static_cast<WrappedANPEvent*>(data); + WebViewCore* core = wrapper->fWVC; + PluginWidgetAndroid* widget = wrapper->fPWA; + + // be sure we're still alive before delivering the event + if (WebViewCore::isInstance(core) && core->isPlugin(widget)) { + widget->sendEvent(wrapper->fEvent); + } + delete wrapper; +} + +static void anp_postEvent(NPP instance, const ANPEvent* event) { + if (instance && instance->ndata && event) { + PluginView* pluginView = static_cast<PluginView*>(instance->ndata); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + WebViewCore* wvc = pluginWidget->webViewCore(); + + WrappedANPEvent* wrapper = new WrappedANPEvent; + // recored these, and recheck that they are valid before delivery + // in send_anpevent + wrapper->fWVC = pluginWidget->webViewCore(); + wrapper->fPWA = pluginWidget; + // make a copy of the event + wrapper->fEvent = *event; + JavaSharedClient::EnqueueFunctionPtr(send_anpevent, wrapper); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void ANPEventInterfaceV0_Init(ANPInterface* value) { + ANPEventInterfaceV0* i = reinterpret_cast<ANPEventInterfaceV0*>(value); + + ASSIGN(i, postEvent); +} diff --git a/WebKit/android/plugins/ANPKeyCodes.h b/WebKit/android/plugins/ANPKeyCodes.h index 5213f57..328eb56 100644 --- a/WebKit/android/plugins/ANPKeyCodes.h +++ b/WebKit/android/plugins/ANPKeyCodes.h @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -122,4 +122,3 @@ enum ANPKeyCodes { }; #endif - diff --git a/WebKit/android/plugins/ANPLogInterface.cpp b/WebKit/android/plugins/ANPLogInterface.cpp index 6ccca0a..23a4ed6 100644 --- a/WebKit/android/plugins/ANPLogInterface.cpp +++ b/WebKit/android/plugins/ANPLogInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,13 +23,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define LOG_TAG "plugin" +#define LOG_TAG "webkitPlugin" #include "utils/Log.h" #include "android_npapi.h" #include <stdarg.h> -static void anp_log(NPP inst, ANPLogType logType, const char format[], ...) { +static void anp_log(ANPLogType logType, const char format[], ...) { va_list args; va_start(args, format); @@ -58,4 +58,3 @@ void ANPLogInterfaceV0_Init(ANPInterface* value) { i->log = anp_log; } - diff --git a/WebKit/android/plugins/ANPMatrixInterface.cpp b/WebKit/android/plugins/ANPMatrixInterface.cpp index 815b954..f322315 100644 --- a/WebKit/android/plugins/ANPMatrixInterface.cpp +++ b/WebKit/android/plugins/ANPMatrixInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -165,4 +165,3 @@ void ANPMatrixInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, invert); ASSIGN(i, mapPoints); } - diff --git a/WebKit/android/plugins/ANPPaintInterface.cpp b/WebKit/android/plugins/ANPPaintInterface.cpp index 4b561f0..5c59df9 100644 --- a/WebKit/android/plugins/ANPPaintInterface.cpp +++ b/WebKit/android/plugins/ANPPaintInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -210,4 +210,3 @@ void ANPPaintInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, getTextWidths); ASSIGN(i, getFontMetrics); } - diff --git a/WebKit/android/plugins/ANPPathInterface.cpp b/WebKit/android/plugins/ANPPathInterface.cpp index 468d866..69cabcf 100644 --- a/WebKit/android/plugins/ANPPathInterface.cpp +++ b/WebKit/android/plugins/ANPPathInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -110,4 +110,3 @@ void ANPPathInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, offset); ASSIGN(i, transform); } - diff --git a/WebKit/android/plugins/ANPSoundInterface.cpp b/WebKit/android/plugins/ANPSoundInterface.cpp index c4bec1c..8e31d69 100644 --- a/WebKit/android/plugins/ANPSoundInterface.cpp +++ b/WebKit/android/plugins/ANPSoundInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -27,6 +27,7 @@ #include "config.h" #include "android_npapi.h" +#include "SkTypes.h" #include "media/AudioTrack.h" struct ANPAudioTrack { @@ -146,4 +147,3 @@ void ANPAudioTrackInterfaceV0_Init(ANPInterface* value) { si->stop = ANPTrackStop; si->isStopped = ANPTrackIsStopped; } - diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp index dd5dbe0..02ff77e 100644 --- a/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -39,23 +39,48 @@ using namespace android; +// used to cache JNI method and field IDs for Surface Objects +static struct ANPSurfaceInterfaceJavaGlue { + bool initialized; + jmethodID getSurfaceHolder; + jmethodID getSurface; + jfieldID surfacePointer; +} gSurfaceJavaGlue; + static inline sp<Surface> getSurface(JNIEnv* env, jobject view) { if (!env || !view) { return NULL; } - jclass clazz = env->FindClass("android/view/Surface"); - jfieldID surfaceField = env->GetFieldID(clazz, "mSurface", "I"); + if (!gSurfaceJavaGlue.initialized) { + + jclass surfaceViewClass = env->FindClass("android/view/SurfaceView"); + gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", + "()Landroid/view/SurfaceHolder;"); + + jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder"); + gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", + "()Landroid/view/Surface;"); - clazz = env->FindClass("android/view/SurfaceView"); - jmethodID getHolder = env->GetMethodID(clazz, "getHolder", "()Landroid/view/SurfaceHolder;"); + jclass surfaceClass = env->FindClass("android/view/Surface"); + gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, + "mSurface", "I"); - clazz = env->FindClass("android/view/SurfaceHolder"); - jmethodID getSurface = env->GetMethodID(clazz, "getSurface", "()Landroid/view/Surface;"); + env->DeleteLocalRef(surfaceClass); + env->DeleteLocalRef(surfaceViewClass); + env->DeleteLocalRef(surfaceHolderClass); + + gSurfaceJavaGlue.initialized = true; + } - jobject holder = env->CallObjectMethod(view, getHolder); - jobject surface = env->CallObjectMethod(holder, getSurface); - return sp<Surface>((Surface*) env->GetIntField(surface, surfaceField)); + jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder); + jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface); + jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer); + + env->DeleteLocalRef(holder); + env->DeleteLocalRef(surface); + + return sp<Surface>((Surface*) surfacePointer); } static inline ANPBitmapFormat convertPixelFormat(PixelFormat format) { @@ -133,5 +158,7 @@ void ANPSurfaceInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, lock); ASSIGN(i, unlock); -} + // setup the java glue struct + gSurfaceJavaGlue.initialized = false; +} diff --git a/WebKit/android/plugins/ANPSurface_npapi.h b/WebKit/android/plugins/ANPSurface_npapi.h index 7dcec92..910a948 100644 --- a/WebKit/android/plugins/ANPSurface_npapi.h +++ b/WebKit/android/plugins/ANPSurface_npapi.h @@ -1,3 +1,28 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef ANPSurface_npapi_H #define ANPSurface_npapi_H diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp index a5b9bcb..42ec9e4 100644 --- a/WebKit/android/plugins/ANPSystemInterface.cpp +++ b/WebKit/android/plugins/ANPSystemInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -26,10 +26,16 @@ // must include config.h first for webkit to fiddle with new/delete #include "config.h" -#include "android_npapi.h" #include "CString.h" #include "JavaSharedClient.h" #include "PluginClient.h" +#include "PluginPackage.h" +#include "PluginView.h" +#include "PluginWidgetAndroid.h" +#include "SkString.h" +#include "WebViewCore.h" + +#include "ANPSystem_npapi.h" static const char* gApplicationDataDir = NULL; @@ -61,6 +67,22 @@ static const char* anp_getApplicationDataDirectory() { return gApplicationDataDir; } +static WebCore::PluginView* pluginViewForInstance(NPP instance) { + if (instance && instance->ndata) + return static_cast<WebCore::PluginView*>(instance->ndata); + return PluginView::currentPluginView(); +} + +static jclass anp_loadJavaClass(NPP instance, const char* className) { + WebCore::PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + + jclass result; + result = pluginWidget->webViewCore()->getPluginClass(pluginView->plugin()->path(), + className); + return result; +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -69,4 +91,5 @@ void ANPSystemInterfaceV0_Init(ANPInterface* v) { ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v); ASSIGN(i, getApplicationDataDirectory); + ASSIGN(i, loadJavaClass); } diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h new file mode 100644 index 0000000..6a102a7 --- /dev/null +++ b/WebKit/android/plugins/ANPSystem_npapi.h @@ -0,0 +1,50 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ANPSystem_npapi_H +#define ANPSystem_npapi_H + +#include "android_npapi.h" +#include <jni.h> + +struct ANPSystemInterfaceV0 : ANPInterface { + /** Return the path name for the current Application's plugin data directory, + or NULL if not supported + */ + const char* (*getApplicationDataDirectory)(); + + /** A helper function to load java classes from the plugin's apk. The + function looks for a class given the fully qualified and null terminated + string representing the className. For example, + + const char* className = "com.android.mypackage.MyClass"; + + If the class cannot be found or there is a problem loading the class + NULL will be returned. + */ + jclass (*loadJavaClass)(NPP instance, const char* className); +}; + +#endif //ANPSystem_npapi_H diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp index e33e580..4b2dda2 100644 --- a/WebKit/android/plugins/ANPTypefaceInterface.cpp +++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -102,4 +102,3 @@ void ANPTypefaceInterfaceV0_Init(ANPInterface* v) { ASSIGN(i, getFontPath); ASSIGN(i, getFontDirectoryPath); } - diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp index 7a2f94c..06afab1 100644 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/WebKit/android/plugins/ANPWindowInterface.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -30,27 +30,6 @@ #include "PluginView.h" #include "PluginWidgetAndroid.h" -static bool anp_lockRect(void* window, const ANPRectI* inval, - ANPBitmap* bitmap) { - if (window) { - // todo - return true; - } - return false; -} - -static bool anp_lockRegion(void* window, const ANPRegion* inval, - ANPBitmap* bitmap) { - if (window) { - // todo - return true; - } - return false; -} - -static void anp_unlock(void* window) { -} - static PluginView* pluginViewForInstance(NPP instance) { if (instance && instance->ndata) return static_cast<PluginView*>(instance->ndata); @@ -68,14 +47,23 @@ static void anp_clearVisibleRects(NPP instance) { } static void anp_showKeyboard(NPP instance, bool value) { - ScrollView* scrollView = pluginViewForInstance(instance)->parent(); - android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); - core->requestKeyboard(value); + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->webViewCore()->requestKeyboard(value, false); } static void anp_requestFullScreen(NPP instance) { PluginView* pluginView = pluginViewForInstance(instance); - pluginView->platformPluginWidget()->requestFullScreenMode(); + // call focusPluginElement() so that the pluginView receives keyboard events + pluginView->focusPluginElement(); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->requestFullScreen(); +} + +static void anp_exitFullScreen(NPP instance) { + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->exitFullScreen(true); } /////////////////////////////////////////////////////////////////////////////// @@ -85,12 +73,9 @@ static void anp_requestFullScreen(NPP instance) { void ANPWindowInterfaceV0_Init(ANPInterface* value) { ANPWindowInterfaceV0* i = reinterpret_cast<ANPWindowInterfaceV0*>(value); - ASSIGN(i, lockRect); - ASSIGN(i, lockRegion); ASSIGN(i, setVisibleRects); ASSIGN(i, clearVisibleRects); ASSIGN(i, showKeyboard); - ASSIGN(i, unlock); ASSIGN(i, requestFullScreen); + ASSIGN(i, exitFullScreen); } - diff --git a/WebKit/android/plugins/PluginDebugAndroid.h b/WebKit/android/plugins/PluginDebugAndroid.h index 992e953..2143b39 100644 --- a/WebKit/android/plugins/PluginDebugAndroid.h +++ b/WebKit/android/plugins/PluginDebugAndroid.h @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR diff --git a/WebKit/android/plugins/PluginTimer.cpp b/WebKit/android/plugins/PluginTimer.cpp index 1097330..cdcde9c 100644 --- a/WebKit/android/plugins/PluginTimer.cpp +++ b/WebKit/android/plugins/PluginTimer.cpp @@ -5,23 +5,23 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" diff --git a/WebKit/android/plugins/PluginTimer.h b/WebKit/android/plugins/PluginTimer.h index ccb49da..3fbe728 100644 --- a/WebKit/android/plugins/PluginTimer.h +++ b/WebKit/android/plugins/PluginTimer.h @@ -5,23 +5,23 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PluginTimer_H diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp b/WebKit/android/plugins/PluginViewBridgeAndroid.cpp index 945115a..2be9dc3 100644 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp +++ b/WebKit/android/plugins/PluginViewBridgeAndroid.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.h b/WebKit/android/plugins/PluginViewBridgeAndroid.h index e17a2dc..5d16f46 100644 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.h +++ b/WebKit/android/plugins/PluginViewBridgeAndroid.h @@ -6,23 +6,23 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PluginViewBridgeAndroid_H diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index fdc4016..113a3bc 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -36,6 +36,9 @@ #include "SkFlipPixelRef.h" #include "SkString.h" #include "WebViewCore.h" +#include "jni_utility.h" + +#define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) : m_pluginView(view) { @@ -47,22 +50,28 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_requestedVisibleRectCount = 0; m_requestedFrameRect.setEmpty(); m_visibleDocRect.setEmpty(); + m_pluginBounds.setEmpty(); m_hasFocus = false; + m_isFullScreen = false; + m_visible = true; m_zoomLevel = 0; - m_javaClassName = NULL; - m_childView = NULL; + m_embeddedView = NULL; } PluginWidgetAndroid::~PluginWidgetAndroid() { if (m_core) { m_core->removePlugin(this); - if (m_childView) { - m_core->destroySurface(m_childView); + if (m_embeddedView) { + m_core->destroySurface(m_embeddedView); } } - if (m_javaClassName) { - free(m_javaClassName); + + // cleanup any remaining JNI References + JNIEnv* env = JSC::Bindings::getJNIEnv(); + if (m_embeddedView) { + env->DeleteGlobalRef(m_embeddedView); } + m_flipPixelRef->safeUnref(); } @@ -77,66 +86,60 @@ static SkBitmap::Config computeConfig(bool isTransparent) { } void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { + + // store the reference locally for easy lookup m_pluginWindow = window; - if (m_drawingModel == kSurface_ANPDrawingModel) { - if (!m_childView) { - IntPoint docPoint = frameToDocumentCoords(window->x, window->y); + // make a copy of the previous bounds + SkIRect oldPluginBounds = m_pluginBounds; - const String& libName = m_pluginView->plugin()->path(); - SkString skLibName; - skLibName.setUTF16(libName.characters(), libName.length()); + // keep a local copy of the plugin bounds because the m_pluginWindow pointer + // gets updated values prior to this method being called + m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y, + m_pluginWindow->x + m_pluginWindow->width, + m_pluginWindow->y + m_pluginWindow->height); - m_childView = m_core->createSurface(skLibName.c_str(), m_javaClassName, - m_pluginView->instance(), - docPoint.x(), docPoint.y(), - window->width, window->height); - } - } else { - m_flipPixelRef->safeUnref(); - m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), - window->width, window->height); - } -} + if (m_drawingModel == kSurface_ANPDrawingModel) { -bool PluginWidgetAndroid::setPluginStubJavaClassName(const char* className) { + IntPoint docPoint = frameToDocumentCoords(window->x, window->y); - if (m_javaClassName) { - free(m_javaClassName); - } + // if the surface exists check for changes and update accordingly + if (m_embeddedView && m_pluginBounds != oldPluginBounds) { - // don't call strdup() if the className is to be set to NULL - if (!className) { - m_javaClassName = NULL; - return true; - } + m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + window->width, window->height); - // make a local copy of the className - m_javaClassName = strdup(className); - return (m_javaClassName != NULL); -} + // if the surface does not exist then create a new surface + } else if(!m_embeddedView) { -void PluginWidgetAndroid::requestFullScreenMode() { + WebCore::PluginPackage* pkg = m_pluginView->plugin(); + NPP instance = m_pluginView->instance(); - if (!m_javaClassName) { - return; - } - const String& libName = m_pluginView->plugin()->path(); - SkString skLibName; - skLibName.setUTF16(libName.characters(), libName.length()); + jobject pluginSurface; + pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, + static_cast<void*>(&pluginSurface)); - m_core->startFullScreenPluginActivity(skLibName.c_str(), m_javaClassName, - m_pluginView->instance()); + jobject tempObj = m_core->addSurface(pluginSurface, + docPoint.x(), docPoint.y(), + window->width, window->height); + if (tempObj) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + m_embeddedView = env->NewGlobalRef(tempObj); + } + } + if (m_isFullScreen && m_pluginBounds != oldPluginBounds) { + m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(), + window->width, window->height); + } + } else { + m_flipPixelRef->safeUnref(); + m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), + window->width, window->height); + } } bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { - - // disallow the surface drawing model if no java class name has been given - if (model == kSurface_ANPDrawingModel && m_javaClassName == NULL) { - return false; - } - m_drawingModel = model; return true; } @@ -264,7 +267,10 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { } void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d)", __FUNCTION__, visibleDocRect.left, + visibleDocRect.top, visibleDocRect.right, visibleDocRect.bottom); +#endif // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel) int oldScreenW = m_visibleDocRect.width(); @@ -278,10 +284,24 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float if (oldScreenW != newScreenW || oldScreenH != newScreenH) computeVisibleFrameRect(); + + bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds); + if(m_visible != visible) { + // change the visibility + m_visible = visible; + // send the event + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction + : kOffScreen_ANPLifecycleAction; + sendEvent(event); + } } void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s count=%d", __FUNCTION__, count); +#endif // ensure the count does not exceed our allocated space if (count > MAX_REQUESTED_RECTS) count = MAX_REQUESTED_RECTS; @@ -290,6 +310,24 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) m_requestedVisibleRectCount = count; memcpy(m_requestedVisibleRect, rects, count * sizeof(rects[0])); +#if DEBUG_VISIBLE_RECTS // FIXME: this fixes bad data from the plugin + // take it out once plugin supplies better data + for (int index = 0; index < count; index++) { + SkDebugf("%s [%d](%d,%d,%d,%d)", __FUNCTION__, index, + m_requestedVisibleRect[index].left, + m_requestedVisibleRect[index].top, + m_requestedVisibleRect[index].right, + m_requestedVisibleRect[index].bottom); + if (m_requestedVisibleRect[index].left == + m_requestedVisibleRect[index].right) { + m_requestedVisibleRect[index].right += 1; + } + if (m_requestedVisibleRect[index].top == + m_requestedVisibleRect[index].bottom) { + m_requestedVisibleRect[index].bottom += 1; + } + } +#endif computeVisibleFrameRect(); } @@ -299,12 +337,6 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { if (m_visibleDocRect.isEmpty() || !m_pluginWindow) return; - // create a rect that represents the plugin's bounds - SkIRect pluginBounds; - pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->x + m_pluginWindow->width, - m_pluginWindow->y + m_pluginWindow->height); - // create a rect that will contain as many of the rects that will fit on screen SkIRect visibleRect; visibleRect.setEmpty(); @@ -319,9 +351,18 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y); // ensure the rect falls within the plugin's bounds - if (!pluginBounds.contains(pluginRect)) - continue; - + if (!m_pluginBounds.contains(pluginRect)) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__, + m_pluginBounds.fLeft, m_pluginBounds.fTop, + m_pluginBounds.fRight, m_pluginBounds.fBottom, + pluginRect.fLeft, pluginRect.fTop, + pluginRect.fRight, pluginRect.fBottom); + // FIXME: assume that the desired outcome is to clamp to the container + pluginRect.intersect(m_pluginBounds); +#endif + continue; + } // combine this new rect with the higher priority rects pluginRect.join(visibleRect); @@ -342,9 +383,14 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { void PluginWidgetAndroid::scrollToVisibleFrameRect() { - if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) + if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call m_hasFocus=%d m_requestedFrameRect.isEmpty()=%d" + " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, + m_requestedFrameRect.isEmpty(), m_visibleDocRect.isEmpty()); +#endif return; - + } // if the entire rect is already visible then we don't need to scroll, which // requires converting the m_requestedFrameRect from frame to doc coordinates IntPoint pluginDocPoint = frameToDocumentCoords(m_requestedFrameRect.fLeft, @@ -371,6 +417,9 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { ScrollView* scrollView = m_pluginView->parent(); android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY); +#endif core->scrollBy(deltaX, deltaY, true); } @@ -391,3 +440,49 @@ IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) cons return docPoint; } + +void PluginWidgetAndroid::requestFullScreen() { + if (m_isFullScreen || !m_embeddedView) { + return; + } + + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kEnterFullScreen_ANPLifecycleAction; + sendEvent(event); + + // remove the embedded surface from the view hierarchy + m_core->destroySurface(m_embeddedView); + + // add the full screen view + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(), + docPoint.x(), docPoint.y(), m_pluginWindow->width, + m_pluginWindow->height); + m_isFullScreen = true; +} + +void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { + if (!m_isFullScreen || !m_embeddedView) { + return; + } + + // remove the full screen surface from the view hierarchy + if (pluginInitiated) { + m_core->hideFullScreenPlugin(); + } + + // add the embedded view back + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + m_pluginWindow->width, m_pluginWindow->height); + + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction; + sendEvent(event); + + m_isFullScreen = false; +} diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 9fc2209..93ad4a8 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -67,12 +67,6 @@ struct PluginWidgetAndroid { */ void setWindow(NPWindow* window, bool isTransparent); - /* Called to notify us of the plugin's java class that implements the - * PluginStub interface. A local copy is made of the className so the caller - * can safely free the memory as soon as the function returns. - */ - bool setPluginStubJavaClassName(const char* className); - /* Called whenever the plugin itself requests a new drawing model. If the hardware does not support the requested model then false is returned, otherwise true is returned. @@ -131,11 +125,20 @@ struct PluginWidgetAndroid { */ void setVisibleRects(const ANPRectI rects[], int32_t count); - /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (set using setPluginStubJavaClassName(...)) will be called - asynchronously to provide a View to be displayed in full screen. + /** Called when a plugin wishes to enter into full screen mode. It invokes + the plugin's Java class (defined in the plugin's apk manifest), which is + called asynchronously and provides a View to be displayed full screen. */ - void requestFullScreenMode(); + void requestFullScreen(); + + /** Called when a plugin wishes to exit from full screen mode. As a result, + the plugin's full-screen view is discarded by the view system. It is also + called in order to notify the native code that the browser has discarded + the view. + */ + void exitFullScreen(bool pluginInitiated); + + bool inFullScreen() { return m_isFullScreen; } private: WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const; @@ -148,12 +151,14 @@ private: ANPDrawingModel m_drawingModel; ANPEventFlags m_eventFlags; NPWindow* m_pluginWindow; + SkIRect m_pluginBounds; SkIRect m_visibleDocRect; SkIRect m_requestedFrameRect; bool m_hasFocus; + bool m_isFullScreen; + bool m_visible; float m_zoomLevel; - char* m_javaClassName; - jobject m_childView; + jobject m_embeddedView; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/WebKit/android/plugins/SkANP.cpp b/WebKit/android/plugins/SkANP.cpp index 3912f99..9bbb09e 100644 --- a/WebKit/android/plugins/SkANP.cpp +++ b/WebKit/android/plugins/SkANP.cpp @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -103,4 +103,3 @@ void SkANP::InitEvent(ANPEvent* event, ANPEventType et) { event->inSize = sizeof(ANPEvent); event->eventType = et; } - diff --git a/WebKit/android/plugins/SkANP.h b/WebKit/android/plugins/SkANP.h index f319c9b..5c2a936 100644 --- a/WebKit/android/plugins/SkANP.h +++ b/WebKit/android/plugins/SkANP.h @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -77,4 +77,3 @@ public: }; #endif - diff --git a/WebKit/android/plugins/SurfaceCallback.h b/WebKit/android/plugins/SurfaceCallback.h index fb2e015..945fc3f 100644 --- a/WebKit/android/plugins/SurfaceCallback.h +++ b/WebKit/android/plugins/SurfaceCallback.h @@ -5,16 +5,16 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 95ab889..4173528 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -1,5 +1,5 @@ /* - * Copyright 2008, The Android Open Source Project + * Copyright 2009, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -118,15 +118,20 @@ typedef uint32_t ANPMatrixFlag; #define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) #define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) #define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) +#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) -/** queries for which drawing model is desired (for the draw event) +/** queries for the drawing models supported on this device. - Should be called inside NPP_New(...) - - NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits) + NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) */ #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) +/** queries for the context (android.content.Context) in which the plugin resides + + NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) + */ +#define kJavaContext_ANPGetValue ((NPNVariable)2001) + /////////////////////////////////////////////////////////////////////////////// // NPN_SetValue @@ -137,20 +142,6 @@ typedef uint32_t ANPMatrixFlag; */ #define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) -/** Set the name of the Java class found in the plugin's apk that implements the - PluginStub interface. The value provided must be a null terminated char* - that contains the fully qualified class name (e.g., your.package.className). - A local copy is made of the char* so the caller can safely free the memory - as soon as the function returns. - - This value must be set prior to selecting the Surface_ANPDrawingModel or - requesting to enter full-screen mode. - - NPN_SetValue(inst, kSetPluginStubJavaClassName_ANPSetValue, - (void*)nullTerminatedChar*) - */ -#define kSetPluginStubJavaClassName_ANPSetValue ((NPPVariable)1001) - /** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines how to interpret the ANPDrawingContext provided in the Draw event and how @@ -160,18 +151,28 @@ enum ANPDrawingModels { /** Draw into a bitmap from the browser thread in response to a Draw event. NPWindow->window is reserved (ignore) */ - kBitmap_ANPDrawingModel = 0, - /** Draw into a surface (e.g. raster, opengl, etc.)using the surface interface. - Unlike the bitmap model a surface model is opaque so no html content behind - the plugin will be visible. Unless the surface needs to be transparent the - surface model should be chosen over the bitmap model as it will have faster - performance. An example surface is the raster surface where the service - interface is used to lock/unlock and draw into bitmap without waiting for - draw events. Prior to requesting this drawing model the plugin must provide - the name of the Java class that implements the PluginStub interface via - kSetJavaClassName_ANPSetValue. - */ - kSurface_ANPDrawingModel = 1, + kBitmap_ANPDrawingModel = 1 << 0, + /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface + interface. When this model is used the browser will invoke the Java + class specified in the plugin's apk manifest. From that class the browser + will invoke the appropriate method to return an an instance of a android + Java View. The instance is then embedded in the html. The plugin can then + manipulate the view as it would any normal Java View in android. + + Unlike the bitmap model, a surface model is opaque so no html content + behind the plugin will be visible. Unless the plugin needs to be + transparent the surface model should be chosen over the bitmap model as + it will have better performance. + + Further, a plugin can manipulate some surfaces in native code using the + ANPSurfaceInterface. This interface can be used to manipulate Java + objects that extend Surface.class by allowing them to access the + surface's underlying bitmap in native code. For instance, if a raster + surface is used the plugin can lock, draw directly into the bitmap, and + unlock the surface in native code without making JNI calls to the Java + surface object. + */ + kSurface_ANPDrawingModel = 1 << 1, }; typedef int32_t ANPDrawingModel; @@ -181,7 +182,7 @@ typedef int32_t ANPDrawingModel; NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) */ -#define kAcceptEvents_ANPSetValue ((NPPVariable)1002) +#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) /** The EventFlags are a set of bits used to determine which types of events the plugin wishes to receive. For example, if the value is 0x03 then both key @@ -193,6 +194,20 @@ enum ANPEventFlag { }; typedef uint32_t ANPEventFlags; +/////////////////////////////////////////////////////////////////////////////// +// NPP_GetValue + +/** Requests that the plugin return a java surface to be displayed. This will + only be used if the plugin has choosen the kSurface_ANPDrawingModel. + + NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) + */ +#define kJavaSurface_ANPGetValue ((NPPVariable)2000) + + +/////////////////////////////////////////////////////////////////////////////// +// ANDROID INTERFACE DEFINITIONS + /** Interfaces provide additional functionality to the plugin via function ptrs. Once an interface is retrieved, it is valid for the lifetime of the plugin (just like browserfuncs). @@ -216,7 +231,7 @@ struct ANPLogInterfaceV0 : ANPInterface { /** dumps printf messages to the log file e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); */ - void (*log)(NPP instance, ANPLogType, const char format[], ...); + void (*log)(ANPLogType, const char format[], ...); }; struct ANPBitmapInterfaceV0 : ANPInterface { @@ -622,23 +637,6 @@ struct ANPCanvasInterfaceV0 : ANPInterface { }; struct ANPWindowInterfaceV0 : ANPInterface { - /** Given the window field from the NPWindow struct, and an optional rect - describing the subset of the window that will be drawn to (may be null) - return true if the bitmap for that window can be accessed, and if so, - fill out the specified ANPBitmap to point to the window's pixels. - - When drawing is complete, call unlock(window) - */ - bool (*lockRect)(void* window, const ANPRectI* inval, ANPBitmap*); - /** The same as lockRect, but takes a region instead of a rect to specify - the area that will be changed/drawn. - */ - bool (*lockRegion)(void* window, const ANPRegion* inval, ANPBitmap*); - /** Given a successful call to lock(window, inval, &bitmap), call unlock - to release access to the pixels, and allow the browser to display the - results. If lock returned false, unlock should not be called. - */ - void (*unlock)(void* window); /** Registers a set of rectangles that the plugin would like to keep on screen. The rectangles are listed in order of priority with the highest priority rectangle in location rects[0]. The browser will attempt to keep @@ -660,10 +658,14 @@ struct ANPWindowInterfaceV0 : ANPInterface { */ void (*showKeyboard)(NPP instance, bool value); /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (set using kSetPluginStubJavaClassName_ANPSetValue) will be - called asynchronously to provide a View object to be displayed full screen. + Java class (defined in the plugin's apk manifest) will be called + asynchronously to provide a View object to be displayed full screen. */ void (*requestFullScreen)(NPP instance); + /** Called when a plugin wishes to exit from full screen mode. As a result, + the plugin's full screen view will be discarded by the view system. + */ + void (*exitFullScreen)(NPP instance); }; /////////////////////////////////////////////////////////////////////////////// @@ -751,7 +753,7 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { }; /////////////////////////////////////////////////////////////////////////////// -// HandleEvent +// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent enum ANPEventTypes { kNull_ANPEventType = 0, @@ -772,6 +774,21 @@ enum ANPEventTypes { */ kDraw_ANPEventType = 4, kLifecycle_ANPEventType = 5, + + /** This event type is completely defined by the plugin. + When creating an event, the caller must always set the first + two fields, the remaining data is optional. + ANPEvent evt; + evt.inSize = sizeof(ANPEvent); + evt.eventType = kCustom_ANPEventType + // other data slots are optional + evt.other[] = ...; + To post a copy of the event, call + eventInterface->postEvent(myNPPInstance, &evt); + That call makes a copy of the event struct, and post that on the event + queue for the plugin. + */ + kCustom_ANPEventType = 6, }; typedef int32_t ANPEventType; @@ -803,39 +820,73 @@ enum ANPTouchActions { the plugin chooses to not handle this action then no other events related to that particular touch gesture will be generated. */ - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, - kMove_ANPTouchAction = 2, - kCancel_ANPTouchAction = 3, + kDown_ANPTouchAction = 0, + kUp_ANPTouchAction = 1, + kMove_ANPTouchAction = 2, + kCancel_ANPTouchAction = 3, + // The web view will ignore the return value from the following actions + kLongPress_ANPTouchAction = 4, + kDoubleTap_ANPTouchAction = 5, }; typedef int32_t ANPTouchAction; +/** + * When a plugin returns from NPP_HandleEvent() for a touch event, it can use + * ANPTouchResultMask to tell the web view which touch event it wants to handle. + * kHandleTouch_ANPTouchResult will handle all touch event inside the plugin. If + * it is not set, a plugin can choose only handle individual event like long + * press, or double tap. + */ +enum ANPTouchResultMask { + kHandleTouch_ANPTouchResult = 1, + kHandleLongPress_ANPTouchResult = 2, + kHandleDoubleTap_ANPTouchResult = 4, +}; + enum ANPLifecycleActions { /** The web view containing this plugin has been paused. See documentation on the android activity lifecycle for more information. */ - kPause_ANPLifecycleAction = 0, + kPause_ANPLifecycleAction = 0, /** The web view containing this plugin has been resumed. See documentation on the android activity lifecycle for more information. */ - kResume_ANPLifecycleAction = 1, + kResume_ANPLifecycleAction = 1, /** The plugin has focus and is now the recipient of input events (e.g. key, touch, etc.) */ - kGainFocus_ANPLifecycleAction = 2, + kGainFocus_ANPLifecycleAction = 2, /** The plugin has lost focus and will not receive any input events until it regains focus. This event is always preceded by a GainFocus action. */ - kLoseFocus_ANPLifecycleAction = 3, + kLoseFocus_ANPLifecycleAction = 3, /** The browser is running low on available memory and is requesting that the plugin free any unused/inactive resources to prevent a performance degradation. */ - kFreeMemory_ANPLifecycleAction = 4, + kFreeMemory_ANPLifecycleAction = 4, /** The page has finished loading. This happens when the page's top level frame reports that it has completed loading. */ - kOnLoad_ANPLifecycleAction = 5, + kOnLoad_ANPLifecycleAction = 5, + /** The browser is honoring the plugin's request to go full screen. Upon + returning from this event the browser will resize the plugin's java + surface to full-screen coordinates. + */ + kEnterFullScreen_ANPLifecycleAction = 6, + /** The browser has exited from full screen mode. Immediately prior to + sending this event the browser has resized the plugin's java surface to + its original coordinates. + */ + kExitFullScreen_ANPLifecycleAction = 7, + /** The plugin is visible to the user on the screen. This event will always + occur after a kOffScreen_ANPLifecycleAction event. + */ + kOnScreen_ANPLifecycleAction = 8, + /** The plugin is no longer visible to the user on the screen. This event + will always occur prior to an kOnScreen_ANPLifecycleAction event. + */ + kOffScreen_ANPLifecycleAction = 9, }; typedef uint32_t ANPLifecycleAction; @@ -880,15 +931,14 @@ struct ANPEvent { } data; }; -/////////////////////////////////////////////////////////////////////////////// -// System properties - -struct ANPSystemInterfaceV0 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - * or NULL if not supported +struct ANPEventInterfaceV0 : ANPInterface { + /** Post a copy of the specified event to the plugin. The event will be + delivered to the plugin in its main thread (the thread that receives + other ANPEvents). If, after posting before delivery, the NPP instance + is torn down, the event will be discarded. */ - const char* (*getApplicationDataDirectory)(); + void (*postEvent)(NPP inst, const ANPEvent* event); }; -#endif +#endif |
