diff options
author | Leon Scroggins <scroggo@google.com> | 2010-01-06 17:04:38 -0500 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-01-07 08:33:34 -0500 |
commit | 3a5033996e9df21abbd5b296d817c2acaedcb0f9 (patch) | |
tree | 7516a9f39369843b49adceccdeb705a2c861b81f | |
parent | e3bbaf6c4f51f8201922cae29daa7e46f6c43bda (diff) | |
download | frameworks_base-3a5033996e9df21abbd5b296d817c2acaedcb0f9.zip frameworks_base-3a5033996e9df21abbd5b296d817c2acaedcb0f9.tar.gz frameworks_base-3a5033996e9df21abbd5b296d817c2acaedcb0f9.tar.bz2 |
Request <label> info only when accessing a textfield.
Previously, we were storing the label info each time we build the
navigation cache.
Requires a change to external/webkit.
-rw-r--r-- | core/java/android/webkit/WebTextView.java | 5 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 34 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewCore.java | 21 |
3 files changed, 51 insertions, 9 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index cd2d26a..b6891b1 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -814,7 +814,6 @@ import java.util.ArrayList; | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT; setImeOptions(EditorInfo.IME_ACTION_NONE); - setHint(null); break; case 2: // PASSWORD inPassword = true; @@ -843,9 +842,11 @@ import java.util.ArrayList; default: break; } + setHint(null); if (single) { + mWebView.requestLabel(mWebView.nativeFocusCandidateFramePointer(), + mNodePointer); maxLength = mWebView.nativeFocusCandidateMaxLength(); - setHint(mWebView.nativeFocusCandidateLabel()); if (type != 2 /* PASSWORD */) { String name = mWebView.nativeFocusCandidateName(); if (name != null && name.length() > 0) { diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 583195a..bf8ab7d 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -499,6 +499,7 @@ public class WebView extends AbsoluteLayout static final int DOM_FOCUS_CHANGED = 31; static final int IMMEDIATE_REPAINT_MSG_ID = 32; static final int SET_ROOT_LAYER_MSG_ID = 33; + static final int RETURN_LABEL = 34; static final String[] HandlerDebugString = { "REMEMBER_PASSWORD", // = 1; @@ -533,7 +534,8 @@ public class WebView extends AbsoluteLayout "HIDE_FULLSCREEN", // = 30; "DOM_FOCUS_CHANGED", // = 31; "IMMEDIATE_REPAINT_MSG_ID", // = 32; - "SET_ROOT_LAYER_MSG_ID" // = 33; + "SET_ROOT_LAYER_MSG_ID", // = 33; + "RETURN_LABEL" // = 34; }; // If the site doesn't use the viewport meta tag to specify the viewport, @@ -3308,6 +3310,17 @@ public class WebView extends AbsoluteLayout } } + /** + * Pass a message to find out the <label> associated with the <input> + * identified by nodePointer + * @param framePointer Pointer to the frame containing the <input> node + * @param nodePointer Pointer to the node for which a <label> is desired. + */ + /* package */ void requestLabel(int framePointer, int nodePointer) { + mWebViewCore.sendMessage(EventHub.REQUEST_LABEL, framePointer, + nodePointer); + } + /* * This class runs the layers animations in their own thread, * so that we do not slow down the UI. @@ -5361,7 +5374,7 @@ public class WebView extends AbsoluteLayout // exclude INVAL_RECT_MSG_ID since it is frequently output if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) { Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what - > SET_ROOT_LAYER_MSG_ID ? Integer.toString(msg.what) + > RETURN_LABEL ? Integer.toString(msg.what) : HandlerDebugString[msg.what - REMEMBER_PASSWORD]); } if (mWebViewCore == null) { @@ -5592,6 +5605,20 @@ public class WebView extends AbsoluteLayout tData.mEnd); } break; + case RETURN_LABEL: + if (inEditingMode() + && mWebTextView.isSameTextField(msg.arg1)) { + mWebTextView.setHint((String) msg.obj); + InputMethodManager imm + = InputMethodManager.peekInstance(); + // The hint is propagated to the IME in + // onCreateInputConnection. If the IME is already + // active, restart it so that its hint text is updated. + if (imm != null && imm.isActive(mWebTextView)) { + imm.restartInput(mWebTextView); + } + } + break; case MOVE_OUT_OF_PLUGIN: navHandledKey(msg.arg1, 1, false, 0, true); break; @@ -6350,12 +6377,11 @@ public class WebView extends AbsoluteLayout private native void nativeDumpDisplayTree(String urlOrNull); private native int nativeFindAll(String findLower, String findUpper); private native void nativeFindNext(boolean forward); - private native int nativeFocusCandidateFramePointer(); + /* package */ native int nativeFocusCandidateFramePointer(); private native boolean nativeFocusCandidateIsPassword(); private native boolean nativeFocusCandidateIsPlugin(); private native boolean nativeFocusCandidateIsRtlText(); private native boolean nativeFocusCandidateIsTextInput(); - /* package */ native String nativeFocusCandidateLabel(); /* package */ native int nativeFocusCandidateMaxLength(); /* package */ native String nativeFocusCandidateName(); private native Rect nativeFocusCandidateNodeBounds(); diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 2de25e8..1ef37e6 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -746,6 +746,7 @@ final class WebViewCore { } static final String[] HandlerDebugString = { + "REQUEST_LABEL", // 97 "UPDATE_FRAME_CACHE_IF_LOADING", // = 98 "SCROLL_TEXT_INPUT", // = 99 "LOAD_URL", // = 100; @@ -799,6 +800,7 @@ final class WebViewCore { class EventHub { // Message Ids + static final int REQUEST_LABEL = 97; static final int UPDATE_FRAME_CACHE_IF_LOADING = 98; static final int SCROLL_TEXT_INPUT = 99; static final int LOAD_URL = 100; @@ -911,11 +913,11 @@ final class WebViewCore { @Override public void handleMessage(Message msg) { if (DebugFlags.WEB_VIEW_CORE) { - Log.v(LOGTAG, (msg.what < UPDATE_FRAME_CACHE_IF_LOADING + Log.v(LOGTAG, (msg.what < REQUEST_LABEL || msg.what > VALID_NODE_BOUNDS ? Integer.toString(msg.what) : HandlerDebugString[msg.what - - UPDATE_FRAME_CACHE_IF_LOADING]) + - REQUEST_LABEL]) + " arg1=" + msg.arg1 + " arg2=" + msg.arg2 + " obj=" + msg.obj); } @@ -936,6 +938,19 @@ final class WebViewCore { } break; + case REQUEST_LABEL: + if (mWebView != null) { + int nodePointer = msg.arg2; + String label = nativeRequestLabel(msg.arg1, + nodePointer); + if (label != null && label.length() > 0) { + Message.obtain(mWebView.mPrivateHandler, + WebView.RETURN_LABEL, nodePointer, + 0, label).sendToTarget(); + } + } + break; + case UPDATE_FRAME_CACHE_IF_LOADING: nativeUpdateFrameCacheIfLoading(); break; @@ -2201,7 +2216,7 @@ final class WebViewCore { } private native void nativeUpdateFrameCacheIfLoading(); - + private native String nativeRequestLabel(int framePtr, int nodePtr); /** * Scroll the focused textfield to (xPercent, y) in document space */ |