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

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

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 SchedulePaint(); 152 SchedulePaint();
153 } 153 }
154 154
155 void Link::SetFontList(const gfx::FontList& font_list) { 155 void Link::SetFontList(const gfx::FontList& font_list) {
156 Label::SetFontList(font_list); 156 Label::SetFontList(font_list);
157 RecalculateFont(); 157 RecalculateFont();
158 } 158 }
159 159
160 void Link::SetText(const base::string16& text) { 160 void Link::SetText(const base::string16& text) {
161 Label::SetText(text); 161 Label::SetText(text);
162
163 #if !defined(OS_MACOSX)
162 // Disable focusability for empty links. Otherwise Label::GetInsets() will 164 // 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 165 // 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. 166 // border, when in this case we probably wanted zero width.
165 SetFocusable(!text.empty()); 167 SetFocusable(!text.empty());
168 #else
169 // On Mac, only allow links to have focus, when the accessibility mode is on.
tapted 2016/02/12 02:56:44 this isn't what Chrome does in the content area --
karandeepb 2016/02/22 07:15:37 As discussed, keeping the links not focusable by d
170 SetFocusable(false);
171 SetAccessibilityFocusable(!text.empty());
172 #endif
166 } 173 }
167 174
168 void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) { 175 void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) {
169 Label::SetEnabledColor(GetEnabledColor()); 176 Label::SetEnabledColor(GetEnabledColor());
170 SetDisabledColor( 177 SetDisabledColor(
171 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled)); 178 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled));
172 } 179 }
173 180
174 void Link::SetEnabledColor(SkColor color) { 181 void Link::SetEnabledColor(SkColor color) {
175 requested_enabled_color_set_ = true; 182 requested_enabled_color_set_ = true;
(...skipping 15 matching lines...) Expand all
191 } 198 }
192 199
193 void Link::Init() { 200 void Link::Init() {
194 listener_ = NULL; 201 listener_ = NULL;
195 pressed_ = false; 202 pressed_ = false;
196 underline_ = true; 203 underline_ = true;
197 RecalculateFont(); 204 RecalculateFont();
198 205
199 // Label::Init() calls SetText(), but if that's being called from Label(), our 206 // 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 207 // 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() 208 // only a Label at the moment, not yet a Link). So explicitly set focusability
202 // call explicitly here. 209 // here.
210 #if !defined(OS_MACOSX)
203 SetFocusable(!text().empty()); 211 SetFocusable(!text().empty());
212 #else
213 SetFocusable(false);
214 SetAccessibilityFocusable(!text().empty());
215 #endif
204 } 216 }
205 217
206 void Link::SetPressed(bool pressed) { 218 void Link::SetPressed(bool pressed) {
207 if (pressed_ != pressed) { 219 if (pressed_ != pressed) {
208 pressed_ = pressed; 220 pressed_ = pressed;
209 Label::SetEnabledColor(GetEnabledColor()); 221 Label::SetEnabledColor(GetEnabledColor());
210 RecalculateFont(); 222 RecalculateFont();
211 SchedulePaint(); 223 SchedulePaint();
212 } 224 }
213 } 225 }
(...skipping 19 matching lines...) Expand all
233 } 245 }
234 246
235 if (!requested_pressed_color_set_ && GetNativeTheme()) 247 if (!requested_pressed_color_set_ && GetNativeTheme())
236 return GetNativeTheme()->GetSystemColor( 248 return GetNativeTheme()->GetSystemColor(
237 ui::NativeTheme::kColorId_LinkPressed); 249 ui::NativeTheme::kColorId_LinkPressed);
238 250
239 return requested_pressed_color_; 251 return requested_pressed_color_;
240 } 252 }
241 253
242 } // namespace views 254 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698