Chromium Code Reviews| Index: content/common/accessibility_mode.h |
| diff --git a/content/common/accessibility_mode.h b/content/common/accessibility_mode.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6eadb0d36ad44708714092c91b362f0e801627cb |
| --- /dev/null |
| +++ b/content/common/accessibility_mode.h |
| @@ -0,0 +1,89 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ |
| +#define CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ |
| + |
| +namespace content { |
| + |
| +class AccessibilityMode { |
| + public: |
| + static constexpr int kOff = 0; |
| + |
| + // Native accessibility APIs, specific to each platform, are enabled. |
| + // When this mode is set that indicates the presence of a third-party |
| + // client accessing Chrome via accessibility APIs. However, unless one |
| + // of the modes below is set, the contents of web pages will not be |
| + // accessible. |
| + static constexpr int kNativeAPIs = 1 << 0; |
| + |
| + // The renderer process will generate an accessibility tree containing |
| + // basic information about all nodes, including role, name, value, |
| + // state, and location. This is the minimum mode required in order for |
| + // web contents to be accessible, and the remaining modes are meaningless |
| + // unless this one is set. |
| + // |
| + // Note that sometimes this mode will be set when kNativeAPI is not, when the |
| + // content layer embedder is providing accessibility support via some other |
| + // mechanism other than what's implemented in content/browser. |
| + static constexpr int kWebContents = 1 << 1; |
| + |
| + // The accessibility tree will contain inline text boxes, which are |
| + // necessary to expose information about line breaks and word boundaries. |
| + // Without this mode, you can retrieve the plaintext value of a text field |
| + // but not the information about how it's broken down into lines. |
| + // |
| + // Note that when this mode is off it's still possible to request inline |
| + // text boxes for a specific node on-demand, asynchronously. |
| + static constexpr int kInlineTextBoxes = 1 << 2; |
| + |
| + // The accessibility tree will contain extra accessibility |
| + // attributes typically only needed by screen readers and other |
| + // assistive technology for blind users. Examples include text style |
| + // attributes, table cell information, live region properties, range |
| + // values, and relationship attributes. |
| + static constexpr int kScreenReader = 1 << 3; |
| + |
| + // The accessibility tree will contain the HTML tag name and HTML attributes |
| + // for all accessibility nodes that come from web content. |
| + static constexpr int kHTML = 1 << 4; |
| + |
| + 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
|
| + kNativeAPIs | kWebContents | kInlineTextBoxes | kScreenReader | kHTML; |
| + |
| + static constexpr int kWebContentsOnly = |
| + kWebContents | kInlineTextBoxes | kScreenReader | kHTML; |
| + |
| + AccessibilityMode() : flags_(0) {} |
| + 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.
|
| + |
| + 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
|
| + |
| + void setMode(int flag, bool value) { |
| + flags_ = value ? (flags_ | flag) : (flags_ & ~flag); |
| + } |
| + |
| + bool operator==(AccessibilityMode rhs) const { |
| + if (flags_ == rhs.flags_) |
| + return true; |
| + return false; |
| + } |
| + |
| + bool operator!=(AccessibilityMode rhs) const { return !(*this == rhs); } |
| + |
| + AccessibilityMode& operator|=(const AccessibilityMode& rhs) { |
| + flags_ |= rhs.flags_; |
| + return *this; |
| + } |
| + |
| + // Get internal value for serialization. |
| + int get() const { return flags_; } |
| + |
| + private: |
| + int flags_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_ |