diff options
| author | George Mount <mount@google.com> | 2012-03-01 16:28:12 -0800 |
|---|---|---|
| committer | George Mount <mount@google.com> | 2012-03-02 07:40:38 -0800 |
| commit | 9a676bfb5ff3eff5c1814e8eeaea9e0f2e29aae6 (patch) | |
| tree | 2124078e1505c09706ccc76ac5944d7be505eee4 /core/java | |
| parent | 3c90952036a5ff7ddb2946c643f1a0bf1c31d53a (diff) | |
Quick fix for Monkey NPE.
Bug 6097462
If paste window is shown before the insert thumb, an NPE
would be thrown. This will be fixed fully later when the paste
window is showing up only at the proper times rather than every
time the insert thumb is shown.
Change-Id: I91eec7c28fc64a2274f5c3cd36784fedcae055ca
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/webkit/WebViewClassic.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index e6cee42bb803..76fc8f4d0878 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -736,6 +736,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // handle. // The selection handle is vertically offset by 1/4 of the // line height. + ensureSelectionHandles(); y = cursorRect.bottom - (cursorRect.height() / 4) + mSelectHandleCenter.getIntrinsicHeight(); } @@ -5232,7 +5233,19 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } } + private void ensureSelectionHandles() { + if (mSelectHandleCenter == null) { + mSelectHandleCenter = mContext.getResources().getDrawable( + com.android.internal.R.drawable.text_select_handle_middle); + mSelectHandleLeft = mContext.getResources().getDrawable( + com.android.internal.R.drawable.text_select_handle_left); + mSelectHandleRight = mContext.getResources().getDrawable( + com.android.internal.R.drawable.text_select_handle_right); + } + } + private void drawTextSelectionHandles(Canvas canvas) { + ensureSelectionHandles(); int[] handles = new int[4]; getSelectionHandles(handles); int start_x = contentToViewDimension(handles[0]); @@ -5241,10 +5254,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc int end_y = contentToViewDimension(handles[3]); if (mIsCaretSelection) { - if (mSelectHandleCenter == null) { - mSelectHandleCenter = mContext.getResources().getDrawable( - com.android.internal.R.drawable.text_select_handle_middle); - } // Caret handle is centered start_x -= (mSelectHandleCenter.getIntrinsicWidth() / 2); mSelectHandleCenter.setBounds(start_x, start_y, @@ -5252,19 +5261,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc start_y + mSelectHandleCenter.getIntrinsicHeight()); mSelectHandleCenter.draw(canvas); } else { - if (mSelectHandleLeft == null) { - mSelectHandleLeft = mContext.getResources().getDrawable( - com.android.internal.R.drawable.text_select_handle_left); - } // Magic formula copied from TextView start_x -= (mSelectHandleLeft.getIntrinsicWidth() * 3) / 4; mSelectHandleLeft.setBounds(start_x, start_y, start_x + mSelectHandleLeft.getIntrinsicWidth(), start_y + mSelectHandleLeft.getIntrinsicHeight()); - if (mSelectHandleRight == null) { - mSelectHandleRight = mContext.getResources().getDrawable( - com.android.internal.R.drawable.text_select_handle_right); - } end_x -= mSelectHandleRight.getIntrinsicWidth() / 4; mSelectHandleRight.setBounds(end_x, end_y, end_x + mSelectHandleRight.getIntrinsicWidth(), |
