| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ |
| 6 #define CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // "children": [ ] | 45 // "children": [ ] |
| 46 // }, { | 46 // }, { |
| 47 // "AXName": "child name 2", | 47 // "AXName": "child name 2", |
| 48 // /* ... more attributes */ | 48 // /* ... more attributes */ |
| 49 // "children": [ ] | 49 // "children": [ ] |
| 50 // } ] | 50 // } ] |
| 51 // } | 51 // } |
| 52 scoped_ptr<base::DictionaryValue> BuildAccessibilityTree(); | 52 scoped_ptr<base::DictionaryValue> BuildAccessibilityTree(); |
| 53 | 53 |
| 54 // Dumps a BrowserAccessibility tree into a string. | 54 // Dumps a BrowserAccessibility tree into a string. |
| 55 void FormatAccessibilityTree(string16* contents); | 55 void FormatAccessibilityTree(base::string16* contents); |
| 56 | 56 |
| 57 // A single filter specification. See GetAllowString() and GetDenyString() | 57 // A single filter specification. See GetAllowString() and GetDenyString() |
| 58 // for more information. | 58 // for more information. |
| 59 struct Filter { | 59 struct Filter { |
| 60 enum Type { | 60 enum Type { |
| 61 ALLOW, | 61 ALLOW, |
| 62 ALLOW_EMPTY, | 62 ALLOW_EMPTY, |
| 63 DENY | 63 DENY |
| 64 }; | 64 }; |
| 65 string16 match_str; | 65 base::string16 match_str; |
| 66 Type type; | 66 Type type; |
| 67 | 67 |
| 68 Filter(string16 match_str, Type type) | 68 Filter(base::string16 match_str, Type type) |
| 69 : match_str(match_str), type(type) {} | 69 : match_str(match_str), type(type) {} |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // Set regular expression filters that apply to each component of every | 72 // Set regular expression filters that apply to each component of every |
| 73 // line before it's output. | 73 // line before it's output. |
| 74 void SetFilters(const std::vector<Filter>& filters); | 74 void SetFilters(const std::vector<Filter>& filters); |
| 75 | 75 |
| 76 // Suffix of the expectation file corresponding to html file. | 76 // Suffix of the expectation file corresponding to html file. |
| 77 // Example: | 77 // Example: |
| 78 // HTML test: test-file.html | 78 // HTML test: test-file.html |
| (...skipping 14 matching lines...) Expand all Loading... |
| 93 // @MAC-ALLOW:roleDescription* | 93 // @MAC-ALLOW:roleDescription* |
| 94 // @MAC-DENY:subrole* | 94 // @MAC-DENY:subrole* |
| 95 // --> | 95 // --> |
| 96 // <p>Text</p> | 96 // <p>Text</p> |
| 97 static const std::string GetAllowEmptyString(); | 97 static const std::string GetAllowEmptyString(); |
| 98 static const std::string GetAllowString(); | 98 static const std::string GetAllowString(); |
| 99 static const std::string GetDenyString(); | 99 static const std::string GetDenyString(); |
| 100 | 100 |
| 101 protected: | 101 protected: |
| 102 void RecursiveFormatAccessibilityTree(const BrowserAccessibility& node, | 102 void RecursiveFormatAccessibilityTree(const BrowserAccessibility& node, |
| 103 string16* contents, | 103 base::string16* contents, |
| 104 int indent); | 104 int indent); |
| 105 void RecursiveBuildAccessibilityTree(const BrowserAccessibility& node, | 105 void RecursiveBuildAccessibilityTree(const BrowserAccessibility& node, |
| 106 base::DictionaryValue* tree_node); | 106 base::DictionaryValue* tree_node); |
| 107 void RecursiveFormatAccessibilityTree(const base::DictionaryValue& tree_node, | 107 void RecursiveFormatAccessibilityTree(const base::DictionaryValue& tree_node, |
| 108 string16* contents, | 108 base::string16* contents, |
| 109 int depth = 0); | 109 int depth = 0); |
| 110 | 110 |
| 111 // Overridden by each platform to add the required attributes for each node | 111 // Overridden by each platform to add the required attributes for each node |
| 112 // into the given dict. | 112 // into the given dict. |
| 113 void AddProperties(const BrowserAccessibility& node, | 113 void AddProperties(const BrowserAccessibility& node, |
| 114 base::DictionaryValue* dict); | 114 base::DictionaryValue* dict); |
| 115 | 115 |
| 116 string16 FormatCoordinates(const char* name, | 116 base::string16 FormatCoordinates(const char* name, |
| 117 const char* x_name, | 117 const char* x_name, |
| 118 const char* y_name, | 118 const char* y_name, |
| 119 const base::DictionaryValue& value); | 119 const base::DictionaryValue& value); |
| 120 | 120 |
| 121 // Returns a platform specific representation of a BrowserAccessibility. | 121 // Returns a platform specific representation of a BrowserAccessibility. |
| 122 // Should be zero or more complete lines, each with |prefix| prepended | 122 // Should be zero or more complete lines, each with |prefix| prepended |
| 123 // (to indent each line). | 123 // (to indent each line). |
| 124 string16 ToString(const base::DictionaryValue& node, const string16& indent); | 124 base::string16 ToString(const base::DictionaryValue& node, |
| 125 const base::string16& indent); |
| 125 | 126 |
| 126 void Initialize(); | 127 void Initialize(); |
| 127 | 128 |
| 128 bool MatchesFilters(const string16& text, bool default_result) const; | 129 bool MatchesFilters(const base::string16& text, bool default_result) const; |
| 129 | 130 |
| 130 // Writes the given attribute string out to |line| if it matches the filters. | 131 // Writes the given attribute string out to |line| if it matches the filters. |
| 131 void WriteAttribute(bool include_by_default, | 132 void WriteAttribute(bool include_by_default, |
| 132 const string16& attr, | 133 const base::string16& attr, |
| 133 string16* line); | 134 base::string16* line); |
| 134 void WriteAttribute(bool include_by_default, | 135 void WriteAttribute(bool include_by_default, |
| 135 const std::string& attr, | 136 const std::string& attr, |
| 136 string16* line); | 137 base::string16* line); |
| 137 | 138 |
| 138 BrowserAccessibility* root_; | 139 BrowserAccessibility* root_; |
| 139 | 140 |
| 140 // Filters used when formatting the accessibility tree as text. | 141 // Filters used when formatting the accessibility tree as text. |
| 141 std::vector<Filter> filters_; | 142 std::vector<Filter> filters_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatter); | 144 DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatter); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 } // namespace content | 147 } // namespace content |
| 147 | 148 |
| 148 #endif // CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ | 149 #endif // CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ |
| OLD | NEW |