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