Chromium Code Reviews| Index: ui/views/controls/label.cc |
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
| index 717d2e08a445b2af147a964653f10b86a80f5c81..73cecd9a94e2ecc1a2c59e12f03dcdbed3fb346a 100644 |
| --- a/ui/views/controls/label.cc |
| +++ b/ui/views/controls/label.cc |
| @@ -378,14 +378,26 @@ void Label::OnPaint(gfx::Canvas* canvas) { |
| } |
| void Label::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| - UpdateColorsFromTheme(theme); |
| + if (!enabled_color_set_) { |
| + requested_enabled_color_ = theme->GetSystemColor( |
| + ui::NativeTheme::kColorId_LabelEnabledColor); |
| + } |
| + if (!disabled_color_set_) { |
| + requested_disabled_color_ = theme->GetSystemColor( |
| + ui::NativeTheme::kColorId_LabelDisabledColor); |
| + } |
| + if (!background_color_set_) { |
| + background_color_ = theme->GetSystemColor( |
| + ui::NativeTheme::kColorId_LabelBackgroundColor); |
| + } |
| + RecalculateColors(); |
| } |
| void Label::Init(const base::string16& text, const gfx::FontList& font_list) { |
| font_list_ = font_list; |
| enabled_color_set_ = disabled_color_set_ = background_color_set_ = false; |
| auto_color_readability_ = true; |
| - UpdateColorsFromTheme(ui::NativeTheme::instance()); |
| + OnNativeThemeChanged(ui::NativeTheme::instance()); |
|
sky
2014/04/28 23:22:15
Won't this end up invoking a virtual function from
Evan Stade
2014/04/29 19:20:26
Is that a problem in this case? AFAIK it will do w
|
| horizontal_alignment_ = gfx::ALIGN_CENTER; |
| line_height_ = 0; |
| is_multi_line_ = false; |
| @@ -479,12 +491,12 @@ int Label::ComputeDrawStringFlags() const { |
| flags |= gfx::Canvas::MULTI_LINE; |
| #if !defined(OS_WIN) |
| - // Don't elide multiline labels on Linux. |
| - // Todo(davemoore): Do we depend on eliding multiline text? |
| - // Pango insists on limiting the number of lines to one if text is |
| - // elided. You can get around this if you can pass a maximum height |
| - // but we don't currently have that data when we call the pango code. |
| - flags |= gfx::Canvas::NO_ELLIPSIS; |
| + // Don't elide multiline labels on Linux. |
| + // Todo(davemoore): Do we depend on eliding multiline text? |
| + // Pango insists on limiting the number of lines to one if text is |
| + // elided. You can get around this if you can pass a maximum height |
| + // but we don't currently have that data when we call the pango code. |
| + flags |= gfx::Canvas::NO_ELLIPSIS; |
| #endif |
| if (allow_character_break_) |
| flags |= gfx::Canvas::CHARACTER_BREAK; |
| @@ -534,22 +546,6 @@ void Label::CalculateDrawStringParams(base::string16* paint_text, |
| *flags |= gfx::Canvas::NO_ELLIPSIS; |
| } |
| -void Label::UpdateColorsFromTheme(const ui::NativeTheme* theme) { |
| - if (!enabled_color_set_) { |
| - requested_enabled_color_ = theme->GetSystemColor( |
| - ui::NativeTheme::kColorId_LabelEnabledColor); |
| - } |
| - if (!disabled_color_set_) { |
| - requested_disabled_color_ = theme->GetSystemColor( |
| - ui::NativeTheme::kColorId_LabelDisabledColor); |
| - } |
| - if (!background_color_set_) { |
| - background_color_ = theme->GetSystemColor( |
| - ui::NativeTheme::kColorId_LabelBackgroundColor); |
| - } |
| - RecalculateColors(); |
| -} |
| - |
| void Label::ResetCachedSize() { |
| text_size_valid_ = false; |
| cached_heights_cursor_ = 0; |