Some fixes for positioning the WebTextView.

Move the change in position/size before the call to bring into view,
so that the properly positioned field will be brought into view.  It
is also now before we check to see if it is the same textfield, so
it happens in both cases.

Also remove some code which checks the selection and then sets it
unnecessarily.  It was originally surrounding some code which called
setRect, which had a side-effect of changing the selection.  That
code was removed (rendering the remaining code useless), and setRect
no longer has the side effect (the side effect was a result of calling
reqestFocus, which it no longer does - further, the change in selection from
requestFocus no longer affects the textfield's text).
This commit is contained in:
Leon Scroggins
2009-12-08 13:43:47 -05:00
parent f7d0b01387
commit 6be3bf2393
2 changed files with 4 additions and 14 deletions

View File

@@ -789,7 +789,6 @@ import java.util.ArrayList;
// Set up a measure spec so a layout can always be recreated.
mWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
mHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
requestFocus();
}
/**

View File

@@ -3205,6 +3205,8 @@ public class WebView extends AbsoluteLayout
// Note that sendOurVisibleRect calls viewToContent, so the coordinates
// should be in content coordinates.
Rect bounds = nativeFocusCandidateNodeBounds();
Rect vBox = contentToViewRect(bounds);
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
if (!Rect.intersects(bounds, visibleRect)) {
mWebTextView.bringIntoView();
}
@@ -3215,25 +3217,14 @@ public class WebView extends AbsoluteLayout
// i.e. In the case of opening/closing the screen.
// In that case, we need to set the dimensions, but not the other
// aspects.
// We also need to restore the selection, which gets wrecked by
// calling setTextEntryRect.
Spannable spannable = (Spannable) mWebTextView.getText();
int start = Selection.getSelectionStart(spannable);
int end = Selection.getSelectionEnd(spannable);
// If the text has been changed by webkit, update it. However, if
// there has been more UI text input, ignore it. We will receive
// another update when that text is recognized.
if (text != null && !text.equals(spannable.toString())
if (text != null && !text.equals(mWebTextView.getText().toString())
&& nativeTextGeneration() == mTextGeneration) {
mWebTextView.setTextAndKeepSelection(text);
} else {
// FIXME: Determine whether this is necessary.
Selection.setSelection(spannable, start, end);
}
} else {
Rect vBox = contentToViewRect(bounds);
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
vBox.height());
mWebTextView.setGravity(nativeFocusCandidateIsRtlText() ?
Gravity.RIGHT : Gravity.NO_GRAVITY);
// This needs to be called before setType, which may call
@@ -3247,8 +3238,8 @@ public class WebView extends AbsoluteLayout
text = "";
}
mWebTextView.setTextAndKeepSelection(text);
mWebTextView.requestFocus();
}
mWebTextView.requestFocus();
}
/**