Flutter Engine
 
Loading...
Searching...
No Matches
semantics_node.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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 FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_NODE_H_
6#define FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_NODE_H_
7
8#include <cstdint>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13#include "third_party/skia/include/core/SkM44.h"
14#include "third_party/skia/include/core/SkRect.h"
15
18
19namespace flutter {
20
21// Must match the SemanticsAction enum in semantics.dart and in each of the
22// embedders.
23enum class SemanticsAction : int32_t {
24 kTap = 1 << 0,
25 kLongPress = 1 << 1,
26 kScrollLeft = 1 << 2,
27 kScrollRight = 1 << 3,
28 kScrollUp = 1 << 4,
29 kScrollDown = 1 << 5,
30 kIncrease = 1 << 6,
31 kDecrease = 1 << 7,
32 kShowOnScreen = 1 << 8,
35 kSetSelection = 1 << 11,
36 kCopy = 1 << 12,
37 kCut = 1 << 13,
38 kPaste = 1 << 14,
41 kCustomAction = 1 << 17,
42 kDismiss = 1 << 18,
45 kSetText = 1 << 21,
46 kFocus = 1 << 22,
47 kScrollToOffset = 1 << 23,
48 kExpand = 1 << 24,
49 kCollapse = 1 << 25,
50};
51
53 static_cast<int32_t>(SemanticsAction::kScrollUp) |
54 static_cast<int32_t>(SemanticsAction::kScrollDown);
55
57 static_cast<int32_t>(SemanticsAction::kScrollLeft) |
58 static_cast<int32_t>(SemanticsAction::kScrollRight);
59
62
63/// The following actions are not user-initiated.
64constexpr int kSystemActions =
67
68/// C/C++ representation of `SemanticsRole` defined in
69/// `lib/ui/semantics.dart`.
70///\warning This must match the `SemanticsRole` enum in
71/// `lib/ui/semantics.dart`.
72/// See also:
73/// - file://./../../../lib/ui/semantics.dart
74enum class SemanticsRole : int32_t {
75 kNone = 0,
76 kTab = 1,
77 kTabBar = 2,
78 kTabPanel = 3,
79 kDialog = 4,
80 kAlertDialog = 5,
81 kTable = 6,
82 kCell = 7,
83 kRow = 8,
84 kColumnHeader = 9,
85 kDragHandle = 10,
86 kSpinButton = 11,
87 kComboBox = 12,
88 kMenuBar = 13,
89 kMenu = 14,
90 kMenuItem = 15,
92 kMenuItemRadio = 17,
93 kList = 18,
94 kListItem = 19,
95 kForm = 20,
96 kTooltip = 21,
97 kLoadingSpinner = 22,
98 kProgressBar = 23,
99 kHotKey = 24,
100 kRadioGroup = 25,
101 kStatus = 26,
102 kAlert = 27,
103 kComplementary = 28,
104 kContentInfo = 29,
105 kMain = 30,
106 kNavigation = 31,
107 kRegion = 32,
108};
109
110/// C/C++ representation of `SemanticsValidationResult` defined in
111/// `lib/ui/semantics.dart`.
112///\warning This must match the `SemanticsValidationResult` enum in
113/// `lib/ui/semantics.dart`.
114/// See also:
115/// - file://./../../../lib/ui/semantics.dart
116enum class SemanticsValidationResult : int32_t {
117 kNone = 0,
118 kValid = 1,
119 kInvalid = 2,
120};
121
124
126
128
129 bool HasAction(SemanticsAction action) const;
130
131 // Whether this node is for embedded platform views.
132 bool IsPlatformViewNode() const;
133
134 int32_t id = 0;
136 int32_t actions = 0;
137 int32_t maxValueLength = -1;
138 int32_t currentValueLength = -1;
139 int32_t textSelectionBase = -1;
141 int32_t platformViewId = -1;
142 int32_t scrollChildren = 0;
143 int32_t scrollIndex = 0;
144 int32_t traversalParent = 0;
145 double scrollPosition = std::nan("");
146 double scrollExtentMax = std::nan("");
147 double scrollExtentMin = std::nan("");
148 std::string identifier;
149 std::string label;
151 std::string hint;
153 std::string value;
155 std::string increasedValue;
157 std::string decreasedValue;
159 std::string tooltip;
160 int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
161
162 SkRect rect = SkRect::MakeEmpty(); // Local space, relative to parent.
163 SkM44 transform = SkM44{}; // Identity
164 SkM44 hitTestTransform = SkM44{}; // Identity
165 std::vector<int32_t> childrenInTraversalOrder;
166 std::vector<int32_t> childrenInHitTestOrder;
167 std::vector<int32_t> customAccessibilityActions;
168 int32_t headingLevel = 0;
169
170 std::string linkUrl;
173 // A locale string in BCP 47 format
174 std::string locale;
175};
176
177// Contains semantic nodes that need to be updated.
178//
179// The keys in the map are stable node IDd, and the values contain
180// semantic information for the node corresponding to the ID.
181using SemanticsNodeUpdates = std::unordered_map<int32_t, SemanticsNode>;
182
183} // namespace flutter
184
185#endif // FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_NODE_H_
@ kNone
Definition layer.h:43
constexpr int kHorizontalScrollSemanticsActions
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
constexpr int kSystemActions
The following actions are not user-initiated.
SemanticsValidationResult
constexpr int kScrollableSemanticsActions
constexpr int kVerticalScrollSemanticsActions
std::vector< StringAttributePtr > StringAttributes
SemanticsNode(const SemanticsNode &other)
StringAttributes decreasedValueAttributes
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInHitTestOrder
bool HasAction(SemanticsAction action) const
SemanticsValidationResult validationResult
std::vector< int32_t > customAccessibilityActions
bool IsPlatformViewNode() const
std::vector< int32_t > childrenInTraversalOrder