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

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/accessibility/browser_accessibility.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 10 #include "content/browser/accessibility/browser_accessibility_manager.h"
11 #include "content/common/view_messages.h"
10 12
13 typedef WebAccessibility::BoolAttribute BoolAttribute;
14 typedef WebAccessibility::FloatAttribute FloatAttribute;
11 typedef WebAccessibility::IntAttribute IntAttribute; 15 typedef WebAccessibility::IntAttribute IntAttribute;
12 typedef WebAccessibility::StringAttribute StringAttribute; 16 typedef WebAccessibility::StringAttribute StringAttribute;
13 17
14 #if defined(OS_POSIX) && !defined(OS_MACOSX) 18 #if defined(OS_POSIX) && !defined(OS_MACOSX)
15 // There's no OS-specific implementation of BrowserAccessibilityManager 19 // There's no OS-specific implementation of BrowserAccessibilityManager
16 // on Unix, so just instantiate the base class. 20 // on Unix, so just instantiate the base class.
17 // static 21 // static
18 BrowserAccessibility* BrowserAccessibility::Create() { 22 BrowserAccessibility* BrowserAccessibility::Create() {
19 return new BrowserAccessibility(); 23 return new BrowserAccessibility();
20 } 24 }
(...skipping 27 matching lines...) Expand all
48 BrowserAccessibilityManager* manager, 52 BrowserAccessibilityManager* manager,
49 BrowserAccessibility* parent, 53 BrowserAccessibility* parent,
50 int32 child_id, 54 int32 child_id,
51 int32 index_in_parent, 55 int32 index_in_parent,
52 const webkit_glue::WebAccessibility& src) { 56 const webkit_glue::WebAccessibility& src) {
53 manager_ = manager; 57 manager_ = manager;
54 parent_ = parent; 58 parent_ = parent;
55 child_id_ = child_id; 59 child_id_ = child_id;
56 index_in_parent_ = index_in_parent; 60 index_in_parent_ = index_in_parent;
57 61
58 renderer_id_ = src.id; 62 // Update all of the rest of the attributes.
59 name_ = src.name; 63 name_ = src.name;
60 value_ = src.value; 64 value_ = src.value;
65 role_ = src.role;
66 state_ = src.state;
67 renderer_id_ = src.id;
61 string_attributes_ = src.string_attributes; 68 string_attributes_ = src.string_attributes;
62 int_attributes_ = src.int_attributes; 69 int_attributes_ = src.int_attributes;
70 float_attributes_ = src.float_attributes;
71 bool_attributes_ = src.bool_attributes;
63 html_attributes_ = src.html_attributes; 72 html_attributes_ = src.html_attributes;
64 location_ = src.location; 73 location_ = src.location;
65 role_ = src.role;
66 state_ = src.state;
67 indirect_child_ids_ = src.indirect_child_ids; 74 indirect_child_ids_ = src.indirect_child_ids;
68 line_breaks_ = src.line_breaks; 75 line_breaks_ = src.line_breaks;
69 cell_ids_ = src.cell_ids; 76 cell_ids_ = src.cell_ids;
77 unique_cell_ids_ = src.unique_cell_ids;
70 78
71 Initialize(); 79 Initialize();
72 } 80 }
73 81
74 void BrowserAccessibility::Initialize() { 82 void BrowserAccessibility::Initialize() {
75 instance_active_ = true; 83 instance_active_ = true;
76 } 84 }
77 85
78 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { 86 void BrowserAccessibility::AddChild(BrowserAccessibility* child) {
79 children_.push_back(child); 87 children_.push_back(child);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (recursive || ref_count_ == 1) { 167 if (recursive || ref_count_ == 1) {
160 for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin(); 168 for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin();
161 iter != children_.end(); 169 iter != children_.end();
162 ++iter) { 170 ++iter) {
163 (*iter)->InternalReleaseReference(true); 171 (*iter)->InternalReleaseReference(true);
164 } 172 }
165 } 173 }
166 174
167 ref_count_--; 175 ref_count_--;
168 if (ref_count_ == 0) { 176 if (ref_count_ == 0) {
177 // Allow the object to fire a TEXT_REMOVED notification.
178 name_.clear();
179 value_.clear();
180 SendNodeUpdateEvents();
181
182 manager_->NotifyAccessibilityEvent(
183 ViewHostMsg_AccessibilityNotification_Type::
184 NOTIFICATION_TYPE_OBJECT_HIDE,
185 this);
David Tseng 2011/08/26 16:14:37 I think you want to align this with "ViewHostMsg_A
dmazzoni 2011/08/29 18:08:51 You're right, thanks!
186
169 instance_active_ = false; 187 instance_active_ = false;
170 children_.clear(); 188 children_.clear();
171 manager_->Remove(child_id_, renderer_id_); 189 manager_->Remove(child_id_, renderer_id_);
172 NativeReleaseReference(); 190 NativeReleaseReference();
173 } 191 }
174 } 192 }
175 193
176 void BrowserAccessibility::NativeReleaseReference() { 194 void BrowserAccessibility::NativeReleaseReference() {
177 delete this; 195 delete this;
178 } 196 }
(...skipping 15 matching lines...) Expand all
194 IntAttribute attribute, int* value) { 212 IntAttribute attribute, int* value) {
195 std::map<IntAttribute, int32>::iterator iter = 213 std::map<IntAttribute, int32>::iterator iter =
196 int_attributes_.find(attribute); 214 int_attributes_.find(attribute);
197 if (iter != int_attributes_.end()) { 215 if (iter != int_attributes_.end()) {
198 *value = iter->second; 216 *value = iter->second;
199 return true; 217 return true;
200 } 218 }
201 219
202 return false; 220 return false;
203 } 221 }
222
223 bool BrowserAccessibility::GetFloatAttribute(
224 FloatAttribute attribute, float* value) {
225 std::map<FloatAttribute, float>::iterator iter =
226 float_attributes_.find(attribute);
227 if (iter != float_attributes_.end()) {
228 *value = iter->second;
229 return true;
230 }
231
232 return false;
233 }
234
235 bool BrowserAccessibility::GetBoolAttribute(
236 BoolAttribute attribute, bool* value) {
237 std::map<BoolAttribute, bool>::iterator iter =
238 bool_attributes_.find(attribute);
239 if (iter != bool_attributes_.end()) {
240 *value = iter->second;
241 return true;
242 }
243
244 return false;
245 }
246
247 bool BrowserAccessibility::GetHtmlAttribute(
248 const char* html_attr, string16* value) {
249 for (size_t i = 0; i < html_attributes_.size(); i++) {
250 string16& attr = html_attributes_[i].first;
251 if (LowerCaseEqualsASCII(attr, html_attr)) {
252 *value = html_attributes_[i].second;
253 return true;
254 }
255 }
256
257 return false;
258 }
259
260 bool BrowserAccessibility::IsEditableText() {
David Tseng 2011/08/26 16:14:37 const method?
dmazzoni 2011/08/29 18:08:51 Done. I made some other methods const as well.
261 return (role_ == WebAccessibility::ROLE_TEXT_FIELD ||
262 role_ == WebAccessibility::ROLE_TEXTAREA);
263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698