diff options
Diffstat (limited to 'WebCore/plugins')
| -rw-r--r-- | WebCore/plugins/PluginPackage.h | 8 | ||||
| -rw-r--r-- | WebCore/plugins/PluginView.cpp | 14 | ||||
| -rw-r--r-- | WebCore/plugins/PluginView.h | 2 | ||||
| -rw-r--r-- | WebCore/plugins/android/PluginPackageAndroid.cpp | 73 | ||||
| -rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 76 | ||||
| -rw-r--r-- | WebCore/plugins/gtk/PluginViewGtk.cpp | 2 | ||||
| -rw-r--r-- | WebCore/plugins/mac/PluginViewMac.cpp | 14 | ||||
| -rw-r--r-- | WebCore/plugins/npfunctions.h | 2 | ||||
| -rw-r--r-- | WebCore/plugins/qt/PluginViewQt.cpp | 9 | ||||
| -rw-r--r-- | WebCore/plugins/symbian/PluginViewSymbian.cpp | 8 | ||||
| -rw-r--r-- | WebCore/plugins/win/PluginViewWin.cpp | 4 |
11 files changed, 86 insertions, 126 deletions
diff --git a/WebCore/plugins/PluginPackage.h b/WebCore/plugins/PluginPackage.h index c46c7eb..d409ab6 100644 --- a/WebCore/plugins/PluginPackage.h +++ b/WebCore/plugins/PluginPackage.h @@ -35,9 +35,6 @@ #include "npruntime_internal.h" #include <wtf/HashMap.h> #include <wtf/RefCounted.h> -#if defined(ANDROID_PLUGINS) -#include <nativehelper/jni.h> -#endif #if PLATFORM(SYMBIAN) class QPluginLoader; @@ -123,11 +120,6 @@ namespace WebCore { Timer<PluginPackage> m_freeLibraryTimer; PluginQuirkSet m_quirks; - -#if defined(ANDROID_PLUGINS) - // Java Plugin object. - jobject m_pluginObject; -#endif }; struct PluginPackageHash { diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp index 3f40000..89713b5 100644 --- a/WebCore/plugins/PluginView.cpp +++ b/WebCore/plugins/PluginView.cpp @@ -27,6 +27,12 @@ #include "config.h" #include "PluginView.h" +// ANDROID +// Temporary guard required until Bridge.h is script-engine independent +// See https://bugs.webkit.org/show_bug.cgi?id=32154 +#if USE(JSC) +#include "Bridge.h" +#endif #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -71,7 +77,6 @@ #include "JSDOMBinding.h" #include "c_instance.h" #include "runtime_root.h" -#include "runtime.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> @@ -126,15 +131,8 @@ void PluginView::setFrameRect(const IntRect& rect) if (m_element->document()->printing()) return; -#if defined(ANDROID_PLUGINS) - if (rect != frameRect()) { - Widget::setFrameRect(rect); - setNPWindowRect(rect); // only call when it changes - } -#else if (rect != frameRect()) Widget::setFrameRect(rect); -#endif updatePluginWidget(); diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h index a5618f7..0ce9c7c 100644 --- a/WebCore/plugins/PluginView.h +++ b/WebCore/plugins/PluginView.h @@ -373,7 +373,7 @@ public: private: -#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) +#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) || defined(ANDROID_PLUGINS) void setNPWindowIfNeeded(); #elif defined(XP_MACOSX) NP_CGContext m_npCgContext; diff --git a/WebCore/plugins/android/PluginPackageAndroid.cpp b/WebCore/plugins/android/PluginPackageAndroid.cpp index 664f31c..d55da87 100644 --- a/WebCore/plugins/android/PluginPackageAndroid.cpp +++ b/WebCore/plugins/android/PluginPackageAndroid.cpp @@ -25,24 +25,23 @@ */ #include "config.h" -#include "PluginDatabase.h" #include "PluginPackage.h" #ifdef ANDROID_PLUGINS -#include "Timer.h" +#include "CString.h" +#include "JNIUtility.h" #include "PlatformString.h" +#include "PluginDatabase.h" +#include "PluginDebug.h" +#include "PluginDebugAndroid.h" #include "PluginMainThreadScheduler.h" -#include "CString.h" -#include "jni_utility.h" -#include "npruntime_impl.h" +#include "Timer.h" #include "npfunctions.h" +#include "npruntime_impl.h" #include <dlfcn.h> #include <errno.h> -#include "PluginDebug.h" -#include "PluginDebugAndroid.h" - #define LOG_TAG "WebKit" namespace WebCore { @@ -188,45 +187,6 @@ static void initializeExtraBrowserFuncs(NPNetscapeFuncs *funcs) funcs->enumerate = _NPN_Enumerate; } -static jobject createPluginObject(const char *name, - const char *path, - const char *fileName, - const char *description) -{ - JNIEnv *env = JSC::Bindings::getJNIEnv(); - // Create a Java "class Plugin" object instance - jclass pluginClass = env->FindClass("android/webkit/Plugin"); - if(!pluginClass) { - PLUGIN_LOG("Couldn't find class android.webkit.Plugin\n"); - return 0; - } - // Get Plugin(String, String, String, String, Context) - jmethodID pluginConstructor = env->GetMethodID( - pluginClass, - "<init>", - "(Ljava/lang/String;" - "Ljava/lang/String;" - "Ljava/lang/String;" - "Ljava/lang/String;)V"); - if(!pluginConstructor) { - PLUGIN_LOG("Couldn't get android.webkit.Plugin constructor\n"); - return 0; - } - // Make Java strings of name, path, fileName, description - jstring javaName = env->NewStringUTF(name); - jstring javaPath = env->NewStringUTF(path); - jstring javaFileName = env->NewStringUTF(fileName); - jstring javaDescription = env->NewStringUTF(description); - // Make a plugin instance - jobject pluginObject = env->NewObject(pluginClass, - pluginConstructor, - javaName, - javaPath, - javaFileName, - javaDescription); - return pluginObject; -} - bool PluginPackage::load() { PLUGIN_LOG("tid:%d isActive:%d isLoaded:%d loadCount:%d\n", @@ -284,8 +244,7 @@ bool PluginPackage::load() m_pluginFuncs.size = sizeof(m_pluginFuncs); if(NP_Initialize(&m_browserFuncs, &m_pluginFuncs, - JSC::Bindings::getJNIEnv(), - m_pluginObject) != NPERR_NO_ERROR) { + JSC::Bindings::getJNIEnv()) != NPERR_NO_ERROR) { PLUGIN_LOG("Couldn't initialize plugin\n"); return false; } @@ -393,22 +352,6 @@ bool PluginPackage::fetchInfo() m_mimeToDescriptions.set(mimeType, description); } - // Create a new Java Plugin object, this object is an instance of - // android.os.WebView.Plugin - CString path = m_path.utf8(); - CString filename = m_fileName.utf8(); - jobject pluginObject = createPluginObject(name, - path.data(), - filename.data(), - description); - if(!pluginObject) { - PLUGIN_LOG("Couldn't create Java Plugin\n"); - return false; - } - - // Retain the Java Plugin object - m_pluginObject = JSC::Bindings::getJNIEnv()->NewGlobalRef(pluginObject); - PLUGIN_LOG("Fetch Info Loaded plugin details ok \"%s\"\n", m_path.utf8().data()); diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index e10641d..72fdf3f 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -52,7 +52,9 @@ #include "PlatformKeyboardEvent.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" +#include "Touch.h" #include "TouchEvent.h" +#include "TouchList.h" #include "android_graphics.h" #include "SkCanvas.h" #include "npruntime_impl.h" @@ -206,11 +208,16 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.modifiers = 0; // todo - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.touch.x = event->pageX() - m_npWindow.x; - evt.data.touch.y = event->pageY() - m_npWindow.y; + // In the event of a touchend (up) event, we must ask the changedTouch for the + // co-ordinates as there is no touch in touches anymore. + TouchList* touches = (evt.data.touch.action == kUp_ANPTouchAction) ? + event->changedTouches() : event->touches(); + + // Convert to coordinates that are relative to the plugin. + // We only support single touch points at the moment, so we want to look at index 0 only. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(IntPoint(touches->item(0)->pageX(), touches->item(0)->pageY()))); + evt.data.touch.x = localPos.x(); + evt.data.touch.y = localPos.y(); int16 ret = m_plugin->pluginFuncs()->event(m_instance, &evt); if (ignoreRet) @@ -243,11 +250,11 @@ void PluginView::handleMouseEvent(MouseEvent* event) SkANP::InitEvent(&evt, kMouse_ANPEventType); evt.data.mouse.action = isUp ? kUp_ANPMouseAction : kDown_ANPMouseAction; - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.mouse.x = event->pageX() - m_npWindow.x; - evt.data.mouse.y = event->pageY() - m_npWindow.y; + // Convert to coordinates that are relative to the plugin. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation())); + evt.data.mouse.x = localPos.x(); + evt.data.mouse.y = localPos.y(); + if (isDown) { // The plugin needs focus to receive keyboard events if (Page* page = m_parentFrame->page()) @@ -394,21 +401,34 @@ void PluginView::setParent(ScrollView* parent) } } -void PluginView::setNPWindowRect(const IntRect& rect) +void PluginView::setNPWindowRect(const IntRect&) { - if (!m_isStarted) - return; + setNPWindowIfNeeded(); +} - // the rect is relative to the frameview's (0,0) - m_npWindow.x = rect.x(); - m_npWindow.y = rect.y(); - m_npWindow.width = rect.width(); - m_npWindow.height = rect.height(); +void PluginView::setNPWindowIfNeeded() +{ + if (!m_isStarted || !parent()) + return; - m_npWindow.clipRect.left = 0; - m_npWindow.clipRect.top = 0; - m_npWindow.clipRect.right = rect.width(); - m_npWindow.clipRect.bottom = rect.height(); + // in Android, plugin always get the setwindow() in the page coordinate. + IntRect pageRect = m_windowRect; + ScrollView* top = parent(); + while (top->parent()) + top = top->parent(); + // only the top ScrollView can have the offset + pageRect.move(top->scrollOffset()); + + // the m_npWindow is relative to the page + m_npWindow.x = pageRect.x(); + m_npWindow.y = pageRect.y(); + m_npWindow.width = pageRect.width(); + m_npWindow.height = pageRect.height(); + + m_npWindow.clipRect.left = pageRect.x(); + m_npWindow.clipRect.top = pageRect.y(); + m_npWindow.clipRect.right = pageRect.x() + pageRect.width(); + m_npWindow.clipRect.bottom = pageRect.y() + pageRect.height(); if (m_plugin->pluginFuncs()->setwindow) { #if USE(JSC) @@ -587,16 +607,22 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) } m_window->inval(rect, false); + context->save(); + context->translate(frame.x(), frame.y()); m_window->draw(android_gc2canvas(context)); + context->restore(); } -// new as of SVN 38068, Nov 5 2008 void PluginView::updatePluginWidget() { - // I bet/hope we can move all of setNPWindowRect() into here FrameView* frameView = static_cast<FrameView*>(parent()); if (frameView) { - m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size()); + IntRect oldWindowRect = m_windowRect; + + m_windowRect = frameView->contentsToWindow(frameRect()); + + if (m_windowRect != oldWindowRect) + setNPWindowIfNeeded(); } } diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp index 6ea9417..3e7e3ee 100644 --- a/WebCore/plugins/gtk/PluginViewGtk.cpp +++ b/WebCore/plugins/gtk/PluginViewGtk.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -51,7 +52,6 @@ #include "JSDOMBinding.h" #include "ScriptController.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp index 44a0262..816efa0 100644 --- a/WebCore/plugins/mac/PluginViewMac.cpp +++ b/WebCore/plugins/mac/PluginViewMac.cpp @@ -31,10 +31,7 @@ #include "config.h" #include "PluginView.h" -#include <runtime/JSLock.h> -#include <runtime/JSValue.h> -#include "wtf/RetainPtr.h" - +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -53,7 +50,6 @@ #include "KeyboardEvent.h" #include "MouseEvent.h" #include "NotImplemented.h" -#include "npruntime_impl.h" #include "Page.h" #include "PlatformMouseEvent.h" #include "PlatformKeyboardEvent.h" @@ -61,10 +57,14 @@ #include "PluginPackage.h" #include "PluginMainThreadScheduler.h" #include "RenderLayer.h" -#include "runtime.h" -#include "runtime_root.h" #include "ScriptController.h" #include "Settings.h" +#include "npruntime_impl.h" +#include "runtime_root.h" +#include <runtime/JSLock.h> +#include <runtime/JSValue.h> +#include <wtf/RetainPtr.h> + using JSC::ExecState; using JSC::Interpreter; diff --git a/WebCore/plugins/npfunctions.h b/WebCore/plugins/npfunctions.h index 9f1b470..8bf5acb 100644 --- a/WebCore/plugins/npfunctions.h +++ b/WebCore/plugins/npfunctions.h @@ -206,7 +206,7 @@ typedef NPError (*MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownPro typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*); typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void); #elif defined(ANDROID_PLUGINS) -typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv *java_environment, jobject application_context); +typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv *java_environment); typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void); #else typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*); diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp index 063a7e5..bda76ce 100644 --- a/WebCore/plugins/qt/PluginViewQt.cpp +++ b/WebCore/plugins/qt/PluginViewQt.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -53,27 +54,27 @@ #include "PluginDebug.h" #include "PluginPackage.h" #include "PluginMainThreadScheduler.h" +#include "QWebPageClient.h" #include "RenderLayer.h" #include "ScriptController.h" #include "Settings.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" -#include "QWebPageClient.h" + #include <QApplication> #include <QDesktopWidget> #include <QKeyEvent> #include <QPainter> #include <QWidget> #include <QX11Info> -#include <runtime/JSLock.h> -#include <runtime/JSValue.h> #include <X11/X.h> #ifndef QT_NO_XRENDER #define Bool int #define Status int #include <X11/extensions/Xrender.h> #endif +#include <runtime/JSLock.h> +#include <runtime/JSValue.h> using JSC::ExecState; using JSC::Interpreter; diff --git a/WebCore/plugins/symbian/PluginViewSymbian.cpp b/WebCore/plugins/symbian/PluginViewSymbian.cpp index 14e25b1..44702fd 100644 --- a/WebCore/plugins/symbian/PluginViewSymbian.cpp +++ b/WebCore/plugins/symbian/PluginViewSymbian.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -36,8 +37,6 @@ #include "KeyboardEvent.h" #include "MouseEvent.h" #include "NotImplemented.h" -#include "npfunctions.h" -#include "npinterface.h" #include "Page.h" #include "PlatformKeyboardEvent.h" #include "PlatformMouseEvent.h" @@ -45,13 +44,14 @@ #include "PluginDebug.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" +#include "QWebPageClient.h" #include "RenderLayer.h" #include "ScriptController.h" #include "Settings.h" +#include "npfunctions.h" +#include "npinterface.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" -#include "QWebPageClient.h" #include <QKeyEvent> #include <QPixmap.h> #include <QRegion> diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp index 89eecc6..37f1fc8 100644 --- a/WebCore/plugins/win/PluginViewWin.cpp +++ b/WebCore/plugins/win/PluginViewWin.cpp @@ -33,6 +33,7 @@ #if !PLATFORM(WX) #include "BitmapInfo.h" #endif +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -62,11 +63,10 @@ #include "PluginDatabase.h" #include "PluginDebug.h" #include "PluginPackage.h" +#include "Settings.h" #include "c_instance.h" #include "npruntime_impl.h" #include "runtime_root.h" -#include "Settings.h" -#include "runtime.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> #include <wtf/ASCIICType.h> |
