Commit 731c10ef authored by Takumi Fujimoto's avatar Takumi Fujimoto Committed by Commit Bot

Cleanup: Remove unused code in HoverButton

Remove HoverButton::SetStyle() and SetSubtitleColor(), which were being
called only by a test. Also remove some #includes.

Change-Id: I82796f7263763cbc58204b74e02d4e26796f202f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024271
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736030}
parent 01ddc793
......@@ -8,13 +8,10 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/hover_button_controller.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
......@@ -24,7 +21,6 @@
#include "ui/views/focus/focus_manager.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/style/typography.h"
#include "ui/views/view_class_properties.h"
namespace {
......@@ -353,35 +349,8 @@ void HoverButton::OnBoundsChanged(const gfx::Rect& previous_bounds) {
}
}
void HoverButton::SetStyle(Style style) {
if (style == STYLE_PROMINENT) {
SkColor background_color = GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ProminentButtonColor);
SetBackground(views::CreateSolidBackground(background_color));
// White text on |gfx::kGoogleBlue500| would be adjusted by
// AutoColorRedability. However, this specific combination has an
// exception (http://go/mdcontrast). So, disable AutoColorReadability.
title_->SetAutoColorReadabilityEnabled(false);
SetTitleTextStyle(views::style::STYLE_DIALOG_BUTTON_DEFAULT,
background_color);
SetSubtitleColor(GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_TextOnProminentButtonColor));
} else if (style == STYLE_ERROR) {
DCHECK_EQ(nullptr, background());
title_->SetDefaultTextStyle(STYLE_RED);
} else {
NOTREACHED();
}
}
void HoverButton::SetTitleTextStyle(views::style::TextStyle text_style,
SkColor background_color) {
title_->SetDisplayedOnBackgroundColor(background_color);
title_->SetDefaultTextStyle(text_style);
}
void HoverButton::SetSubtitleColor(SkColor color) {
if (subtitle_)
subtitle_->SetEnabledColor(color);
}
......@@ -101,17 +101,12 @@ class HoverButton : public views::LabelButton {
// non-empty subtitle.
void SetSubtitleElideBehavior(gfx::ElideBehavior elide_behavior);
// Adjusts the background and the text color according to |style|.
void SetStyle(Style style);
// Sets the text style of the title considering the color of the background.
// Passing |background_color| makes sure that the text color will not be
// changed to a color that is not readable on the specified background.
void SetTitleTextStyle(views::style::TextStyle text_style,
SkColor background_color);
void SetSubtitleColor(SkColor color);
void set_auto_compute_tooltip(bool auto_compute_tooltip) {
auto_compute_tooltip_ = auto_compute_tooltip;
}
......
......@@ -181,12 +181,11 @@ TEST_F(HoverButtonTest, CustomTooltip) {
}
}
// Tests that setting the style and the subtitle elide behavior don't lead to a
// crash for a HoverButton with an empty subtitle.
TEST_F(HoverButtonTest, SetStyleAndSubtitleElideBehavior) {
// Tests that setting the subtitle elide behavior doesn't lead to a crash for a
// HoverButton with an empty subtitle.
TEST_F(HoverButtonTest, SetSubtitleElideBehavior) {
HoverButton button(nullptr, CreateIcon(), base::ASCIIToUTF16("Test title"),
base::string16());
button.SetStyle(HoverButton::STYLE_PROMINENT);
button.SetSubtitleElideBehavior(gfx::ELIDE_EMAIL);
}
......
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