Commit 44d4b2a1 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

aw: Avoid resize when entering fullscreen

This reverts and rewrites r654240. The old implementation caused issues
in focus / layouts. This implementation simply avoids sending size down
on entering fullscreen since the newly created FullScreenView is
guaranteed to be 0x0. Generally FullScreenView is resized directly to
its final size, so there is need for more complex workarounds.

Bug: 1061837, 1065173
Change-Id: Id182d28b4731f6a3bc097076804e7305b4d8f951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124948Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754482}
parent a0380b99
...@@ -1007,8 +1007,7 @@ public class AwContents implements SmartClipProvider { ...@@ -1007,8 +1007,7 @@ public class AwContents implements SmartClipProvider {
// In fullscreen mode FullScreenView owns the AwViewMethodsImpl and AwContents // In fullscreen mode FullScreenView owns the AwViewMethodsImpl and AwContents
// a NullAwViewMethods. // a NullAwViewMethods.
FullScreenView fullScreenView = new FullScreenView(mContext, mAwViewMethods, this, FullScreenView fullScreenView = new FullScreenView(mContext, mAwViewMethods, this);
mContainerView.getWidth(), mContainerView.getHeight());
fullScreenView.setFocusable(true); fullScreenView.setFocusable(true);
fullScreenView.setFocusableInTouchMode(true); fullScreenView.setFocusableInTouchMode(true);
boolean wasInitialContainerViewFocused = mContainerView.isFocused(); boolean wasInitialContainerViewFocused = mContainerView.isFocused();
...@@ -1122,8 +1121,15 @@ public class AwContents implements SmartClipProvider { ...@@ -1122,8 +1121,15 @@ public class AwContents implements SmartClipProvider {
} else if (!containerViewAttached && mIsAttachedToWindow) { } else if (!containerViewAttached && mIsAttachedToWindow) {
awViewMethodsImpl.onDetachedFromWindow(); awViewMethodsImpl.onDetachedFromWindow();
} }
// Skip passing size of FullScreenView down. FullScreenView is newly created and detached
// so has initial size 0x0 before layout. Avoid this temporary resize to 0x0 which can
// cause flickers and sometimes layout problems in the web page.
if ((mContainerView instanceof FullScreenView)) {
assert !containerViewAttached;
} else {
awViewMethodsImpl.onSizeChanged( awViewMethodsImpl.onSizeChanged(
mContainerView.getWidth(), mContainerView.getHeight(), 0, 0); mContainerView.getWidth(), mContainerView.getHeight(), 0, 0);
}
awViewMethodsImpl.onWindowFocusChanged(mContainerView.hasWindowFocus()); awViewMethodsImpl.onWindowFocusChanged(mContainerView.hasWindowFocus());
awViewMethodsImpl.onFocusChanged(mContainerView.hasFocus(), 0, null); awViewMethodsImpl.onFocusChanged(mContainerView.hasFocus(), 0, null);
mContainerView.requestLayout(); mContainerView.requestLayout();
......
...@@ -29,11 +29,8 @@ public class FullScreenView extends FrameLayout { ...@@ -29,11 +29,8 @@ public class FullScreenView extends FrameLayout {
private final AwContents mAwContents; private final AwContents mAwContents;
private InternalAccessAdapter mInternalAccessAdapter; private InternalAccessAdapter mInternalAccessAdapter;
public FullScreenView(Context context, AwViewMethods awViewMethods, AwContents awContents, public FullScreenView(Context context, AwViewMethods awViewMethods, AwContents awContents) {
int initialWidth, int initialHeight) {
super(context); super(context);
setRight(initialWidth);
setBottom(initialHeight);
setAwViewMethods(awViewMethods); setAwViewMethods(awViewMethods);
mAwContents = awContents; mAwContents = awContents;
mInternalAccessAdapter = new InternalAccessAdapter(); mInternalAccessAdapter = new InternalAccessAdapter();
...@@ -139,11 +136,8 @@ public class FullScreenView extends FrameLayout { ...@@ -139,11 +136,8 @@ public class FullScreenView extends FrameLayout {
@Override @Override
public void onSizeChanged(final int w, final int h, final int ow, final int oh) { public void onSizeChanged(final int w, final int h, final int ow, final int oh) {
super.onSizeChanged(w, h, ow, oh); super.onSizeChanged(w, h, ow, oh);
// Null check for setting initial size before mAwViewMethods is set.
if (mAwViewMethods != null) {
mAwViewMethods.onSizeChanged(w, h, ow, oh); mAwViewMethods.onSizeChanged(w, h, ow, oh);
} }
}
@Override @Override
protected void onVisibilityChanged(View changedView, int visibility) { protected void onVisibilityChanged(View changedView, int visibility) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment