| Index: ui/views/controls/button/label_button.cc
|
| diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
|
| index ee72e83bd6153321e93688f17804ae72f10813aa..347d2d755f9e1e0a565c661e73a5e780a701b4d5 100644
|
| --- a/ui/views/controls/button/label_button.cc
|
| +++ b/ui/views/controls/button/label_button.cc
|
| @@ -59,7 +59,7 @@ const int LabelButton::kHoverAnimationDurationMs = 170;
|
| // static
|
| const char LabelButton::kViewClassName[] = "LabelButton";
|
|
|
| -LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
|
| +LabelButton::LabelButton(ButtonListener* listener)
|
| : CustomButton(listener),
|
| image_(new ImageView()),
|
| label_(new Label()),
|
| @@ -69,11 +69,10 @@ LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
|
| button_state_colors_(),
|
| explicitly_set_colors_(),
|
| is_default_(false),
|
| - style_(STYLE_TEXTBUTTON),
|
| + style_(STYLE_COUNT), // Something invalid to ensure Init() is called.
|
| border_is_themed_border_(true),
|
| image_label_spacing_(kSpacing) {
|
| SetAnimationDuration(kHoverAnimationDurationMs);
|
| - SetText(text);
|
|
|
| AddChildView(image_);
|
| image_->set_interactive(false);
|
| @@ -82,14 +81,25 @@ LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
|
| label_->SetFontList(cached_normal_font_list_);
|
| label_->SetAutoColorReadabilityEnabled(false);
|
| label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| +}
|
|
|
| - // Initialize the colors, border, and layout.
|
| - SetStyle(style_);
|
| +LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
|
| + : LabelButton(listener) {
|
| + InitAsTextbutton(text);
|
| +}
|
|
|
| - SetAccessibleName(text);
|
| +LabelButton::~LabelButton() {
|
| }
|
|
|
| -LabelButton::~LabelButton() {}
|
| +void LabelButton::InitAsTextbutton(const base::string16& text) {
|
| + SetText(text);
|
| + SetStyle(STYLE_TEXTBUTTON);
|
| +}
|
| +
|
| +void LabelButton::InitAsButton(const base::string16& text) {
|
| + SetText(text);
|
| + SetStyle(STYLE_BUTTON);
|
| +}
|
|
|
| const gfx::ImageSkia& LabelButton::GetImage(ButtonState for_state) {
|
| if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull())
|
| @@ -356,6 +366,7 @@ gfx::Rect LabelButton::GetChildAreaBounds() {
|
| }
|
|
|
| void LabelButton::OnPaint(gfx::Canvas* canvas) {
|
| + DCHECK_NE(STYLE_COUNT, style_) << "LabelButton::Init() not called.";
|
| View::OnPaint(canvas);
|
| Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
|
| }
|
|
|