Commit 5e6ed805 authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Fix regression in VTS and a11y tab switcher

Currently, the vertical and a11y tab switchers observe the browser
controls even if they aren't visible. This affects the rendering
performance for the tabs.

The fix is to add/remove the observer when the layout shows/hides.

Bug: 1105601
Change-Id: I60fd18fdeebf3d281ab95146a16c99ff8c5acde5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300986Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#789241}
parent f9bff745
......@@ -58,7 +58,6 @@ public class OverviewListLayout extends Layout
adjustForFullscreen();
}
};
mBrowserControlsStateProvider.addObserver(mBrowserControlsObserver);
}
@Override
......@@ -163,10 +162,14 @@ public class OverviewListLayout extends Layout
mTabModelWrapper.setStateBasedOnModel();
doneShowing();
mBrowserControlsStateProvider.addObserver(mBrowserControlsObserver);
adjustForFullscreen();
}
@Override
public void startHiding(int nextId, boolean hintAtTabSelection) {
mBrowserControlsStateProvider.removeObserver(mBrowserControlsObserver);
super.startHiding(nextId, hintAtTabSelection);
doneHiding();
......
......@@ -404,6 +404,8 @@ public abstract class StackLayoutBase extends Layout {
@Override
public void onControlsOffsetChanged(int topOffset, int topControlsMinHeightOffset,
int bottomOffset, int bottomControlsMinHeightOffset, boolean needsAnimate) {
if (!isActive()) return;
notifySizeChanged(mWidth, mHeight, mOrientation);
}
};
......@@ -952,6 +954,16 @@ public abstract class StackLayoutBase extends Layout {
updateLayout(time, 0);
}
@Override
public void doneShowing() {
super.doneShowing();
if (mBrowserControlsSupplier.get() != null) {
mBrowserControlsSupplier.get().addObserver(mBrowserControlsObserver);
notifySizeChanged(mWidth, mHeight, mOrientation);
}
}
@Override
public void notifySizeChanged(float width, float height, @Orientation int orientation) {
mWidth = width;
......@@ -1448,6 +1460,10 @@ public abstract class StackLayoutBase extends Layout {
@Override
public void startHiding(int nextTabId, boolean hintAtTabSelection) {
if (mBrowserControlsSupplier.get() != null) {
mBrowserControlsSupplier.get().removeObserver(mBrowserControlsObserver);
}
super.startHiding(nextTabId, hintAtTabSelection);
// Reset mIsActiveLayout here instead of in doneHiding() so if a user hits the tab switcher
......
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