diff options
Diffstat (limited to 'Source/WebKit/android/jni')
-rw-r--r-- | Source/WebKit/android/jni/AndroidHitTestResult.cpp | 5 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 47 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 1 |
3 files changed, 49 insertions, 4 deletions
diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.cpp b/Source/WebKit/android/jni/AndroidHitTestResult.cpp index 9be5613..a135c42 100644 --- a/Source/WebKit/android/jni/AndroidHitTestResult.cpp +++ b/Source/WebKit/android/jni/AndroidHitTestResult.cpp @@ -141,9 +141,10 @@ void AndroidHitTestResult::buildHighlightRects() IntPoint frameOffset = m_webViewCore->convertGlobalContentToFrameContent(IntPoint(), frame); RenderObject* renderer = node->renderer(); Vector<FloatQuad> quads; - renderer->absoluteFocusRingQuads(quads); + if (renderer->isInline()) + renderer->absoluteFocusRingQuads(quads); if (!quads.size()) - renderer->absoluteQuads(quads); // No fancy rings, grab some backups + renderer->absoluteQuads(quads); // No fancy rings, grab a bounding box for (size_t i = 0; i < quads.size(); i++) { IntRect boundingBox = quads[i].enclosingBoundingBox(); boundingBox.move(-frameOffset.x(), -frameOffset.y()); diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index ae00941..9f66d7e 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -457,7 +457,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_scrollTo = GetJMethod(env, clazz, "contentScrollTo", "(IIZZ)V"); m_javaGlue->m_contentDraw = GetJMethod(env, clazz, "contentDraw", "()V"); m_javaGlue->m_requestListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[I[I)V"); - m_javaGlue->m_openFileChooser = GetJMethod(env, clazz, "openFileChooser", "(Ljava/lang/String;)Ljava/lang/String;"); + m_javaGlue->m_openFileChooser = GetJMethod(env, clazz, "openFileChooser", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); m_javaGlue->m_requestSingleListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[II)V"); m_javaGlue->m_jsAlert = GetJMethod(env, clazz, "jsAlert", "(Ljava/lang/String;Ljava/lang/String;)V"); m_javaGlue->m_jsConfirm = GetJMethod(env, clazz, "jsConfirm", "(Ljava/lang/String;Ljava/lang/String;)Z"); @@ -3008,11 +3008,19 @@ void WebViewCore::openFileChooser(PassRefPtr<WebCore::FileChooser> chooser) return; WTF::String acceptType = chooser->acceptTypes(); + WTF::String capture; + +#if ENABLE(MEDIA_CAPTURE) + capture = chooser->capture(); +#endif + jstring jAcceptType = wtfStringToJstring(env, acceptType, true); + jstring jCapture = wtfStringToJstring(env, capture, true); jstring jName = (jstring) env->CallObjectMethod( - javaObject.get(), m_javaGlue->m_openFileChooser, jAcceptType); + javaObject.get(), m_javaGlue->m_openFileChooser, jAcceptType, jCapture); checkException(env); env->DeleteLocalRef(jAcceptType); + env->DeleteLocalRef(jCapture); WTF::String wtfString = jstringToWtfString(env, jName); env->DeleteLocalRef(jName); @@ -3124,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 { @@ -4393,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(); @@ -5065,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 |