diff options
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 11 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 3 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 32 |
3 files changed, 42 insertions, 4 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 37c7445..e391148 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -282,6 +282,7 @@ struct WebViewCore::JavaGlue { jmethodID m_getPluginClass; jmethodID m_showFullScreenPlugin; jmethodID m_hideFullScreenPlugin; + jmethodID m_createSurface; jmethodID m_addSurface; jmethodID m_updateSurface; jmethodID m_destroySurface; @@ -376,6 +377,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;"); m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/ViewManager$ChildView;I)V"); m_javaGlue->m_hideFullScreenPlugin = GetJMethod(env, clazz, "hideFullScreenPlugin", "()V"); + m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Landroid/view/View;)Landroid/webkit/ViewManager$ChildView;"); m_javaGlue->m_addSurface = GetJMethod(env, clazz, "addSurface", "(Landroid/view/View;IIII)Landroid/webkit/ViewManager$ChildView;"); m_javaGlue->m_updateSurface = GetJMethod(env, clazz, "updateSurface", "(Landroid/webkit/ViewManager$ChildView;IIII)V"); m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/webkit/ViewManager$ChildView;)V"); @@ -3270,6 +3272,15 @@ void WebViewCore::hideFullScreenPlugin() checkException(env); } +jobject WebViewCore::createSurface(jobject view) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jobject result = env->CallObjectMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_createSurface, view); + checkException(env); + return result; +} + jobject WebViewCore::addSurface(jobject view, int x, int y, int width, int height) { JNIEnv* env = JSC::Bindings::getJNIEnv(); diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index b223191..b13e3a5 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -454,6 +454,9 @@ namespace android { // Instructs the UI thread to discard the plugin's full-screen surface void hideFullScreenPlugin(); + // Creates a childView for the plugin but does not attach to the view hierarchy + jobject createSurface(jobject view); + // Adds the plugin's view (aka surface) to the view hierarchy jobject addSurface(jobject view, int x, int y, int width, int height); diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 83bc8cb..925f823 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -536,7 +536,29 @@ void PluginWidgetAndroid::scrollToVisiblePluginRect() { } void PluginWidgetAndroid::requestFullScreen() { - if (m_isFullScreen || !m_embeddedView) { + if (m_isFullScreen) { + return; + } + + if (!m_embeddedView && m_drawingModel == kOpenGL_ANPDrawingModel) { + WebCore::PluginPackage* pkg = m_pluginView->plugin(); + NPP instance = m_pluginView->instance(); + + jobject pluginSurface; + pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, + static_cast<void*>(&pluginSurface)); + + // create the surface, but do not add it to the view hierarchy + jobject tempObj = m_core->createSurface(pluginSurface); + + if (tempObj) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + m_embeddedView = env->NewGlobalRef(tempObj); + m_embeddedViewAttached = false; + } + } + + if (!m_embeddedView) { return; } @@ -547,7 +569,8 @@ void PluginWidgetAndroid::requestFullScreen() { sendEvent(event); // remove the embedded surface from the view hierarchy - m_core->destroySurface(m_embeddedView); + if (m_drawingModel != kOpenGL_ANPDrawingModel) + m_core->destroySurface(m_embeddedView); // add the full screen view m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance()); @@ -565,8 +588,9 @@ void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { } // add the embedded view back - m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); + if (m_drawingModel != kOpenGL_ANPDrawingModel) + m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, + m_pluginWindow->width, m_pluginWindow->height); // send event to notify plugin of full screen change ANPEvent event; |