Commit c7ebb01e authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Chromium LUCI CQ

Toolbar: Fix wrong location bar background color

The theme color for location bar background should come from a specified
tab, not the current theme color from TopUiThemeColorProvider. This
addresses the wrong color when multiple tabs are being presented
such as in tab switcher.

This CL makes TUTCP#calculateColor public to get the right theme color
for a given tab object.

Bug: 1157417, 1157433
Change-Id: I10c30a7fc93bf9a21b0d113847651c4138a3c02e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589135Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837338}
parent 590d9ba3
......@@ -805,8 +805,8 @@ public class LayoutManagerImpl implements LayoutManager, LayoutUpdateHost, Layou
TopUiThemeColorProvider topUiTheme = mTopUiThemeColorProvider.get();
layoutTab.initFromHost(topUiTheme.getBackgroundColor(tab), shouldStall(tab),
canUseLiveTexture, topUiTheme.getSceneLayerBackground(tab),
ToolbarColors.getTextBoxColorForToolbarBackground(
mContext.getResources(), tab, topUiTheme.getThemeColor()),
ToolbarColors.getTextBoxColorForToolbarBackground(mContext.getResources(), tab,
topUiTheme.calculateColor(tab, tab.getThemeColor())),
topUiTheme.getTextBoxBackgroundAlpha(tab));
mHost.requestRender();
......
......@@ -374,8 +374,8 @@ public class StaticLayout extends Layout {
return sToolbarTextBoxBackgroundColorForTesting;
}
return ToolbarColors.getTextBoxColorForToolbarBackground(
mContext.getResources(), tab, mTopUiThemeColorProvider.get().getThemeColor());
return ToolbarColors.getTextBoxColorForToolbarBackground(mContext.getResources(), tab,
mTopUiThemeColorProvider.get().calculateColor(tab, tab.getThemeColor()));
}
@VisibleForTesting
......
......@@ -56,11 +56,11 @@ public class TopUiThemeColorProvider extends ThemeColorProvider {
mTabObserver = new CurrentTabObserver(tabSupplier, new EmptyTabObserver() {
@Override
public void onDidChangeThemeColor(Tab tab, int themeColor) {
updateColor(tab, themeColor, false);
updateColor(tab, themeColor, true);
}
});
tabSupplier.addObserver((tab) -> {
if (tab != null) updateColor(tab, tab.getThemeColor(), true);
if (tab != null) updateColor(tab, tab.getThemeColor(), false);
});
mActivityThemeColorSupplier = activityThemeColorSupplier;
mIsTabletSupplier = isTabletSupplier;
......@@ -80,7 +80,13 @@ public class TopUiThemeColorProvider extends ThemeColorProvider {
mIsDefaultColorUsed = isUsingDefaultColor(tab, themeColor);
}
private int calculateColor(Tab tab, int themeColor) {
/**
* Calculate theme color to be used for a given tab.
* @param tab Tab to get the theme color for.
* @param themeColor Initial color to calculate the theme color with.
* @return Final theme color for a given tab, with other signals taken into account.
*/
public int calculateColor(Tab tab, int themeColor) {
// This method is used not only for the current tab but also for
// any given tab. Therefore it should not alter any class state.
boolean isThemingAllowed = isThemingAllowed(tab);
......
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