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; | |
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 static constexpr int kComplete = | |
dmazzoni
2017/02/23 17:08:21
I would have made kComplete and kWebContentsOnly i
dougt
2017/02/27 03:12:57
After discussion, we decided to try to remove the
| |
53 kNativeAPIs | kWebContents | kInlineTextBoxes | kScreenReader | kHTML; | |
54 | |
55 static constexpr int kWebContentsOnly = | |
56 kWebContents | kInlineTextBoxes | kScreenReader | kHTML; | |
57 | |
58 AccessibilityMode() : flags_(0) {} | |
59 AccessibilityMode(int flag) : flags_(flag) {} | |
dmazzoni
2017/02/23 17:08:21
nit: flag -> flags
danakj
2017/02/23 21:15:02
explicit
dougt
2017/02/27 03:12:57
Done.
| |
60 | |
61 bool hasMode(int flag) const { return (flags_ & flag) > 0; } | |
dmazzoni
2017/02/23 17:08:21
No strong feelings either way, but I wonder if thi
danakj
2017/02/23 21:15:02
+1. Also has_mode, not hasMode, is chromium style.
dougt
2017/02/27 03:12:57
Then, we should also change setMode to setModeFlag
| |
62 | |
63 void setMode(int flag, bool value) { | |
64 flags_ = value ? (flags_ | flag) : (flags_ & ~flag); | |
65 } | |
66 | |
67 bool operator==(AccessibilityMode rhs) const { | |
68 if (flags_ == rhs.flags_) | |
69 return true; | |
70 return false; | |
71 } | |
72 | |
73 bool operator!=(AccessibilityMode rhs) const { return !(*this == rhs); } | |
74 | |
75 AccessibilityMode& operator|=(const AccessibilityMode& rhs) { | |
76 flags_ |= rhs.flags_; | |
77 return *this; | |
78 } | |
79 | |
80 // Get internal value for serialization. | |
81 int get() const { return flags_; } | |
82 | |
83 private: | |
84 int flags_; | |
85 }; | |
86 | |
87 } // namespace content | |
88 | |
89 #endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
OLD | NEW |