Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(941)

Side by Side Diff: ui/views/controls/link.cc

Issue 1870573003: Full Keyboard Access: Second Approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/accessibility/ax_view_state.h" 11 #include "ui/accessibility/ax_view_state.h"
12 #include "ui/base/cursor/cursor.h" 12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/material_design/material_design_controller.h" 13 #include "ui/base/material_design/material_design_controller.h"
14 #include "ui/events/event.h" 14 #include "ui/events/event.h"
15 #include "ui/events/keycodes/keyboard_codes.h" 15 #include "ui/events/keycodes/keyboard_codes.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/color_palette.h" 17 #include "ui/gfx/color_palette.h"
18 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
19 #include "ui/gfx/font_list.h" 19 #include "ui/gfx/font_list.h"
20 #include "ui/native_theme/native_theme.h" 20 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/controls/link_listener.h" 21 #include "ui/views/controls/link_listener.h"
22 #include "ui/views/native_cursor.h" 22 #include "ui/views/native_cursor.h"
23 #include "ui/views/style/platform_style.h"
23 24
24 namespace views { 25 namespace views {
25 26
26 const char Link::kViewClassName[] = "Link"; 27 const char Link::kViewClassName[] = "Link";
27 28
28 Link::Link() : Link(base::string16()) {} 29 Link::Link() : Link(base::string16()) {}
29 30
30 Link::Link(const base::string16& title) 31 Link::Link(const base::string16& title)
31 : Label(title), 32 : Label(title),
32 requested_enabled_color_(gfx::kPlaceholderColor), 33 requested_enabled_color_(gfx::kPlaceholderColor),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void Link::SetFontList(const gfx::FontList& font_list) { 156 void Link::SetFontList(const gfx::FontList& font_list) {
156 Label::SetFontList(font_list); 157 Label::SetFontList(font_list);
157 RecalculateFont(); 158 RecalculateFont();
158 } 159 }
159 160
160 void Link::SetText(const base::string16& text) { 161 void Link::SetText(const base::string16& text) {
161 Label::SetText(text); 162 Label::SetText(text);
162 // Disable focusability for empty links. Otherwise Label::GetInsets() will 163 // Disable focusability for empty links. Otherwise Label::GetInsets() will
163 // give them an unconditional 1-px. inset on every side to allow for a focus 164 // give them an unconditional 1-px. inset on every side to allow for a focus
164 // border, when in this case we probably wanted zero width. 165 // border, when in this case we probably wanted zero width.
165 SetFocusable(!text.empty()); 166 if (!text.empty())
167 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::LINK, this);
166 } 168 }
167 169
168 void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) { 170 void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) {
169 Label::SetEnabledColor(GetEnabledColor()); 171 Label::SetEnabledColor(GetEnabledColor());
170 SetDisabledColor( 172 SetDisabledColor(
171 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled)); 173 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled));
172 } 174 }
173 175
174 void Link::SetEnabledColor(SkColor color) { 176 void Link::SetEnabledColor(SkColor color) {
175 requested_enabled_color_set_ = true; 177 requested_enabled_color_set_ = true;
(...skipping 15 matching lines...) Expand all
191 } 193 }
192 194
193 void Link::Init() { 195 void Link::Init() {
194 listener_ = NULL; 196 listener_ = NULL;
195 pressed_ = false; 197 pressed_ = false;
196 underline_ = true; 198 underline_ = true;
197 RecalculateFont(); 199 RecalculateFont();
198 200
199 // Label::Init() calls SetText(), but if that's being called from Label(), our 201 // Label::Init() calls SetText(), but if that's being called from Label(), our
200 // SetText() override will not be reached (because the constructed class is 202 // SetText() override will not be reached (because the constructed class is
201 // only a Label at the moment, not yet a Link). So so the set_focusable() 203 // only a Label at the moment, not yet a Link). So explicitly set
202 // call explicitly here. 204 // focusability here.
203 SetFocusable(!text().empty()); 205 if (!text().empty())
206 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::LINK, this);
204 } 207 }
205 208
206 void Link::SetPressed(bool pressed) { 209 void Link::SetPressed(bool pressed) {
207 if (pressed_ != pressed) { 210 if (pressed_ != pressed) {
208 pressed_ = pressed; 211 pressed_ = pressed;
209 Label::SetEnabledColor(GetEnabledColor()); 212 Label::SetEnabledColor(GetEnabledColor());
210 RecalculateFont(); 213 RecalculateFont();
211 SchedulePaint(); 214 SchedulePaint();
212 } 215 }
213 } 216 }
(...skipping 19 matching lines...) Expand all
233 } 236 }
234 237
235 if (!requested_pressed_color_set_ && GetNativeTheme()) 238 if (!requested_pressed_color_set_ && GetNativeTheme())
236 return GetNativeTheme()->GetSystemColor( 239 return GetNativeTheme()->GetSystemColor(
237 ui::NativeTheme::kColorId_LinkPressed); 240 ui::NativeTheme::kColorId_LinkPressed);
238 241
239 return requested_pressed_color_; 242 return requested_pressed_color_;
240 } 243 }
241 244
242 } // namespace views 245 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698