diff options
author | John Reck <jreck@google.com> | 2012-03-06 14:30:50 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-03-06 14:30:50 -0800 |
commit | a7151f16f5233a27b2e2ea837ed801e8ac85ccfd (patch) | |
tree | 10cbd99b95e7208db983dddb5c8466658f934074 | |
parent | cc845c6b387500f968dea35d760d4a6bddae805a (diff) | |
download | external_webkit-a7151f16f5233a27b2e2ea837ed801e8ac85ccfd.zip external_webkit-a7151f16f5233a27b2e2ea837ed801e8ac85ccfd.tar.gz external_webkit-a7151f16f5233a27b2e2ea837ed801e8ac85ccfd.tar.bz2 |
Support passing focus to the chrome
Bug: 6109044
This is primarily for tab navigation, arrow keys are handled differently
Change-Id: I72968014535afe21bbcb43913bd11cbb676daaf9
-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. |