Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Unified Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 1763713004: Adjusts content bubble animation with respect to icon size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjusts content bubble animation with respect to icon size (code comment) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b60d76758b535c8088c568eb3df845fd69c3168b..faf7d5a38e0d3e4a91c41fd1b82dee9bf10a7239 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,12 +135,25 @@ double ContentSettingImageView::WidthMultiplier() const {
return size_fraction;
}
+void ContentSettingImageView::StopAnimation() {
+ slide_animator_.Stop();
Peter Kasting 2016/03/07 20:24:27 Stop() is redundant with Reset(). You should only
varkha 2016/03/08 18:01:03 Done. also this method is no longer necessary.
+ slide_animator_.Reset();
+}
+
+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_) {
label()->SetVisible(false);
parent_->Layout();
parent_->SchedulePaint();
+ SchedulePaint();
Peter Kasting 2016/03/07 20:24:27 Given the definition of SchedulePaint(), it seems
varkha 2016/03/08 18:01:03 Done.
varkha 2016/03/08 21:56:03 Will remove the commented line obviously before co
}
}
@@ -245,6 +261,17 @@ void ContentSettingImageView::OnClick() {
if (!pause_animation_) {
pause_animation_ = true;
pause_animation_state_ = slide_animator_.GetCurrentValue();
+
+ // Snap animation to target if a user clicks before the image is exposed.
Peter Kasting 2016/03/07 20:24:27 Nit: a -> the
varkha 2016/03/08 18:01:03 Done.
+ const double kOpenFraction =
+ static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
+ if (pause_animation_state_ < kOpenFraction &&
Peter Kasting 2016/03/07 20:24:27 Is this first portion of the conditional needed?
varkha 2016/03/08 18:01:03 Done.
+ width() < image()->GetPreferredSize().width() +
+ GetBubbleOuterPadding(true) +
+ GetBubbleOuterPadding(false)) {
+ pause_animation_ = false;
+ StopAnimation();
+ }
}
slide_animator_.Reset();
}

Powered by Google App Engine
This is Rietveld 408576698