diff options
| author | John Reck <jreck@google.com> | 2012-04-13 13:25:37 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-13 13:25:37 -0700 |
| commit | a4b85e417c6df8390ea31caadbde76ee8cf447e0 (patch) | |
| tree | 560dd65ef7d94a9ce2da6bab18f13c68a5397702 | |
| parent | 9ff7dc14df31be3a39a5693f81ed6683c6e4e2c8 (diff) | |
| parent | 8f05073be1549b39eaf2e0ff3b6fe0f8cae3afcd (diff) | |
| download | external_webkit-a4b85e417c6df8390ea31caadbde76ee8cf447e0.zip external_webkit-a4b85e417c6df8390ea31caadbde76ee8cf447e0.tar.gz external_webkit-a4b85e417c6df8390ea31caadbde76ee8cf447e0.tar.bz2 | |
Merge "Set initial focus"
| -rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 35 | ||||
| -rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 7da8103..9f66d7e 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -3132,6 +3132,32 @@ void WebViewCore::chromeTakeFocus(FocusDirection direction) env->CallVoidMethod(javaObject.get(), m_javaGlue->m_chromeTakeFocus, direction); } +void WebViewCore::setInitialFocus(const WebCore::PlatformKeyboardEvent& platformEvent) +{ + Frame* frame = focusedFrame(); + Document* document = frame->document(); + if (document) + document->setFocusedNode(0); + FocusDirection direction; + switch (platformEvent.nativeVirtualKeyCode()) { + case AKEYCODE_DPAD_LEFT: + direction = FocusDirectionLeft; + break; + case AKEYCODE_DPAD_RIGHT: + direction = FocusDirectionRight; + break; + case AKEYCODE_DPAD_UP: + direction = FocusDirectionUp; + break; + default: + direction = FocusDirectionDown; + break; + } + RefPtr<KeyboardEvent> webkitEvent = KeyboardEvent::create(platformEvent, 0); + m_mainFrame->page()->focusController()->setInitialFocus(direction, + webkitEvent.get()); +} + #if USE(ACCELERATED_COMPOSITING) GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const { @@ -4401,6 +4427,14 @@ static jboolean Key(JNIEnv* env, jobject obj, jint nativeClass, jint keyCode, unichar, repeatCount, isDown, isShift, isAlt, isSym)); } +static void SetInitialFocus(JNIEnv* env, jobject obj, jint nativeClass, + jint keyDirection) +{ + WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); + viewImpl->setInitialFocus(PlatformKeyboardEvent(keyDirection, + 0, 0, false, false, false, false)); +} + static void ContentInvalidateAll(JNIEnv* env, jobject obj, jint nativeClass) { reinterpret_cast<WebViewCore*>(nativeClass)->contentInvalidateAll(); @@ -5073,6 +5107,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) FindAll }, { "nativeFindNext", "(IZ)I", (void*) FindNext }, + { "nativeSetInitialFocus", "(II)V", (void*) SetInitialFocus }, }; int registerWebViewCore(JNIEnv* env) diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 82a65cf..eec98b0 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -321,6 +321,7 @@ namespace android { bool key(const WebCore::PlatformKeyboardEvent& event); bool chromeCanTakeFocus(WebCore::FocusDirection direction); void chromeTakeFocus(WebCore::FocusDirection direction); + void setInitialFocus(const WebCore::PlatformKeyboardEvent& event); /** * Handle touch event |
