Commit 8e7fabcd authored by Lijin Shen's avatar Lijin Shen Committed by Commit Bot

Fix white background of toolbar when there is no visible tab

When closing the last tab through tab switcher longpress menu, there
exists one monent at which there is no visible tab. Color.WHITE is
hard-coded but the browser control background color should be
determined based on whether chrome is on dark mode or light mode.

Bug: 1034843
Change-Id: I332fee777cbc095704e19e786905c983778fcacf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976434Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Lijin Shen <lazzzis@google.com>
Cr-Commit-Position: refs/heads/master@{#729961}
parent 3ba18f99
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.compositor;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
......@@ -30,6 +31,7 @@ import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.SysUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.compat.ApiHelperForN;
......@@ -961,9 +963,10 @@ public class CompositorViewHolder extends FrameLayout
}
@Override
public int getBrowserControlsBackgroundColor() {
return mTabVisible == null ? Color.WHITE
: ToolbarColors.getToolbarSceneLayerBackground(mTabVisible);
public int getBrowserControlsBackgroundColor(Resources res) {
return mTabVisible == null
? ApiCompatibilityUtils.getColor(res, R.color.toolbar_background_primary)
: ToolbarColors.getToolbarSceneLayerBackground(mTabVisible);
}
@Override
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.compositor.layouts;
import android.content.res.Resources;
import android.graphics.Rect;
import org.chromium.ui.resources.ResourceManager;
......@@ -54,7 +55,7 @@ public interface LayoutRenderHost {
/**
* @return The background color of the toolbar.
*/
int getBrowserControlsBackgroundColor();
int getBrowserControlsBackgroundColor(Resources resources);
/**
* @return The {@link ResourceManager}.
......
......@@ -164,7 +164,7 @@ public class ToolbarSceneLayer extends SceneOverlayLayer implements SceneOverlay
// compositor.
float alpha = 1;
update(mRenderHost.getBrowserControlsBackgroundColor(), alpha,
update(mRenderHost.getBrowserControlsBackgroundColor(mContext.getResources()), alpha,
mLayoutProvider.getFullscreenManager(), resourceManager,
forceHideBrowserControlsAndroidView, viewportMode,
DeviceFormFactor.isNonMultiDisplayContextOnTablet(mContext), viewport.height());
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.compositor;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.support.test.filters.SmallTest;
......@@ -62,7 +63,7 @@ public class CompositorVisibilityTest {
public void loadPersitentTextureDataIfNeeded() {}
@Override
public int getBrowserControlsBackgroundColor() {
public int getBrowserControlsBackgroundColor(Resources res) {
return 0;
}
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.compositor.layouts;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.RectF;
......@@ -148,7 +149,7 @@ class MockLayoutHost implements LayoutManagerHost, LayoutRenderHost {
public void onContentChanged() {}
@Override
public int getBrowserControlsBackgroundColor() {
public int getBrowserControlsBackgroundColor(Resources res) {
return 0;
}
......
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