Skip to content

Commit 062d6d5

Browse files
George MountAndroid (Google) Code Review
authored andcommitted
Merge "Quick fix for Monkey NPE."
2 parents 6c9e5d4 + 9a676bf commit 062d6d5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

core/java/android/webkit/WebViewClassic.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ public void show(Rect cursorRect, int windowLeft, int windowTop) {
736736
// handle.
737737
// The selection handle is vertically offset by 1/4 of the
738738
// line height.
739+
ensureSelectionHandles();
739740
y = cursorRect.bottom - (cursorRect.height() / 4) +
740741
mSelectHandleCenter.getIntrinsicHeight();
741742
}
@@ -5232,7 +5233,19 @@ && nativeEvaluateLayersAnimations(mNativeClass)) {
52325233
}
52335234
}
52345235

5236+
private void ensureSelectionHandles() {
5237+
if (mSelectHandleCenter == null) {
5238+
mSelectHandleCenter = mContext.getResources().getDrawable(
5239+
com.android.internal.R.drawable.text_select_handle_middle);
5240+
mSelectHandleLeft = mContext.getResources().getDrawable(
5241+
com.android.internal.R.drawable.text_select_handle_left);
5242+
mSelectHandleRight = mContext.getResources().getDrawable(
5243+
com.android.internal.R.drawable.text_select_handle_right);
5244+
}
5245+
}
5246+
52355247
private void drawTextSelectionHandles(Canvas canvas) {
5248+
ensureSelectionHandles();
52365249
int[] handles = new int[4];
52375250
getSelectionHandles(handles);
52385251
int start_x = contentToViewDimension(handles[0]);
@@ -5241,30 +5254,18 @@ private void drawTextSelectionHandles(Canvas canvas) {
52415254
int end_y = contentToViewDimension(handles[3]);
52425255

52435256
if (mIsCaretSelection) {
5244-
if (mSelectHandleCenter == null) {
5245-
mSelectHandleCenter = mContext.getResources().getDrawable(
5246-
com.android.internal.R.drawable.text_select_handle_middle);
5247-
}
52485257
// Caret handle is centered
52495258
start_x -= (mSelectHandleCenter.getIntrinsicWidth() / 2);
52505259
mSelectHandleCenter.setBounds(start_x, start_y,
52515260
start_x + mSelectHandleCenter.getIntrinsicWidth(),
52525261
start_y + mSelectHandleCenter.getIntrinsicHeight());
52535262
mSelectHandleCenter.draw(canvas);
52545263
} else {
5255-
if (mSelectHandleLeft == null) {
5256-
mSelectHandleLeft = mContext.getResources().getDrawable(
5257-
com.android.internal.R.drawable.text_select_handle_left);
5258-
}
52595264
// Magic formula copied from TextView
52605265
start_x -= (mSelectHandleLeft.getIntrinsicWidth() * 3) / 4;
52615266
mSelectHandleLeft.setBounds(start_x, start_y,
52625267
start_x + mSelectHandleLeft.getIntrinsicWidth(),
52635268
start_y + mSelectHandleLeft.getIntrinsicHeight());
5264-
if (mSelectHandleRight == null) {
5265-
mSelectHandleRight = mContext.getResources().getDrawable(
5266-
com.android.internal.R.drawable.text_select_handle_right);
5267-
}
52685269
end_x -= mSelectHandleRight.getIntrinsicWidth() / 4;
52695270
mSelectHandleRight.setBounds(end_x, end_y,
52705271
end_x + mSelectHandleRight.getIntrinsicWidth(),

0 commit comments

Comments
 (0)