Commit e25744d6 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Fixing tab switching animation when bottom toolbar is visible

When selecting a tab in the tab switcher the animation that brought
the selected tab to full-screen placed offset the tab down and this
led to janky looking animation. This happened because the tab switcher
animation code assumed that the browser controls only contained the top
bar. This CL fixes that assumption.

Bug: 839181
Change-Id: Ide349b8bcd5290acd8a8d9cde80b6f10886ac177
Reviewed-on: https://chromium-review.googlesource.com/1041162Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555855}
parent 064e46a2
...@@ -2326,7 +2326,7 @@ public class Stack { ...@@ -2326,7 +2326,7 @@ public class Stack {
setWarpState(true, false); setWarpState(true, false);
final float opaqueTopPadding = mBorderTopPadding - mBorderTransparentTop; final float opaqueTopPadding = mBorderTopPadding - mBorderTransparentTop;
mAnimationFactory = StackAnimation.createAnimationFactory(this, mLayout.getWidth(), mAnimationFactory = StackAnimation.createAnimationFactory(this, mLayout.getWidth(),
mLayout.getHeight(), mLayout.getHeightMinusBrowserControls(), mBorderTopPadding, mLayout.getHeight(), mLayout.getTopBrowserControlsHeight(), mBorderTopPadding,
opaqueTopPadding, mBorderLeftPadding, mCurrentMode); opaqueTopPadding, mBorderLeftPadding, mCurrentMode);
float dpToPx = mLayout.getContext().getResources().getDisplayMetrics().density; float dpToPx = mLayout.getContext().getResources().getDisplayMetrics().density;
mViewAnimationFactory = new StackViewAnimation(dpToPx, mLayout.getWidth()); mViewAnimationFactory = new StackViewAnimation(dpToPx, mLayout.getWidth());
......
...@@ -14,8 +14,6 @@ import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation; ...@@ -14,8 +14,6 @@ import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation;
import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable; import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable;
import org.chromium.chrome.browser.compositor.layouts.Layout.Orientation; import org.chromium.chrome.browser.compositor.layouts.Layout.Orientation;
import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab;
import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.ui.interpolators.BakedBezierInterpolator; import org.chromium.ui.interpolators.BakedBezierInterpolator;
/** /**
...@@ -77,7 +75,7 @@ public abstract class StackAnimation { ...@@ -77,7 +75,7 @@ public abstract class StackAnimation {
protected final float mWidth; protected final float mWidth;
protected final float mHeight; protected final float mHeight;
protected final float mHeightMinusBrowserControls; protected final float mTopBrowserControlsHeight;
protected final float mBorderTopHeight; protected final float mBorderTopHeight;
protected final float mBorderTopOpaqueHeight; protected final float mBorderTopOpaqueHeight;
protected final float mBorderLeftWidth; protected final float mBorderLeftWidth;
...@@ -94,13 +92,13 @@ public abstract class StackAnimation { ...@@ -94,13 +92,13 @@ public abstract class StackAnimation {
* @param borderFramePaddingTopOpaque The opaque top padding of the border frame in dp. * @param borderFramePaddingTopOpaque The opaque top padding of the border frame in dp.
* @param borderFramePaddingLeft The left padding of the border frame in dp. * @param borderFramePaddingLeft The left padding of the border frame in dp.
*/ */
protected StackAnimation(Stack stack, float width, float height, protected StackAnimation(Stack stack, float width, float height, float topBrowserControlsHeight,
float heightMinusBrowserControls, float borderFramePaddingTop, float borderFramePaddingTop, float borderFramePaddingTopOpaque,
float borderFramePaddingTopOpaque, float borderFramePaddingLeft) { float borderFramePaddingLeft) {
mStack = stack; mStack = stack;
mWidth = width; mWidth = width;
mHeight = height; mHeight = height;
mHeightMinusBrowserControls = heightMinusBrowserControls; mTopBrowserControlsHeight = topBrowserControlsHeight;
mBorderTopHeight = borderFramePaddingTop; mBorderTopHeight = borderFramePaddingTop;
mBorderTopOpaqueHeight = borderFramePaddingTopOpaque; mBorderTopOpaqueHeight = borderFramePaddingTopOpaque;
...@@ -123,20 +121,19 @@ public abstract class StackAnimation { ...@@ -123,20 +121,19 @@ public abstract class StackAnimation {
* @return The TabSwitcherAnimationFactory instance. * @return The TabSwitcherAnimationFactory instance.
*/ */
public static StackAnimation createAnimationFactory(Stack stack, float width, float height, public static StackAnimation createAnimationFactory(Stack stack, float width, float height,
float heightMinusBrowserControls, float borderFramePaddingTop, float topBrowserControlsHeight, float borderFramePaddingTop,
float borderFramePaddingTopOpaque, float borderFramePaddingLeft, int orientation) { float borderFramePaddingTopOpaque, float borderFramePaddingLeft, int orientation) {
StackAnimation factory = null; StackAnimation factory = null;
switch (orientation) { switch (orientation) {
case Orientation.LANDSCAPE: case Orientation.LANDSCAPE:
factory = new StackAnimationLandscape(stack, width, height, factory = new StackAnimationLandscape(stack, width, height,
heightMinusBrowserControls, borderFramePaddingTop, topBrowserControlsHeight, borderFramePaddingTop,
borderFramePaddingTopOpaque, borderFramePaddingLeft); borderFramePaddingTopOpaque, borderFramePaddingLeft);
break; break;
case Orientation.PORTRAIT: case Orientation.PORTRAIT:
default: default:
factory = new StackAnimationPortrait(stack, width, height, factory = new StackAnimationPortrait(stack, width, height, topBrowserControlsHeight,
heightMinusBrowserControls, borderFramePaddingTop, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft);
borderFramePaddingTopOpaque, borderFramePaddingLeft);
break; break;
} }
...@@ -418,22 +415,13 @@ public abstract class StackAnimation { ...@@ -418,22 +415,13 @@ public abstract class StackAnimation {
* border. * border.
*/ */
protected float getToolbarOffsetToLineUpWithBorder() { protected float getToolbarOffsetToLineUpWithBorder() {
final float toolbarHeight = mHeight - mHeightMinusBrowserControls; return mTopBrowserControlsHeight - mBorderTopOpaqueHeight;
return toolbarHeight - mBorderTopOpaqueHeight;
} }
/** /**
* @return The position of the static tab when entering or exiting the tab switcher. * @return The position of the static tab when entering or exiting the tab switcher.
*/ */
protected float getStaticTabPosition() { protected float getStaticTabPosition() {
// The y position of the tab will depend on whether or not the toolbar is at the top or return mTopBrowserControlsHeight - mBorderTopHeight;
// bottom of the screen. All values are in DP.
float yPos = -mBorderTopHeight;
if (!FeatureUtilities.isChromeHomeEnabled()) {
yPos += mHeight - mHeightMinusBrowserControls;
} else {
yPos -= StackLayout.MODERN_TOP_MARGIN_DP;
}
return yPos;
} }
} }
...@@ -30,9 +30,9 @@ class StackAnimationLandscape extends StackAnimation { ...@@ -30,9 +30,9 @@ class StackAnimationLandscape extends StackAnimation {
* Only Constructor. * Only Constructor.
*/ */
public StackAnimationLandscape(Stack stack, float width, float height, public StackAnimationLandscape(Stack stack, float width, float height,
float heightMinusBrowserControls, float borderFramePaddingTop, float topBrowserControlsHeight, float borderFramePaddingTop,
float borderFramePaddingTopOpaque, float borderFramePaddingLeft) { float borderFramePaddingTopOpaque, float borderFramePaddingLeft) {
super(stack, width, height, heightMinusBrowserControls, borderFramePaddingTop, super(stack, width, height, topBrowserControlsHeight, borderFramePaddingTop,
borderFramePaddingTopOpaque, borderFramePaddingLeft); borderFramePaddingTopOpaque, borderFramePaddingLeft);
} }
......
...@@ -29,9 +29,9 @@ class StackAnimationPortrait extends StackAnimation { ...@@ -29,9 +29,9 @@ class StackAnimationPortrait extends StackAnimation {
* Only Constructor. * Only Constructor.
*/ */
public StackAnimationPortrait(Stack stack, float width, float height, public StackAnimationPortrait(Stack stack, float width, float height,
float heightMinusBrowserControls, float borderFramePaddingTop, float topBrowserControlsHeight, float borderFramePaddingTop,
float borderFramePaddingTopOpaque, float borderFramePaddingLeft) { float borderFramePaddingTopOpaque, float borderFramePaddingLeft) {
super(stack, width, height, heightMinusBrowserControls, borderFramePaddingTop, super(stack, width, height, topBrowserControlsHeight, borderFramePaddingTop,
borderFramePaddingTopOpaque, borderFramePaddingLeft); borderFramePaddingTopOpaque, borderFramePaddingLeft);
} }
......
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