| Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| index 8ecc734cec45b2daa9e8f9a2957948b62baab280..fe1d4bf2f9a147641f22ec72c048881688ccd29b 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -323,13 +323,20 @@ public class AwContents implements SmartClipProvider,
|
| /**
|
| * A class that stores the state needed to enter and exit fullscreen.
|
| */
|
| - private static class FullScreenTransitionsState {
|
| + private class FullScreenTransitionsState {
|
| private final ViewGroup mInitialContainerView;
|
| private final InternalAccessDelegate mInitialInternalAccessAdapter;
|
| private final AwViewMethods mInitialAwViewMethods;
|
| + private float mInitialPageScaleFactor;
|
| + private int[] mInitialScrollOffset;
|
| private FullScreenView mFullScreenView;
|
| /** Whether the initial container view was focused when we entered fullscreen */
|
| private boolean mWasInitialContainerViewFocused;
|
| + /**
|
| + * Wheter the WebView needs to restore to the original scroll offset after
|
| + * exiting full screen
|
| + */
|
| + private boolean mNeedRestoreIntialScrollOffest;
|
|
|
| private FullScreenTransitionsState(ViewGroup initialContainerView,
|
| InternalAccessDelegate initialInternalAccessAdapter,
|
| @@ -343,6 +350,9 @@ public class AwContents implements SmartClipProvider,
|
| boolean wasInitialContainerViewFocused) {
|
| mFullScreenView = fullScreenView;
|
| mWasInitialContainerViewFocused = wasInitialContainerViewFocused;
|
| + mInitialPageScaleFactor = AwContents.this.mPageScaleFactor;
|
| + mInitialScrollOffset =
|
| + new int[] {mContainerView.getScrollX(), mContainerView.getScrollY()};
|
| }
|
|
|
| private boolean wasInitialContainerViewFocused() {
|
| @@ -351,6 +361,15 @@ public class AwContents implements SmartClipProvider,
|
|
|
| private void exitFullScreen() {
|
| mFullScreenView = null;
|
| +
|
| + // When the current (fullscreen) page scale factor is not the same as
|
| + // the initial page scale factor, WebView needs to restore the
|
| + // initial scroll offset when the page scale factor is restored to
|
| + // the initial value. This happens quite a few onDraws later after
|
| + // exitFullScreen(), when the page scale factor is propogated from
|
| + // blink to compositor thread.
|
| + mNeedRestoreIntialScrollOffest =
|
| + (mInitialPageScaleFactor != AwContents.this.mPageScaleFactor);
|
| }
|
|
|
| private boolean isFullScreen() {
|
| @@ -369,9 +388,31 @@ public class AwContents implements SmartClipProvider,
|
| return mInitialAwViewMethods;
|
| }
|
|
|
| + private float getInitialPageScaleFactor() {
|
| + return mInitialPageScaleFactor;
|
| + }
|
| +
|
| + private int[] getInitialScrollOffset() {
|
| + return mInitialScrollOffset;
|
| + }
|
| +
|
| private FullScreenView getFullScreenView() {
|
| return mFullScreenView;
|
| }
|
| +
|
| + private void restoreScrollOffsetIfNeeded() {
|
| + if (mNeedRestoreIntialScrollOffest
|
| + && (AwContents.this.mPageScaleFactor == mInitialPageScaleFactor)) {
|
| + mHandler.post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + AwContents.this.scrollContainerViewTo(
|
| + mInitialScrollOffset[0], mInitialScrollOffset[1]);
|
| + mNeedRestoreIntialScrollOffest = false;
|
| + }
|
| + });
|
| + }
|
| + }
|
| }
|
|
|
| // Reference to the active mNativeAwContents pointer while it is active use
|
| @@ -2793,6 +2834,8 @@ public class AwContents implements SmartClipProvider,
|
| mContentsClient.getCallbackHelper().postOnScaleChangedScaled(
|
| (float) (oldPageScaleFactor * mDIPScale),
|
| (float) (mPageScaleFactor * mDIPScale));
|
| +
|
| + mFullScreenTransitionsState.restoreScrollOffsetIfNeeded();
|
| }
|
| }
|
|
|
|
|