Commit 89bddcd4 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Prevent background color update during tab switcher exit

This patch prevents a flash in the toolbar when creating new tabs. The
theme color of the toolbar was being set prior to being needed due to
an inconsistency in state in ToolbarPhone. Now, the update logic
blocks theme color updates while exiting the tab switcher and requests
an update once the transition finishes.

Bug: 832594
Change-Id: Idf89eb43a8ce4ed155a815cdfe11147801ef40a6
Reviewed-on: https://chromium-review.googlesource.com/1067715Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560762}
parent 50257b9e
......@@ -848,6 +848,7 @@ public class ToolbarPhone extends ToolbarLayout
}
protected void updateToolbarBackground(int color) {
if (mToolbarBackground.getColor() == color) return;
mToolbarBackground.setColor(color);
invalidate();
}
......@@ -1965,6 +1966,7 @@ public class ToolbarPhone extends ToolbarLayout
if (mTabSwitcherState == EXITING_TAB_SWITCHER) {
mLocationBar.setUrlBarFocusable(true);
mTabSwitcherState = STATIC_TAB;
updateVisualsForToolbarState();
}
if (mTabSwitcherState == ENTERING_TAB_SWITCHER) mTabSwitcherState = TAB_SWITCHER;
......@@ -2569,6 +2571,12 @@ public class ToolbarPhone extends ToolbarLayout
updateOverlayDrawables();
updateShadowVisibility();
updateUrlExpansionAnimation();
// This exception is to prevent early change of theme color when exiting the tab switcher
// since currently visual state does not map correctly to tab switcher state. See
// https://crbug.com/832594 for more info.
if (mTabSwitcherState != EXITING_TAB_SWITCHER) updateToolbarBackground(mVisualState);
if (!visualStateChanged) {
if (mVisualState == VisualState.NEW_TAB_NORMAL) {
updateNtpTransitionAnimation();
......@@ -2581,7 +2589,6 @@ public class ToolbarPhone extends ToolbarLayout
mUseLightToolbarDrawables = false;
mUnfocusedLocationBarUsesTransparentBg = false;
mLocationBarBackgroundAlpha = 255;
updateToolbarBackground(mVisualState);
getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito());
if (inOrEnteringTabSwitcher) {
......
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