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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 AXNodeData::AXNodeData(const AXNodeData& other) { | 178 AXNodeData::AXNodeData(const AXNodeData& other) { |
179 id = other.id; | 179 id = other.id; |
180 role = other.role; | 180 role = other.role; |
181 state = other.state; | 181 state = other.state; |
182 string_attributes = other.string_attributes; | 182 string_attributes = other.string_attributes; |
183 int_attributes = other.int_attributes; | 183 int_attributes = other.int_attributes; |
184 float_attributes = other.float_attributes; | 184 float_attributes = other.float_attributes; |
185 bool_attributes = other.bool_attributes; | 185 bool_attributes = other.bool_attributes; |
186 intlist_attributes = other.intlist_attributes; | 186 intlist_attributes = other.intlist_attributes; |
| 187 stringlist_attributes = other.stringlist_attributes; |
187 html_attributes = other.html_attributes; | 188 html_attributes = other.html_attributes; |
188 child_ids = other.child_ids; | 189 child_ids = other.child_ids; |
189 location = other.location; | 190 location = other.location; |
190 offset_container_id = other.offset_container_id; | 191 offset_container_id = other.offset_container_id; |
191 if (other.transform) | 192 if (other.transform) |
192 transform.reset(new gfx::Transform(*other.transform)); | 193 transform.reset(new gfx::Transform(*other.transform)); |
193 } | 194 } |
194 | 195 |
195 AXNodeData& AXNodeData::operator=(AXNodeData other) { | 196 AXNodeData& AXNodeData::operator=(AXNodeData other) { |
196 id = other.id; | 197 id = other.id; |
197 role = other.role; | 198 role = other.role; |
198 state = other.state; | 199 state = other.state; |
199 string_attributes = other.string_attributes; | 200 string_attributes = other.string_attributes; |
200 int_attributes = other.int_attributes; | 201 int_attributes = other.int_attributes; |
201 float_attributes = other.float_attributes; | 202 float_attributes = other.float_attributes; |
202 bool_attributes = other.bool_attributes; | 203 bool_attributes = other.bool_attributes; |
203 intlist_attributes = other.intlist_attributes; | 204 intlist_attributes = other.intlist_attributes; |
| 205 stringlist_attributes = other.stringlist_attributes; |
204 html_attributes = other.html_attributes; | 206 html_attributes = other.html_attributes; |
205 child_ids = other.child_ids; | 207 child_ids = other.child_ids; |
206 location = other.location; | 208 location = other.location; |
207 offset_container_id = other.offset_container_id; | 209 offset_container_id = other.offset_container_id; |
208 if (other.transform) | 210 if (other.transform) |
209 transform.reset(new gfx::Transform(*other.transform)); | 211 transform.reset(new gfx::Transform(*other.transform)); |
210 else | 212 else |
211 transform.reset(nullptr); | 213 transform.reset(nullptr); |
212 return *this; | 214 return *this; |
213 } | 215 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 std::vector<int32_t>* value) const { | 342 std::vector<int32_t>* value) const { |
341 auto iter = FindInVectorOfPairs(attribute, intlist_attributes); | 343 auto iter = FindInVectorOfPairs(attribute, intlist_attributes); |
342 if (iter != intlist_attributes.end()) { | 344 if (iter != intlist_attributes.end()) { |
343 *value = iter->second; | 345 *value = iter->second; |
344 return true; | 346 return true; |
345 } | 347 } |
346 | 348 |
347 return false; | 349 return false; |
348 } | 350 } |
349 | 351 |
| 352 bool AXNodeData::HasStringListAttribute(AXStringListAttribute attribute) const { |
| 353 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 354 return iter != stringlist_attributes.end(); |
| 355 } |
| 356 |
| 357 const std::vector<std::string>& AXNodeData::GetStringListAttribute( |
| 358 AXStringListAttribute attribute) const { |
| 359 CR_DEFINE_STATIC_LOCAL(std::vector<std::string>, empty_vector, ()); |
| 360 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 361 if (iter != stringlist_attributes.end()) |
| 362 return iter->second; |
| 363 return empty_vector; |
| 364 } |
| 365 |
| 366 bool AXNodeData::GetStringListAttribute(AXStringListAttribute attribute, |
| 367 std::vector<std::string>* value) const { |
| 368 auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); |
| 369 if (iter != stringlist_attributes.end()) { |
| 370 *value = iter->second; |
| 371 return true; |
| 372 } |
| 373 |
| 374 return false; |
| 375 } |
| 376 |
350 bool AXNodeData::GetHtmlAttribute( | 377 bool AXNodeData::GetHtmlAttribute( |
351 const char* html_attr, std::string* value) const { | 378 const char* html_attr, std::string* value) const { |
352 for (size_t i = 0; i < html_attributes.size(); ++i) { | 379 for (size_t i = 0; i < html_attributes.size(); ++i) { |
353 const std::string& attr = html_attributes[i].first; | 380 const std::string& attr = html_attributes[i].first; |
354 if (base::LowerCaseEqualsASCII(attr, html_attr)) { | 381 if (base::LowerCaseEqualsASCII(attr, html_attr)) { |
355 *value = html_attributes[i].second; | 382 *value = html_attributes[i].second; |
356 return true; | 383 return true; |
357 } | 384 } |
358 } | 385 } |
359 | 386 |
(...skipping 27 matching lines...) Expand all Loading... |
387 void AXNodeData::AddBoolAttribute( | 414 void AXNodeData::AddBoolAttribute( |
388 AXBoolAttribute attribute, bool value) { | 415 AXBoolAttribute attribute, bool value) { |
389 bool_attributes.push_back(std::make_pair(attribute, value)); | 416 bool_attributes.push_back(std::make_pair(attribute, value)); |
390 } | 417 } |
391 | 418 |
392 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, | 419 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, |
393 const std::vector<int32_t>& value) { | 420 const std::vector<int32_t>& value) { |
394 intlist_attributes.push_back(std::make_pair(attribute, value)); | 421 intlist_attributes.push_back(std::make_pair(attribute, value)); |
395 } | 422 } |
396 | 423 |
| 424 void AXNodeData::AddStringListAttribute(AXStringListAttribute attribute, |
| 425 const std::vector<std::string>& value) { |
| 426 stringlist_attributes.push_back(std::make_pair(attribute, value)); |
| 427 } |
| 428 |
397 void AXNodeData::SetName(const std::string& name) { | 429 void AXNodeData::SetName(const std::string& name) { |
398 for (size_t i = 0; i < string_attributes.size(); ++i) { | 430 for (size_t i = 0; i < string_attributes.size(); ++i) { |
399 if (string_attributes[i].first == AX_ATTR_NAME) { | 431 if (string_attributes[i].first == AX_ATTR_NAME) { |
400 string_attributes[i].second = name; | 432 string_attributes[i].second = name; |
401 return; | 433 return; |
402 } | 434 } |
403 } | 435 } |
404 | 436 |
405 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); | 437 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); |
406 } | 438 } |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 937 } |
906 } | 938 } |
907 | 939 |
908 if (!child_ids.empty()) | 940 if (!child_ids.empty()) |
909 result += " child_ids=" + IntVectorToString(child_ids); | 941 result += " child_ids=" + IntVectorToString(child_ids); |
910 | 942 |
911 return result; | 943 return result; |
912 } | 944 } |
913 | 945 |
914 } // namespace ui | 946 } // namespace ui |
OLD | NEW |