Skip to content

Commit a12e1fe

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Set initial focus"
2 parents 8b0d90e + a4eddb5 commit a12e1fe

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/java/android/webkit/WebViewClassic.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7144,7 +7144,8 @@ public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
71447144
if (mFindIsUp) return false;
71457145
boolean result = false;
71467146
result = mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRect);
7147-
if (mWebViewCore.getSettings().getNeedInitialFocus() && !mWebView.isInTouchMode()) {
7147+
if (mWebViewCore.getSettings().getNeedInitialFocus()
7148+
&& !mWebView.isInTouchMode()) {
71487149
// For cases such as GMail, where we gain focus from a direction,
71497150
// we want to move to the first available link.
71507151
// FIXME: If there are no visible links, we may not want to
@@ -7165,7 +7166,7 @@ public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
71657166
default:
71667167
return result;
71677168
}
7168-
// TODO: Send initial focus request to webkit (b/6108927)
7169+
mWebViewCore.sendMessage(EventHub.SET_INITIAL_FOCUS, fakeKeyDirection);
71697170
}
71707171
return result;
71717172
}

core/java/android/webkit/WebViewCore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ public class EventHub implements WebViewInputDispatcher.WebKitCallbacks {
11761176

11771177
// key was pressed (down and up)
11781178
static final int KEY_PRESS = 223;
1179+
static final int SET_INITIAL_FOCUS = 224;
11791180

11801181
// Private handler for WebCore messages.
11811182
private Handler mHandler;
@@ -1748,6 +1749,9 @@ public void handleMessage(Message msg) {
17481749
WebViewClassic.UPDATE_MATCH_COUNT, request).sendToTarget();
17491750
break;
17501751
}
1752+
case SET_INITIAL_FOCUS:
1753+
nativeSetInitialFocus(mNativeClass, msg.arg1);
1754+
break;
17511755
}
17521756
}
17531757
};
@@ -3071,6 +3075,7 @@ private native void nativeSelectText(int nativeClass,
30713075
private native void nativeClearTextSelection(int nativeClass);
30723076
private native boolean nativeSelectWordAt(int nativeClass, int x, int y);
30733077
private native void nativeSelectAll(int nativeClass);
3078+
private native void nativeSetInitialFocus(int nativeClass, int keyDirection);
30743079

30753080
private static native void nativeCertTrustChanged();
30763081
}

0 commit comments

Comments
 (0)