diff options
-rw-r--r-- | Android.mk | 15 | ||||
-rw-r--r-- | WebCore/Android.jscbindings.mk | 1 | ||||
-rw-r--r-- | WebCore/Android.v8bindings.mk | 1 | ||||
-rw-r--r-- | WebCore/bindings/v8/NPV8Object.cpp | 23 | ||||
-rw-r--r-- | WebCore/bindings/v8/NPV8Object.h | 7 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptController.cpp | 18 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptObject.cpp | 2 | ||||
-rw-r--r-- | WebCore/bindings/v8/V8DOMWrapper.cpp | 9 | ||||
-rw-r--r-- | WebCore/bindings/v8/V8DOMWrapper.h | 3 | ||||
-rw-r--r-- | WebCore/bindings/v8/WorkerContextExecutionProxy.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 54 | ||||
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 6 | ||||
-rw-r--r-- | WebKit/Android.mk | 1 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 20 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 8 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginDebugAndroid.cpp | 130 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginDebugAndroid.h | 14 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 53 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 6 |
19 files changed, 270 insertions, 106 deletions
@@ -110,6 +110,7 @@ LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(LOCAL_PATH)/WebCore/platform/animation \ $(LOCAL_PATH)/WebCore/platform/graphics \ $(LOCAL_PATH)/WebCore/platform/graphics/android \ + $(LOCAL_PATH)/WebCore/platform/graphics/filters \ $(LOCAL_PATH)/WebCore/platform/graphics/network \ $(LOCAL_PATH)/WebCore/platform/graphics/skia \ $(LOCAL_PATH)/WebCore/platform/graphics/transforms \ @@ -124,6 +125,10 @@ LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(LOCAL_PATH)/WebCore/rendering \ $(LOCAL_PATH)/WebCore/rendering/style \ $(LOCAL_PATH)/WebCore/storage \ + $(LOCAL_PATH)/WebCore/svg \ + $(LOCAL_PATH)/WebCore/svg/animation \ + $(LOCAL_PATH)/WebCore/svg/graphics \ + $(LOCAL_PATH)/WebCore/svg/graphics/filters \ $(LOCAL_PATH)/WebCore/workers \ $(LOCAL_PATH)/WebCore/xml @@ -146,16 +151,6 @@ LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(base_intermediates)/WebCore/html \ $(base_intermediates)/WebCore/platform -ifeq ($(ENABLE_SVG), true) -LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ - $(LOCAL_PATH)/WebCore/platform/graphics/filters \ - $(LOCAL_PATH)/WebCore/svg \ - $(LOCAL_PATH)/WebCore/svg/animation \ - $(LOCAL_PATH)/WebCore/svg/graphics \ - $(LOCAL_PATH)/WebCore/svg/graphics/filters \ - $(base_intermediates)/WebCore/svg -endif - ifeq ($(JAVASCRIPT_ENGINE),v8) # Include WTF source file. d := JavaScriptCore diff --git a/WebCore/Android.jscbindings.mk b/WebCore/Android.jscbindings.mk index 428f99a..59daf8d 100644 --- a/WebCore/Android.jscbindings.mk +++ b/WebCore/Android.jscbindings.mk @@ -53,6 +53,7 @@ BINDING_C_INCLUDES := \ $(base_intermediates)/WebCore/page \ $(base_intermediates)/WebCore/plugins \ $(base_intermediates)/WebCore/storage \ + $(base_intermediates)/WebCore/svg \ $(base_intermediates)/WebCore/workers \ $(base_intermediates)/WebCore/xml diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk index d5eb37a..683de78 100644 --- a/WebCore/Android.v8bindings.mk +++ b/WebCore/Android.v8bindings.mk @@ -33,6 +33,7 @@ BINDING_C_INCLUDES := \ $(LOCAL_PATH)/bridge \ \ $(base_intermediates)/WebCore/bindings \ + $(base_intermediates)/WebCore/svg \ $(base_intermediates)/JavaScriptCore LOCAL_SRC_FILES += \ diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp index 69cd303..e222ecd 100644 --- a/WebCore/bindings/v8/NPV8Object.cpp +++ b/WebCore/bindings/v8/NPV8Object.cpp @@ -28,10 +28,7 @@ #include "NPV8Object.h" -#if PLATFORM(CHROMIUM) -// TODO(andreip): upstream -#include "ChromiumBridge.h" -#endif +#include "PlatformBridge.h" #include "DOMWindow.h" #include "Frame.h" #include "OwnArrayPtr.h" @@ -42,11 +39,6 @@ #include "V8Helpers.h" #include "V8NPUtils.h" #include "V8Proxy.h" -#if PLATFORM(CHROMIUM) -#include "bindings/npruntime.h" -#else -#include "bridge/npruntime.h" -#endif #include "npruntime_impl.h" #include "npruntime_priv.h" @@ -242,13 +234,7 @@ bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments, bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result) { -#if PLATFORM(CHROMIUM) - bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp); -#else - // TODO(andreip): Some of the binding code is specific to Chromium - // and we don't want it to Android. What is the preferred way to handle this? - bool popupsAllowed = false; -#endif + bool popupsAllowed = WebCore::PlatformBridge::popupsAllowed(npp); return _NPN_EvaluateHelper(npp, popupsAllowed, npObject, npScript, result); } @@ -461,12 +447,7 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint v8::Handle<v8::Value> enumeratorObj = script->Run(); v8::Handle<v8::Function> enumerator = v8::Handle<v8::Function>::Cast(enumeratorObj); v8::Handle<v8::Value> argv[] = { obj }; -#if PLATFORM(ANDROID) -// TODO(benm): implement an arry size function on android - v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), 1, argv); -#else v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), ARRAYSIZE_UNSAFE(argv), argv); -#endif if (propsObj.IsEmpty()) return false; diff --git a/WebCore/bindings/v8/NPV8Object.h b/WebCore/bindings/v8/NPV8Object.h index 1b65a1f..62b3ba4 100644 --- a/WebCore/bindings/v8/NPV8Object.h +++ b/WebCore/bindings/v8/NPV8Object.h @@ -31,10 +31,13 @@ #define NPV8Object_h #if PLATFORM(CHROMIUM) -// TODO(andreip): diff and consolidate +// FIXME: Chromium uses a different npruntime.h, which is in +// the Chromium source repository under third_party/npapi/bindings. +// The Google-specific changes in that file should probably be +// moved into bridge/npruntime.h, guarded by an #if PlATFORM(CHROMIUM). #include "bindings/npruntime.h" #else -#include "bridge/npruntime.h" // use WebCore version +#include "bridge/npruntime.h" // Use WebCore version for Android and other ports. #endif #include <v8.h> diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index 5b4dbc2..6ba70d6 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -32,12 +32,8 @@ #include "config.h" #include "ScriptController.h" -#if PLATFORM(CHROMIUM) -#include "ChromiumBridge.h" -#elif PLATFORM(ANDROID) -#include "PluginView.h" -#endif +#include "PlatformBridge.h" #include "CString.h" #include "Document.h" #include "DOMWindow.h" @@ -306,23 +302,13 @@ PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widge { ASSERT(widget); -#if PLATFORM(CHROMIUM) if (widget->isFrameView()) return 0; - NPObject* npObject = ChromiumBridge::pluginScriptableObject(widget); - if (!npObject) - return 0; - -#elif PLATFORM(ANDROID) - if (!widget->isPluginView()) - return 0; + NPObject* npObject = PlatformBridge::pluginScriptableObject(widget); - PluginView* pluginView = static_cast<PluginView*>(widget); - NPObject* npObject = pluginView->getNPObject(); if (!npObject) return 0; -#endif // Frame Memory Management for NPObjects // ------------------------------------- diff --git a/WebCore/bindings/v8/ScriptObject.cpp b/WebCore/bindings/v8/ScriptObject.cpp index 5f5609c..8d80d34 100644 --- a/WebCore/bindings/v8/ScriptObject.cpp +++ b/WebCore/bindings/v8/ScriptObject.cpp @@ -144,9 +144,7 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value) { ScriptScope scope(scriptState); -#if !PLATFORM(ANDROID) scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value)); -#endif return scope.success(); } diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index 6a691a9..28b316a 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -32,18 +32,11 @@ #include "V8DOMWrapper.h" #include "CSSMutableStyleDeclaration.h" -// ANDROID: Upstream CHROMIUM guard. -#if PLATFORM(CHROMIUM) -#include "ChromiumBridge.h" -#endif #include "DOMObjectsInclude.h" #include "DocumentLoader.h" #include "FrameLoaderClient.h" #include "Notification.h" -// ANDROID: Upstream SVG guard. -#if ENABLE(SVG) #include "SVGElementInstance.h" -#endif #include "ScriptController.h" #include "V8AbstractEventListener.h" #include "V8Binding.h" @@ -592,13 +585,11 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W instanceTemplate->SetInternalFieldCount(V8Custom::kXMLHttpRequestInternalFieldCount); break; } -// ANDROID: Upstream XPATH guard. #if ENABLE(XPATH) case V8ClassIndex::XPATHEVALUATOR: descriptor->SetCallHandler(USE_CALLBACK(XPathEvaluatorConstructor)); break; #endif -// ANDROID: Upstream XSLT guard. #if ENABLE(XSLT) case V8ClassIndex::XSLTPROCESSOR: descriptor->SetCallHandler(USE_CALLBACK(XSLTProcessorConstructor)); diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h index 660b827..2761100 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.h +++ b/WebCore/bindings/v8/V8DOMWrapper.h @@ -242,8 +242,6 @@ namespace WebCore { static PassRefPtr<EventListener> getEventListener(V8Proxy* proxy, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup); -#if PLATFORM(ANDROID) -// TODO: upstream XPATH guard. #if ENABLE(XPATH) // XPath-related utilities static RefPtr<XPathNSResolver> getXPathNSResolver(v8::Handle<v8::Value> value, V8Proxy* proxy = 0) @@ -256,7 +254,6 @@ namespace WebCore { return resolver; } #endif -#endif // DOMImplementation is a singleton and it is handled in a special // way. A wrapper is generated per document and stored in an diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp index 8c66d7b..412fde0 100644 --- a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp +++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp @@ -124,11 +124,6 @@ void WorkerContextExecutionProxy::initV8IfNeeded() v8::V8::IgnoreOutOfMemoryException(); v8::V8::SetFatalErrorHandler(reportFatalErrorInV8); -#if PLATFORM(ANDROID) - const int workerThreadPreemptionIntervalMs = 5; - v8::Locker::StartPreemption(workerThreadPreemptionIntervalMs); -#endif - v8::ResourceConstraints resource_constraints; uint32_t here; resource_constraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uint32_t*)); diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index a73abab..cf9f561 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -27,13 +27,62 @@ #define PlatformBridge_h #include "KURL.h" +#include "npapi.h" #include "PlatformString.h" #include <wtf/Vector.h> +// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied +// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h +// +// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize, +// but can be used on anonymous types or types defined inside +// functions. It's less safe than arraysize as it accepts some +// (although not all) pointers. Therefore, you should use arraysize +// whenever possible. +// +// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type +// size_t. +// +// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error +// +// "warning: division by zero in ..." +// +// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer. +// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays. +// +// The following comments are on the implementation details, and can +// be ignored by the users. +// +// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in +// the array) and sizeof(*(arr)) (the # of bytes in one array +// element). If the former is divisible by the latter, perhaps arr is +// indeed an array, in which case the division result is the # of +// elements in the array. Otherwise, arr cannot possibly be an array, +// and we generate a compiler error to prevent the code from +// compiling. +// +// Since the size of bool is implementation-defined, we need to cast +// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final +// result has type size_t. +// +// This macro is not perfect as it wrongfully accepts certain +// pointers, namely where the pointer size is divisible by the pointee +// size. Since all our code has to go through a 32-bit compiler, +// where a pointer is 4 bytes, this means all pointers to a type whose +// size is 3 or greater than 4 will be (righteously) rejected. + +#define ARRAYSIZE_UNSAFE(a) \ + ((sizeof(a) / sizeof(*(a))) / \ + static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) + + +class NPObject; + namespace WebCore { class FrameView; +class Widget; // An interface to the embedding layer, which has the ability to answer // questions about the system and so on... @@ -54,6 +103,11 @@ public: static void setCookies(const KURL&, const String& value); static String cookies(const KURL&); static bool cookiesEnabled(); + // Plugin + static NPObject* pluginScriptableObject(Widget*); + // Popups + static bool popupsAllowed(NPP); + // These ids need to be in sync with the constants in BrowserFrame.java enum rawResId { NoDomain = 1, diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 72fdf3f..41dc668 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -219,7 +219,7 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.x = localPos.x(); evt.data.touch.y = localPos.y(); - int16 ret = m_plugin->pluginFuncs()->event(m_instance, &evt); + int16 ret = m_window->sendEvent(evt); if (ignoreRet) return; if (ret & kHandleTouch_ANPTouchResult) { @@ -266,7 +266,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) return; } - if (m_plugin->pluginFuncs()->event(m_instance, &evt)) { + if (m_window->sendEvent(evt)) { event->setDefaultHandled(); } } @@ -355,7 +355,7 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) evt.data.key.modifiers = make_modifiers(pke->shiftKey(), pke->altKey()); evt.data.key.unichar = pke->unichar(); - if (m_plugin->pluginFuncs()->event(m_instance, &evt)) { + if (m_window->sendEvent(evt)) { event->setDefaultHandled(); } else if (m_window->inFullScreen()){ // while in the full screen mode, always consumes the key events and diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 16ba925..ca2a7ff 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -76,6 +76,7 @@ LOCAL_SRC_FILES := \ android/plugins/ANPSystemInterface.cpp \ android/plugins/ANPTypefaceInterface.cpp \ android/plugins/ANPWindowInterface.cpp \ + android/plugins/PluginDebugAndroid.cpp \ android/plugins/PluginTimer.cpp \ android/plugins/PluginViewBridgeAndroid.cpp \ android/plugins/PluginWidgetAndroid.cpp \ diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index f36ecf7..b91a5d8 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -29,7 +29,9 @@ #include "CookieClient.h" #include "JavaSharedClient.h" #include "KeyGeneratorClient.h" +#include "PluginView.h" #include "WebViewCore.h" +#include "npruntime.h" #include <wtf/android/AndroidThreading.h> #include <wtf/MainThread.h> @@ -98,11 +100,29 @@ bool PlatformBridge::cookiesEnabled() return client->cookiesEnabled(); } +NPObject* PlatformBridge::pluginScriptableObject(Widget* widget) +{ +#if USE(V8) + if (!widget->isPluginView()) + return 0; + + PluginView* pluginView = static_cast<PluginView*>(widget); + return pluginView->getNPObject(); +#else + return 0; +#endif +} + bool PlatformBridge::isWebViewPaused() { return WebViewCore::isPaused(); } +bool PlatformBridge::popupsAllowed(NPP) +{ + return false; +} + } // namespace WebCore diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 98f308c..dae93fc 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1998,13 +1998,15 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); if (!root) return; - const CachedNode* current = root->currentCursor(); + const CachedFrame* containingFrame; + const CachedNode* current = root->currentCursor(&containingFrame); if (!current) - current = root->currentFocus(); + current = root->currentFocus(&containingFrame); if (!current) return; const CachedFrame* frame; - const CachedNode* next = root->nextTextField(current, &frame, true); + const CachedNode* next = containingFrame->nextTextField(current, &frame, + true); if (!next) return; const WebCore::IntRect& bounds = next->bounds(); diff --git a/WebKit/android/plugins/PluginDebugAndroid.cpp b/WebKit/android/plugins/PluginDebugAndroid.cpp new file mode 100644 index 0000000..ddb00c5 --- /dev/null +++ b/WebKit/android/plugins/PluginDebugAndroid.cpp @@ -0,0 +1,130 @@ +/* + * Copyright 2010, 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. + */ + +#include "PluginDebugAndroid.h" +#include "utils/Log.h" +#include <stdarg.h> + +#define ARRAY_COUNT(array) static_cast<int32_t>(sizeof(array) / sizeof(array[0])) + +// used for key, mouse, and touch inputs +static const char* const inputActions[] = { + "down", + "up", + "move", /* touch only */ + "cancel", /* touch only */ + "longPress", /* touch only */ + "doubleTap" /* touch only */ +}; + +static const char* const lifecycleActions[] = { + "kPause_ANPLifecycleAction", + "kResume_ANPLifecycleAction", + "kGainFocus_ANPLifecycleAction", + "kLoseFocus_ANPLifecycleAction", + "kFreeMemory_ANPLifecycleAction", + "kOnLoad_ANPLifecycleAction", + "kEnterFullScreen_ANPLifecycleAction", + "kExitFullScreen_ANPLifecycleAction", + "kOnScreen_ANPLifecycleAction", + "kOffScreen_ANPLifecycleAction" +}; + +void anp_logPlugin(const char format[], ...) { + va_list args; + va_start(args, format); + LOG_PRI_VA(ANDROID_LOG_DEBUG, "webkit_plugin", format, args); + va_end(args); +} + +void anp_logPluginEvent(void* npp, const ANPEvent* evt, int16 returnVal) { + + switch(evt->eventType) { + + case kNull_ANPEventType: + PLUGIN_LOG("%p EVENT::NULL", npp); + break; + + case kKey_ANPEventType: + if(evt->data.key.action < ARRAY_COUNT(inputActions)) { + PLUGIN_LOG("%p EVENT::KEY[%d] action=%s code=%d vcode=%d unichar=%d repeat=%d mods=%x", + npp, returnVal, inputActions[evt->data.key.action], + evt->data.key.nativeCode, evt->data.key.virtualCode, + evt->data.key.unichar, evt->data.key.repeatCount, + evt->data.key.modifiers); + } else { + PLUGIN_LOG("%p EVENT::KEY[%d] unknown action", npp, returnVal); + } + break; + + case kMouse_ANPEventType: + if(evt->data.mouse.action < ARRAY_COUNT(inputActions)) { + PLUGIN_LOG("%p EVENT::MOUSE[%d] action=%s [%d %d]", npp, + returnVal, inputActions[evt->data.mouse.action], + evt->data.touch.x, evt->data.touch.y); + } else { + PLUGIN_LOG("%p EVENT::MOUSE[%d] unknown action", npp, returnVal); + } + break; + + case kTouch_ANPEventType: + if(evt->data.touch.action < ARRAY_COUNT(inputActions)) { + PLUGIN_LOG("%p EVENT::TOUCH[%d] action=%s [%d %d]", npp, + returnVal, inputActions[evt->data.touch.action], + evt->data.touch.x, evt->data.touch.y); + } else { + PLUGIN_LOG("%p EVENT::TOUCH[%d] unknown action", npp, returnVal); + } + break; + + case kDraw_ANPEventType: + if (evt->data.draw.model == kBitmap_ANPDrawingModel) { + PLUGIN_LOG("%p EVENT::DRAW bitmap format=%d clip=[%d,%d,%d,%d]", + npp, evt->data.draw.data.bitmap.format, + evt->data.draw.clip.left, evt->data.draw.clip.top, + evt->data.draw.clip.right, evt->data.draw.clip.bottom); + } else { + PLUGIN_LOG("%p EVENT::DRAW unknown drawing model", npp); + } + break; + + case kLifecycle_ANPEventType: + if(evt->data.lifecycle.action < ARRAY_COUNT(lifecycleActions)) { + PLUGIN_LOG("%p EVENT::LIFECYCLE %s", npp, + lifecycleActions[evt->data.lifecycle.action]); + } else { + PLUGIN_LOG("%p EVENT::LIFECYCLE unknown action", npp); + } + break; + + case kCustom_ANPEventType: + PLUGIN_LOG("%p EVENT::CUSTOM", npp); + break; + + default: + PLUGIN_LOG("%p EVENT::UNKNOWN", npp); + break; + } +} diff --git a/WebKit/android/plugins/PluginDebugAndroid.h b/WebKit/android/plugins/PluginDebugAndroid.h index 2143b39..24944cb 100644 --- a/WebKit/android/plugins/PluginDebugAndroid.h +++ b/WebKit/android/plugins/PluginDebugAndroid.h @@ -26,21 +26,25 @@ #ifndef PLUGIN_DEBUG_ANDROID_H__ #define PLUGIN_DEBUG_ANDROID_H__ -#ifdef ANDROID_PLUGINS +#include "android_npapi.h" // Define PLUGIN_DEBUG_LOCAL in an individual C++ file to enable for // that file only. // Define PLUGIN_DEBUG_GLOBAL to 1 to turn plug-in debug for all -// Android plug-in code in this direectory. +// Android plug-in code in this directory. #define PLUGIN_DEBUG_GLOBAL 0 #if PLUGIN_DEBUG_GLOBAL || defined(PLUGIN_DEBUG_LOCAL) -# define PLUGIN_LOG(A, B...) do { LOGI( A , ## B ); } while(0) +# define PLUGIN_LOG(FORMAT, ARGS...) do { anp_logPlugin(FORMAT, ## ARGS); } while(0) +# define PLUGIN_LOG_EVENT(NPP, EVT, RET) do { anp_logPluginEvent(NPP, EVT, RET); } while(0) + +void anp_logPlugin(const char format[], ...); +void anp_logPluginEvent(void* npp, const ANPEvent* event, int16 returnVal); + #else # define PLUGIN_LOG(A, B...) do { } while(0) -#endif - +# define PLUGIN_LOG_EVENT(NPP, EVENT) do { } while(0) #endif #endif // defined(PLUGIN_DEBUG_ANDROID_H__) diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 553b455..9dd9154 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -44,8 +44,12 @@ #include "android_graphics.h" #include <JNIUtility.h> +#define PLUGIN_DEBUG_LOCAL 0 // controls the printing of log messages #define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes +// this include statement must follow the declaration of PLUGIN_DEBUG_LOCAL +#include "PluginDebugAndroid.h" + PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) : m_pluginView(view) { m_flipPixelRef = NULL; @@ -113,14 +117,8 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { if (m_drawingModel == kSurface_ANPDrawingModel) { - // if the surface exists check for changes and update accordingly - if (m_embeddedView && m_pluginBounds != oldPluginBounds) { - - m_core->updateSurface(m_embeddedView, window->x, window->y, - window->width, window->height); - // if the surface does not exist then create a new surface - } else if(!m_embeddedView) { + if (!m_embeddedView) { WebCore::PluginPackage* pkg = m_pluginView->plugin(); NPP instance = m_pluginView->instance(); @@ -136,10 +134,15 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { JNIEnv* env = JSC::Bindings::getJNIEnv(); m_embeddedView = env->NewGlobalRef(tempObj); } - } - if (m_isFullScreen && m_pluginBounds != oldPluginBounds) { - m_core->updateFullScreenPlugin(window->x, window->y, - window->width, window->height); + } else if (m_pluginBounds != oldPluginBounds) { + // if the surface exists check for changes and update accordingly + if (m_isFullScreen) { + m_core->updateFullScreenPlugin(window->x, window->y, + window->width, window->height); + } else { + m_core->updateSurface(m_embeddedView, window->x, window->y, + window->width, window->height); + } } } else { m_flipPixelRef->safeUnref(); @@ -224,9 +227,9 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) { } } -bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { +int16 PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { if (!m_acceptEvents) - return false; + return 0; WebCore::PluginPackage* pkg = m_pluginView->plugin(); NPP instance = m_pluginView->instance(); // "missing" plugins won't have these @@ -243,9 +246,11 @@ bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { // make a localCopy since the actual plugin may not respect its constness, // and so we don't want our caller to have its param modified ANPEvent localCopy = evt; - return pkg->pluginFuncs()->event(instance, &localCopy); + int16 result = pkg->pluginFuncs()->event(instance, &localCopy); + PLUGIN_LOG_EVENT(instance, &evt, result); + return result; } - return false; + return 0; } void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) { @@ -278,8 +283,8 @@ 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); + PLUGIN_LOG("%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) @@ -310,7 +315,7 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { #if DEBUG_VISIBLE_RECTS - SkDebugf("%s count=%d", __FUNCTION__, count); + PLUGIN_LOG("%s count=%d", __FUNCTION__, count); #endif // ensure the count does not exceed our allocated space if (count > MAX_REQUESTED_RECTS) @@ -323,7 +328,7 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) #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, + PLUGIN_LOG("%s [%d](%d,%d,%d,%d)", __FUNCTION__, index, m_requestedVisibleRect[index].left, m_requestedVisibleRect[index].top, m_requestedVisibleRect[index].right, @@ -363,7 +368,7 @@ void PluginWidgetAndroid::computeVisibleDocRect() { // ensure the rect falls within the plugin's bounds if (!m_pluginBounds.contains(pluginRect)) { #if DEBUG_VISIBLE_RECTS - SkDebugf("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__, + PLUGIN_LOG("%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, @@ -395,9 +400,9 @@ void PluginWidgetAndroid::scrollToVisibleDocRect() { if (!m_hasFocus || m_requestedDocRect.isEmpty() || m_visibleDocRect.isEmpty()) { #if DEBUG_VISIBLE_RECTS - SkDebugf("%s call m_hasFocus=%d m_requestedDocRect.isEmpty()=%d" - " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, - m_requestedDocRect.isEmpty(), m_visibleDocRect.isEmpty()); + PLUGIN_LOG("%s call m_hasFocus=%d m_requestedDocRect.isEmpty()=%d" + " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, + m_requestedDocRect.isEmpty(), m_visibleDocRect.isEmpty()); #endif return; } @@ -420,7 +425,7 @@ void PluginWidgetAndroid::scrollToVisibleDocRect() { 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); + PLUGIN_LOG("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY); #endif core->scrollBy(deltaX, deltaY, true); } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 6633e1b..ae6fcb7 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -89,10 +89,10 @@ struct PluginWidgetAndroid { */ void draw(SkCanvas* canvas = NULL); - /* Send this event to the plugin instance, and return true if the plugin - handled it. + /* Send this event to the plugin instance. A non-zero value will be + returned if the plugin handled the event. */ - bool sendEvent(const ANPEvent&); + int16 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. |