diff options
author | Grace Kloba <klobag@google.com> | 2009-12-16 11:39:26 -0800 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2009-12-16 11:39:26 -0800 |
commit | fcce71fa296bf3b42bfc978caa059c55ce8df998 (patch) | |
tree | c5e13819f3f5f49b1ee8e4cfe848922214c5d682 /WebKit | |
parent | d4924af12855cd19162ba1442a6055664c98ca32 (diff) | |
download | external_webkit-fcce71fa296bf3b42bfc978caa059c55ce8df998.zip external_webkit-fcce71fa296bf3b42bfc978caa059c55ce8df998.tar.gz external_webkit-fcce71fa296bf3b42bfc978caa059c55ce8df998.tar.bz2 |
Implement the full screen WebView plugin.
Use a NoTitleBar_Fullscreen dialog to implement the
full screen plugin. This runs in the same thread as
WebView (UI in the Browser case). One catch is that
the SurfaceView provided by the plugin needs to be
opaque if it doesn't want to see through the WebView.
The PluginFullScreenHolder translates the events to
the underline WebView. Special treatment in the touch
case as it needs to translate the coordinates.
WebView can't be panned, or double tap to zoom, or
long press to trigger the context menu while having
a full screen plugin.
Inside webkit, we also give the plugin element focus
when it goes to the full screen so that it takes key
events. While handling key events, we don't let it
loose focus or scroll out.
Todo:
When a plugin goes to full screen, we should make
sure the embedded plugin is fully visible. Otherwise
when we translate the touch events back, they will be
outside of the visible rect and will be ignored.
This is part 2 of 2-project check in.
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 23 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 5 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPWindowInterface.cpp | 2 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 2 |
5 files changed, 36 insertions, 5 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index e62b362..26bf315 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -212,6 +212,7 @@ struct WebViewCore::JavaGlue { jmethodID m_createPluginJavaInstance; jmethodID m_showFullScreenPlugin; jmethodID m_hideFullScreenPlugin; + jmethodID m_updateFullScreenPlugin; jmethodID m_createSurface; jmethodID m_updateSurface; jmethodID m_destroySurface; @@ -291,8 +292,9 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V"); m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;"); m_javaGlue->m_createPluginJavaInstance = GetJMethod(env, clazz, "createPluginJavaInstance", "(Ljava/lang/String;I)Landroid/webkit/plugin/WebkitPlugin;"); - m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/plugin/WebkitPlugin;I)V"); + m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/plugin/WebkitPlugin;IIIII)V"); m_javaGlue->m_hideFullScreenPlugin = GetJMethod(env, clazz, "hideFullScreenPlugin", "()V"); + m_javaGlue->m_updateFullScreenPlugin = GetJMethod(env, clazz, "updateFullScreenPlugin", "(IIII)V"); m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Landroid/webkit/plugin/WebkitPlugin;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"); @@ -2560,7 +2562,8 @@ jobject WebViewCore::createPluginJavaInstance(const WebCore::String& libName, NP return result; } -void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp) +void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x, + int y, int width, int height) { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = m_javaGlue->object(env); @@ -2571,7 +2574,7 @@ void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp) env->CallVoidMethod(obj.get(), m_javaGlue->m_showFullScreenPlugin, - webkitPlugin, (int)npp); + webkitPlugin, (int)npp, x, y, width, height); checkException(env); } @@ -2588,6 +2591,20 @@ void WebViewCore::hideFullScreenPlugin() checkException(env); } +void WebViewCore::updateFullScreenPlugin(int x, int y, int width, int height) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = m_javaGlue->object(env); + // if it is called during DESTROY is handled, the real object of WebViewCore + // can be gone. Check before using it. + if (!obj.get()) + return; + + env->CallVoidMethod(obj.get(), m_javaGlue->m_updateFullScreenPlugin, x, y, + width, height); + checkException(env); +} + jobject WebViewCore::createSurface(jobject webkitPlugin, 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 21dd51b..4c8de78 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -383,11 +383,14 @@ namespace android { jobject createPluginJavaInstance(const WebCore::String& libName, NPP npp); // Creates a full screen surface for a plugin - void showFullScreenPlugin(jobject webkitPlugin, NPP npp); + void showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x, int y, int width, int height); // Instructs the UI thread to discard the plugin's full-screen surface void hideFullScreenPlugin(); + // Update coordinates and dimensions for a full screen plugin + void updateFullScreenPlugin(int x, int y, int width, int height); + // Creates a Surface (i.e. View) for a plugin jobject createSurface(jobject webkitPlugin, int x, int y, int width, int height); diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp index c8c2c70..f3304a9 100644 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/WebKit/android/plugins/ANPWindowInterface.cpp @@ -54,6 +54,8 @@ static void anp_showKeyboard(NPP instance, bool value) { static void anp_requestFullScreen(NPP instance) { PluginView* pluginView = pluginViewForInstance(instance); + // call focusPluginElement() so that the pluginView receives keyboard events + pluginView->focusPluginElement(); PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); pluginWidget->requestFullScreen(); } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index f8862b2..cd7076d 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -135,6 +135,10 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { m_embeddedView = env->NewGlobalRef(tempObj); } } + if (m_isFullScreen && m_pluginBounds != oldPluginBounds) { + m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(), + window->width, window->height); + } } else { m_flipPixelRef->safeUnref(); m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), @@ -437,7 +441,10 @@ void PluginWidgetAndroid::requestFullScreen() { return; } - m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance()); + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance(), + docPoint.x(), docPoint.y(), m_pluginWindow->width, + m_pluginWindow->height); m_isFullScreen = true; } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index ef3e40c..3a76073 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -145,6 +145,8 @@ struct PluginWidgetAndroid { */ void exitFullScreen(bool pluginInitiated); + bool inFullScreen() { return m_isFullScreen; } + private: WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const; void computeVisibleFrameRect(); |