Flutter Engine
The 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
15
16#include "flutter/lib/ui/semantics/string_attribute.h"
17
18namespace flutter {
19
20// Must match the SemanticsAction enum in semantics.dart and in each of the
21// embedders.
22enum class SemanticsAction : int32_t {
23 kTap = 1 << 0,
24 kLongPress = 1 << 1,
25 kScrollLeft = 1 << 2,
26 kScrollRight = 1 << 3,
27 kScrollUp = 1 << 4,
28 kScrollDown = 1 << 5,
29 kIncrease = 1 << 6,
30 kDecrease = 1 << 7,
31 kShowOnScreen = 1 << 8,
34 kSetSelection = 1 << 11,
35 kCopy = 1 << 12,
36 kCut = 1 << 13,
37 kPaste = 1 << 14,
40 kCustomAction = 1 << 17,
41 kDismiss = 1 << 18,
44 kSetText = 1 << 21,
45};
46
48 static_cast<int32_t>(SemanticsAction::kScrollUp) |
49 static_cast<int32_t>(SemanticsAction::kScrollDown);
50
52 static_cast<int32_t>(SemanticsAction::kScrollLeft) |
53 static_cast<int32_t>(SemanticsAction::kScrollRight);
54
57
58/// C/C++ representation of `SemanticsFlags` defined in
59/// `lib/ui/semantics.dart`.
60///\warning This must match the `SemanticsFlags` enum in
61/// `lib/ui/semantics.dart`.
62/// See also:
63/// - file://./../../../lib/ui/semantics.dart
64enum class SemanticsFlags : int32_t {
65 kHasCheckedState = 1 << 0,
66 kIsChecked = 1 << 1,
67 kIsSelected = 1 << 2,
68 kIsButton = 1 << 3,
69 kIsTextField = 1 << 4,
70 kIsFocused = 1 << 5,
71 kHasEnabledState = 1 << 6,
72 kIsEnabled = 1 << 7,
74 kIsHeader = 1 << 9,
75 kIsObscured = 1 << 10,
76 kScopesRoute = 1 << 11,
77 kNamesRoute = 1 << 12,
78 kIsHidden = 1 << 13,
79 kIsImage = 1 << 14,
80 kIsLiveRegion = 1 << 15,
81 kHasToggledState = 1 << 16,
82 kIsToggled = 1 << 17,
83 kHasImplicitScrolling = 1 << 18,
84 kIsMultiline = 1 << 19,
85 kIsReadOnly = 1 << 20,
86 kIsFocusable = 1 << 21,
87 kIsLink = 1 << 22,
88 kIsSlider = 1 << 23,
89 kIsKeyboardKey = 1 << 24,
90 kIsCheckStateMixed = 1 << 25,
91 kHasExpandedState = 1 << 26,
92 kIsExpanded = 1 << 27,
93};
94
96 static_cast<int32_t>(SemanticsFlags::kHasImplicitScrolling);
97
100
102
104
105 bool HasAction(SemanticsAction action) const;
106 bool HasFlag(SemanticsFlags flag) const;
107
108 // Whether this node is for embedded platform views.
109 bool IsPlatformViewNode() const;
110
111 int32_t id = 0;
112 int32_t flags = 0;
113 int32_t actions = 0;
114 int32_t maxValueLength = -1;
115 int32_t currentValueLength = -1;
116 int32_t textSelectionBase = -1;
118 int32_t platformViewId = -1;
119 int32_t scrollChildren = 0;
120 int32_t scrollIndex = 0;
121 double scrollPosition = std::nan("");
122 double scrollExtentMax = std::nan("");
123 double scrollExtentMin = std::nan("");
124 double elevation = 0.0;
125 double thickness = 0.0;
126 std::string identifier;
127 std::string label;
129 std::string hint;
131 std::string value;
133 std::string increasedValue;
135 std::string decreasedValue;
137 std::string tooltip;
138 int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
139
140 SkRect rect = SkRect::MakeEmpty(); // Local space, relative to parent.
141 SkM44 transform = SkM44{}; // Identity
142 std::vector<int32_t> childrenInTraversalOrder;
143 std::vector<int32_t> childrenInHitTestOrder;
144 std::vector<int32_t> customAccessibilityActions;
145};
146
147// Contains semantic nodes that need to be updated.
148//
149// The keys in the map are stable node IDd, and the values contain
150// semantic information for the node corresponding to the ID.
151using SemanticsNodeUpdates = std::unordered_map<int32_t, SemanticsNode>;
152
153} // namespace flutter
154
155#endif // FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_NODE_H_
Definition SkM44.h:150
FlutterSemanticsFlag flag
const int kScrollableSemanticsFlags
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
const int kHorizontalScrollSemanticsActions
const int kVerticalScrollSemanticsActions
std::vector< StringAttributePtr > StringAttributes
const int kScrollableSemanticsActions
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
SemanticsNode(const SemanticsNode &other)
StringAttributes decreasedValueAttributes
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInHitTestOrder
bool HasAction(SemanticsAction action) const
bool HasFlag(SemanticsFlags flag) const
std::vector< int32_t > customAccessibilityActions
bool IsPlatformViewNode() const
std::vector< int32_t > childrenInTraversalOrder