| Index: chrome/browser/ui/views/location_bar/content_setting_image_view.cc
|
| diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
|
| index a3b7640cee9233d14d98151610c663c4d0eb3110..d66561e9e25562c70a5587d01d53715dc854b486 100644
|
| --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
|
| +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
|
| @@ -56,7 +56,9 @@ ContentSettingImageView::ContentSettingImageView(
|
| SetBackgroundImageGrid(kBackgroundImages);
|
| }
|
|
|
| - image()->SetHorizontalAlignment(views::ImageView::LEADING);
|
| + image()->SetHorizontalAlignment(base::i18n::IsRTL()
|
| + ? views::ImageView::TRAILING
|
| + : views::ImageView::LEADING);
|
| image()->set_interactive(true);
|
| image()->EnableCanvasFlippingForRTLUI(true);
|
| image()->SetAccessibilityFocusable(true);
|
| @@ -113,7 +115,8 @@ SkColor ContentSettingImageView::GetBorderColor() const {
|
| }
|
|
|
| bool ContentSettingImageView::ShouldShowBackground() const {
|
| - return slide_animator_.is_animating() || pause_animation_;
|
| + return label()->visible() &&
|
| + (slide_animator_.is_animating() || pause_animation_);
|
| }
|
|
|
| double ContentSettingImageView::WidthMultiplier() const {
|
| @@ -132,6 +135,13 @@ double ContentSettingImageView::WidthMultiplier() const {
|
| return size_fraction;
|
| }
|
|
|
| +bool ContentSettingImageView::IsShrinking() const {
|
| + const double kOpenFraction =
|
| + static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
|
| + return (!pause_animation_ && slide_animator_.is_animating() &&
|
| + slide_animator_.GetCurrentValue() > (1.0 - kOpenFraction));
|
| +}
|
| +
|
| void ContentSettingImageView::AnimationEnded(const gfx::Animation* animation) {
|
| slide_animator_.Reset();
|
| if (!pause_animation_) {
|
| @@ -242,7 +252,18 @@ void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget,
|
|
|
| void ContentSettingImageView::OnClick() {
|
| if (slide_animator_.is_animating()) {
|
| - if (!pause_animation_) {
|
| + // If the user clicks while we're animating, the bubble arrow will be
|
| + // pointing to the image, and if we allow the animation to keep running, the
|
| + // image will move away from the arrow (or we'll have to move the bubble,
|
| + // which is even worse). So we want to stop the animation. We have two
|
| + // choices: jump to the final post-animation state (no label visible), or
|
| + // pause the animation where we are and continue running after the bubble
|
| + // closes. The former looks more jerky, so we avoid it unless the animation
|
| + // hasn't even fully exposed the image yet, in which case pausing with half
|
| + // an image visible will look broken.
|
| + const int final_width = image()->GetPreferredSize().width() +
|
| + GetBubbleOuterPadding(true) + GetBubbleOuterPadding(false);
|
| + if (!pause_animation_ && (width() > final_width)) {
|
| pause_animation_ = true;
|
| pause_animation_state_ = slide_animator_.GetCurrentValue();
|
| }
|
|
|