Flutter Engine
The Flutter Engine
ax_mode.h
Go to the documentation of this file.
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 UI_ACCESSIBILITY_AX_MODE_H_
6#define UI_ACCESSIBILITY_AX_MODE_H_
7
8#include <cstdint>
9#include <ostream>
10#include <string>
11
12#include "ax_base_export.h"
13
14namespace ui {
15
17 public:
18 static constexpr uint32_t kFirstModeFlag = 1 << 0;
19
20 // Native accessibility APIs, specific to each platform, are enabled.
21 // When this mode is set that indicates the presence of a third-party
22 // client accessing Chrome via accessibility APIs. However, unless one
23 // of the modes below is set, the contents of web pages will not be
24 // accessible.
25 static constexpr uint32_t kNativeAPIs = 1 << 0;
26
27 // The renderer process will generate an accessibility tree containing
28 // basic information about all nodes, including role, name, value,
29 // state, and location. This is the minimum mode required in order for
30 // web contents to be accessible, and the remaining modes are meaningless
31 // unless this one is set.
32 //
33 // Note that sometimes this mode will be set when kNativeAPI is not, when the
34 // content layer embedder is providing accessibility support via some other
35 // mechanism other than what's implemented in content/browser.
36 static constexpr uint32_t kWebContents = 1 << 1;
37
38 // The accessibility tree will contain inline text boxes, which are
39 // necessary to expose information about line breaks and word boundaries.
40 // Without this mode, you can retrieve the plaintext value of a text field
41 // but not the information about how it's broken down into lines.
42 //
43 // Note that when this mode is off it's still possible to request inline
44 // text boxes for a specific node on-demand, asynchronously.
45 static constexpr uint32_t kInlineTextBoxes = 1 << 2;
46
47 // The accessibility tree will contain extra accessibility
48 // attributes typically only needed by screen readers and other
49 // assistive technology for blind users. Examples include text style
50 // attributes, table cell information, live region properties, range
51 // values, and relationship attributes.
52 static constexpr uint32_t kScreenReader = 1 << 3;
53
54 // The accessibility tree will contain the HTML tag name and HTML attributes
55 // for all accessibility nodes that come from web content.
56 static constexpr uint32_t kHTML = 1 << 4;
57
58 // The accessibility tree will contain automatic image annotations.
59 static constexpr uint32_t kLabelImages = 1 << 5;
60
61 // The accessibility tree will contain enough information to export
62 // an accessible PDF.
63 static constexpr uint32_t kPDF = 1 << 6;
64
65 // Update this to include the last supported mode flag. If you add
66 // another, be sure to update the stream insertion operator for
67 // logging and debugging.
68 static constexpr uint32_t kLastModeFlag = 1 << 6;
69
70 constexpr AXMode() : flags_(0) {}
71 constexpr AXMode(uint32_t flags) : flags_(flags) {}
72
73 bool has_mode(uint32_t flag) const { return (flags_ & flag) > 0; }
74
75 void set_mode(uint32_t flag, bool value) {
76 flags_ = value ? (flags_ | flag) : (flags_ & ~flag);
77 }
78
79 uint32_t mode() const { return flags_; }
80
81 bool operator==(AXMode rhs) const { return flags_ == rhs.flags_; }
82
83 bool is_mode_off() const { return flags_ == 0; }
84
85 bool operator!=(AXMode rhs) const { return !(*this == rhs); }
86
87 AXMode& operator|=(const AXMode& rhs) {
88 flags_ |= rhs.flags_;
89 return *this;
90 }
91
92 std::string ToString() const;
93
94 private:
95 uint32_t flags_;
96};
97
102
107
108// For debugging, test assertions, etc.
109AX_BASE_EXPORT std::ostream& operator<<(std::ostream& stream,
110 const AXMode& mode);
111
112} // namespace ui
113
114#endif // UI_ACCESSIBILITY_AX_MODE_H_
#define AX_BASE_EXPORT
bool has_mode(uint32_t flag) const
Definition: ax_mode.h:73
static constexpr uint32_t kInlineTextBoxes
Definition: ax_mode.h:45
static constexpr uint32_t kScreenReader
Definition: ax_mode.h:52
uint32_t mode() const
Definition: ax_mode.h:79
static constexpr uint32_t kNativeAPIs
Definition: ax_mode.h:25
AXMode & operator|=(const AXMode &rhs)
Definition: ax_mode.h:87
constexpr AXMode()
Definition: ax_mode.h:70
bool is_mode_off() const
Definition: ax_mode.h:83
static constexpr uint32_t kHTML
Definition: ax_mode.h:56
constexpr AXMode(uint32_t flags)
Definition: ax_mode.h:71
static constexpr uint32_t kWebContents
Definition: ax_mode.h:36
bool operator!=(AXMode rhs) const
Definition: ax_mode.h:85
void set_mode(uint32_t flag, bool value)
Definition: ax_mode.h:75
bool operator==(AXMode rhs) const
Definition: ax_mode.h:81
FlutterSemanticsFlag flag
FlutterSemanticsFlag flags
uint8_t value
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
static constexpr AXMode kAXModeComplete(AXMode::kNativeAPIs|AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)
const char * ToString(ax::mojom::Event event)
Definition: ax_enum_util.cc:9
std::ostream & operator<<(std::ostream &os, AXEventGenerator::Event event)
static constexpr AXMode kAXModeWebContentsOnly(AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)