summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-01-25 07:39:50 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-01-25 07:39:50 -0800
commit8f790f8dd3f2e5085a6f3c7bbff878e77fd7ed01 (patch)
tree7cc61d539ae13869cef313aac23df533f9639fb7
parent5106648b32c4af91bb26f2a5af60a2c1eac14a78 (diff)
parent53e1af87fa4f19eac50b3d6fb45a3a386d156cd0 (diff)
downloadexternal_webkit-8f790f8dd3f2e5085a6f3c7bbff878e77fd7ed01.zip
external_webkit-8f790f8dd3f2e5085a6f3c7bbff878e77fd7ed01.tar.gz
external_webkit-8f790f8dd3f2e5085a6f3c7bbff878e77fd7ed01.tar.bz2
am 53e1af87: am 2eb76d0b: Add logging for all plugin events and their return values.
Merge commit '53e1af87fa4f19eac50b3d6fb45a3a386d156cd0' * commit '53e1af87fa4f19eac50b3d6fb45a3a386d156cd0': Add logging for all plugin events and their return values.
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp6
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/plugins/PluginDebugAndroid.cpp130
-rw-r--r--WebKit/android/plugins/PluginDebugAndroid.h14
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp32
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h6
6 files changed, 165 insertions, 24 deletions
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/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 b815c90..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;
@@ -223,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
@@ -242,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) {
@@ -277,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)
@@ -309,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)
@@ -322,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,
@@ -362,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,
@@ -394,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;
}
@@ -419,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.