[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
| 6 | #define UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include "base/strings/string16.h" |
| 13 | #include "ui/accessibility/ax_enums.h" |
| 14 | #include "ui/accessibility/ax_export.h" |
| 15 | #include "ui/gfx/rect.h" |
| 16 | |
| 17 | namespace ui { |
| 18 | |
| 19 | // A compact representation of the accessibility information for a |
| 20 | // single web object, in a form that can be serialized and sent from |
| 21 | // one process to another. |
| 22 | struct AX_EXPORT AXNodeData { |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 23 | AXNodeData(); |
| 24 | virtual ~AXNodeData(); |
| 25 | |
[email protected] | 5eec2f5 | 2014-01-06 22:30:54 | [diff] [blame^] | 26 | void AddStringAttribute(AXStringAttribute attribute, |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 27 | const std::string& value); |
[email protected] | 5eec2f5 | 2014-01-06 22:30:54 | [diff] [blame^] | 28 | void AddIntAttribute(AXIntAttribute attribute, int value); |
| 29 | void AddFloatAttribute(AXFloatAttribute attribute, float value); |
| 30 | void AddBoolAttribute(AXBoolAttribute attribute, bool value); |
| 31 | void AddIntListAttribute(AXIntListAttribute attribute, |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 32 | const std::vector<int32>& value); |
| 33 | |
| 34 | // Convenience functions, mainly for writing unit tests. |
| 35 | // Equivalent to AddStringAttribute(ATTR_NAME, name). |
| 36 | void SetName(std::string name); |
| 37 | // Equivalent to AddStringAttribute(ATTR_VALUE, value). |
| 38 | void SetValue(std::string value); |
| 39 | |
[email protected] | 5eec2f5 | 2014-01-06 22:30:54 | [diff] [blame^] | 40 | // Return a string representation of this data, for debugging. |
| 41 | std::string ToString() const; |
| 42 | |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 43 | // This is a simple serializable struct. All member variables should be |
| 44 | // public and copyable. |
| 45 | int32 id; |
| 46 | AXRole role; |
| 47 | uint32 state; |
| 48 | gfx::Rect location; |
[email protected] | 5eec2f5 | 2014-01-06 22:30:54 | [diff] [blame^] | 49 | std::vector<std::pair<AXStringAttribute, std::string> > string_attributes; |
| 50 | std::vector<std::pair<AXIntAttribute, int32> > int_attributes; |
| 51 | std::vector<std::pair<AXFloatAttribute, float> > float_attributes; |
| 52 | std::vector<std::pair<AXBoolAttribute, bool> > bool_attributes; |
| 53 | std::vector<std::pair<AXIntListAttribute, std::vector<int32> > > |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 54 | intlist_attributes; |
| 55 | std::vector<std::pair<std::string, std::string> > html_attributes; |
| 56 | std::vector<int32> child_ids; |
| 57 | }; |
| 58 | |
| 59 | } // namespace ui |
| 60 | |
| 61 | #endif // UI_ACCESSIBILITY_AX_NODE_DATA_H_ |