Skip to content

Commit 37f29ab

Browse files
George MountAndroid (Google) Code Review
authored andcommitted
Merge "DO NOT MERGE Consider current scroll position to move text field into view." into jb-dev
2 parents 76cf781 + 12221d1 commit 37f29ab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

core/java/android/webkit/WebViewClassic.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5504,8 +5504,8 @@ private void scrollEditIntoView() {
55045504
if (visibleRect.contains(mEditTextContentBounds)) {
55055505
return; // no need to scroll
55065506
}
5507-
nativeFindMaxVisibleRect(mNativeClass, mEditTextLayerId, visibleRect);
55085507
syncSelectionCursors();
5508+
nativeFindMaxVisibleRect(mNativeClass, mEditTextLayerId, visibleRect);
55095509
final int buffer = Math.max(1, viewToContentDimension(EDIT_RECT_BUFFER));
55105510
Rect showRect = new Rect(
55115511
Math.max(0, mEditTextContentBounds.left - buffer),
@@ -5538,17 +5538,19 @@ private void scrollEditIntoView() {
55385538
return; // no need to scroll
55395539
}
55405540

5541-
int scrollX = visibleRect.left;
5541+
int scrollX = viewToContentX(getScrollX());
55425542
if (visibleRect.left > showRect.left) {
5543-
scrollX = showRect.left;
5543+
// We are scrolled too far
5544+
scrollX += showRect.left - visibleRect.left;
55445545
} else if (visibleRect.right < showRect.right) {
5545-
scrollX = Math.max(0, showRect.right - visibleRect.width());
5546+
// We aren't scrolled enough to include the right
5547+
scrollX += showRect.right - visibleRect.right;
55465548
}
5547-
int scrollY = visibleRect.top;
5549+
int scrollY = viewToContentY(getScrollY());
55485550
if (visibleRect.top > showRect.top) {
5549-
scrollY = showRect.top;
5551+
scrollY += showRect.top - visibleRect.top;
55505552
} else if (visibleRect.bottom < showRect.bottom) {
5551-
scrollY = Math.max(0, showRect.bottom - visibleRect.height());
5553+
scrollY += showRect.bottom - visibleRect.bottom;
55525554
}
55535555

55545556
contentScrollTo(scrollX, scrollY, false);

0 commit comments

Comments
 (0)