Commit 7f8c6946 authored by sangwoo.ko's avatar sangwoo.ko Committed by Commit Bot

Suppress animation from some UI components.

When gfx::Animation::ShouldRenderRichAnimation() returns false,
we shouldn't do heavy animation. In favor of this, disable
the following animations:

* find bar
* info bar
* download shelf
* bookmarks bar

While doing this, fix a bug in gfx::SlideAnimtion::Hide().
As the previous comment mentioned, we should pass 1.0
to AnimateToState() in order to skip to the end of animation.
The parameter represents the progress of each animation, not
the value.

Bug: 8944
Change-Id: Ifc7d3ea8a5379d41f37cafa5a3094a0fe4555dd4
Reviewed-on: https://chromium-review.googlesource.com/c/1457697Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Sang Woo Ko <sangwoo108@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633747}
parent 295bc21a
......@@ -136,8 +136,7 @@ static const int kBookmarkBarAppsShortcutButtonTag = 2;
namespace {
// To enable/disable BookmarkBar animations during testing. In production
// animations are enabled by default.
// Used to globally disable rich animations.
bool animations_enabled = true;
gfx::ImageSkia* GetImageSkiaNamed(int id) {
......@@ -560,6 +559,8 @@ BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view)
SetPaintToLayer();
size_animation_.Reset(1);
if (!gfx::Animation::ShouldRenderRichAnimation())
animations_enabled = false;
}
BookmarkBarView::~BookmarkBarView() {
......
......@@ -85,8 +85,13 @@ DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
accessible_alert_ = new views::View();
AddChildView(accessible_alert_);
new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs);
shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs);
if (gfx::Animation::ShouldRenderRichAnimation()) {
new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs);
shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs);
} else {
new_item_animation_.SetSlideDuration(0);
shelf_animation_.SetSlideDuration(0);
}
GetViewAccessibility().OverrideName(
l10n_util::GetStringUTF16(IDS_ACCNAME_DOWNLOADS_BAR));
......@@ -106,6 +111,7 @@ void DownloadShelfView::AddDownloadView(DownloadItemView* view) {
mouse_watcher_.Stop();
DCHECK(view);
const bool was_empty = download_views_.empty();
download_views_.push_back(view);
// Insert the new view as the first child, so the logical child order matches
......@@ -117,6 +123,10 @@ void DownloadShelfView::AddDownloadView(DownloadItemView* view) {
new_item_animation_.Reset();
new_item_animation_.Show();
if (was_empty && !shelf_animation_.is_animating() && visible()) {
// Force a re-layout of the parent to adjust height of shelf properly.
parent_->ToolbarSizeChanged(shelf_animation_.IsShowing());
}
}
void DownloadShelfView::DoAddDownload(
......
......@@ -72,6 +72,9 @@ void DropdownBarHost::Init(views::View* host_view,
}
animation_.reset(new gfx::SlideAnimation(this));
if (!gfx::Animation::ShouldRenderRichAnimation())
animation_->SetSlideDuration(0);
// Update the widget and |view_| bounds to the hidden state.
AnimationProgressed(animation_.get());
}
......
......@@ -24,6 +24,8 @@ InfoBar::InfoBar(std::unique_ptr<InfoBarDelegate> delegate)
target_height_(0) {
DCHECK(delegate_ != nullptr);
animation_.SetTweenType(gfx::Tween::LINEAR);
if (!gfx::Animation::ShouldRenderRichAnimation())
animation_.SetSlideDuration(0);
delegate_->set_infobar(this);
}
......
......@@ -73,9 +73,7 @@ void SlideAnimation::Hide() {
// Make sure we actually have something to do.
if (slide_duration_ == 0) {
// TODO(bruthig): Investigate if this should really be animating to 0.0, I
// think it should be animating to 1.0.
AnimateToState(0.0); // Skip to the end of the animation.
AnimateToState(1.0); // Skip to the end of the animation.
if (delegate()) {
delegate()->AnimationProgressed(this);
delegate()->AnimationEnded(this);
......
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