Commit 0a28e604 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Fix tab switcher page browser control offset

Previously we only exposed the view height minus the sum of both
top and bottom browser control heights. Now we also expose the top and
bottom browser control heights. This allows the tab switcher to
correctly compute the top height offset.

BUG: 826360
Change-Id: Ia031479621673968dc14fa1649c4f7a2d5fb2736
Reviewed-on: https://chromium-review.googlesource.com/1006365Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550389}
parent 1f11e3ef
......@@ -617,7 +617,6 @@ public class CompositorViewHolder extends FrameLayout
@Override
public float getHeightMinusBrowserControls() {
return getHeight() - (getTopControlsHeightPixels() + getBottomControlsHeightPixels());
}
@Override
......@@ -733,16 +732,12 @@ public class CompositorViewHolder extends FrameLayout
: ColorUtils.getTextBoxAlphaForToolbarBackground(mTabVisible);
}
/**
* @return The height of the top browser controls in pixels.
*/
@Override
public int getTopControlsHeightPixels() {
return mFullscreenManager != null ? mFullscreenManager.getTopControlsHeight() : 0;
}
/**
* @return The height of the bottom conrols in pixels.
*/
@Override
public int getBottomControlsHeightPixels() {
return mFullscreenManager != null ? mFullscreenManager.getBottomControlsHeight() : 0;
}
......
......@@ -79,7 +79,8 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
// Drawing area properties.
private float mWidthDp;
private float mHeightDp;
private float mHeightMinusBrowserControlsDp;
private float mTopBrowserControlsHeightDp;
private float mBottomBrowserControlsHeightDp;
/** A {@link Context} instance. */
private Context mContext;
......@@ -128,7 +129,8 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
// Invalid sizes
mWidthDp = -1;
mHeightDp = -1;
mHeightMinusBrowserControlsDp = -1;
mTopBrowserControlsHeightDp = -1;
mBottomBrowserControlsHeightDp = -1;
mCurrentOrientation = Orientation.UNSET;
mDpToPx = context.getResources().getDisplayMetrics().density;
......@@ -309,22 +311,26 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
* {@link Orientation}.
*/
public final void sizeChanged(RectF visibleViewportPx, RectF screenViewportPx,
float heightMinusBrowserControlsPx, int orientation) {
float topBrowserControlsHeightPx, float bottomBrowserControlsHeightPx,
int orientation) {
// 1. Pull out this Layout's width and height properties based on the viewport.
float width = screenViewportPx.width() / mDpToPx;
float height = screenViewportPx.height() / mDpToPx;
float heightMinusBrowserControlsDp = heightMinusBrowserControlsPx / mDpToPx;
float topBrowserControlsHeightDp = topBrowserControlsHeightPx / mDpToPx;
float bottomBrowserControlsHeightDp = bottomBrowserControlsHeightPx / mDpToPx;
// 2. Check if any Layout-specific properties have changed.
boolean layoutPropertiesChanged = Float.compare(mWidthDp, width) != 0
|| Float.compare(mHeightDp, height) != 0
|| Float.compare(mHeightMinusBrowserControlsDp, heightMinusBrowserControlsDp) != 0
|| Float.compare(mTopBrowserControlsHeightDp, topBrowserControlsHeightDp) != 0
|| Float.compare(mBottomBrowserControlsHeightDp, bottomBrowserControlsHeightDp) != 0
|| mCurrentOrientation != orientation;
// 3. Update the internal sizing properties.
mWidthDp = width;
mHeightDp = height;
mHeightMinusBrowserControlsDp = heightMinusBrowserControlsDp;
mTopBrowserControlsHeightDp = topBrowserControlsHeightDp;
mBottomBrowserControlsHeightDp = bottomBrowserControlsHeightDp;
mCurrentOrientation = orientation;
// 4. Notify the actual Layout if necessary.
......@@ -556,11 +562,25 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
return mHeightDp;
}
/**
* @return The height of the top browser controls in dp.
*/
public float getTopBrowserControlsHeight() {
return mTopBrowserControlsHeightDp;
}
/**
* @return The height of the bottom browser controls in dp.
*/
public float getBottomBrowserControlsHeight() {
return mBottomBrowserControlsHeightDp;
}
/**
* @return The height of the drawing area minus the browser controls in dp.
*/
public float getHeightMinusBrowserControls() {
return mHeightMinusBrowserControlsDp;
return getHeight() - (getTopBrowserControlsHeight() + getBottomBrowserControlsHeight());
}
/**
......
......@@ -515,7 +515,8 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
mHost.getWindowViewport(mCachedWindowViewport);
mHost.getVisibleViewport(mCachedVisibleViewport);
getActiveLayout().sizeChanged(mCachedVisibleViewport, mCachedWindowViewport,
mHost.getHeightMinusBrowserControls(), getOrientation());
mHost.getTopControlsHeightPixels(), mHost.getBottomControlsHeightPixels(),
getOrientation());
}
for (int i = 0; i < mTabCache.size(); i++) {
......
......@@ -68,6 +68,16 @@ public interface LayoutManagerHost {
*/
float getHeightMinusBrowserControls();
/**
* @return The height of the top browser controls in pixels.
*/
int getTopControlsHeightPixels();
/**
* @return The height of the bottom browsers controls in pixels.
*/
int getBottomControlsHeightPixels();
/**
* @return The associated {@link LayoutRenderHost} to be used from the GL Thread.
*/
......
......@@ -943,8 +943,7 @@ public abstract class StackLayoutBase
float getTopHeightOffset() {
if (FeatureUtilities.isChromeHomeEnabled()) return MODERN_TOP_MARGIN_DP;
return (StackLayoutBase.this.getHeight() - getHeightMinusBrowserControls())
* mStackOffsetYPercent;
return getTopBrowserControlsHeight() * mStackOffsetYPercent;
}
}
......
......@@ -24,7 +24,6 @@ import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelUtils;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelAdapter.AccessibilityTabModelAdapterListener;
import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelWrapper;
......@@ -81,12 +80,9 @@ public class OverviewListLayout extends Layout implements AccessibilityTabModelA
(FrameLayout.LayoutParams) mTabModelWrapper.getLayoutParams();
if (params == null) return;
int margin = (int) ((getHeight() - getHeightMinusBrowserControls()) * mDensity);
if (FeatureUtilities.isChromeHomeEnabled()) {
params.bottomMargin = margin;
} else {
params.topMargin = margin;
}
params.bottomMargin = (int) (getTopBrowserControlsHeight() * mDensity);
params.topMargin = (int) (getTopBrowserControlsHeight() * mDensity);
mTabModelWrapper.setLayoutParams(params);
}
......
......@@ -102,6 +102,16 @@ class MockLayoutHost implements LayoutManagerHost, LayoutRenderHost {
return getHeight();
}
@Override
public int getTopControlsHeightPixels() {
return 0;
}
@Override
public int getBottomControlsHeightPixels() {
return 0;
}
@Override
public LayoutRenderHost getLayoutRenderHost() {
return this;
......
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