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