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_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_IMPL_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_IMPL_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" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "content/browser/accessibility/browser_accessibility.h" | 13 #include "content/browser/accessibility/browser_accessibility.h" |
14 #include "content/public/browser/accessibility_tree_formatter.h" | |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 // A utility class for retrieving platform specific accessibility information. | 18 // A utility class for retrieving platform specific accessibility information. |
dmazzoni
2013/02/27 16:41:01
Maybe update this comment to say "formatting" plat
aboxhall
2013/02/27 18:58:50
Done.
| |
18 // This is extended by a subclass for each platform where accessibility is | 19 // This is extended by a subclass for each platform where accessibility is |
19 // implemented. | 20 // implemented. |
20 class DumpAccessibilityTreeHelper { | 21 class AccessibilityTreeFormatterImpl : public AccessibilityTreeFormatter { |
21 public: | 22 public: |
22 DumpAccessibilityTreeHelper(); | 23 explicit AccessibilityTreeFormatterImpl(BrowserAccessibility* node); |
23 virtual ~DumpAccessibilityTreeHelper(); | 24 virtual ~AccessibilityTreeFormatterImpl(); |
24 | 25 |
25 // Dumps a BrowserAccessibility tree into a string. | 26 // Dumps a BrowserAccessibility tree into a string. |
26 void DumpAccessibilityTree(BrowserAccessibility* node, | 27 virtual void FormatAccessibilityTree(string16* contents) OVERRIDE; |
27 string16* contents); | |
28 | 28 |
29 // A single filter specification. See GetAllowString() and GetDenyString() | 29 // A single filter specification. See GetAllowString() and GetDenyString() |
30 // for more information. | 30 // for more information. |
31 struct Filter { | 31 struct Filter { |
32 enum Type { | 32 enum Type { |
33 ALLOW, | 33 ALLOW, |
34 ALLOW_EMPTY, | 34 ALLOW_EMPTY, |
35 DENY | 35 DENY |
36 }; | 36 }; |
37 string16 match_str; | 37 string16 match_str; |
38 Type type; | 38 Type type; |
39 | 39 |
40 Filter(string16 match_str, Type type) | 40 Filter(string16 match_str, Type type) |
41 : match_str(match_str), type(type) {} | 41 : match_str(match_str), type(type) {} |
42 }; | 42 }; |
43 | 43 |
44 // Set regular expression filters that apply to each component of every | 44 // Set regular expression filters that apply to each component of every |
45 // line before it's output. | 45 // line before it's output. |
46 void SetFilters(const std::vector<Filter>& filters); | 46 void SetFilters(const std::vector<Filter>& filters); |
47 | 47 |
48 // Suffix of the expectation file corresponding to html file. | 48 // Suffix of the expectation file corresponding to html file. |
49 // Example: | 49 // Example: |
50 // HTML test: test-file.html | 50 // HTML test: test-file.html |
51 // Expected: test-file-expected-mac.txt. | 51 // Expected: test-file-expected-mac.txt. |
52 // Auto-generated: test-file-actual-mac.txt | 52 // Auto-generated: test-file-actual-mac.txt |
53 const base::FilePath::StringType GetActualFileSuffix() const; | 53 static const base::FilePath::StringType GetActualFileSuffix(); |
54 const base::FilePath::StringType GetExpectedFileSuffix() const; | 54 static const base::FilePath::StringType GetExpectedFileSuffix(); |
55 | 55 |
56 // A platform-specific string that indicates a given line in a file | 56 // A platform-specific string that indicates a given line in a file |
57 // is an allow-empty, allow or deny filter. Example: | 57 // is an allow-empty, allow or deny filter. Example: |
58 // Mac values: | 58 // Mac values: |
59 // GetAllowEmptyString() -> "@MAC-ALLOW-EMPTY:" | 59 // GetAllowEmptyString() -> "@MAC-ALLOW-EMPTY:" |
60 // GetAllowString() -> "@MAC-ALLOW:" | 60 // GetAllowString() -> "@MAC-ALLOW:" |
61 // GetDenyString() -> "@MAC-DENY:" | 61 // GetDenyString() -> "@MAC-DENY:" |
62 // Example html: | 62 // Example html: |
63 // <!-- | 63 // <!-- |
64 // @MAC-ALLOW-EMPTY:description* | 64 // @MAC-ALLOW-EMPTY:description* |
65 // @MAC-ALLOW:roleDescription* | 65 // @MAC-ALLOW:roleDescription* |
66 // @MAC-DENY:subrole* | 66 // @MAC-DENY:subrole* |
67 // --> | 67 // --> |
68 // <p>Text</p> | 68 // <p>Text</p> |
69 const std::string GetAllowEmptyString() const; | 69 static const std::string GetAllowEmptyString(); |
70 const std::string GetAllowString() const; | 70 static const std::string GetAllowString(); |
71 const std::string GetDenyString() const; | 71 static const std::string GetDenyString(); |
72 | 72 |
73 protected: | 73 protected: |
74 void RecursiveDumpAccessibilityTree(BrowserAccessibility* node, | 74 void RecursiveFormatAccessibilityTree(BrowserAccessibility* node, |
75 string16* contents, | 75 string16* contents, |
76 int indent); | 76 int indent); |
77 | 77 |
78 // Returns a platform specific representation of a BrowserAccessibility. | 78 // Returns a platform specific representation of a BrowserAccessibility. |
79 // Should be zero or more complete lines, each with |prefix| prepended | 79 // Should be zero or more complete lines, each with |prefix| prepended |
80 // (to indent each line). | 80 // (to indent each line). |
81 string16 ToString(BrowserAccessibility* node, char* prefix); | 81 string16 ToString(BrowserAccessibility* node, char* prefix); |
82 | 82 |
83 void Initialize(); | 83 void Initialize(); |
84 | 84 |
85 bool MatchesFilters(const string16& text, bool default_result); | 85 bool MatchesFilters(const string16& text, bool default_result) const; |
86 void StartLine(); | 86 void StartLine(); |
87 void Add(bool include_by_default, const string16& attr); | 87 void Add(bool include_by_default, const string16& attr); |
88 string16 FinishLine(); | 88 string16 FinishLine(); |
89 | 89 |
90 BrowserAccessibility* node_; | |
90 std::vector<Filter> filters_; | 91 std::vector<Filter> filters_; |
91 string16 line_; | 92 string16 line_; |
92 | 93 |
93 DISALLOW_COPY_AND_ASSIGN(DumpAccessibilityTreeHelper); | 94 DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatterImpl); |
94 }; | 95 }; |
95 | 96 |
96 } // namespace content | 97 } // namespace content |
97 | 98 |
98 #endif // CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 99 #endif // CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_IMPL_H_ |
OLD | NEW |