summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-09-30 08:37:10 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-09-30 08:37:10 -0700
commit0fade321435f38382c614ade7b64e6b68440d747 (patch)
treed39936947a3b45a3b3415ecb7f6fa15322b6d52c /WebKit/android
parent8ce618ea67480ae663d52350339a95fff3d6f1f5 (diff)
parent14e3d9bdf2270d399bae78946e3efe62a6c6c373 (diff)
downloadexternal_webkit-0fade321435f38382c614ade7b64e6b68440d747.zip
external_webkit-0fade321435f38382c614ade7b64e6b68440d747.tar.gz
external_webkit-0fade321435f38382c614ade7b64e6b68440d747.tar.bz2
Merge commit 'remotes/goog/eclair' into eclair-release
Diffstat (limited to 'WebKit/android')
-rwxr-xr-xWebKit/android/WebCoreSupport/GeolocationPermissions.cpp5
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp2
-rw-r--r--WebKit/android/jni/WebSettings.cpp2
-rw-r--r--WebKit/android/jni/WebViewCore.cpp60
-rw-r--r--WebKit/android/jni/WebViewCore.h16
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp2
6 files changed, 58 insertions, 29 deletions
diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp
index a0b234b..b77edd3 100755
--- a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp
+++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp
@@ -181,7 +181,10 @@ void GeolocationPermissions::cancelPendingRequests(String origin)
if (index != WTF::notFound) {
// Get the permission from the permanent list.
PermissionsMap::const_iterator iter = s_permanentPermissions.find(origin);
- ASSERT(iter != (PermissionsMap::const_iterator end = s_permanentPermissions.end()));
+#ifndef NDEBUG
+ PermissionsMap::const_iterator end = s_permanentPermissions.end();
+ ASSERT(iter != end);
+#endif
bool allow = iter->second;
maybeCallbackFrames(origin, allow);
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 6c97acc..2981441 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -637,7 +637,7 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request)
if (!mUserInitiatedClick && !request.getUserGesture() &&
(requestUrl.protocolIs("http") || requestUrl.protocolIs("https") ||
requestUrl.protocolIs("file") || requestUrl.protocolIs("about") ||
- requestUrl.protocolIs("javascript")))
+ WebCore::protocolIsJavaScript(requestUrl.string())))
return true;
WebCore::String url(request.url().string());
// Empty urls should not be sent to java
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 3cba99c..4240dd5 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -316,7 +316,7 @@ public:
str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath);
if (str) {
WebCore::String path = to_string(env, str);
- if (path.length()) {
+ if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) {
WebCore::cacheStorage().setCacheDirectory(path);
}
}
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 359da03..ac47cbf 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -257,7 +257,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)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", "()[Ljava/lang/String;");
+ m_javaGlue->m_populateVisitedLinks = GetJMethod(env, clazz, "populateVisitedLinks", "()V");
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");
@@ -336,6 +336,7 @@ void WebViewCore::reset(bool fromConstructor)
m_scrollOffsetY = 0;
m_screenWidth = 0;
m_screenHeight = 0;
+ m_groupForVisitedLinks = NULL;
}
static bool layoutIfNeededRecursive(WebCore::Frame* f)
@@ -1649,7 +1650,7 @@ void WebViewCore::passToJs(int generation, const WebCore::String& current,
updateTextfield(focus, false, test);
}
-void WebViewCore::scrollFocusedTextInput(int x, int y)
+void WebViewCore::scrollFocusedTextInput(float xPercent, int y)
{
WebCore::Node* focus = currentFocus();
if (!focus) {
@@ -1665,6 +1666,10 @@ void WebViewCore::scrollFocusedTextInput(int x, int y)
}
WebCore::RenderTextControl* renderText =
static_cast<WebCore::RenderTextControl*>(renderer);
+ int x = (int) (xPercent * (renderText->scrollWidth() -
+ renderText->clientWidth()));
+ DBG_NAV_LOGD("x=%d y=%d xPercent=%g scrollW=%d clientW=%d", x, y,
+ xPercent, renderText->scrollWidth(), renderText->clientWidth());
renderText->setScrollLeft(x);
renderText->setScrollTop(y);
}
@@ -2086,23 +2091,12 @@ void WebViewCore::reachedMaxAppCacheSize(const unsigned long long spaceNeeded)
void WebViewCore::populateVisitedLinks(WebCore::PageGroup* group)
{
+ m_groupForVisitedLinks = group;
JNIEnv* env = JSC::Bindings::getJNIEnv();
- jobjectArray array = static_cast<jobjectArray>(env->CallObjectMethod(m_javaGlue->object(env).get(), m_javaGlue->m_populateVisitedLinks));
- if (!array)
- return;
- jsize len = env->GetArrayLength(array);
- for (jsize i = 0; i < len; i++) {
- jstring item = static_cast<jstring>(env->GetObjectArrayElement(array, i));
- const UChar* str = static_cast<const UChar*>(env->GetStringChars(item, NULL));
- jsize len = env->GetStringLength(item);
- group->addVisitedLink(str, len);
- env->ReleaseStringChars(item, str);
- env->DeleteLocalRef(item);
- }
- env->DeleteLocalRef(array);
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_populateVisitedLinks);
+ checkException(env);
}
-
void WebViewCore::geolocationPermissionsShowPrompt(const WebCore::String& origin)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -2398,13 +2392,14 @@ static void PassToJs(JNIEnv *env, jobject obj,
PlatformKeyboardEvent(keyCode, keyValue, 0, down, cap, fn, sym));
}
-static void ScrollFocusedTextInput(JNIEnv *env, jobject obj, jint x, jint y)
+static void ScrollFocusedTextInput(JNIEnv *env, jobject obj, jfloat xPercent,
+ jint y)
{
#ifdef ANDROID_INSTRUMENT
TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- viewImpl->scrollFocusedTextInput(x, y);
+ viewImpl->scrollFocusedTextInput(xPercent, y);
}
static void SetFocusControllerActive(JNIEnv *env, jobject obj, jboolean active)
@@ -2429,6 +2424,12 @@ static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame)
viewImpl->saveDocumentState((WebCore::Frame*) frame);
}
+void WebViewCore::addVisitedLink(const UChar* string, int length)
+{
+ if (m_groupForVisitedLinks)
+ m_groupForVisitedLinks->addVisitedLink(string, length);
+}
+
static bool RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt)
{
#ifdef ANDROID_INSTRUMENT
@@ -2785,6 +2786,25 @@ static void FreeMemory(JNIEnv* env, jobject obj)
GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event);
}
+static void ProvideVisitedHistory(JNIEnv *env, jobject obj, jobject hist)
+{
+ WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+
+ jobjectArray array = static_cast<jobjectArray>(hist);
+
+ jsize len = env->GetArrayLength(array);
+ for (jsize i = 0; i < len; i++) {
+ jstring item = static_cast<jstring>(env->GetObjectArrayElement(array, i));
+ const UChar* str = static_cast<const UChar*>(env->GetStringChars(item, NULL));
+ jsize len = env->GetStringLength(item);
+ viewImpl->addVisitedLink(str, len);
+ env->ReleaseStringChars(item, str);
+ env->DeleteLocalRef(item);
+ }
+ env->DeleteLocalRef(array);
+}
+
// ----------------------------------------------------------------------------
/*
@@ -2825,7 +2845,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) MoveMouseIfLatest },
{ "passToJs", "(ILjava/lang/String;IIZZZZ)V",
(void*) PassToJs },
- { "nativeScrollFocusedTextInput", "(II)V",
+ { "nativeScrollFocusedTextInput", "(FI)V",
(void*) ScrollFocusedTextInput },
{ "nativeSetFocusControllerActive", "(Z)V",
(void*) SetFocusControllerActive },
@@ -2872,6 +2892,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
{ "nativeUpdatePluginState", "(III)V", (void*) UpdatePluginState },
{ "nativeUpdateFrameCacheIfLoading", "()V",
(void*) UpdateFrameCacheIfLoading },
+ { "nativeProvideVisitedHistory", "([Ljava/lang/String;)V",
+ (void*) ProvideVisitedHistory },
};
int register_webviewcore(JNIEnv* env)
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 1a86482..5d12158 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -217,11 +217,12 @@ namespace android {
*/
void reachedMaxAppCacheSize(const unsigned long long spaceNeeded);
- /**
- * Set up the PageGroup's idea of which links have been visited, with the browser history.
- * @param group the object to deliver the links to.
- */
- void populateVisitedLinks(WebCore::PageGroup*);
+ /**
+ * Set up the PageGroup's idea of which links have been visited,
+ * with the browser history.
+ * @param group the object to deliver the links to.
+ */
+ void populateVisitedLinks(WebCore::PageGroup*);
/**
* Instruct the browser to show a Geolocation permission prompt for the
@@ -319,11 +320,13 @@ namespace android {
/**
* Scroll the focused textfield to (x, y) in document space
*/
- void scrollFocusedTextInput(int x, int y);
+ void scrollFocusedTextInput(float x, int y);
void setFocusControllerActive(bool active);
void saveDocumentState(WebCore::Frame* frame);
+ void addVisitedLink(const UChar*, int);
+
// TODO: I don't like this hack but I need to access the java object in
// order to send it as a parameter to java
AutoJObject getJavaObject();
@@ -483,6 +486,7 @@ namespace android {
float m_screenWidthScale;
unsigned m_domtree_version;
bool m_check_domtree_version;
+ PageGroup* m_groupForVisitedLinks;
SkTDArray<PluginWidgetAndroid*> m_plugins;
WebCore::Timer<WebViewCore> m_pluginInvalTimer;
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 037a6e5..4acf598 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1117,7 +1117,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
hasMouseOver = NodeHasEventListeners(node, &eventNames().mouseoverEvent, 1);
isAnchor = true;
KURL href = anchorNode->href();
- if (!href.isEmpty() && !href.protocolIs("javascript"))
+ if (!href.isEmpty() && !WebCore::protocolIsJavaScript(href.string()))
// Set the exported string for all non-javascript anchors.
exported = href.string().copy();
}