OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
6 #define CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
7 | |
8 namespace content { | |
9 | |
10 class AccessibilityMode { | |
11 public: | |
12 static constexpr int kOff = 0; | |
dmazzoni
2017/02/27 23:54:20
I still think kOff doesn't belong. There's no indi
| |
13 | |
14 // Native accessibility APIs, specific to each platform, are enabled. | |
15 // When this mode is set that indicates the presence of a third-party | |
16 // client accessing Chrome via accessibility APIs. However, unless one | |
17 // of the modes below is set, the contents of web pages will not be | |
18 // accessible. | |
19 static constexpr int kNativeAPIs = 1 << 0; | |
20 | |
21 // The renderer process will generate an accessibility tree containing | |
22 // basic information about all nodes, including role, name, value, | |
23 // state, and location. This is the minimum mode required in order for | |
24 // web contents to be accessible, and the remaining modes are meaningless | |
25 // unless this one is set. | |
26 // | |
27 // Note that sometimes this mode will be set when kNativeAPI is not, when the | |
28 // content layer embedder is providing accessibility support via some other | |
29 // mechanism other than what's implemented in content/browser. | |
30 static constexpr int kWebContents = 1 << 1; | |
31 | |
32 // The accessibility tree will contain inline text boxes, which are | |
33 // necessary to expose information about line breaks and word boundaries. | |
34 // Without this mode, you can retrieve the plaintext value of a text field | |
35 // but not the information about how it's broken down into lines. | |
36 // | |
37 // Note that when this mode is off it's still possible to request inline | |
38 // text boxes for a specific node on-demand, asynchronously. | |
39 static constexpr int kInlineTextBoxes = 1 << 2; | |
40 | |
41 // The accessibility tree will contain extra accessibility | |
42 // attributes typically only needed by screen readers and other | |
43 // assistive technology for blind users. Examples include text style | |
44 // attributes, table cell information, live region properties, range | |
45 // values, and relationship attributes. | |
46 static constexpr int kScreenReader = 1 << 3; | |
47 | |
48 // The accessibility tree will contain the HTML tag name and HTML attributes | |
49 // for all accessibility nodes that come from web content. | |
50 static constexpr int kHTML = 1 << 4; | |
51 | |
52 AccessibilityMode() : flags_(kOff) {} | |
53 AccessibilityMode(int flags) : flags_(flags) {} | |
54 | |
55 bool has_mode(int flag) const { return (flags_ & flag) > 0; } | |
56 | |
57 void set_mode(int flag, bool value) { | |
58 flags_ = value ? (flags_ | flag) : (flags_ & ~flag); | |
59 } | |
60 | |
61 int get_mode() const { return flags_; } | |
62 | |
63 bool operator==(AccessibilityMode rhs) const { | |
64 if (flags_ == rhs.flags_) | |
65 return true; | |
66 return false; | |
67 } | |
68 | |
69 bool operator!=(AccessibilityMode rhs) const { return !(*this == rhs); } | |
70 | |
71 AccessibilityMode& operator|=(const AccessibilityMode& rhs) { | |
72 flags_ |= rhs.flags_; | |
73 return *this; | |
74 } | |
75 | |
76 private: | |
77 int flags_; | |
78 }; | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
OLD | NEW |