Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: content/common/accessibility_mode.h

Issue 2694413006: Scope and clean up uses of AccessibilityMode. (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 uint32_t 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 uint32_t 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 uint32_t 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 uint32_t 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 uint32_t kHTML = 1 << 4;
49
50 constexpr AccessibilityMode() : flags_(0) {}
51 constexpr AccessibilityMode(uint32_t flags) : flags_(flags) {}
52
53 bool has_mode(uint32_t flag) const { return (flags_ & flag) > 0; }
54
55 void set_mode(uint32_t flag, bool value) {
56 flags_ = value ? (flags_ | flag) : (flags_ & ~flag);
57 }
58
59 uint32_t mode() const { return flags_; }
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 uint32_t flags_;
78 };
79
80 static constexpr AccessibilityMode kAccessibilityModeWebContentsOnly(
81 AccessibilityMode::kWebContents | AccessibilityMode::kInlineTextBoxes |
82 AccessibilityMode::kScreenReader |
83 AccessibilityMode::kHTML);
84
85 static constexpr AccessibilityMode kAccessibilityModeComplete(
86 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents |
87 AccessibilityMode::kInlineTextBoxes |
88 AccessibilityMode::kScreenReader |
89 AccessibilityMode::kHTML);
90
91 } // namespace content
92
93 #endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/accessibility_mode_enums.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698