Skip to content

Commit d22bf4b

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Initial support for keyboard navigation"
2 parents e83b83f + 9b24dad commit d22bf4b

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

core/java/android/webkit/WebView.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5592,7 +5592,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
55925592
return false;
55935593
}
55945594

5595-
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
5595+
if (isEnterActionKey(keyCode)) {
55965596
switchOutDrawHistory();
55975597
boolean wantsKeyEvents = nativeCursorNodePointer() == 0
55985598
|| nativeCursorWantsKeyEvents();
@@ -5741,33 +5741,35 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
57415741
return true; // discard press if copy in progress
57425742
}
57435743

5744-
// perform the single click
5745-
Rect visibleRect = sendOurVisibleRect();
5746-
// Note that sendOurVisibleRect calls viewToContent, so the
5747-
// coordinates should be in content coordinates.
5748-
if (!nativeCursorIntersects(visibleRect)) {
5749-
return false;
5750-
}
5751-
WebViewCore.CursorData data = cursorData();
5752-
mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
5753-
playSoundEffect(SoundEffectConstants.CLICK);
5754-
if (nativeCursorIsTextInput()) {
5755-
rebuildWebTextView();
5756-
centerKeyPressOnTextField();
5757-
if (inEditingMode()) {
5758-
mWebTextView.setDefaultSelection();
5744+
if (!sDisableNavcache) {
5745+
// perform the single click
5746+
Rect visibleRect = sendOurVisibleRect();
5747+
// Note that sendOurVisibleRect calls viewToContent, so the
5748+
// coordinates should be in content coordinates.
5749+
if (!nativeCursorIntersects(visibleRect)) {
5750+
return false;
5751+
}
5752+
WebViewCore.CursorData data = cursorData();
5753+
mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
5754+
playSoundEffect(SoundEffectConstants.CLICK);
5755+
if (nativeCursorIsTextInput()) {
5756+
rebuildWebTextView();
5757+
centerKeyPressOnTextField();
5758+
if (inEditingMode()) {
5759+
mWebTextView.setDefaultSelection();
5760+
}
5761+
return true;
5762+
}
5763+
clearTextEntry();
5764+
nativeShowCursorTimed();
5765+
if (mCallbackProxy.uiOverrideUrlLoading(nativeCursorText())) {
5766+
return true;
5767+
}
5768+
if (nativeCursorNodePointer() != 0 && !nativeCursorWantsKeyEvents()) {
5769+
mWebViewCore.sendMessage(EventHub.CLICK, data.mFrame,
5770+
nativeCursorNodePointer());
5771+
return true;
57595772
}
5760-
return true;
5761-
}
5762-
clearTextEntry();
5763-
nativeShowCursorTimed();
5764-
if (mCallbackProxy.uiOverrideUrlLoading(nativeCursorText())) {
5765-
return true;
5766-
}
5767-
if (nativeCursorNodePointer() != 0 && !nativeCursorWantsKeyEvents()) {
5768-
mWebViewCore.sendMessage(EventHub.CLICK, data.mFrame,
5769-
nativeCursorNodePointer());
5770-
return true;
57715773
}
57725774
}
57735775

core/java/android/webkit/WebViewCore.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ private void formDidBlur(int nodePointer) {
333333
nodePointer, 0).sendToTarget();
334334
}
335335

336+
/**
337+
* Called by JNI when the focus node changed.
338+
*/
339+
private void focusNodeChanged(WebKitHitTest hitTest) {
340+
if (mWebView == null) return;
341+
mWebView.mPrivateHandler.obtainMessage(WebView.HIT_TEST_RESULT, hitTest)
342+
.sendToTarget();
343+
}
344+
336345
/**
337346
* Called by JNI. Open a file chooser to upload a file.
338347
* @param acceptType The value of the 'accept' attribute of the
@@ -615,7 +624,6 @@ private native String nativeRetrieveAnchorText(int nativeClass,
615624
int x, int y);
616625
private native String nativeRetrieveImageSource(int nativeClass,
617626
int x, int y);
618-
private native void nativeStopPaintingCaret(int nativeClass);
619627
private native void nativeTouchUp(int nativeClass,
620628
int touchGeneration, int framePtr, int nodePtr, int x, int y);
621629

@@ -1539,9 +1547,6 @@ public void handleMessage(Message msg) {
15391547
nativeMoveMouseIfLatest(mNativeClass,
15401548
cData.mMoveGeneration,
15411549
cData.mFrame, cData.mX, cData.mY);
1542-
if (msg.arg1 == 1) {
1543-
nativeStopPaintingCaret(mNativeClass);
1544-
}
15451550
break;
15461551

15471552
case REQUEST_CURSOR_HREF: {

0 commit comments

Comments
 (0)