summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2011-11-10 08:32:18 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-10 08:32:18 -0800
commitc60baec7a737d3c3cd596c5c4378a6e12450da3d (patch)
tree5bf7e9264f31596906a6000570059a72807a1c7b /core/java
parent7c61fa70a50e15466f807dd194e530bc4fd3a96a (diff)
parent331493085d7afd88158c83d0f1f9605da671049c (diff)
Merge "DO NOT MERGE Set the initial scroll position for RTL." into ics-mr1
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/webkit/BrowserFrame.java13
-rw-r--r--core/java/android/webkit/WebView.java39
-rw-r--r--core/java/android/webkit/WebViewCore.java7
3 files changed, 38 insertions, 21 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index 388920c38d12..c1945599d337 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -1404,4 +1404,17 @@ class BrowserFrame extends Handler {
native void nativeSslClientCert(int handle,
byte[] pkcs8EncodedPrivateKey,
byte[][] asn1DerEncodedCertificateChain);
+
+ /**
+ * Returns true when the contents of the frame is an RTL or vertical-rl
+ * page. This is used for determining whether a frame should be initially
+ * scrolled right-most as opposed to left-most.
+ * @return true when the frame should be initially scrolled right-most
+ * based on the text direction and writing mode.
+ */
+ /* package */ boolean getShouldStartScrolledRight() {
+ return nativeGetShouldStartScrolledRight(mNativeFrame);
+ }
+
+ private native boolean nativeGetShouldStartScrolledRight(int nativeBrowserFrame);
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 35efabcb6d81..c80994a9fbf7 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -8733,27 +8733,6 @@ public class WebView extends AbsoluteLayout
isPictureAfterFirstLayout, registerPageSwapCallback);
}
final Point viewSize = draw.mViewSize;
- if (isPictureAfterFirstLayout) {
- // Reset the last sent data here since dealing with new page.
- mLastWidthSent = 0;
- mZoomManager.onFirstLayout(draw);
- if (!mDrawHistory) {
- // Do not send the scroll event for this particular
- // scroll message. Note that a scroll event may
- // still be fired if the user scrolls before the
- // message can be handled.
- mSendScrollEvent = false;
- setContentScrollTo(viewState.mScrollX, viewState.mScrollY);
- mSendScrollEvent = true;
-
- // As we are on a new page, remove the WebTextView. This
- // is necessary for page loads driven by webkit, and in
- // particular when the user was on a password field, so
- // the WebTextView was visible.
- clearTextEntry();
- }
- }
-
// We update the layout (i.e. request a layout from the
// view system) if the last view size that we sent to
// WebCore matches the view size of the picture we just
@@ -8766,7 +8745,25 @@ public class WebView extends AbsoluteLayout
mSendScrollEvent = false;
recordNewContentSize(draw.mContentSize.x,
draw.mContentSize.y, updateLayout);
+
+ if (isPictureAfterFirstLayout) {
+ // Reset the last sent data here since dealing with new page.
+ mLastWidthSent = 0;
+ mZoomManager.onFirstLayout(draw);
+ int scrollX = viewState.mShouldStartScrolledRight
+ ? getContentWidth() : viewState.mScrollX;
+ int scrollY = viewState.mScrollY;
+ setContentScrollTo(scrollX, scrollY);
+ if (!mDrawHistory) {
+ // As we are on a new page, remove the WebTextView. This
+ // is necessary for page loads driven by webkit, and in
+ // particular when the user was on a password field, so
+ // the WebTextView was visible.
+ clearTextEntry();
+ }
+ }
mSendScrollEvent = true;
+
if (DebugFlags.WEB_VIEW) {
Rect b = draw.mInvalRegion.getBounds();
Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" +
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 754d6e9f7b5e..cd61481eed67 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1982,6 +1982,7 @@ public final class WebViewCore {
int mScrollY;
boolean mMobileSite;
boolean mIsRestored;
+ boolean mShouldStartScrolledRight;
}
static class DrawData {
@@ -2382,6 +2383,7 @@ public final class WebViewCore {
viewState.mMobileSite = false;
// for non-mobile site, we don't need minPrefWidth, set it as 0
viewState.mScrollX = 0;
+ viewState.mShouldStartScrolledRight = false;
Message.obtain(mWebView.mPrivateHandler,
WebView.UPDATE_ZOOM_RANGE, viewState).sendToTarget();
return;
@@ -2412,6 +2414,11 @@ public final class WebViewCore {
mInitialViewState.mDefaultScale = adjust;
mInitialViewState.mScrollX = mRestoredX;
mInitialViewState.mScrollY = mRestoredY;
+ mInitialViewState.mShouldStartScrolledRight = (mRestoredX == 0)
+ && (mRestoredY == 0)
+ && (mBrowserFrame != null)
+ && mBrowserFrame.getShouldStartScrolledRight();
+
mInitialViewState.mMobileSite = (0 == mViewportWidth);
if (mIsRestored) {
mInitialViewState.mIsRestored = true;