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

Side by Side Diff: views/controls/label.cc

Issue 1616004: Fix Regression for Accessible Names (Closed)
Patch Set: Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/label.h" 5 #include "views/controls/label.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 void Label::SetFont(const gfx::Font& font) { 112 void Label::SetFont(const gfx::Font& font) {
113 font_ = font; 113 font_ = font;
114 text_size_valid_ = false; 114 text_size_valid_ = false;
115 SchedulePaint(); 115 SchedulePaint();
116 } 116 }
117 117
118 void Label::SetText(const std::wstring& text) { 118 void Label::SetText(const std::wstring& text) {
119 text_ = text; 119 text_ = text;
120 url_set_ = false; 120 url_set_ = false;
121 text_size_valid_ = false; 121 text_size_valid_ = false;
122 SetAccessibleName(text);
122 SchedulePaint(); 123 SchedulePaint();
123 } 124 }
124 125
125 const std::wstring Label::GetText() const { 126 const std::wstring Label::GetText() const {
126 return url_set_ ? UTF8ToWide(url_.spec()) : text_; 127 return url_set_ ? UTF8ToWide(url_.spec()) : text_;
127 } 128 }
128 129
129 void Label::SetURL(const GURL& url) { 130 void Label::SetURL(const GURL& url) {
130 url_ = url; 131 url_ = url;
131 text_ = UTF8ToWide(url_.spec()); 132 text_ = UTF8ToWide(url_.spec());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 SizeToPreferredSize(); 245 SizeToPreferredSize();
245 } 246 }
246 247
247 bool Label::GetAccessibleRole(AccessibilityTypes::Role* role) { 248 bool Label::GetAccessibleRole(AccessibilityTypes::Role* role) {
248 DCHECK(role); 249 DCHECK(role);
249 250
250 *role = AccessibilityTypes::ROLE_TEXT; 251 *role = AccessibilityTypes::ROLE_TEXT;
251 return true; 252 return true;
252 } 253 }
253 254
254 bool Label::GetAccessibleName(std::wstring* name) {
255 DCHECK(name);
256 *name = GetText();
257 return !name->empty();
258 }
259
260 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { 255 bool Label::GetAccessibleState(AccessibilityTypes::State* state) {
261 DCHECK(state); 256 DCHECK(state);
262 257
263 *state = AccessibilityTypes::STATE_READONLY; 258 *state = AccessibilityTypes::STATE_READONLY;
264 return true; 259 return true;
265 } 260 }
266 261
267 void Label::SetHasFocusBorder(bool has_focus_border) { 262 void Label::SetHasFocusBorder(bool has_focus_border) {
268 has_focus_border_ = has_focus_border; 263 has_focus_border_ = has_focus_border;
269 text_size_valid_ &= !is_multi_line_; 264 text_size_valid_ &= !is_multi_line_;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 420 }
426 421
427 gfx::Rect Label::GetAvailableRect() const { 422 gfx::Rect Label::GetAvailableRect() const {
428 gfx::Rect bounds(gfx::Point(), size()); 423 gfx::Rect bounds(gfx::Point(), size());
429 gfx::Insets insets(GetInsets()); 424 gfx::Insets insets(GetInsets());
430 bounds.Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); 425 bounds.Inset(insets.left(), insets.top(), insets.right(), insets.bottom());
431 return bounds; 426 return bounds;
432 } 427 }
433 428
434 } // namespace views 429 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698