| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 AXBoolAttribute attribute, bool value) { | 280 AXBoolAttribute attribute, bool value) { |
| 281 bool_attributes.push_back(std::make_pair(attribute, value)); | 281 bool_attributes.push_back(std::make_pair(attribute, value)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, | 284 void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, |
| 285 const std::vector<int32_t>& value) { | 285 const std::vector<int32_t>& value) { |
| 286 intlist_attributes.push_back(std::make_pair(attribute, value)); | 286 intlist_attributes.push_back(std::make_pair(attribute, value)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void AXNodeData::SetName(const std::string& name) { | 289 void AXNodeData::SetName(const std::string& name) { |
| 290 for (size_t i = 0; i < string_attributes.size(); ++i) { |
| 291 if (string_attributes[i].first == AX_ATTR_NAME) { |
| 292 string_attributes[i].second = name; |
| 293 return; |
| 294 } |
| 295 } |
| 296 |
| 290 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); | 297 string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); |
| 291 } | 298 } |
| 292 | 299 |
| 300 void AXNodeData::SetName(const base::string16& name) { |
| 301 SetName(base::UTF16ToUTF8(name)); |
| 302 } |
| 303 |
| 293 void AXNodeData::SetValue(const std::string& value) { | 304 void AXNodeData::SetValue(const std::string& value) { |
| 305 for (size_t i = 0; i < string_attributes.size(); ++i) { |
| 306 if (string_attributes[i].first == AX_ATTR_VALUE) { |
| 307 string_attributes[i].second = value; |
| 308 return; |
| 309 } |
| 310 } |
| 311 |
| 294 string_attributes.push_back(std::make_pair(AX_ATTR_VALUE, value)); | 312 string_attributes.push_back(std::make_pair(AX_ATTR_VALUE, value)); |
| 295 } | 313 } |
| 296 | 314 |
| 315 void AXNodeData::SetValue(const base::string16& value) { |
| 316 SetValue(base::UTF16ToUTF8(value)); |
| 317 } |
| 318 |
| 319 // static |
| 320 bool AXNodeData::IsFlagSet(uint32_t state, ui::AXState state_flag) { |
| 321 return 0 != (state & (1 << state_flag)); |
| 322 } |
| 323 |
| 324 void AXNodeData::AddStateFlag(ui::AXState state_flag) { |
| 325 state |= (1 << state_flag); |
| 326 } |
| 327 |
| 328 bool AXNodeData::HasStateFlag(ui::AXState state_flag) const { |
| 329 return IsFlagSet(state, state_flag); |
| 330 } |
| 331 |
| 297 std::string AXNodeData::ToString() const { | 332 std::string AXNodeData::ToString() const { |
| 298 std::string result; | 333 std::string result; |
| 299 | 334 |
| 300 result += "id=" + IntToString(id); | 335 result += "id=" + IntToString(id); |
| 301 result += " " + ui::ToString(role); | 336 result += " " + ui::ToString(role); |
| 302 | 337 |
| 303 if (state & (1 << AX_STATE_BUSY)) | 338 if (state & (1 << AX_STATE_BUSY)) |
| 304 result += " BUSY"; | 339 result += " BUSY"; |
| 305 if (state & (1 << AX_STATE_CHECKED)) | 340 if (state & (1 << AX_STATE_CHECKED)) |
| 306 result += " CHECKED"; | 341 result += " CHECKED"; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 } | 781 } |
| 747 } | 782 } |
| 748 | 783 |
| 749 if (!child_ids.empty()) | 784 if (!child_ids.empty()) |
| 750 result += " child_ids=" + IntVectorToString(child_ids); | 785 result += " child_ids=" + IntVectorToString(child_ids); |
| 751 | 786 |
| 752 return result; | 787 return result; |
| 753 } | 788 } |
| 754 | 789 |
| 755 } // namespace ui | 790 } // namespace ui |
| OLD | NEW |