Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::PlatformViewAndroidDelegate Class Reference

#include <platform_view_android_delegate.h>

Public Member Functions

 PlatformViewAndroidDelegate (std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
 
void UpdateSemantics (const flutter::SemanticsNodeUpdates &update, const flutter::CustomAccessibilityActionUpdates &actions)
 

Detailed Description

Definition at line 17 of file platform_view_android_delegate.h.

Constructor & Destructor Documentation

◆ PlatformViewAndroidDelegate()

flutter::PlatformViewAndroidDelegate::PlatformViewAndroidDelegate ( std::shared_ptr< PlatformViewAndroidJNI jni_facade)
explicit

Definition at line 40 of file platform_view_android_delegate.cc.

42 : jni_facade_(std::move(jni_facade)){};

Member Function Documentation

◆ UpdateSemantics()

void flutter::PlatformViewAndroidDelegate::UpdateSemantics ( const flutter::SemanticsNodeUpdates update,
const flutter::CustomAccessibilityActionUpdates actions 
)

Definition at line 44 of file platform_view_android_delegate.cc.

46 {
47 constexpr size_t kBytesPerNode = 48 * sizeof(int32_t);
48 constexpr size_t kBytesPerChild = sizeof(int32_t);
49 constexpr size_t kBytesPerCustomAction = sizeof(int32_t);
50 constexpr size_t kBytesPerAction = 4 * sizeof(int32_t);
51 constexpr size_t kBytesPerStringAttribute = 4 * sizeof(int32_t);
52
53 {
54 size_t num_bytes = 0;
55 for (const auto& value : update) {
56 num_bytes += kBytesPerNode;
57 num_bytes +=
58 value.second.childrenInTraversalOrder.size() * kBytesPerChild;
59 num_bytes += value.second.childrenInHitTestOrder.size() * kBytesPerChild;
60 num_bytes += value.second.customAccessibilityActions.size() *
61 kBytesPerCustomAction;
62 num_bytes +=
63 value.second.labelAttributes.size() * kBytesPerStringAttribute;
64 num_bytes +=
65 value.second.valueAttributes.size() * kBytesPerStringAttribute;
66 num_bytes += value.second.increasedValueAttributes.size() *
67 kBytesPerStringAttribute;
68 num_bytes += value.second.decreasedValueAttributes.size() *
69 kBytesPerStringAttribute;
70 num_bytes +=
71 value.second.hintAttributes.size() * kBytesPerStringAttribute;
72 }
73 // The encoding defined here is used in:
74 //
75 // * AccessibilityBridge.java
76 // * AccessibilityBridgeTest.java
77 // * accessibility_bridge.mm
78 //
79 // If any of the encoding structure or length is changed, those locations
80 // must be updated (at a minimum).
81 std::vector<uint8_t> buffer(num_bytes);
82 int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&buffer[0]);
83 float* buffer_float32 = reinterpret_cast<float*>(&buffer[0]);
84
85 std::vector<std::string> strings;
86 std::vector<std::vector<uint8_t>> string_attribute_args;
87 size_t position = 0;
88 for (const auto& value : update) {
89 // If you edit this code, make sure you update kBytesPerNode
90 // and/or kBytesPerChild above to match the number of values you are
91 // sending.
92 const flutter::SemanticsNode& node = value.second;
93 buffer_int32[position++] = node.id;
94 buffer_int32[position++] = node.flags;
95 buffer_int32[position++] = node.actions;
96 buffer_int32[position++] = node.maxValueLength;
97 buffer_int32[position++] = node.currentValueLength;
98 buffer_int32[position++] = node.textSelectionBase;
99 buffer_int32[position++] = node.textSelectionExtent;
100 buffer_int32[position++] = node.platformViewId;
101 buffer_int32[position++] = node.scrollChildren;
102 buffer_int32[position++] = node.scrollIndex;
103 buffer_float32[position++] = static_cast<float>(node.scrollPosition);
104 buffer_float32[position++] = static_cast<float>(node.scrollExtentMax);
105 buffer_float32[position++] = static_cast<float>(node.scrollExtentMin);
106
107 if (node.identifier.empty()) {
108 buffer_int32[position++] = -1;
109 } else {
110 buffer_int32[position++] = strings.size();
111 strings.push_back(node.identifier);
112 }
113
114 if (node.label.empty()) {
115 buffer_int32[position++] = -1;
116 } else {
117 buffer_int32[position++] = strings.size();
118 strings.push_back(node.label);
119 }
120
122 position, string_attribute_args);
123 if (node.value.empty()) {
124 buffer_int32[position++] = -1;
125 } else {
126 buffer_int32[position++] = strings.size();
127 strings.push_back(node.value);
128 }
129
131 position, string_attribute_args);
132 if (node.increasedValue.empty()) {
133 buffer_int32[position++] = -1;
134 } else {
135 buffer_int32[position++] = strings.size();
136 strings.push_back(node.increasedValue);
137 }
138
140 position, string_attribute_args);
141 if (node.decreasedValue.empty()) {
142 buffer_int32[position++] = -1;
143 } else {
144 buffer_int32[position++] = strings.size();
145 strings.push_back(node.decreasedValue);
146 }
147
149 position, string_attribute_args);
150
151 if (node.hint.empty()) {
152 buffer_int32[position++] = -1;
153 } else {
154 buffer_int32[position++] = strings.size();
155 strings.push_back(node.hint);
156 }
157
158 putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position,
159 string_attribute_args);
160
161 if (node.tooltip.empty()) {
162 buffer_int32[position++] = -1;
163 } else {
164 buffer_int32[position++] = strings.size();
165 strings.push_back(node.tooltip);
166 }
167
168 buffer_int32[position++] = node.textDirection;
169 buffer_float32[position++] = node.rect.left();
170 buffer_float32[position++] = node.rect.top();
171 buffer_float32[position++] = node.rect.right();
172 buffer_float32[position++] = node.rect.bottom();
173 node.transform.getColMajor(&buffer_float32[position]);
174 position += 16;
175
176 buffer_int32[position++] = node.childrenInTraversalOrder.size();
177 for (int32_t child : node.childrenInTraversalOrder) {
178 buffer_int32[position++] = child;
179 }
180
181 for (int32_t child : node.childrenInHitTestOrder) {
182 buffer_int32[position++] = child;
183 }
184
185 buffer_int32[position++] = node.customAccessibilityActions.size();
186 for (int32_t child : node.customAccessibilityActions) {
187 buffer_int32[position++] = child;
188 }
189 }
190
191 // custom accessibility actions.
192 size_t num_action_bytes = actions.size() * kBytesPerAction;
193 std::vector<uint8_t> actions_buffer(num_action_bytes);
194 int32_t* actions_buffer_int32 =
195 reinterpret_cast<int32_t*>(&actions_buffer[0]);
196
197 std::vector<std::string> action_strings;
198 size_t actions_position = 0;
199 for (const auto& value : actions) {
200 // If you edit this code, make sure you update kBytesPerAction
201 // to match the number of values you are
202 // sending.
204 actions_buffer_int32[actions_position++] = action.id;
205 actions_buffer_int32[actions_position++] = action.overrideId;
206 if (action.label.empty()) {
207 actions_buffer_int32[actions_position++] = -1;
208 } else {
209 actions_buffer_int32[actions_position++] = action_strings.size();
210 action_strings.push_back(action.label);
211 }
212 if (action.hint.empty()) {
213 actions_buffer_int32[actions_position++] = -1;
214 } else {
215 actions_buffer_int32[actions_position++] = action_strings.size();
216 action_strings.push_back(action.hint);
217 }
218 }
219
220 // Calling NewDirectByteBuffer in API level 22 and below with a size of zero
221 // will cause a JNI crash.
222 if (!actions_buffer.empty()) {
223 jni_facade_->FlutterViewUpdateCustomAccessibilityActions(actions_buffer,
224 action_strings);
225 }
226
227 if (!buffer.empty()) {
228 jni_facade_->FlutterViewUpdateSemantics(buffer, strings,
229 string_attribute_args);
230 }
231 }
232}
void getColMajor(SkScalar v[]) const
Definition SkM44.h:256
uint8_t value
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition switches.h:126
void putStringAttributesIntoBuffer(const StringAttributes &attributes, int32_t *buffer_int32, size_t &position, std::vector< std::vector< uint8_t > > &string_attribute_args)
constexpr float left() const
Definition SkRect.h:734
constexpr float top() const
Definition SkRect.h:741
constexpr float right() const
Definition SkRect.h:748
constexpr float bottom() const
Definition SkRect.h:755
StringAttributes decreasedValueAttributes
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > customAccessibilityActions
std::vector< int32_t > childrenInTraversalOrder

The documentation for this class was generated from the following files: