Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: content/browser/accessibility/accessibility_tree_formatter.h

Issue 13479003: Modify AccessibilityTreeFormatter to build up an internal representation of the tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code cleanup Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
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 "base/values.h"
13 #include "content/browser/accessibility/browser_accessibility.h" 14 #include "content/browser/accessibility/browser_accessibility.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class RenderViewHost; 19 class RenderViewHost;
19 20
20 // A utility class for formatting platform-specific accessibility information, 21 // A utility class for formatting platform-specific accessibility information,
21 // for use in testing, debugging, and developer tools. 22 // for use in testing, debugging, and developer tools.
22 // This is extended by a subclass for each platform where accessibility is 23 // This is extended by a subclass for each platform where accessibility is
23 // implemented. 24 // implemented.
24 class CONTENT_EXPORT AccessibilityTreeFormatter { 25 class CONTENT_EXPORT AccessibilityTreeFormatter {
25 public: 26 public:
26 explicit AccessibilityTreeFormatter(BrowserAccessibility* node); 27 explicit AccessibilityTreeFormatter(BrowserAccessibility* root);
27 virtual ~AccessibilityTreeFormatter(); 28 virtual ~AccessibilityTreeFormatter();
28 29
29 static AccessibilityTreeFormatter* Create(RenderViewHost* rvh); 30 static AccessibilityTreeFormatter* Create(RenderViewHost* rvh);
30 31
32 // Populates the given DictionaryValue with the accessibility tree.
dmazzoni 2013/04/08 05:46:35 Can you document the JSON schema here, or point to
aboxhall 2013/04/10 03:09:34 Done.
33 void BuildAccessibilityTree(DictionaryValue* dict);
34
31 // Dumps a BrowserAccessibility tree into a string. 35 // Dumps a BrowserAccessibility tree into a string.
32 void FormatAccessibilityTree(string16* contents); 36 void FormatAccessibilityTree(string16* contents);
33 37
38 // Overridden by each platform to add the required attributes for each node
39 // into the given dict.
40 void AddProperties(BrowserAccessibility* node, DictionaryValue* dict);
dmazzoni 2013/04/08 05:46:35 Try making the first argument const to better dist
aboxhall 2013/04/10 03:09:34 Unfortunately ToBrowserAccessibilityCocoa() (and p
41
34 // A single filter specification. See GetAllowString() and GetDenyString() 42 // A single filter specification. See GetAllowString() and GetDenyString()
35 // for more information. 43 // for more information.
36 struct Filter { 44 struct Filter {
37 enum Type { 45 enum Type {
38 ALLOW, 46 ALLOW,
39 ALLOW_EMPTY, 47 ALLOW_EMPTY,
40 DENY 48 DENY
41 }; 49 };
42 string16 match_str; 50 string16 match_str;
43 Type type; 51 Type type;
(...skipping 28 matching lines...) Expand all
72 // --> 80 // -->
73 // <p>Text</p> 81 // <p>Text</p>
74 static const std::string GetAllowEmptyString(); 82 static const std::string GetAllowEmptyString();
75 static const std::string GetAllowString(); 83 static const std::string GetAllowString();
76 static const std::string GetDenyString(); 84 static const std::string GetDenyString();
77 85
78 protected: 86 protected:
79 void RecursiveFormatAccessibilityTree(BrowserAccessibility* node, 87 void RecursiveFormatAccessibilityTree(BrowserAccessibility* node,
80 string16* contents, 88 string16* contents,
81 int indent); 89 int indent);
90 void RecursiveBuildAccessibilityTree(BrowserAccessibility* node,
91 DictionaryValue* tree_node);
92 void RecursiveFormatAccessibilityTree(DictionaryValue* tree_node,
93 string16* contents,
94 int depth = 0);
82 95
83 // Returns a platform specific representation of a BrowserAccessibility. 96 // Returns a platform specific representation of a BrowserAccessibility.
84 // Should be zero or more complete lines, each with |prefix| prepended 97 // Should be zero or more complete lines, each with |prefix| prepended
85 // (to indent each line). 98 // (to indent each line).
86 string16 ToString(BrowserAccessibility* node, char* prefix); 99 string16 ToString(DictionaryValue* node, const string16& indent);
87 100
88 void Initialize(); 101 void Initialize();
89 102
90 bool MatchesFilters(const string16& text, bool default_result) const; 103 bool MatchesFilters(const string16& text, bool default_result) const;
91 void StartLine();
92 void Add(bool include_by_default, const string16& attr);
93 string16 FinishLine();
94 104
95 BrowserAccessibility* node_; 105 // Writes the given attribute string out to |line| if it matches the filters.
106 void WriteAttribute(bool include_by_default,
107 const string16& attr,
108 string16* line);
109
110 BrowserAccessibility* root_;
111
112 // Filters used when formatting the accessibility tree as text.
96 std::vector<Filter> filters_; 113 std::vector<Filter> filters_;
97 string16 line_;
98 114
99 DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatter); 115 DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatter);
100 }; 116 };
101 117
102 } // namespace content 118 } // namespace content
103 119
104 #endif // CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_ 120 #endif // CONTENT_BROWSER_ACCESSIBILITY_ACCESSIBILITY_TREE_FORMATTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698