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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 Label::OnBlur(); | 165 Label::OnBlur(); |
166 // We render differently focused. | 166 // We render differently focused. |
167 SchedulePaint(); | 167 SchedulePaint(); |
168 } | 168 } |
169 | 169 |
170 void Link::SetFont(const gfx::Font& font) { | 170 void Link::SetFont(const gfx::Font& font) { |
171 Label::SetFont(font); | 171 Label::SetFont(font); |
172 RecalculateFont(); | 172 RecalculateFont(); |
173 } | 173 } |
174 | 174 |
175 void Link::SetText(const string16& text) { | 175 void Link::SetText(const base::string16& text) { |
176 Label::SetText(text); | 176 Label::SetText(text); |
177 // Disable focusability for empty links. Otherwise Label::GetInsets() will | 177 // Disable focusability for empty links. Otherwise Label::GetInsets() will |
178 // give them an unconditional 1-px. inset on every side to allow for a focus | 178 // give them an unconditional 1-px. inset on every side to allow for a focus |
179 // border, when in this case we probably wanted zero width. | 179 // border, when in this case we probably wanted zero width. |
180 SetFocusable(!text.empty()); | 180 SetFocusable(!text.empty()); |
181 } | 181 } |
182 | 182 |
183 void Link::SetEnabledColor(SkColor color) { | 183 void Link::SetEnabledColor(SkColor color) { |
184 requested_enabled_color_ = color; | 184 requested_enabled_color_ = color; |
185 if (!pressed_) | 185 if (!pressed_) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void Link::RecalculateFont() { | 234 void Link::RecalculateFont() { |
235 // Underline the link iff it is enabled and |underline_| is true. | 235 // Underline the link iff it is enabled and |underline_| is true. |
236 const int style = font().GetStyle(); | 236 const int style = font().GetStyle(); |
237 const int intended_style = (enabled() && underline_) ? | 237 const int intended_style = (enabled() && underline_) ? |
238 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); | 238 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); |
239 if (style != intended_style) | 239 if (style != intended_style) |
240 Label::SetFont(font().DeriveFont(0, intended_style)); | 240 Label::SetFont(font().DeriveFont(0, intended_style)); |
241 } | 241 } |
242 | 242 |
243 } // namespace views | 243 } // namespace views |
OLD | NEW |