diff options
author | John Reck <jreck@google.com> | 2012-03-06 17:05:52 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-06 17:05:52 -0800 |
commit | 45affaf529022d400844698d81d318be913c7748 (patch) | |
tree | 14f82b2ecc64db71680911782bd795a77a917c1c /Source | |
parent | 221265b7850cf40a096dd513e2a492454405a6d0 (diff) | |
parent | a7151f16f5233a27b2e2ea837ed801e8ac85ccfd (diff) | |
download | external_webkit-45affaf529022d400844698d81d318be913c7748.zip external_webkit-45affaf529022d400844698d81d318be913c7748.tar.gz external_webkit-45affaf529022d400844698d81d318be913c7748.tar.bz2 |
Merge "Support passing focus to the chrome"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 11 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 22 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 3 |
3 files changed, 34 insertions, 2 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 1328675..5e16152 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -161,8 +161,15 @@ void ChromeClientAndroid::focus() } void ChromeClientAndroid::unfocus() { notImplemented(); } -bool ChromeClientAndroid::canTakeFocus(FocusDirection) { notImplemented(); return false; } -void ChromeClientAndroid::takeFocus(FocusDirection) { notImplemented(); } +bool ChromeClientAndroid::canTakeFocus(FocusDirection direction) +{ + return android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->chromeCanTakeFocus(direction); +} + +void ChromeClientAndroid::takeFocus(FocusDirection direction) +{ + android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->chromeTakeFocus(direction); +} void ChromeClientAndroid::focusedNodeChanged(Node* node) { diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 41a8339..397f9c1 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -366,6 +366,8 @@ struct WebViewCore::JavaGlue { jmethodID m_selectAt; jmethodID m_initEditField; jmethodID m_updateMatchCount; + jmethodID m_chromeCanTakeFocus; + jmethodID m_chromeTakeFocus; AutoJObject object(JNIEnv* env) { // We hold a weak reference to the Java WebViewCore to avoid memeory // leaks due to circular references when WebView.destroy() is not @@ -482,6 +484,8 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_selectAt = GetJMethod(env, clazz, "selectAt", "(II)V"); m_javaGlue->m_initEditField = GetJMethod(env, clazz, "initEditField", "(ILjava/lang/String;IZZLjava/lang/String;IIII)V"); m_javaGlue->m_updateMatchCount = GetJMethod(env, clazz, "updateMatchCount", "(IILjava/lang/String;)V"); + m_javaGlue->m_chromeCanTakeFocus = GetJMethod(env, clazz, "chromeCanTakeFocus", "(I)Z"); + m_javaGlue->m_chromeTakeFocus = GetJMethod(env, clazz, "chromeTakeFocus", "(I)V"); env->DeleteLocalRef(clazz); env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); @@ -2990,6 +2994,24 @@ bool WebViewCore::key(const PlatformKeyboardEvent& event) return eventHandler->keyEvent(event); } +bool WebViewCore::chromeCanTakeFocus(FocusDirection direction) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject javaObject = m_javaGlue->object(env); + if (!javaObject.get()) + return false; + return env->CallBooleanMethod(javaObject.get(), m_javaGlue->m_chromeCanTakeFocus, direction); +} + +void WebViewCore::chromeTakeFocus(FocusDirection direction) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject javaObject = m_javaGlue->object(env); + if (!javaObject.get()) + return; + env->CallVoidMethod(javaObject.get(), m_javaGlue->m_chromeTakeFocus, direction); +} + // For when the user clicks the trackball, presses dpad center, or types into an // unfocused textfield. In the latter case, 'fake' will be true void WebViewCore::click(WebCore::Frame* frame, WebCore::Node* node, bool fake) { diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 4cbc566..1db498b 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -29,6 +29,7 @@ #include "DeviceMotionAndOrientationManager.h" #include "DOMSelection.h" #include "FileChooser.h" +#include "FocusDirection.h" #include "HitTestResult.h" #include "PictureSet.h" #include "PlatformGraphicsContext.h" @@ -318,6 +319,8 @@ namespace android { * @return Whether keyCode was handled by this class. */ bool key(const WebCore::PlatformKeyboardEvent& event); + bool chromeCanTakeFocus(FocusDirection direction); + void chromeTakeFocus(FocusDirection direction); /** * Handle (trackball) click event / dpad center press from Java. |