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