From 2ca912ec1350a8196abe4630e6c629ee8191926d Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Tue, 28 Apr 2009 16:51:55 -0400 Subject: [PATCH] Lazily initialize the TextDialog. --- core/java/android/webkit/WebView.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 6e79bc9acb43a..935e928579ae9 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2959,19 +2959,16 @@ public class WebView extends AbsoluteLayout } private void updateTextEntry() { - if (mTextEntry == null) { - mTextEntry = new TextDialog(mContext, WebView.this); - // Initialize our generation number. - mTextGeneration = 0; - } // If we do not have focus, do nothing until we gain focus. - if (!hasFocus() && !mTextEntry.hasFocus() + if (!hasFocus() && (null == mTextEntry || !mTextEntry.hasFocus()) || (mTouchMode >= FIRST_SCROLL_ZOOM && mTouchMode <= LAST_SCROLL_ZOOM)) { mNeedsUpdateTextEntry = true; return; } boolean alreadyThere = inEditingMode(); + // inEditingMode can only return true if mTextEntry is non-null, + // so we can safely call remove() if (alreadyThere) if (0 == mNativeClass || !nativeUpdateFocusNode()) { if (alreadyThere) { mTextEntry.remove(); @@ -2985,6 +2982,13 @@ public class WebView extends AbsoluteLayout } return; } + // At this point, we know we have found an input field, so go ahead + // and create the TextDialog if necessary. + if (mTextEntry == null) { + mTextEntry = new TextDialog(mContext, WebView.this); + // Initialize our generation number. + mTextGeneration = 0; + } mTextEntry.setTextSize(contentToView(node.mTextSize)); Rect visibleRect = sendOurVisibleRect(); // Note that sendOurVisibleRect calls viewToContent, so the coordinates