diff options
author | Derek Sollenberger <djsollen@google.com> | 2010-01-22 14:40:05 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2010-01-25 09:56:56 -0500 |
commit | 2eb76d0bcdf5cdc45cf6188c8bb76a409612235b (patch) | |
tree | 910857e6b273ce472cd74b084e6f404af1b68f51 /WebKit | |
parent | ec4b5ee43c88d914221e8c9f668421ace6bdd72d (diff) | |
download | external_webkit-2eb76d0bcdf5cdc45cf6188c8bb76a409612235b.zip external_webkit-2eb76d0bcdf5cdc45cf6188c8bb76a409612235b.tar.gz external_webkit-2eb76d0bcdf5cdc45cf6188c8bb76a409612235b.tar.bz2 |
Add logging for all plugin events and their return values.
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/Android.mk | 1 | ||||
-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 | 32 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 6 |
5 files changed, 162 insertions, 21 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 87b08a2..ff759eb 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -77,6 +77,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/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 bf1289a..942e94d 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -38,8 +38,12 @@ #include "WebViewCore.h" #include "jni_utility.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; @@ -217,9 +221,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 @@ -236,9 +240,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) { @@ -265,8 +271,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) @@ -297,7 +303,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) @@ -310,7 +316,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, @@ -350,7 +356,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, @@ -382,9 +388,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; } @@ -407,7 +413,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 f0cebcf..db70912 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -88,10 +88,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. |