diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-03-18 12:42:33 -0400 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2010-03-18 12:51:08 -0400 |
| commit | b415779e3ba8147704f1d408cd932554c0a45a22 (patch) | |
| tree | 29736226982486ff3015c94a6a89d3c8550ba6aa /core/java/android/webkit/WebView.java | |
| parent | b82ac6bf374c14082f7142614eb7d8e545b9a18b (diff) | |
Pass selection data with the message to open the keyboard.
Fix for http://b/issue?id=2431351
Requires a change to external/webkit.
Change-Id: I501c3b1a9ae602458b830d34f779ccedf51dba9b
Diffstat (limited to 'core/java/android/webkit/WebView.java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 418dc9c9cdac..622d22d03b93 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -536,9 +536,11 @@ public class WebView extends AbsoluteLayout static final int RETURN_LABEL = 125; static final int FIND_AGAIN = 126; static final int CENTER_FIT_RECT = 127; + static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128; private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID; - private static final int LAST_PACKAGE_MSG_ID = CENTER_FIT_RECT; + private static final int LAST_PACKAGE_MSG_ID + = REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID; static final String[] HandlerPrivateDebugString = { "REMEMBER_PASSWORD", // = 1; @@ -580,7 +582,8 @@ public class WebView extends AbsoluteLayout "SET_ROOT_LAYER_MSG_ID", // = 124; "RETURN_LABEL", // = 125; "FIND_AGAIN", // = 126; - "CENTER_FIT_RECT" // = 127; + "CENTER_FIT_RECT", // = 127; + "REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID" // = 128; }; // If the site doesn't use the viewport meta tag to specify the viewport, @@ -6307,19 +6310,18 @@ public class WebView extends AbsoluteLayout } } break; + case REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID: + displaySoftKeyboard(true); + updateTextSelectionFromMessage(msg.arg1, msg.arg2, + (WebViewCore.TextSelectionData) msg.obj); + break; case UPDATE_TEXT_SELECTION_MSG_ID: // If no textfield was in focus, and the user touched one, // causing it to send this message, then WebTextView has not // been set up yet. Rebuild it so it can set its selection. rebuildWebTextView(); - if (inEditingMode() - && mWebTextView.isSameTextField(msg.arg1) - && msg.arg2 == mTextGeneration) { - WebViewCore.TextSelectionData tData - = (WebViewCore.TextSelectionData) msg.obj; - mWebTextView.setSelectionFromWebKit(tData.mStart, - tData.mEnd); - } + updateTextSelectionFromMessage(msg.arg1, msg.arg2, + (WebViewCore.TextSelectionData) msg.obj); break; case RETURN_LABEL: if (inEditingMode() @@ -6475,7 +6477,7 @@ public class WebView extends AbsoluteLayout if (msg.arg1 == 0) { hideSoftKeyboard(); } else { - displaySoftKeyboard(1 == msg.arg2); + displaySoftKeyboard(false); } break; @@ -6598,6 +6600,19 @@ public class WebView extends AbsoluteLayout } } + /** + * Used when receiving messages for REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID + * and UPDATE_TEXT_SELECTION_MSG_ID. Update the selection of WebTextView. + */ + private void updateTextSelectionFromMessage(int nodePointer, + int textGeneration, WebViewCore.TextSelectionData data) { + if (inEditingMode() + && mWebTextView.isSameTextField(nodePointer) + && textGeneration == mTextGeneration) { + mWebTextView.setSelectionFromWebKit(data.mStart, data.mEnd); + } + } + // Class used to use a dropdown for a <select> element private class InvokeListBox implements Runnable { // Whether the listbox allows multiple selection. |
