Skip to content

Commit 9b24dad

Browse files
committed
Initial support for keyboard navigation
Bug: 6019693 Change-Id: I8d29a5cb46fc59bb2f53e8d334bc767b5ed16901
1 parent 8181201 commit 9b24dad

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
@@ -5555,7 +5555,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
55555555
return false;
55565556
}
55575557

5558-
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
5558+
if (isEnterActionKey(keyCode)) {
55595559
switchOutDrawHistory();
55605560
boolean wantsKeyEvents = nativeCursorNodePointer() == 0
55615561
|| nativeCursorWantsKeyEvents();
@@ -5704,33 +5704,35 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
57045704
return true; // discard press if copy in progress
57055705
}
57065706

5707-
// perform the single click
5708-
Rect visibleRect = sendOurVisibleRect();
5709-
// Note that sendOurVisibleRect calls viewToContent, so the
5710-
// coordinates should be in content coordinates.
5711-
if (!nativeCursorIntersects(visibleRect)) {
5712-
return false;
5713-
}
5714-
WebViewCore.CursorData data = cursorData();
5715-
mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
5716-
playSoundEffect(SoundEffectConstants.CLICK);
5717-
if (nativeCursorIsTextInput()) {
5718-
rebuildWebTextView();
5719-
centerKeyPressOnTextField();
5720-
if (inEditingMode()) {
5721-
mWebTextView.setDefaultSelection();
5707+
if (!sDisableNavcache) {
5708+
// perform the single click
5709+
Rect visibleRect = sendOurVisibleRect();
5710+
// Note that sendOurVisibleRect calls viewToContent, so the
5711+
// coordinates should be in content coordinates.
5712+
if (!nativeCursorIntersects(visibleRect)) {
5713+
return false;
5714+
}
5715+
WebViewCore.CursorData data = cursorData();
5716+
mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
5717+
playSoundEffect(SoundEffectConstants.CLICK);
5718+
if (nativeCursorIsTextInput()) {
5719+
rebuildWebTextView();
5720+
centerKeyPressOnTextField();
5721+
if (inEditingMode()) {
5722+
mWebTextView.setDefaultSelection();
5723+
}
5724+
return true;
5725+
}
5726+
clearTextEntry();
5727+
nativeShowCursorTimed();
5728+
if (mCallbackProxy.uiOverrideUrlLoading(nativeCursorText())) {
5729+
return true;
5730+
}
5731+
if (nativeCursorNodePointer() != 0 && !nativeCursorWantsKeyEvents()) {
5732+
mWebViewCore.sendMessage(EventHub.CLICK, data.mFrame,
5733+
nativeCursorNodePointer());
5734+
return true;
57225735
}
5723-
return true;
5724-
}
5725-
clearTextEntry();
5726-
nativeShowCursorTimed();
5727-
if (mCallbackProxy.uiOverrideUrlLoading(nativeCursorText())) {
5728-
return true;
5729-
}
5730-
if (nativeCursorNodePointer() != 0 && !nativeCursorWantsKeyEvents()) {
5731-
mWebViewCore.sendMessage(EventHub.CLICK, data.mFrame,
5732-
nativeCursorNodePointer());
5733-
return true;
57345736
}
57355737
}
57365738

core/java/android/webkit/WebViewCore.java

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

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

@@ -1530,9 +1538,6 @@ public void handleMessage(Message msg) {
15301538
nativeMoveMouseIfLatest(mNativeClass,
15311539
cData.mMoveGeneration,
15321540
cData.mFrame, cData.mX, cData.mY);
1533-
if (msg.arg1 == 1) {
1534-
nativeStopPaintingCaret(mNativeClass);
1535-
}
15361541
break;
15371542

15381543
case REQUEST_CURSOR_HREF: {

0 commit comments

Comments
 (0)