OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/link.h" | 5 #include "ui/views/controls/link.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (pressed_ != pressed) { | 197 if (pressed_ != pressed) { |
198 pressed_ = pressed; | 198 pressed_ = pressed; |
199 Label::SetEnabledColor(pressed_ ? | 199 Label::SetEnabledColor(pressed_ ? |
200 requested_pressed_color_ : requested_enabled_color_); | 200 requested_pressed_color_ : requested_enabled_color_); |
201 RecalculateFont(); | 201 RecalculateFont(); |
202 SchedulePaint(); | 202 SchedulePaint(); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 void Link::RecalculateFont() { | 206 void Link::RecalculateFont() { |
207 // The font should be underlined iff the link is enabled and |underline_| is | 207 // Underline the link iff it is enabled and |underline_| is true. |
208 // true. | 208 const int style = font().GetStyle(); |
209 if ((enabled() && underline_) == | 209 const int intended_style = (enabled() && underline_) ? |
210 !(font().GetStyle() & gfx::Font::UNDERLINED)) { | 210 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); |
211 Label::SetFont(font().DeriveFont(0, enabled() && underline_ ? | 211 if (style != intended_style) |
212 (font().GetStyle() | gfx::Font::UNDERLINED) : | 212 Label::SetFont(font().DeriveFont(0, intended_style)); |
213 (font().GetStyle() & ~gfx::Font::UNDERLINED))); | |
214 } | |
215 } | 213 } |
216 | 214 |
217 } // namespace views | 215 } // namespace views |
OLD | NEW |