Commit aa374456 authored by Lijin Shen's avatar Lijin Shen Committed by Chromium LUCI CQ

Set extra toolbar offset after background is cleared

When clank is switched from phone layout to tablet layout, the image
will be set as the background of toolbar until the compositor is ready
to clear the background.

The existence of the bg image yields an unexpected height measure of
the toolbar, which moves the toolbar upwards.

Bug: 1157859
Change-Id: I27566156e8015abbb09bd0ae3a03ac1a1b2ee527
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623124Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Lijin Shen <lazzzis@google.com>
Cr-Commit-Position: refs/heads/master@{#843664}
parent 60104ddc
...@@ -16,6 +16,7 @@ import android.view.MotionEvent; ...@@ -16,6 +16,7 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnAttachStateChangeListener; import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLayoutChangeListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewStub; import android.view.ViewStub;
...@@ -679,12 +680,27 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve ...@@ -679,12 +680,27 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
}; };
mBrowserControlsObserver = new BrowserControlsStateProvider.Observer() { mBrowserControlsObserver = new BrowserControlsStateProvider.Observer() {
private OnLayoutChangeListener mLayoutChangeListener;
@Override @Override
public void onControlsOffsetChanged(int topOffset, int topControlsMinHeightOffset, public void onControlsOffsetChanged(int topOffset, int topControlsMinHeightOffset,
int bottomOffset, int bottomControlsMinHeightOffset, boolean needsAnimate) { int bottomOffset, int bottomControlsMinHeightOffset, boolean needsAnimate) {
// Controls need to be offset to match the composited layer, which is // Controls need to be offset to match the composited layer, which is
// anchored at the bottom of the controls container. // anchored at the bottom of the controls container.
// https://crbug.com/1157859 wait until the background is cleared so that
// the height won't be measured by the background image.
if (mControlContainer.getBackground() == null) {
setControlContainerTopMargin(getToolbarExtraYOffset()); setControlContainerTopMargin(getToolbarExtraYOffset());
} else if (mLayoutChangeListener == null) {
mLayoutChangeListener = (view, left, top, right, bottom, oldLeft, oldTop,
oldRight, oldBottom) -> {
if (mControlContainer.getBackground() == null) {
setControlContainerTopMargin(getToolbarExtraYOffset());
mControlContainer.removeOnLayoutChangeListener(mLayoutChangeListener);
mLayoutChangeListener = null;
}
};
mControlContainer.addOnLayoutChangeListener(mLayoutChangeListener);
}
} }
}; };
mBrowserControlsSizer.addObserver(mBrowserControlsObserver); mBrowserControlsSizer.addObserver(mBrowserControlsObserver);
......
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