OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/accessibility/ax_node_data.h" | 5 #include "ui/accessibility/ax_node_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 AXNodeData::AXNodeData(const AXNodeData& other) { | 198 AXNodeData::AXNodeData(const AXNodeData& other) { |
199 id = other.id; | 199 id = other.id; |
200 role = other.role; | 200 role = other.role; |
201 state = other.state; | 201 state = other.state; |
202 actions = other.actions; | 202 actions = other.actions; |
203 string_attributes = other.string_attributes; | 203 string_attributes = other.string_attributes; |
204 int_attributes = other.int_attributes; | 204 int_attributes = other.int_attributes; |
205 float_attributes = other.float_attributes; | 205 float_attributes = other.float_attributes; |
206 bool_attributes = other.bool_attributes; | 206 bool_attributes = other.bool_attributes; |
207 intlist_attributes = other.intlist_attributes; | 207 intlist_attributes = other.intlist_attributes; |
| 208 stringlist_attributes = other.stringlist_attributes; |
208 html_attributes = other.html_attributes; | 209 html_attributes = other.html_attributes; |
209 child_ids = other.child_ids; | 210 child_ids = other.child_ids; |
210 location = other.location; | 211 location = other.location; |
211 offset_container_id = other.offset_container_id; | 212 offset_container_id = other.offset_container_id; |
212 if (other.transform) | 213 if (other.transform) |
213 transform.reset(new gfx::Transform(*other.transform)); | 214 transform.reset(new gfx::Transform(*other.transform)); |
214 } | 215 } |
215 | 216 |
216 AXNodeData& AXNodeData::operator=(AXNodeData other) { | 217 AXNodeData& AXNodeData::operator=(AXNodeData other) { |
217 id = other.id; | 218 id = other.id; |
218 role = other.role; | 219 role = other.role; |
219 state = other.state; | 220 state = other.state; |
220 actions = other.actions; | 221 actions = other.actions; |
221 string_attributes = other.string_attributes; | 222 string_attributes = other.string_attributes; |
222 int_attributes = other.int_attributes; | 223 int_attributes = other.int_attributes; |
223 float_attributes = other.float_attributes; | 224 float_attributes = other.float_attributes; |
224 bool_attributes = other.bool_attributes; | 225 bool_attributes = other.bool_attributes; |
225 intlist_attributes = other.intlist_attributes; | 226 intlist_attributes = other.intlist_attributes; |
| 227 stringlist_attributes = other.stringlist_attributes; |
226 html_attributes = other.html_attributes; | 228 html_attributes = other.html_attributes; |
227 child_ids = other.child_ids; | 229 child_ids = other.child_ids; |
228 location = other.location; | 230 location = other.location; |
229 offset_container_id = other.offset_container_id; | 231 offset_container_id = other.offset_container_id; |
230 if (other.transform) | 232 if (other.transform) |
231 transform.reset(new gfx::Transform(*other.transform)); | 233 transform.reset(new gfx::Transform(*other.transform)); |
232 else | 234 else |
233 transform.reset(nullptr); | 235 transform.reset(nullptr); |
234 return *this; | 236 return *this; |
235 } | 237 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 std::vector<int32_t>* value) const { | 364 std::vector<int32_t>* value) const { |
363 auto iter = FindInVectorOfPairs(attribute, intlist_attributes); | 365 auto iter = FindInVectorOfPairs(attribute, intlist_attributes); |
364 if (iter != intlist_attributes.end()) { | 366 if (iter != intlist_attributes.end()) { |
365 *value = iter->second; | 367 *value = iter->second; |
366 return true; | 368 return true; |
367 } | 369 } |
368 | 370 |
369 return false; | 371 return false; |
370 } | 372 } |
371 | 373 |
| 374 bool AXNodeData::HasStringListAttribute(AXStringListAttribute attribute) const { |
| 375 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 376 return iter != stringlist_attributes.end(); |
| 377 } |
| 378 |
| 379 const std::vector<std::string>& AXNodeData::GetStringListAttribute( |
| 380 AXStringListAttribute attribute) const { |
| 381 CR_DEFINE_STATIC_LOCAL(std::vector<std::string>, empty_vector, ()); |
| 382 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 383 if (iter != stringlist_attributes.end()) |
| 384 return iter->second; |
| 385 return empty_vector; |
| 386 } |
| 387 |
| 388 bool AXNodeData::GetStringListAttribute(AXStringListAttribute attribute, |
| 389 std::vector<std::string>* value) const { |
| 390 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 391 if (iter != stringlist_attributes.end()) { |
| 392 *value = iter->second; |
| 393 return true; |
| 394 } |
| 395 |
| 396 return false; |
| 397 } |
| 398 |
372 bool AXNodeData::GetHtmlAttribute( | 399 bool AXNodeData::GetHtmlAttribute( |
373 const char* html_attr, std::string* value) const { | 400 const char* html_attr, std::string* value) const { |
374 for (size_t i = 0; i < html_attributes.size(); ++i) { | 401 for (size_t i = 0; i < html_attributes.size(); ++i) { |
375 const std::string& attr = html_attributes[i].first; | 402 const std::string& attr = html_attributes[i].first; |
376 if (base::LowerCaseEqualsASCII(attr, html_attr)) { | 403 if (base::LowerCaseEqualsASCII(attr, html_attr)) { |
377 *value = html_attributes[i].second; | 404 *value = html_attributes[i].second; |
378 return true; | 405 return true; |
379 } | 406 } |
380 } | 407 } |
381 | 408 |
(...skipping 27 matching lines...) Expand all Loading... |
409 void AXNodeData::AddBoolAttribute( | 436 void AXNodeData::AddBoolAttribute( |
410 AXBoolAttribute attribute, bool value) { | 437 AXBoolAttribute attribute, bool value) { |
411 bool_attributes.push_back(std::make_pair(attribute, value)); | 438 bool_attributes.push_back(std::make_pair(attribute, value)); |
412 } | 439 } |
413 | 440 |
414 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, | 441 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, |
415 const std::vector<int32_t>& value) { | 442 const std::vector<int32_t>& value) { |
416 intlist_attributes.push_back(std::make_pair(attribute, value)); | 443 intlist_attributes.push_back(std::make_pair(attribute, value)); |
417 } | 444 } |
418 | 445 |
| 446 void AXNodeData::AddStringListAttribute(AXStringListAttribute attribute, |
| 447 const std::vector<std::string>& value) { |
| 448 stringlist_attributes.push_back(std::make_pair(attribute, value)); |
| 449 } |
| 450 |
419 void AXNodeData::SetName(const std::string& name) { | 451 void AXNodeData::SetName(const std::string& name) { |
420 for (size_t i = 0; i < string_attributes.size(); ++i) { | 452 for (size_t i = 0; i < string_attributes.size(); ++i) { |
421 if (string_attributes[i].first == AX_ATTR_NAME) { | 453 if (string_attributes[i].first == AX_ATTR_NAME) { |
422 string_attributes[i].second = name; | 454 string_attributes[i].second = name; |
423 return; | 455 return; |
424 } | 456 } |
425 } | 457 } |
426 | 458 |
427 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); | 459 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); |
428 } | 460 } |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 | 998 |
967 result += " actions=" + ActionsBitfieldToString(actions); | 999 result += " actions=" + ActionsBitfieldToString(actions); |
968 | 1000 |
969 if (!child_ids.empty()) | 1001 if (!child_ids.empty()) |
970 result += " child_ids=" + IntVectorToString(child_ids); | 1002 result += " child_ids=" + IntVectorToString(child_ids); |
971 | 1003 |
972 return result; | 1004 return result; |
973 } | 1005 } |
974 | 1006 |
975 } // namespace ui | 1007 } // namespace ui |
OLD | NEW |