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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/accessibility_tree_formatter.h
diff --git a/content/browser/accessibility/accessibility_tree_formatter.h b/content/browser/accessibility/accessibility_tree_formatter.h
index ca51a68a735ccd92826050f5e4ff9540ad13c9e6..1946f2bbe239f6bd4c35909ee4c506fc28f45f19 100644
--- a/content/browser/accessibility/accessibility_tree_formatter.h
+++ b/content/browser/accessibility/accessibility_tree_formatter.h
@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
+#include "base/values.h"
#include "content/browser/accessibility/browser_accessibility.h"
#include "content/common/content_export.h"
@@ -23,14 +24,21 @@ class RenderViewHost;
// implemented.
class CONTENT_EXPORT AccessibilityTreeFormatter {
public:
- explicit AccessibilityTreeFormatter(BrowserAccessibility* node);
+ explicit AccessibilityTreeFormatter(BrowserAccessibility* root);
virtual ~AccessibilityTreeFormatter();
static AccessibilityTreeFormatter* Create(RenderViewHost* rvh);
+ // 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.
+ void BuildAccessibilityTree(DictionaryValue* dict);
+
// Dumps a BrowserAccessibility tree into a string.
void FormatAccessibilityTree(string16* contents);
+ // Overridden by each platform to add the required attributes for each node
+ // into the given dict.
+ 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
+
// A single filter specification. See GetAllowString() and GetDenyString()
// for more information.
struct Filter {
@@ -79,22 +87,30 @@ class CONTENT_EXPORT AccessibilityTreeFormatter {
void RecursiveFormatAccessibilityTree(BrowserAccessibility* node,
string16* contents,
int indent);
+ void RecursiveBuildAccessibilityTree(BrowserAccessibility* node,
+ DictionaryValue* tree_node);
+ void RecursiveFormatAccessibilityTree(DictionaryValue* tree_node,
+ string16* contents,
+ int depth = 0);
// Returns a platform specific representation of a BrowserAccessibility.
// Should be zero or more complete lines, each with |prefix| prepended
// (to indent each line).
- string16 ToString(BrowserAccessibility* node, char* prefix);
+ string16 ToString(DictionaryValue* node, const string16& indent);
void Initialize();
bool MatchesFilters(const string16& text, bool default_result) const;
- void StartLine();
- void Add(bool include_by_default, const string16& attr);
- string16 FinishLine();
- BrowserAccessibility* node_;
+ // Writes the given attribute string out to |line| if it matches the filters.
+ void WriteAttribute(bool include_by_default,
+ const string16& attr,
+ string16* line);
+
+ BrowserAccessibility* root_;
+
+ // Filters used when formatting the accessibility tree as text.
std::vector<Filter> filters_;
- string16 line_;
DISALLOW_COPY_AND_ASSIGN(AccessibilityTreeFormatter);
};

Powered by Google App Engine
This is Rietveld 408576698