OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
danakj
2017/02/22 21:27:56
2017
dougt
2017/02/22 22:19:59
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 #ifndef CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
danakj
2017/02/22 21:27:56
white space around the #ifndef#define
dougt
2017/02/22 22:19:59
Done.
| |
5 #define CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
6 // Note: keep enums in content/browser/resources/accessibility/accessibility.js | |
7 // in sync with these two enums | |
danakj
2017/02/22 21:27:56
These aren't enums anymore maybe clarify this comm
dougt
2017/02/22 22:19:58
dropping comment. Adding a PRESUBMIT in a follow
| |
8 | |
9 namespace content { | |
10 | |
11 class AccessibilityMode { | |
12 public: | |
13 const static int OFF = 0; | |
danakj
2017/02/22 21:27:56
constexpr instead of const.
kOff, kNativeApis, et
dougt
2017/02/22 22:19:58
Done.
dougt
2017/02/22 22:19:59
Done.
| |
14 | |
15 // Native accessibility APIs, specific to each platform, are enabled. | |
16 // When this mode is set that indicates the presence of a third-party | |
17 // client accessing Chrome via accessibility APIs. However, unless one | |
18 // of the modes below is set, the contents of web pages will not be | |
19 // accessible. | |
20 const static int NATIVE_APIS = 1 << 0; | |
21 | |
22 // The renderer process will generate an accessibility tree containing | |
23 // basic information about all nodes, including role, name, value, | |
24 // state, and location. This is the minimum mode required in order for | |
25 // web contents to be accessible, and the remaining modes are meaningless | |
26 // unless this one is set. | |
27 // | |
28 // Note that sometimes this mode will be set when NATIVE_APIS is not, when the | |
29 // content layer embedder is providing accessibility support via some other | |
30 // mechanism other than what's implemented in content/browser. | |
31 const static int WEB_CONTENTS = 1 << 1; | |
32 | |
33 // The accessibility tree will contain inline text boxes, which are | |
34 // necessary to expose information about line breaks and word boundaries. | |
35 // Without this mode, you can retrieve the plaintext value of a text field | |
36 // but not the information about how it's broken down into lines. | |
37 // | |
38 // Note that when this mode is off it's still possible to request inline | |
39 // text boxes for a specific node on-demand, asynchronously. | |
40 const static int INLINE_TEXT_BOXES = 1 << 2; | |
41 | |
42 // The accessibility tree will contain extra accessibility | |
43 // attributes typically only needed by screen readers and other | |
44 // assistive technology for blind users. Examples include text style | |
45 // attributes, table cell information, live region properties, range | |
46 // values, and relationship attributes. | |
47 const static int SCREEN_READER = 1 << 3; | |
48 | |
49 // The accessibility tree will contain the HTML tag name and HTML attributes | |
50 // for all accessibility nodes that come from web content. | |
51 const static int HTML = 1 << 4; | |
52 | |
53 const static int COMPLETE = | |
54 NATIVE_APIS | WEB_CONTENTS | INLINE_TEXT_BOXES | SCREEN_READER | HTML; | |
55 | |
56 const static int WEB_CONTENTS_ONLY = | |
57 WEB_CONTENTS | INLINE_TEXT_BOXES | SCREEN_READER | HTML; | |
58 | |
59 AccessibilityMode(int flag = OFF) : flags_(flag) {} | |
danakj
2017/02/22 21:27:56
explicit
dougt
2017/02/22 22:19:58
Done.
| |
60 | |
61 bool has(int flag) const { return (flags_ & flag) > 0; } | |
62 int get() const { return flags_; } | |
danakj
2017/02/22 21:27:56
do you need a get()? it breaks the encapsulation
dougt
2017/02/22 22:19:58
Sadly, for now yes. The encapsulation gets broken
| |
63 | |
64 void set(int flag) { flags_ |= flag; } | |
danakj
2017/02/22 21:27:56
set is maybe an odd name here, you're getting a un
aboxhall
2017/02/22 22:05:50
Maybe set(int flag, bool state)?
danakj
2017/02/22 22:08:19
If you go with a setter that can add or remove the
| |
65 void set(AccessibilityMode& mode) { set(mode.get()); } | |
66 | |
67 void clear() { set(OFF); } | |
danakj
2017/02/22 21:27:56
this does nothing (a |= 0) == a
The OFF flag does
aboxhall
2017/02/22 22:05:50
It's used in a bunch of places to avoid running co
danakj
2017/02/22 22:08:19
An empty() function here could do that for us.
dougt
2017/02/22 22:19:58
Removed.
| |
68 | |
69 void toggle(int flag) { flags_ ^= flag; } | |
70 | |
71 bool operator==(AccessibilityMode rhs) const { | |
danakj
2017/02/22 21:27:56
== should come with a != too
dougt
2017/02/22 22:19:59
Done.
| |
72 if (flags_ == rhs.flags_) | |
73 return true; | |
74 return false; | |
75 } | |
76 | |
77 bool operator==(int rhs) const { | |
78 if (flags_ == rhs) | |
79 return true; | |
80 return false; | |
81 } | |
82 | |
83 bool operator!=(int rhs) const { | |
84 if (flags_ == rhs) | |
danakj
2017/02/22 21:27:56
define operator!= in terms of !operator==(). so re
| |
85 return false; | |
86 return true; | |
87 } | |
88 | |
89 void operator=(int flags) { flags_ = flags; } | |
danakj
2017/02/22 21:27:56
i think you'd do better to have operator=(Accessib
dougt
2017/02/22 22:19:58
What do you think if this also used:
dougt
2017/02/22 22:21:27
setMode(int mode, bool value)
| |
90 | |
91 private: | |
92 int flags_; | |
93 }; | |
94 | |
95 } // namespace content | |
96 | |
97 #endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ | |
OLD | NEW |