summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebKit/android/jni/WebViewCore.cpp16
-rw-r--r--WebKit/android/jni/WebViewCore.h4
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp39
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h1
4 files changed, 47 insertions, 13 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 2340f99..2a86e56 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -188,6 +188,7 @@ struct WebViewCore::JavaGlue {
jmethodID m_addMessageToConsole;
jmethodID m_startFullScreenPluginActivity;
jmethodID m_createSurface;
+ jmethodID m_updateSurface;
jmethodID m_destroySurface;
AutoJObject object(JNIEnv* env) {
return getRealObject(env, m_obj);
@@ -265,6 +266,7 @@ 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_startFullScreenPluginActivity = GetJMethod(env, clazz, "startFullScreenPluginActivity", "(Ljava/lang/String;Ljava/lang/String;I)V");
m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Ljava/lang/String;Ljava/lang/String;IIIII)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");
env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this);
@@ -2441,6 +2443,20 @@ jobject WebViewCore::createSurface(const char* libName, const char* className,
}
+void WebViewCore::updateSurface(jobject childView, 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_updateSurface, childView, x,
+ y, width, height);
+ checkException(env);
+}
+
void WebViewCore::destroySurface(jobject childView)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index f7d04d2..39eca61 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -70,7 +70,6 @@ namespace android {
class CachedRoot;
class ListBoxReply;
- class SurfaceCallback;
class WebCoreReply : public WebCoreRefObject {
public:
@@ -384,6 +383,9 @@ namespace android {
jobject createSurface(const char* libName, const char* className,
NPP npp, int x, int y, int width, int height);
+ // Updates a Surface coordinates and dimensions for a plugin
+ void updateSurface(jobject childView, int x, int y, int width, int height);
+
// Destroys a SurfaceView for a plugin
void destroySurface(jobject childView);
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 5b32259..712d727 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -49,6 +49,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_requestedVisibleRectCount = 0;
m_requestedFrameRect.setEmpty();
m_visibleDocRect.setEmpty();
+ m_pluginBounds.setEmpty();
m_hasFocus = false;
m_zoomLevel = 0;
m_javaClassName = NULL;
@@ -79,11 +80,31 @@ static SkBitmap::Config computeConfig(bool isTransparent) {
}
void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
+
+ // store the reference locally for easy lookup
m_pluginWindow = window;
+ // make a copy of the previous bounds
+ SkIRect oldPluginBounds = m_pluginBounds;
+
+ // keep a local copy of the plugin bounds because the m_pluginWindow pointer
+ // gets updated values prior to this method being called
+ m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y,
+ m_pluginWindow->x + m_pluginWindow->width,
+ m_pluginWindow->y + m_pluginWindow->height);
+
if (m_drawingModel == kSurface_ANPDrawingModel) {
- if (!m_childView) {
- IntPoint docPoint = frameToDocumentCoords(window->x, window->y);
+
+ IntPoint docPoint = frameToDocumentCoords(window->x, window->y);
+
+ // if the surface exists check for changes and update accordingly
+ if (m_childView && m_pluginBounds != oldPluginBounds) {
+
+ m_core->updateSurface(m_childView, docPoint.x(), docPoint.y(),
+ window->width, window->height);
+
+ // if the surface does not exist then create a new surface
+ } else if(!m_childView) {
const String& libName = m_pluginView->plugin()->path();
SkString skLibName;
@@ -324,12 +345,6 @@ void PluginWidgetAndroid::computeVisibleFrameRect() {
if (m_visibleDocRect.isEmpty() || !m_pluginWindow)
return;
- // create a rect that represents the plugin's bounds
- SkIRect pluginBounds;
- pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y,
- m_pluginWindow->x + m_pluginWindow->width,
- m_pluginWindow->y + m_pluginWindow->height);
-
// create a rect that will contain as many of the rects that will fit on screen
SkIRect visibleRect;
visibleRect.setEmpty();
@@ -344,15 +359,15 @@ void PluginWidgetAndroid::computeVisibleFrameRect() {
pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y);
// ensure the rect falls within the plugin's bounds
- if (!pluginBounds.contains(pluginRect)) {
+ if (!m_pluginBounds.contains(pluginRect)) {
#if DEBUG_VISIBLE_RECTS
SkDebugf("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__,
- pluginBounds.fLeft, pluginBounds.fTop,
- pluginBounds.fRight, pluginBounds.fBottom,
+ m_pluginBounds.fLeft, m_pluginBounds.fTop,
+ m_pluginBounds.fRight, m_pluginBounds.fBottom,
pluginRect.fLeft, pluginRect.fTop,
pluginRect.fRight, pluginRect.fBottom);
// FIXME: assume that the desired outcome is to clamp to the container
- pluginRect.intersect(pluginBounds);
+ pluginRect.intersect(m_pluginBounds);
#endif
continue;
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 9fc2209..b6913bb 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -148,6 +148,7 @@ private:
ANPDrawingModel m_drawingModel;
ANPEventFlags m_eventFlags;
NPWindow* m_pluginWindow;
+ SkIRect m_pluginBounds;
SkIRect m_visibleDocRect;
SkIRect m_requestedFrameRect;
bool m_hasFocus;