summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp30
-rw-r--r--WebKit/android/jni/MIMETypeRegistry.cpp65
-rw-r--r--WebKit/android/jni/WebViewCore.cpp95
-rw-r--r--WebKit/android/jni/WebViewCore.h12
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp2
-rw-r--r--WebKit/android/nav/CachedInput.cpp1
-rw-r--r--WebKit/android/nav/CachedInput.h3
-rw-r--r--WebKit/android/nav/CachedRoot.cpp4
-rw-r--r--WebKit/android/nav/WebView.cpp40
-rw-r--r--WebKit/android/plugins/ANPWindowInterface.cpp2
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp77
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h9
-rw-r--r--WebKit/android/plugins/android_npapi.h56
14 files changed, 208 insertions, 189 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk
index f6186ca..87b08a2 100644
--- a/WebKit/Android.mk
+++ b/WebKit/Android.mk
@@ -42,6 +42,7 @@ LOCAL_SRC_FILES := \
android/jni/GeolocationPermissionsBridge.cpp \
android/jni/JavaBridge.cpp \
android/jni/JavaSharedClient.cpp \
+ android/jni/MIMETypeRegistry.cpp \
android/jni/MockGeolocation.cpp \
android/jni/PictureSet.cpp \
android/jni/WebCoreFrameBridge.cpp \
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index c928d46..cb361bf 100644
--- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -1033,35 +1033,7 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createJavaAppletWidget(const I
// the contents and work out if it can render it.
ObjectContentType FrameLoaderClientAndroid::objectContentType(const KURL& url,
const String& mimeType) {
- if (mimeType.length() == 0)
- {
- // Guess the mimeType from the extension
- if (url.hasPath())
- {
- String path = url.path();
- int lastIndex = path.reverseFind('.');
- static const String image("image/");
- if (lastIndex >= 0)
- {
- String mime(path.substring(lastIndex + 1));
- mime.insert(image, 0);
- if (Image::supportsType(mime))
- return ObjectContentImage;
- }
- }
- return ObjectContentFrame;
- }
-
- if (Image::supportsType(mimeType))
- return ObjectContentImage;
-
- if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType))
- return ObjectContentOtherPlugin;
-
- if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
- return ObjectContentFrame;
-
- return ObjectContentNone;
+ return FrameLoader::defaultObjectContentType(url, mimeType);
}
// This function allows the application to set the correct CSS media
diff --git a/WebKit/android/jni/MIMETypeRegistry.cpp b/WebKit/android/jni/MIMETypeRegistry.cpp
new file mode 100644
index 0000000..4e9ae68
--- /dev/null
+++ b/WebKit/android/jni/MIMETypeRegistry.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "WebCore"
+
+#include "config.h"
+
+#include "MIMETypeRegistry.h"
+#include "PlatformString.h"
+#include "jni_utility.h"
+#include "WebCoreJni.h"
+
+#include <jni.h>
+#include <utils/Log.h>
+
+namespace WebCore {
+
+static jmethodID gMimeTypeFromExtension;
+static jclass gMimeClass;
+
+String MIMETypeRegistry::getMIMETypeForExtension(const String& ext)
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!gMimeTypeFromExtension) {
+ gMimeClass = env->FindClass("android/webkit/MimeTypeMap");
+ LOG_ASSERT(gMimeClass, "Could not find class MimeTypeMap");
+ gMimeTypeFromExtension = env->GetStaticMethodID(gMimeClass,
+ "mimeTypeFromExtension",
+ "(Ljava/lang/String;)Ljava/lang/String;");
+ LOG_ASSERT(gMimeTypeFromExtension,
+ "Could not find method mimeTypeFromExtension");
+ }
+ jstring extString =
+ env->NewString((const jchar*) ext.characters(), ext.length());
+ jobject mimeType = env->CallStaticObjectMethod(gMimeClass,
+ gMimeTypeFromExtension, extString);
+ String result = android::to_string(env, (jstring) mimeType);
+ env->DeleteLocalRef(extString);
+ env->DeleteLocalRef(mimeType);
+ return result;
+}
+
+}
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index ee1f880..5d2b8bb 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -218,13 +218,13 @@ struct WebViewCore::JavaGlue {
jmethodID m_geolocationPermissionsHidePrompt;
jmethodID m_addMessageToConsole;
jmethodID m_getPluginClass;
- jmethodID m_createPluginJavaInstance;
jmethodID m_showFullScreenPlugin;
jmethodID m_hideFullScreenPlugin;
jmethodID m_updateFullScreenPlugin;
- jmethodID m_createSurface;
+ jmethodID m_addSurface;
jmethodID m_updateSurface;
jmethodID m_destroySurface;
+ jmethodID m_getContext;
jmethodID m_sendFindAgain;
AutoJObject object(JNIEnv* env) {
return getRealObject(env, m_obj);
@@ -294,7 +294,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V");
m_javaGlue->m_restoreScreenWidthScale = GetJMethod(env, clazz, "restoreScreenWidthScale", "(I)V");
m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V");
- m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V");
+ m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(ZZ)V");
m_javaGlue->m_exceededDatabaseQuota = GetJMethod(env, clazz, "exceededDatabaseQuota", "(Ljava/lang/String;Ljava/lang/String;JJ)V");
m_javaGlue->m_reachedMaxAppCacheSize = GetJMethod(env, clazz, "reachedMaxAppCacheSize", "(J)V");
m_javaGlue->m_populateVisitedLinks = GetJMethod(env, clazz, "populateVisitedLinks", "()V");
@@ -302,13 +302,13 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V");
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;IIIII)V");
+ m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/ViewManager$ChildView;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_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");
+ m_javaGlue->m_getContext = GetJMethod(env, clazz, "getContext", "()Landroid/content/Context;");
m_javaGlue->m_sendFindAgain = GetJMethod(env, clazz, "sendFindAgain", "()V");
env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this);
@@ -1049,7 +1049,7 @@ void WebViewCore::needTouchEvents(bool need)
#endif
}
-void WebViewCore::requestKeyboard(bool showKeyboard)
+void WebViewCore::requestKeyboard(bool showKeyboard, bool isTextView)
{
DBG_NAV_LOGD("showKeyboard=%d", showKeyboard);
LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
@@ -1060,7 +1060,8 @@ void WebViewCore::requestKeyboard(bool showKeyboard)
// can be gone. Check before using it.
if (!obj.get())
return;
- env->CallVoidMethod(obj.get(), m_javaGlue->m_requestKeyboard, showKeyboard);
+ env->CallVoidMethod(obj.get(), m_javaGlue->m_requestKeyboard, showKeyboard,
+ isTextView);
checkException(env);
}
@@ -2294,8 +2295,12 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
m_mousePos.y(), focusNode, handled ? "true" : "false");
if (focusNode) {
WebCore::RenderObject* renderer = focusNode->renderer();
- if (renderer && (renderer->isTextField() || renderer->isTextArea()))
- setFocusControllerActive(true);
+ if (renderer && (renderer->isTextField() || renderer->isTextArea())) {
+ bool ime = !(static_cast<WebCore::HTMLInputElement*>(focusNode))
+ ->readOnly();
+ setFocusControllerActive(ime);
+ requestKeyboard(ime, true);
+ }
}
return handled;
}
@@ -2587,10 +2592,6 @@ jclass WebViewCore::getPluginClass(const WebCore::String& libName, const char* c
{
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 NULL;
jstring libString = env->NewString(libName.characters(), libName.length());
jstring classString = env->NewStringUTF(className);
@@ -2610,40 +2611,15 @@ jclass WebViewCore::getPluginClass(const WebCore::String& libName, const char* c
}
}
-jobject WebViewCore::createPluginJavaInstance(const WebCore::String& libName, NPP npp)
-{
- 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 0;
-
- jstring libString = env->NewString(libName.characters(), libName.length());
- jobject result = env->CallObjectMethod(obj.get(),
- m_javaGlue->m_createPluginJavaInstance,
- libString, (int) npp);
-
- //cleanup unneeded local JNI references
- env->DeleteLocalRef(libString);
-
- checkException(env);
- return result;
-}
-
-void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x,
+void WebViewCore::showFullScreenPlugin(jobject childView, NPP npp, 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_showFullScreenPlugin,
- webkitPlugin, (int)npp, x, y, width, height);
+ childView, (int)npp, x, y, width, height);
checkException(env);
}
@@ -2651,10 +2627,6 @@ void WebViewCore::hideFullScreenPlugin()
{
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_hideFullScreenPlugin);
checkException(env);
@@ -2664,41 +2636,28 @@ 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)
+jobject WebViewCore::addSurface(jobject view, 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 0;
jobject result = env->CallObjectMethod(obj.get(),
- m_javaGlue->m_createSurface,
- webkitPlugin, x, y, width, height);
+ m_javaGlue->m_addSurface,
+ view, x, y, width, height);
checkException(env);
return result;
-
}
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);
@@ -2709,15 +2668,21 @@ void WebViewCore::destroySurface(jobject childView)
{
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_destroySurface, childView);
checkException(env);
}
+jobject WebViewCore::getContext()
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ AutoJObject obj = m_javaGlue->object(env);
+
+ jobject result = env->CallObjectMethod(obj.get(), m_javaGlue->m_getContext);
+ checkException(env);
+ return result;
+}
+
bool WebViewCore::validNodeAndBounds(Frame* frame, Node* node,
const IntRect& originalAbsoluteBounds)
{
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 912b8e6..f1893ff 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -379,14 +379,11 @@ namespace android {
void needTouchEvents(bool);
// Notify the Java side that webkit is requesting a keyboard
- void requestKeyboard(bool);
+ void requestKeyboard(bool showKeyboard, bool isTextView);
// Generates a class loader that contains classes from the plugin's apk
jclass getPluginClass(const WebCore::String& libName, const char* className);
- // Creates a new instance of the plugin's java component
- jobject createPluginJavaInstance(const WebCore::String& libName, NPP npp);
-
// Creates a full screen surface for a plugin
void showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x, int y, int width, int height);
@@ -396,8 +393,8 @@ namespace android {
// 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);
+ // Adds the plugin's view (aka surface) to the view hierarchy
+ jobject addSurface(jobject view, 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);
@@ -405,6 +402,9 @@ namespace android {
// Destroys a SurfaceView for a plugin
void destroySurface(jobject childView);
+ // Returns the context (android.content.Context) of the WebView
+ jobject getContext();
+
bool validNodeAndBounds(Frame* , Node* , const IntRect& );
// other public functions
public:
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index c4c25db..784c3aa 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1106,7 +1106,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
cachedInput.init();
cachedInput.setFormPointer(input->form());
cachedInput.setIsTextField(true);
- cachedInput.setIsReadOnly(input->readOnly());
exported = input->value().threadsafeCopy();
cachedInput.setMaxLength(input->maxLength());
cachedInput.setInputType(inputType);
@@ -1122,7 +1121,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
type = TEXT_INPUT_CACHEDNODETYPE;
HTMLTextAreaElement* area = static_cast<HTMLTextAreaElement*>(node);
cachedInput.setFormPointer(area->form());
- cachedInput.setIsReadOnly(area->readOnly());
// Although technically it is not an HTMLInputElement, and therefore
// has no InputType, this one is the most appropriate.
cachedInput.setInputType(HTMLInputElement::TEXT);
diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp
index d7b96e3..924bbca 100644
--- a/WebKit/android/nav/CachedInput.cpp
+++ b/WebKit/android/nav/CachedInput.cpp
@@ -59,7 +59,6 @@ void CachedInput::Debug::print() const
DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength);
DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize);
DUMP_NAV_LOGD("// int mInputType=%d;\n", b->mInputType);
- DEBUG_PRINT_BOOL(mIsReadOnly);
DEBUG_PRINT_BOOL(mIsRtlText);
DEBUG_PRINT_BOOL(mIsTextField);
}
diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h
index f3cf1fe..42cadf1 100644
--- a/WebKit/android/nav/CachedInput.h
+++ b/WebKit/android/nav/CachedInput.h
@@ -44,14 +44,12 @@ public:
mName = WebCore::String();
}
WebCore::HTMLInputElement::InputType inputType() const { return mInputType; }
- bool isReadOnly() const { return mIsReadOnly; }
bool isRtlText() const { return mIsRtlText; }
bool isTextField() const { return mIsTextField; }
int maxLength() const { return mMaxLength; };
const WebCore::String& name() const { return mName; }
void setFormPointer(void* form) { mForm = form; }
void setInputType(WebCore::HTMLInputElement::InputType type) { mInputType = type; }
- void setIsReadOnly(bool isReadOnly) { mIsReadOnly = isReadOnly; }
void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; }
void setIsTextField(bool isTextField) { mIsTextField = isTextField; }
void setMaxLength(int maxLength) { mMaxLength = maxLength; }
@@ -64,7 +62,6 @@ private:
int mMaxLength;
int mTextSize;
WebCore::HTMLInputElement::InputType mInputType;
- bool mIsReadOnly : 1;
bool mIsRtlText : 1;
bool mIsTextField : 1;
#if DUMP_NAV_CACHE
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index e783eae..d9669bd 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -760,11 +760,11 @@ CachedRoot::ImeAction CachedRoot::currentTextFieldAction() const
{
const CachedFrame* currentFrame;
const CachedNode* current = currentCursor(&currentFrame);
- if (!current) {
+ if (!current || !current->isTextInput()) {
// Although the cursor is not on a textfield, a textfield may have
// focus. Find the action for that textfield.
current = currentFocus(&currentFrame);
- if (!current)
+ if (!current || !current->isTextInput())
// Error case. No cursor and no focus.
return FAILURE;
}
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 1267647..0426337 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -111,7 +111,6 @@ struct JavaGlue {
jmethodID m_getScaledMaxYScroll;
jmethodID m_getVisibleRect;
jmethodID m_rebuildWebTextView;
- jmethodID m_displaySoftKeyboard;
jmethodID m_viewInvalidate;
jmethodID m_viewInvalidateRect;
jmethodID m_postInvalidateDelayed;
@@ -141,7 +140,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl)
m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I");
m_javaGlue.m_getVisibleRect = GetJMethod(env, clazz, "sendOurVisibleRect", "()Landroid/graphics/Rect;");
m_javaGlue.m_rebuildWebTextView = GetJMethod(env, clazz, "rebuildWebTextView", "()V");
- m_javaGlue.m_displaySoftKeyboard = GetJMethod(env, clazz, "displaySoftKeyboard", "(Z)V");
m_javaGlue.m_viewInvalidate = GetJMethod(env, clazz, "viewInvalidate", "()V");
m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V");
m_javaGlue.m_postInvalidateDelayed = GetJMethod(env, clazz,
@@ -628,8 +626,8 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer)
fixCursor();
if (oldFocus && m_frameCacheUI) {
const CachedNode* newFocus = m_frameCacheUI->currentFocus();
- if (newFocus && oldFocus != newFocus && newFocus->isTextInput()
- && oldFocus->isTextInput()
+ if (newFocus && oldFocus->nodePointer() != newFocus->nodePointer()
+ && oldFocus->isTextInput() && newFocus->isTextInput()
&& newFocus != m_frameCacheUI->currentCursor()) {
// The focus has changed. We may need to update things.
LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
@@ -980,12 +978,7 @@ bool motionUp(int x, int y, int slop)
(WebCore::Node*) result->nodePointer(), rx, ry);
}
viewInvalidate();
- if (result->isTextInput()) {
- bool isReadOnly = frame->textInput(result)->isReadOnly();
- rebuildWebTextView();
- if (!isReadOnly)
- displaySoftKeyboard(true);
- } else {
+ if (!result->isTextInput()) {
clearTextEntry();
setFollowedLink(true);
if (syntheticLink)
@@ -1307,19 +1300,6 @@ void rebuildWebTextView()
checkException(env);
}
-void displaySoftKeyboard(bool isTextView)
-{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- AutoJObject obj = m_javaGlue.object(env);
- // if it is called during or after DESTROY is handled, the real object of
- // WebView can be gone. Check before using it.
- if (!obj.get())
- return;
- env->CallVoidMethod(obj.get(),
- m_javaGlue.m_displaySoftKeyboard, isTextView);
- checkException(env);
-}
-
void viewInvalidate()
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -1554,18 +1534,6 @@ static bool nativeCursorIsAnchor(JNIEnv *env, jobject obj)
return node ? node->isAnchor() : false;
}
-static bool nativeCursorIsReadOnly(JNIEnv *env, jobject obj)
-{
- const CachedFrame* frame;
- const CachedNode* node = getCursorNode(env, obj, &frame);
- if (!node)
- return false;
- const CachedInput* input = frame->textInput(node);
- if (!input)
- return false;
- return input->isReadOnly();
-}
-
static bool nativeCursorIsTextInput(JNIEnv *env, jobject obj)
{
const CachedNode* node = getCursorNode(env, obj);
@@ -2205,8 +2173,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeCursorIntersects },
{ "nativeCursorIsAnchor", "()Z",
(void*) nativeCursorIsAnchor },
- { "nativeCursorIsReadOnly", "()Z",
- (void*) nativeCursorIsReadOnly },
{ "nativeCursorIsTextInput", "()Z",
(void*) nativeCursorIsTextInput },
{ "nativeCursorPosition", "()Landroid/graphics/Point;",
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index f3304a9..06afab1 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -49,7 +49,7 @@ static void anp_clearVisibleRects(NPP instance) {
static void anp_showKeyboard(NPP instance, bool value) {
PluginView* pluginView = pluginViewForInstance(instance);
PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
- pluginWidget->webViewCore()->requestKeyboard(value);
+ pluginWidget->webViewCore()->requestKeyboard(value, false);
}
static void anp_requestFullScreen(NPP instance) {
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index cd7076d..113a3bc 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -53,8 +53,8 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_pluginBounds.setEmpty();
m_hasFocus = false;
m_isFullScreen = false;
+ m_visible = true;
m_zoomLevel = 0;
- m_webkitPlugin = NULL;
m_embeddedView = NULL;
}
@@ -68,9 +68,6 @@ PluginWidgetAndroid::~PluginWidgetAndroid() {
// cleanup any remaining JNI References
JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (m_webkitPlugin) {
- env->DeleteGlobalRef(m_webkitPlugin);
- }
if (m_embeddedView) {
env->DeleteGlobalRef(m_embeddedView);
}
@@ -83,19 +80,6 @@ void PluginWidgetAndroid::init(android::WebViewCore* core) {
m_core->addPlugin(this);
}
-jobject PluginWidgetAndroid::getJavaPluginInstance() {
- if (m_webkitPlugin == NULL && m_core != NULL) {
-
- jobject tempObj = m_core->createPluginJavaInstance(m_pluginView->plugin()->path(),
- m_pluginView->instance());
- if (tempObj) {
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- m_webkitPlugin = env->NewGlobalRef(tempObj);
- }
- }
- return m_webkitPlugin;
-}
-
static SkBitmap::Config computeConfig(bool isTransparent) {
return isTransparent ? SkBitmap::kARGB_8888_Config
: SkBitmap::kRGB_565_Config;
@@ -127,9 +111,18 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
// if the surface does not exist then create a new surface
} else if(!m_embeddedView) {
- jobject tempObj = m_core->createSurface(getJavaPluginInstance(),
- docPoint.x(), docPoint.y(),
- window->width, window->height);
+
+ WebCore::PluginPackage* pkg = m_pluginView->plugin();
+ NPP instance = m_pluginView->instance();
+
+
+ jobject pluginSurface;
+ pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue,
+ static_cast<void*>(&pluginSurface));
+
+ jobject tempObj = m_core->addSurface(pluginSurface,
+ docPoint.x(), docPoint.y(),
+ window->width, window->height);
if (tempObj) {
JNIEnv* env = JSC::Bindings::getJNIEnv();
m_embeddedView = env->NewGlobalRef(tempObj);
@@ -291,6 +284,18 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float
if (oldScreenW != newScreenW || oldScreenH != newScreenH)
computeVisibleFrameRect();
+
+ bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds);
+ if(m_visible != visible) {
+ // change the visibility
+ m_visible = visible;
+ // send the event
+ ANPEvent event;
+ SkANP::InitEvent(&event, kLifecycle_ANPEventType);
+ event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction
+ : kOffScreen_ANPLifecycleAction;
+ sendEvent(event);
+ }
}
void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) {
@@ -437,21 +442,47 @@ IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) cons
}
void PluginWidgetAndroid::requestFullScreen() {
- if (m_isFullScreen || !m_webkitPlugin) {
+ if (m_isFullScreen || !m_embeddedView) {
return;
}
+ // send event to notify plugin of full screen change
+ ANPEvent event;
+ SkANP::InitEvent(&event, kLifecycle_ANPEventType);
+ event.data.lifecycle.action = kEnterFullScreen_ANPLifecycleAction;
+ sendEvent(event);
+
+ // remove the embedded surface from the view hierarchy
+ m_core->destroySurface(m_embeddedView);
+
+ // add the full screen view
IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y);
- m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance(),
+ m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(),
docPoint.x(), docPoint.y(), m_pluginWindow->width,
m_pluginWindow->height);
m_isFullScreen = true;
}
void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) {
- if (m_isFullScreen && pluginInitiated) {
+ if (!m_isFullScreen || !m_embeddedView) {
+ return;
+ }
+
+ // remove the full screen surface from the view hierarchy
+ if (pluginInitiated) {
m_core->hideFullScreenPlugin();
}
+ // add the embedded view back
+ IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y);
+ m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(),
+ m_pluginWindow->width, m_pluginWindow->height);
+
+ // send event to notify plugin of full screen change
+ ANPEvent event;
+ SkANP::InitEvent(&event, kLifecycle_ANPEventType);
+ event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction;
+ sendEvent(event);
+
m_isFullScreen = false;
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 3a76073..93ad4a8 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -125,13 +125,6 @@ struct PluginWidgetAndroid {
*/
void setVisibleRects(const ANPRectI rects[], int32_t count);
- /** Returns a java object that implements the WebkitPlugin interface. The
- implementation is located in the plugin's apk and is described in the
- apk's manifest file. For each plugin instance in webkit there is at
- most one instance of the java object associated with that plugin.
- */
- jobject getJavaPluginInstance();
-
/** Called when a plugin wishes to enter into full screen mode. It invokes
the plugin's Java class (defined in the plugin's apk manifest), which is
called asynchronously and provides a View to be displayed full screen.
@@ -163,8 +156,8 @@ private:
SkIRect m_requestedFrameRect;
bool m_hasFocus;
bool m_isFullScreen;
+ bool m_visible;
float m_zoomLevel;
- jobject m_webkitPlugin;
jobject m_embeddedView;
/* We limit the number of rectangles to minimize storage and ensure adequate
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 1111836..4173528 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -120,14 +120,18 @@ typedef uint32_t ANPMatrixFlag;
#define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010)
#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011)
-/** queries for which drawing model is desired (for the draw event)
+/** queries for the drawing models supported on this device.
- Should be called inside NPP_New(...)
-
- NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits)
+ NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits)
*/
#define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000)
+/** queries for the context (android.content.Context) in which the plugin resides
+
+ NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context)
+ */
+#define kJavaContext_ANPGetValue ((NPNVariable)2001)
+
///////////////////////////////////////////////////////////////////////////////
// NPN_SetValue
@@ -147,7 +151,7 @@ enum ANPDrawingModels {
/** Draw into a bitmap from the browser thread in response to a Draw event.
NPWindow->window is reserved (ignore)
*/
- kBitmap_ANPDrawingModel = 0,
+ kBitmap_ANPDrawingModel = 1 << 0,
/** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface
interface. When this model is used the browser will invoke the Java
class specified in the plugin's apk manifest. From that class the browser
@@ -168,7 +172,7 @@ enum ANPDrawingModels {
unlock the surface in native code without making JNI calls to the Java
surface object.
*/
- kSurface_ANPDrawingModel = 0x01,
+ kSurface_ANPDrawingModel = 1 << 1,
};
typedef int32_t ANPDrawingModel;
@@ -190,6 +194,16 @@ enum ANPEventFlag {
};
typedef uint32_t ANPEventFlags;
+///////////////////////////////////////////////////////////////////////////////
+// NPP_GetValue
+
+/** Requests that the plugin return a java surface to be displayed. This will
+ only be used if the plugin has choosen the kSurface_ANPDrawingModel.
+
+ NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface)
+ */
+#define kJavaSurface_ANPGetValue ((NPPVariable)2000)
+
///////////////////////////////////////////////////////////////////////////////
// ANDROID INTERFACE DEFINITIONS
@@ -833,28 +847,46 @@ enum ANPLifecycleActions {
/** The web view containing this plugin has been paused. See documentation
on the android activity lifecycle for more information.
*/
- kPause_ANPLifecycleAction = 0,
+ kPause_ANPLifecycleAction = 0,
/** The web view containing this plugin has been resumed. See documentation
on the android activity lifecycle for more information.
*/
- kResume_ANPLifecycleAction = 1,
+ kResume_ANPLifecycleAction = 1,
/** The plugin has focus and is now the recipient of input events (e.g. key,
touch, etc.)
*/
- kGainFocus_ANPLifecycleAction = 2,
+ kGainFocus_ANPLifecycleAction = 2,
/** The plugin has lost focus and will not receive any input events until it
regains focus. This event is always preceded by a GainFocus action.
*/
- kLoseFocus_ANPLifecycleAction = 3,
+ kLoseFocus_ANPLifecycleAction = 3,
/** The browser is running low on available memory and is requesting that
the plugin free any unused/inactive resources to prevent a performance
degradation.
*/
- kFreeMemory_ANPLifecycleAction = 4,
+ kFreeMemory_ANPLifecycleAction = 4,
/** The page has finished loading. This happens when the page's top level
frame reports that it has completed loading.
*/
- kOnLoad_ANPLifecycleAction = 5,
+ kOnLoad_ANPLifecycleAction = 5,
+ /** The browser is honoring the plugin's request to go full screen. Upon
+ returning from this event the browser will resize the plugin's java
+ surface to full-screen coordinates.
+ */
+ kEnterFullScreen_ANPLifecycleAction = 6,
+ /** The browser has exited from full screen mode. Immediately prior to
+ sending this event the browser has resized the plugin's java surface to
+ its original coordinates.
+ */
+ kExitFullScreen_ANPLifecycleAction = 7,
+ /** The plugin is visible to the user on the screen. This event will always
+ occur after a kOffScreen_ANPLifecycleAction event.
+ */
+ kOnScreen_ANPLifecycleAction = 8,
+ /** The plugin is no longer visible to the user on the screen. This event
+ will always occur prior to an kOnScreen_ANPLifecycleAction event.
+ */
+ kOffScreen_ANPLifecycleAction = 9,
};
typedef uint32_t ANPLifecycleAction;