Commit 8e956337 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Cache feature flag query in TabIcon

Bug: 960913
Change-Id: Ibf563c600e14b817d29643c9986d7127235541d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1607124Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659111}
parent b06ee6f3
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
namespace { namespace {
bool UseNewLoadingAnimation() {
return base::FeatureList::IsEnabled(features::kNewTabLoadingAnimation);
}
constexpr int kAttentionIndicatorRadius = 3; constexpr int kAttentionIndicatorRadius = 3;
constexpr int kNewLoadingAnimationStrokeWidthDp = 2; constexpr int kNewLoadingAnimationStrokeWidthDp = 2;
...@@ -84,6 +80,8 @@ class TabIcon::CrashAnimation : public gfx::LinearAnimation, ...@@ -84,6 +80,8 @@ class TabIcon::CrashAnimation : public gfx::LinearAnimation,
TabIcon::TabIcon() TabIcon::TabIcon()
: clock_(base::DefaultTickClock::GetInstance()), : clock_(base::DefaultTickClock::GetInstance()),
use_new_loading_animation_(
base::FeatureList::IsEnabled(features::kNewTabLoadingAnimation)),
favicon_fade_in_animation_(base::TimeDelta::FromMilliseconds(250), favicon_fade_in_animation_(base::TimeDelta::FromMilliseconds(250),
gfx::LinearAnimation::kDefaultFrameRate, gfx::LinearAnimation::kDefaultFrameRate,
this) { this) {
...@@ -183,7 +181,7 @@ void TabIcon::OnPaint(gfx::Canvas* canvas) { ...@@ -183,7 +181,7 @@ void TabIcon::OnPaint(gfx::Canvas* canvas) {
std::min(gfx::kFaviconSize, contents_bounds.height())); std::min(gfx::kFaviconSize, contents_bounds.height()));
// The old animation replaces the favicon and should early-abort. // The old animation replaces the favicon and should early-abort.
if (!UseNewLoadingAnimation() && ShowingLoadingAnimation()) { if (!use_new_loading_animation_ && ShowingLoadingAnimation()) {
PaintLoadingAnimation(canvas, icon_bounds); PaintLoadingAnimation(canvas, icon_bounds);
return; return;
} }
...@@ -251,7 +249,7 @@ void TabIcon::PaintAttentionIndicatorAndIcon(gfx::Canvas* canvas, ...@@ -251,7 +249,7 @@ void TabIcon::PaintAttentionIndicatorAndIcon(gfx::Canvas* canvas,
void TabIcon::PaintLoadingAnimation(gfx::Canvas* canvas, gfx::Rect bounds) { void TabIcon::PaintLoadingAnimation(gfx::Canvas* canvas, gfx::Rect bounds) {
const ui::ThemeProvider* tp = GetThemeProvider(); const ui::ThemeProvider* tp = GetThemeProvider();
base::Optional<SkScalar> stroke_width; base::Optional<SkScalar> stroke_width;
if (UseNewLoadingAnimation()) if (use_new_loading_animation_)
stroke_width = kNewLoadingAnimationStrokeWidthDp; stroke_width = kNewLoadingAnimationStrokeWidthDp;
if (network_state_ == TabNetworkState::kWaiting) { if (network_state_ == TabNetworkState::kWaiting) {
...@@ -370,7 +368,7 @@ void TabIcon::SetNetworkState(TabNetworkState network_state) { ...@@ -370,7 +368,7 @@ void TabIcon::SetNetworkState(TabNetworkState network_state) {
const bool was_animated = NetworkStateIsAnimated(network_state_); const bool was_animated = NetworkStateIsAnimated(network_state_);
network_state_ = network_state; network_state_ = network_state;
const bool is_animated = NetworkStateIsAnimated(network_state_); const bool is_animated = NetworkStateIsAnimated(network_state_);
if (UseNewLoadingAnimation() && was_animated != is_animated) { if (use_new_loading_animation_ && was_animated != is_animated) {
if (was_animated && HasNonDefaultFavicon()) { if (was_animated && HasNonDefaultFavicon()) {
favicon_fade_in_animation_.Start(); favicon_fade_in_animation_.Start();
} else { } else {
......
...@@ -123,6 +123,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate { ...@@ -123,6 +123,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate {
bool is_crashed_ = false; bool is_crashed_ = false;
int attention_types_ = 0; // Bitmask of AttentionType. int attention_types_ = 0; // Bitmask of AttentionType.
const bool use_new_loading_animation_;
// Value from last call to SetNetworkState. When true, the network loading // Value from last call to SetNetworkState. When true, the network loading
// animation will not be shown. // animation will not be shown.
bool inhibit_loading_animation_ = false; bool inhibit_loading_animation_ = false;
......
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