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