Skip to content

Commit c60baec

Browse files
George MountAndroid (Google) Code Review
authored andcommitted
Merge "DO NOT MERGE Set the initial scroll position for RTL." into ics-mr1
2 parents 7c61fa7 + 3314930 commit c60baec

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

core/java/android/webkit/BrowserFrame.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,4 +1404,17 @@ public void stopLoading() {
14041404
native void nativeSslClientCert(int handle,
14051405
byte[] pkcs8EncodedPrivateKey,
14061406
byte[][] asn1DerEncodedCertificateChain);
1407+
1408+
/**
1409+
* Returns true when the contents of the frame is an RTL or vertical-rl
1410+
* page. This is used for determining whether a frame should be initially
1411+
* scrolled right-most as opposed to left-most.
1412+
* @return true when the frame should be initially scrolled right-most
1413+
* based on the text direction and writing mode.
1414+
*/
1415+
/* package */ boolean getShouldStartScrolledRight() {
1416+
return nativeGetShouldStartScrolledRight(mNativeFrame);
1417+
}
1418+
1419+
private native boolean nativeGetShouldStartScrolledRight(int nativeBrowserFrame);
14071420
}

core/java/android/webkit/WebView.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8733,27 +8733,6 @@ void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {
87338733
isPictureAfterFirstLayout, registerPageSwapCallback);
87348734
}
87358735
final Point viewSize = draw.mViewSize;
8736-
if (isPictureAfterFirstLayout) {
8737-
// Reset the last sent data here since dealing with new page.
8738-
mLastWidthSent = 0;
8739-
mZoomManager.onFirstLayout(draw);
8740-
if (!mDrawHistory) {
8741-
// Do not send the scroll event for this particular
8742-
// scroll message. Note that a scroll event may
8743-
// still be fired if the user scrolls before the
8744-
// message can be handled.
8745-
mSendScrollEvent = false;
8746-
setContentScrollTo(viewState.mScrollX, viewState.mScrollY);
8747-
mSendScrollEvent = true;
8748-
8749-
// As we are on a new page, remove the WebTextView. This
8750-
// is necessary for page loads driven by webkit, and in
8751-
// particular when the user was on a password field, so
8752-
// the WebTextView was visible.
8753-
clearTextEntry();
8754-
}
8755-
}
8756-
87578736
// We update the layout (i.e. request a layout from the
87588737
// view system) if the last view size that we sent to
87598738
// WebCore matches the view size of the picture we just
@@ -8766,7 +8745,25 @@ void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {
87668745
mSendScrollEvent = false;
87678746
recordNewContentSize(draw.mContentSize.x,
87688747
draw.mContentSize.y, updateLayout);
8748+
8749+
if (isPictureAfterFirstLayout) {
8750+
// Reset the last sent data here since dealing with new page.
8751+
mLastWidthSent = 0;
8752+
mZoomManager.onFirstLayout(draw);
8753+
int scrollX = viewState.mShouldStartScrolledRight
8754+
? getContentWidth() : viewState.mScrollX;
8755+
int scrollY = viewState.mScrollY;
8756+
setContentScrollTo(scrollX, scrollY);
8757+
if (!mDrawHistory) {
8758+
// As we are on a new page, remove the WebTextView. This
8759+
// is necessary for page loads driven by webkit, and in
8760+
// particular when the user was on a password field, so
8761+
// the WebTextView was visible.
8762+
clearTextEntry();
8763+
}
8764+
}
87698765
mSendScrollEvent = true;
8766+
87708767
if (DebugFlags.WEB_VIEW) {
87718768
Rect b = draw.mInvalRegion.getBounds();
87728769
Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" +

core/java/android/webkit/WebViewCore.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,7 @@ static class ViewState {
19821982
int mScrollY;
19831983
boolean mMobileSite;
19841984
boolean mIsRestored;
1985+
boolean mShouldStartScrolledRight;
19851986
}
19861987

19871988
static class DrawData {
@@ -2382,6 +2383,7 @@ private void setupViewport(boolean updateViewState) {
23822383
viewState.mMobileSite = false;
23832384
// for non-mobile site, we don't need minPrefWidth, set it as 0
23842385
viewState.mScrollX = 0;
2386+
viewState.mShouldStartScrolledRight = false;
23852387
Message.obtain(mWebView.mPrivateHandler,
23862388
WebView.UPDATE_ZOOM_RANGE, viewState).sendToTarget();
23872389
return;
@@ -2412,6 +2414,11 @@ private void setupViewport(boolean updateViewState) {
24122414
mInitialViewState.mDefaultScale = adjust;
24132415
mInitialViewState.mScrollX = mRestoredX;
24142416
mInitialViewState.mScrollY = mRestoredY;
2417+
mInitialViewState.mShouldStartScrolledRight = (mRestoredX == 0)
2418+
&& (mRestoredY == 0)
2419+
&& (mBrowserFrame != null)
2420+
&& mBrowserFrame.getShouldStartScrolledRight();
2421+
24152422
mInitialViewState.mMobileSite = (0 == mViewportWidth);
24162423
if (mIsRestored) {
24172424
mInitialViewState.mIsRestored = true;

0 commit comments

Comments
 (0)