Skip to content

Commit b9c903f

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Fix rebuildWebTextView issues"
2 parents 2f4ce2e + c0e9fb9 commit b9c903f

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

core/java/android/webkit/WebTextView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ private void setMaxLength(int maxLength) {
10901090
setMaxLength(maxLength);
10911091
setHorizontallyScrolling(single);
10921092
setInputType(inputType);
1093+
clearComposingText();
10931094
setImeOptions(imeOptions);
10941095
setVisibility(VISIBLE);
10951096
if (!autoComplete) {

core/java/android/webkit/WebView.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4804,16 +4804,7 @@ private void hideSoftKeyboard() {
48044804
mTextGeneration = 0;
48054805
}
48064806
mWebTextView.updateTextSize();
4807-
Rect visibleRect = new Rect();
4808-
calcOurContentVisibleRect(visibleRect);
4809-
// Note that sendOurVisibleRect calls viewToContent, so the coordinates
4810-
// should be in content coordinates.
4811-
Rect bounds = nativeFocusCandidateNodeBounds();
4812-
Rect vBox = contentToViewRect(bounds);
4813-
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
4814-
if (!Rect.intersects(bounds, visibleRect)) {
4815-
revealSelection();
4816-
}
4807+
updateWebTextViewPosition();
48174808
String text = nativeFocusCandidateText();
48184809
int nodePointer = nativeFocusCandidatePointer();
48194810
// This needs to be called before setType, which may call
@@ -4822,7 +4813,6 @@ private void hideSoftKeyboard() {
48224813
mWebTextView.setType(nativeFocusCandidateType());
48234814
// Gravity needs to be set after setType
48244815
mWebTextView.setGravityForRtl(nativeFocusCandidateIsRtlText());
4825-
updateWebTextViewPadding();
48264816
if (null == text) {
48274817
if (DebugFlags.WEB_VIEW) {
48284818
Log.v(LOGTAG, "rebuildWebTextView null == text");
@@ -4833,12 +4823,27 @@ private void hideSoftKeyboard() {
48334823
InputMethodManager imm = InputMethodManager.peekInstance();
48344824
if (imm != null && imm.isActive(mWebTextView)) {
48354825
imm.restartInput(mWebTextView);
4826+
mWebTextView.clearComposingText();
48364827
}
48374828
if (isFocused()) {
48384829
mWebTextView.requestFocus();
48394830
}
48404831
}
48414832

4833+
private void updateWebTextViewPosition() {
4834+
Rect visibleRect = new Rect();
4835+
calcOurContentVisibleRect(visibleRect);
4836+
// Note that sendOurVisibleRect calls viewToContent, so the coordinates
4837+
// should be in content coordinates.
4838+
Rect bounds = nativeFocusCandidateNodeBounds();
4839+
Rect vBox = contentToViewRect(bounds);
4840+
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
4841+
if (!Rect.intersects(bounds, visibleRect)) {
4842+
revealSelection();
4843+
}
4844+
updateWebTextViewPadding();
4845+
}
4846+
48424847
/**
48434848
* Update the padding of mWebTextView based on the native textfield/textarea
48444849
*/
@@ -8453,7 +8458,7 @@ public void handleMessage(Message msg) {
84538458
// this is sent after finishing resize in WebViewCore. Make
84548459
// sure the text edit box is still on the screen.
84558460
if (inEditingMode() && nativeCursorIsTextInput()) {
8456-
rebuildWebTextView();
8461+
updateWebTextViewPosition();
84578462
}
84588463
break;
84598464
case CLEAR_TEXT_ENTRY:

0 commit comments

Comments
 (0)