diff options
-rw-r--r-- | WebCore/platform/graphics/android/ImageSourceAndroid.cpp | 22 | ||||
-rw-r--r-- | WebCore/platform/network/android/ResourceHandleAndroid.cpp | 3 | ||||
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreResourceLoader.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreResourceLoader.h | 2 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 16 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 28 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 3 | ||||
-rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSystemInterface.cpp | 28 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSystem_npapi.h | 25 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPWindowInterface.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 7 |
14 files changed, 144 insertions, 32 deletions
diff --git a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp b/WebCore/platform/graphics/android/ImageSourceAndroid.cpp index fc3b098..43facd5 100644 --- a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp +++ b/WebCore/platform/graphics/android/ImageSourceAndroid.cpp @@ -37,6 +37,12 @@ #include "SkStream.h" #include "SkTemplates.h" +// need a flag to tell us when we're on a large-ram device (e.g. >= 256M) +// for now just use this hack +#if 1 + #define ON_LARGE_RAM_DEVICE +#endif + #ifdef ANDROID_ANIMATED_GIF #include "EmojiFont.h" #include "gif/GIFImageDecoder.h" @@ -52,9 +58,17 @@ SkPixelRef* SkCreateRLEPixelRef(const SkBitmap& src); //#define TRACE_RLE_BITMAPS -// don't use RLE for images smaller than this, since they incur a drawing cost -// (and don't work as patterns yet) we only want to use RLE when we must -#define MIN_RLE_ALLOC_SIZE (2*1024*1024) +#ifdef ON_LARGE_RAM_DEVICE + // don't use RLE for images smaller than this, since they incur a drawing cost + // (and don't work as patterns yet) we only want to use RLE when we must + #define MIN_RLE_ALLOC_SIZE (8*1024*1024) + + // see dox for computeMaxBitmapSizeForCache() + #define MAX_SIZE_BEFORE_SUBSAMPLE (8*1024*1024) +#else + #define MIN_RLE_ALLOC_SIZE (2*1024*1024) + #define MAX_SIZE_BEFORE_SUBSAMPLE (2*1024*1024) +#endif /* Images larger than this should be subsampled. Using ashmem, the decoded pixels will be purged as needed, so this value can be pretty large. Making @@ -67,7 +81,7 @@ SkPixelRef* SkCreateRLEPixelRef(const SkBitmap& src); Perhaps this value should be some fraction of the available RAM... */ static size_t computeMaxBitmapSizeForCache() { - return 2*1024*1024; + return MAX_SIZE_BEFORE_SUBSAMPLE; } /* 8bit images larger than this should be recompressed in RLE, to reduce diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp index 8da2446..8a9f689 100644 --- a/WebCore/platform/network/android/ResourceHandleAndroid.cpp +++ b/WebCore/platform/network/android/ResourceHandleAndroid.cpp @@ -98,7 +98,8 @@ bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*) // set the cache policy correctly, copied from // network/mac/ResourceHandleMac.mm request.setCachePolicy(ReturnCacheDataDontLoad); - return WebCoreResourceLoader::willLoadFromCache(request.url()); + FormData* formData = request.httpBody(); + return WebCoreResourceLoader::willLoadFromCache(request.url(), formData ? formData->identifier() : 0); } bool ResourceHandle::loadsBlocked() diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 529458b..69f76b8 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -75,6 +75,7 @@ #include "android_npapi.h" #include "ANPSurface_npapi.h" +#include "ANPSystem_npapi.h" #include "SkANP.h" #include "SkFlipPixelRef.h" @@ -165,8 +166,6 @@ void PluginView::platformInit() bool PluginView::platformStart() { - android::WebViewCore* c = android::WebViewCore::getWebViewCore(this->parent()); - m_window->init(c); return true; } @@ -362,8 +361,15 @@ void PluginView::setParent(ScrollView* parent) { Widget::setParent(parent); - if (parent) + if (parent) { + // the widget needs initialized now so that the plugin has access to + // WebViewCore when NPP_New is called + if (m_window && !m_window->webViewCore()) { + android::WebViewCore* c = android::WebViewCore::getWebViewCore(this->parent()); + m_window->init(c); + } init(); + } } void PluginView::setNPWindowRect(const IntRect& rect) diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 0675bcb..541e878 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -28,6 +28,7 @@ #include <config.h> #include <wtf/Platform.h> +#include <wtf/CurrentTime.h> #include "android_graphics.h" #include "Arena.h" @@ -169,7 +170,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* mJavaFrame->mObj = adoptGlobalRef(env, obj); mJavaFrame->mHistoryList = adoptGlobalRef(env, historyList); mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", - "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BIZ)Landroid/webkit/LoadListener;"); + "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZ)Landroid/webkit/LoadListener;"); mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted", "(Ljava/lang/String;Landroid/graphics/Bitmap;IZ)V"); mJavaFrame->mTransitionToCommitted = env->GetMethodID(clazz, "transitionToCommitted", @@ -441,7 +442,8 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, jobject jLoadListener = env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource, (int)loader, jUrlStr, jMethodStr, jHeaderMap, - jPostDataStr, cacheMode, synchronous); + jPostDataStr, formdata ? formdata->identifier(): 0, + cacheMode, synchronous); env->DeleteLocalRef(jUrlStr); env->DeleteLocalRef(jMethodStr); @@ -1000,7 +1002,11 @@ static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData) if (postData) { jsize size = env->GetArrayLength(postData); jbyte* bytes = env->GetByteArrayElements(postData, NULL); - request.setHTTPBody(WebCore::FormData::create((const void*)bytes, size)); + RefPtr<FormData> formData = FormData::create((const void*)bytes, size); + // the identifier uses the same logic as generateFormDataIdentifier() in + // HTMLFormElement.cpp + formData->setIdentifier(static_cast<int64_t>(WTF::currentTime() * 1000000.0)); + request.setHTTPBody(formData); env->ReleaseByteArrayElements(postData, bytes, 0); } diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index 1b40eb6..0891323 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -100,14 +100,14 @@ void WebCoreResourceLoader::downloadFile() * the cache. This may be slow, but is only used during a navigation to * a POST response. */ -bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url) +bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier) { JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); bool val = env->CallStaticBooleanMethod(resourceLoader, - gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr); + gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier); checkException(env); env->DeleteLocalRef(jUrlStr); @@ -318,7 +318,7 @@ int register_resource_loader(JNIEnv* env) "Could not find method downloadFile on LoadListener"); gResourceLoader.mWillLoadFromCacheMethodID = - env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;)Z"); + env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;J)Z"); LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL, "Could not find static method willLoadFromCache on LoadListener"); diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h index 60c0d0e..7ea1107 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.h +++ b/WebKit/android/jni/WebCoreResourceLoader.h @@ -53,7 +53,7 @@ public: /** * Call to java to find out if this URL is in the cache */ - static bool willLoadFromCache(const WebCore::KURL& url); + static bool willLoadFromCache(const WebCore::KURL& url, int64_t identifier); // Native jni functions static void SetResponseHeader(JNIEnv*, jobject, jint, jstring, jstring); diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index d7aacfb..bed0e84 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -420,9 +420,12 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) // Form data const WebCore::FormData* formData = item->formData(); - if (formData) + if (formData) { write_string(v, formData->flattenToString()); - else + // save the identifier as it is not included in the flatten data + int64_t id = formData->identifier(); + v.append((char*)&id, sizeof(int64_t)); + } else write_string(v, WebCore::String()); // Empty constructor does not allocate a buffer. // Target @@ -573,6 +576,15 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, else return false; data += l; + // Read the identifier + { + int64_t id; + int size = (int)sizeof(int64_t); + memcpy(&id, data, size); + data += size; + if (id) + formData->setIdentifier(id); + } } if (end - data < sizeofUnsigned) return false; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 8f5427a..07f5d62 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -189,6 +189,7 @@ struct WebViewCore::JavaGlue { jmethodID m_geolocationPermissionsShowPrompt; jmethodID m_geolocationPermissionsHidePrompt; jmethodID m_addMessageToConsole; + jmethodID m_getPluginClass; jmethodID m_startFullScreenPluginActivity; jmethodID m_createSurface; jmethodID m_updateSurface; @@ -267,6 +268,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V"); 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_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"); @@ -2425,18 +2427,40 @@ void WebViewCore::setBackgroundColor(SkColor c) view->setBaseBackgroundColor(bcolor); } -void WebViewCore::startFullScreenPluginActivity(const char* libName, - const char* className, NPP npp) +jclass WebViewCore::getPluginClass(const char* libName, const char* className) { 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->NewStringUTF(libName); + jstring classString = env->NewStringUTF(className); + jobject pluginClass = env->CallObjectMethod(obj.get(), + m_javaGlue->m_getPluginClass, + libString, classString); + checkException(env); + + if (pluginClass != NULL) { + return static_cast<jclass>(pluginClass); + } else { + return NULL; + } +} + +void WebViewCore::startFullScreenPluginActivity(const char* libName, + const char* className, 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; + jstring libString = env->NewStringUTF(libName); jstring classString = env->NewStringUTF(className); env->CallVoidMethod(obj.get(), m_javaGlue->m_startFullScreenPluginActivity, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index a7855b8..308ddfc 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -367,6 +367,9 @@ namespace android { // Notify the Java side that webkit is requesting a keyboard void requestKeyboard(bool); + // Generates a class loader that contains classes from the plugin's apk + jclass getPluginClass(const char* libName, const char* className); + // Creates a full screen surface (i.e. View on an Activity) for a plugin void startFullScreenPluginActivity(const char* libName, const char* className, NPP npp); diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 39f0053..1855b44 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1095,6 +1095,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, if (isTextField) { wantsKeyEvents = true; isReadOnly = input->readOnly(); + exported = input->value().threadsafeCopy(); } isPassword = input->inputType() == HTMLInputElement::PASSWORD; maxLength = input->maxLength(); @@ -1104,7 +1105,9 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, isUnclipped = isTransparent; // can't detect if this is drawn on top (example: deviant.com login parts) } else if (node->hasTagName(HTMLNames::textareaTag)) { isTextArea = wantsKeyEvents = true; - isReadOnly = (static_cast<HTMLTextAreaElement*>(node))->readOnly(); + HTMLTextAreaElement* area = static_cast<HTMLTextAreaElement*>(node); + isReadOnly = area->readOnly(); + exported = area->value().threadsafeCopy(); } else if (node->hasTagName(HTMLNames::aTag)) { const HTMLAnchorElement* anchorNode = (const HTMLAnchorElement*) node; @@ -1124,7 +1127,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, static_cast<RenderTextControl*>(nodeRenderer); if (isFocus) cachedRoot->setSelection(renderText->selectionStart(), renderText->selectionEnd()); - exported = renderText->text().threadsafeCopy(); // FIXME: Would it be better to use (float) size()? // FIXME: Are we sure there will always be a style and font, and it's correct? RenderStyle* style = nodeRenderer->style(); diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp index a5b9bcb..a7bf1cb 100644 --- a/WebKit/android/plugins/ANPSystemInterface.cpp +++ b/WebKit/android/plugins/ANPSystemInterface.cpp @@ -26,10 +26,16 @@ // must include config.h first for webkit to fiddle with new/delete #include "config.h" -#include "android_npapi.h" #include "CString.h" #include "JavaSharedClient.h" #include "PluginClient.h" +#include "PluginPackage.h" +#include "PluginView.h" +#include "PluginWidgetAndroid.h" +#include "SkString.h" +#include "WebViewCore.h" + +#include "ANPSystem_npapi.h" static const char* gApplicationDataDir = NULL; @@ -61,6 +67,25 @@ static const char* anp_getApplicationDataDirectory() { return gApplicationDataDir; } +static WebCore::PluginView* pluginViewForInstance(NPP instance) { + if (instance && instance->ndata) + return static_cast<WebCore::PluginView*>(instance->ndata); + return PluginView::currentPluginView(); +} + +static jclass anp_loadJavaClass(NPP instance, const char* className) { + WebCore::PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + + const WebCore::String& libName = pluginView->plugin()->path(); + SkString skLibName; + skLibName.setUTF16(libName.characters(), libName.length()); + + jclass result; + result = pluginWidget->webViewCore()->getPluginClass(skLibName.c_str(), className); + return result; +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -69,4 +94,5 @@ void ANPSystemInterfaceV0_Init(ANPInterface* v) { ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v); ASSIGN(i, getApplicationDataDirectory); + ASSIGN(i, loadJavaClass); } diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h new file mode 100644 index 0000000..1507ef6 --- /dev/null +++ b/WebKit/android/plugins/ANPSystem_npapi.h @@ -0,0 +1,25 @@ +#ifndef ANPSystem_npapi_H +#define ANPSystem_npapi_H + +#include "android_npapi.h" +#include <jni.h> + +struct ANPSystemInterfaceV0 : ANPInterface { + /** Return the path name for the current Application's plugin data directory, + or NULL if not supported + */ + const char* (*getApplicationDataDirectory)(); + + /** A helper function to load java classes from the plugin's apk. The + function looks for a class given the fully qualified and null terminated + string representing the className. For example, + + const char* className = "com.android.mypackage.MyClass"; + + If the class cannot be found or there is a problem loading the class + NULL will be returned. + */ + jclass (*loadJavaClass)(NPP instance, const char* className); +}; + +#endif //ANPSystem_npapi_H diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp index 7a2f94c..3f4dff3 100644 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/WebKit/android/plugins/ANPWindowInterface.cpp @@ -68,9 +68,9 @@ static void anp_clearVisibleRects(NPP instance) { } static void anp_showKeyboard(NPP instance, bool value) { - ScrollView* scrollView = pluginViewForInstance(instance)->parent(); - android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); - core->requestKeyboard(value); + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->webViewCore()->requestKeyboard(value); } static void anp_requestFullScreen(NPP instance) { diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 04f4ef6..9ab814f 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -764,13 +764,6 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { bool (*isStopped)(ANPAudioTrack*); }; -struct ANPSystemInterfaceV0 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - * or NULL if not supported - */ - const char* (*getApplicationDataDirectory)(); -}; - /////////////////////////////////////////////////////////////////////////////// // DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent |