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

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

Issue 1834933002: Misc. cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing spacing Created 4 years, 9 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 234c753ad1b19314684588455b9767f2191b3659..9aaf4e464d9f03f1778fe6d61acc5541499025f6 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
@@ -106,65 +106,6 @@ void ContentSettingImageView::Update(content::WebContents* web_contents) {
content_setting_image_model_->SetAnimationHasRun(web_contents);
}
-SkColor ContentSettingImageView::GetTextColor() const {
- return GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_TextfieldDefaultColor);
-}
-
-SkColor ContentSettingImageView::GetBorderColor() const {
- return gfx::kGoogleYellow700;
-}
-
-bool ContentSettingImageView::ShouldShowBackground() const {
- return (!IsShrinking() || label()->width() > 0) &&
- (slide_animator_.is_animating() || pause_animation_);
-}
-
-double ContentSettingImageView::WidthMultiplier() const {
- double state = pause_animation_ ? pause_animation_state_
- : slide_animator_.GetCurrentValue();
- // The fraction of the animation we'll spend animating the string into view,
- // which is also the fraction we'll spend animating it closed; total
- // animation (slide out, show, then slide in) is 1.0.
- const double kOpenFraction =
- static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
- double size_fraction = 1.0;
- if (state < kOpenFraction)
- size_fraction = state / kOpenFraction;
- if (state > (1.0 - kOpenFraction))
- size_fraction = (1.0 - state) / kOpenFraction;
- 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_) {
- label()->SetVisible(false);
- parent_->Layout();
- parent_->SchedulePaint();
- }
-}
-
-void ContentSettingImageView::AnimationProgressed(
- const gfx::Animation* animation) {
- if (!pause_animation_) {
- parent_->Layout();
- parent_->SchedulePaint();
- }
-}
-
-void ContentSettingImageView::AnimationCanceled(
- const gfx::Animation* animation) {
- AnimationEnded(animation);
-}
-
const char* ContentSettingImageView::GetClassName() const {
return "ContentSettingsImageView";
}
@@ -177,7 +118,7 @@ void ContentSettingImageView::OnBoundsChanged(
bool ContentSettingImageView::OnMousePressed(const ui::MouseEvent& event) {
// If the bubble is showing then don't reshow it when the mouse is released.
- suppress_mouse_released_action_ = IsBubbleShowing();
+ suppress_mouse_released_action_ = bubble_view_ != nullptr;
if (!suppress_mouse_released_action_ && !label()->visible())
ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING);
@@ -225,6 +166,65 @@ void ContentSettingImageView::OnNativeThemeChanged(
IconLabelBubbleView::OnNativeThemeChanged(native_theme);
}
+SkColor ContentSettingImageView::GetTextColor() const {
+ return GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldDefaultColor);
+}
+
+SkColor ContentSettingImageView::GetBorderColor() const {
+ return gfx::kGoogleYellow700;
+}
+
+bool ContentSettingImageView::ShouldShowBackground() const {
+ return (!IsShrinking() || label()->width() > 0) &&
+ (slide_animator_.is_animating() || pause_animation_);
+}
+
+double ContentSettingImageView::WidthMultiplier() const {
+ double state = pause_animation_ ? pause_animation_state_
+ : slide_animator_.GetCurrentValue();
+ // The fraction of the animation we'll spend animating the string into view,
+ // which is also the fraction we'll spend animating it closed; total
+ // animation (slide out, show, then slide in) is 1.0.
+ const double kOpenFraction =
+ static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
+ double size_fraction = 1.0;
+ if (state < kOpenFraction)
+ size_fraction = state / kOpenFraction;
+ if (state > (1.0 - kOpenFraction))
+ size_fraction = (1.0 - state) / kOpenFraction;
+ 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_) {
+ label()->SetVisible(false);
+ parent_->Layout();
+ parent_->SchedulePaint();
+ }
+}
+
+void ContentSettingImageView::AnimationProgressed(
+ const gfx::Animation* animation) {
+ if (!pause_animation_) {
+ parent_->Layout();
+ parent_->SchedulePaint();
+ }
+}
+
+void ContentSettingImageView::AnimationCanceled(
+ const gfx::Animation* animation) {
+ AnimationEnded(animation);
+}
+
void ContentSettingImageView::OnWidgetDestroying(views::Widget* widget) {
DCHECK(bubble_view_);
DCHECK_EQ(bubble_view_->GetWidget(), widget);
@@ -256,10 +256,8 @@ void ContentSettingImageView::OnClick() {
// 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_ && ShouldShowBackground() && width() > final_width) {
+ if (!pause_animation_ && ShouldShowBackground() &&
+ (width() > MinimumWidthForImageWithBackgroundShown())) {
pause_animation_ = true;
pause_animation_state_ = slide_animator_.GetCurrentValue();
}
@@ -293,7 +291,3 @@ void ContentSettingImageView::UpdateImage() {
SetImage(content_setting_image_model_->GetIcon(GetTextColor()).AsImageSkia());
image()->SetTooltipText(content_setting_image_model_->get_tooltip());
}
-
-bool ContentSettingImageView::IsBubbleShowing() const {
- return bubble_view_ != nullptr;
-}

Powered by Google App Engine
This is Rietveld 408576698