Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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)
 

Static Public Attributes

static constexpr size_t kBytesPerNode
 
static constexpr size_t kBytesPerChild = sizeof(int32_t)
 
static constexpr size_t kBytesPerCustomAction = sizeof(int32_t)
 
static constexpr size_t kBytesPerAction = 4 * sizeof(int32_t)
 
static constexpr size_t kBytesPerStringAttribute = 4 * sizeof(int32_t)
 
static constexpr int kEmptyStringIndex = -1
 

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 154 of file platform_view_android_delegate.cc.

156 : 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 158 of file platform_view_android_delegate.cc.

160 {
161 {
162 size_t num_bytes = 0;
163 for (const auto& value : update) {
164 num_bytes += kBytesPerNode;
165 num_bytes +=
166 value.second.childrenInTraversalOrder.size() * kBytesPerChild;
167 num_bytes += value.second.childrenInHitTestOrder.size() * kBytesPerChild;
168 num_bytes += value.second.customAccessibilityActions.size() *
170 num_bytes +=
171 value.second.labelAttributes.size() * kBytesPerStringAttribute;
172 num_bytes +=
173 value.second.valueAttributes.size() * kBytesPerStringAttribute;
174 num_bytes += value.second.increasedValueAttributes.size() *
176 num_bytes += value.second.decreasedValueAttributes.size() *
178 num_bytes +=
179 value.second.hintAttributes.size() * kBytesPerStringAttribute;
180 }
181 // The encoding defined here is used in:
182 //
183 // * AccessibilityBridge.java
184 // * AccessibilityBridgeTest.java
185 // * accessibility_bridge.mm
186 //
187 // If any of the encoding structure or length is changed, those locations
188 // must be updated (at a minimum).
189 std::vector<uint8_t> buffer(num_bytes);
190 int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&buffer[0]);
191 float* buffer_float32 = reinterpret_cast<float*>(&buffer[0]);
192
193 std::vector<std::string> strings;
194 std::vector<std::vector<uint8_t>> string_attribute_args;
195 size_t position = 0;
196 for (const auto& value : update) {
197 // If you edit this code, make sure you update kBytesPerNode
198 // and/or kBytesPerChild above to match the number of values you are
199 // sending.
200 const flutter::SemanticsNode& node = value.second;
201 buffer_int32[position++] = node.id;
202 int64_t flags = flagsToInt64(node.flags);
203 std::memcpy(&buffer_int32[position], &flags, 8);
204 position += 2;
205 buffer_int32[position++] = node.actions;
206 buffer_int32[position++] = node.maxValueLength;
207 buffer_int32[position++] = node.currentValueLength;
208 buffer_int32[position++] = node.textSelectionBase;
209 buffer_int32[position++] = node.textSelectionExtent;
210 buffer_int32[position++] = node.platformViewId;
211 buffer_int32[position++] = node.scrollChildren;
212 buffer_int32[position++] = node.scrollIndex;
213 buffer_int32[position++] = node.traversalParent;
214 buffer_float32[position++] = static_cast<float>(node.scrollPosition);
215 buffer_float32[position++] = static_cast<float>(node.scrollExtentMax);
216 buffer_float32[position++] = static_cast<float>(node.scrollExtentMin);
217 buffer_int32[position++] = static_cast<int32_t>(node.role);
218
219 putStringIntoBuffer(node.identifier, buffer_int32, &position, strings);
220
221 putStringIntoBuffer(node.label, buffer_int32, &position, strings);
222 putStringAttributesIntoBuffer(node.labelAttributes, buffer_int32,
223 &position, string_attribute_args);
224
225 putStringIntoBuffer(node.value, buffer_int32, &position, strings);
226 putStringAttributesIntoBuffer(node.valueAttributes, buffer_int32,
227 &position, string_attribute_args);
228
229 putStringIntoBuffer(node.increasedValue, buffer_int32, &position,
230 strings);
231 putStringAttributesIntoBuffer(node.increasedValueAttributes, buffer_int32,
232 &position, string_attribute_args);
233
234 putStringIntoBuffer(node.decreasedValue, buffer_int32, &position,
235 strings);
236 putStringAttributesIntoBuffer(node.decreasedValueAttributes, buffer_int32,
237 &position, string_attribute_args);
238
239 putStringIntoBuffer(node.hint, buffer_int32, &position, strings);
240 putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32,
241 &position, string_attribute_args);
242
243 putStringIntoBuffer(node.tooltip, buffer_int32, &position, strings);
244 putStringIntoBuffer(node.linkUrl, buffer_int32, &position, strings);
245 putStringIntoBuffer(node.locale, buffer_int32, &position, strings);
246 putStringIntoBuffer(node.minValue, buffer_int32, &position, strings);
247 putStringIntoBuffer(node.maxValue, buffer_int32, &position, strings);
248
249 buffer_int32[position++] = node.headingLevel;
250 buffer_int32[position++] = node.textDirection;
251 buffer_float32[position++] = node.rect.left();
252 buffer_float32[position++] = node.rect.top();
253 buffer_float32[position++] = node.rect.right();
254 buffer_float32[position++] = node.rect.bottom();
255 node.transform.getColMajor(&buffer_float32[position]);
256 position += 16;
257 node.hitTestTransform.getColMajor(&buffer_float32[position]);
258 position += 16;
259 buffer_int32[position++] = node.childrenInTraversalOrder.size();
260 for (int32_t child : node.childrenInTraversalOrder) {
261 buffer_int32[position++] = child;
262 }
263
264 buffer_int32[position++] = node.childrenInHitTestOrder.size();
265 for (int32_t child : node.childrenInHitTestOrder) {
266 buffer_int32[position++] = child;
267 }
268
269 buffer_int32[position++] = node.customAccessibilityActions.size();
270 for (int32_t child : node.customAccessibilityActions) {
271 buffer_int32[position++] = child;
272 }
273 }
274
275 // custom accessibility actions.
276 size_t num_action_bytes = actions.size() * kBytesPerAction;
277 std::vector<uint8_t> actions_buffer(num_action_bytes);
278 int32_t* actions_buffer_int32 =
279 reinterpret_cast<int32_t*>(&actions_buffer[0]);
280
281 std::vector<std::string> action_strings;
282 size_t actions_position = 0;
283 for (const auto& value : actions) {
284 // If you edit this code, make sure you update kBytesPerAction
285 // to match the number of values you are
286 // sending.
288 actions_buffer_int32[actions_position++] = action.id;
289 actions_buffer_int32[actions_position++] = action.overrideId;
290 putStringIntoBuffer(action.label, actions_buffer_int32, &actions_position,
291 action_strings);
292 putStringIntoBuffer(action.hint, actions_buffer_int32, &actions_position,
293 action_strings);
294 }
295
296 // Calling NewDirectByteBuffer in API level 22 and below with a size of zero
297 // will cause a JNI crash.
298 if (!actions_buffer.empty()) {
299 jni_facade_->FlutterViewUpdateCustomAccessibilityActions(actions_buffer,
300 action_strings);
301 }
302
303 if (!buffer.empty()) {
304 jni_facade_->FlutterViewUpdateSemantics(buffer, strings,
305 string_attribute_args);
306 }
307 }
308}
int32_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 disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
StringAttributes decreasedValueAttributes
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > customAccessibilityActions
std::vector< int32_t > childrenInTraversalOrder

References action, flutter::SemanticsNode::actions, flutter::buffer, flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::currentValueLength, flutter::SemanticsNode::customAccessibilityActions, flutter::SemanticsNode::decreasedValue, flutter::SemanticsNode::decreasedValueAttributes, flutter::SemanticsNode::flags, flutter::SemanticsNode::headingLevel, flutter::SemanticsNode::hint, flutter::SemanticsNode::hintAttributes, flutter::SemanticsNode::hitTestTransform, flutter::SemanticsNode::id, flutter::SemanticsNode::identifier, flutter::SemanticsNode::increasedValue, flutter::SemanticsNode::increasedValueAttributes, kBytesPerAction, kBytesPerChild, kBytesPerCustomAction, kBytesPerNode, kBytesPerStringAttribute, flutter::SemanticsNode::label, flutter::SemanticsNode::labelAttributes, flutter::SemanticsNode::linkUrl, flutter::SemanticsNode::locale, flutter::SemanticsNode::maxValue, flutter::SemanticsNode::maxValueLength, flutter::SemanticsNode::minValue, flutter::SemanticsNode::platformViewId, flutter::SemanticsNode::rect, flutter::SemanticsNode::role, flutter::SemanticsNode::scrollChildren, flutter::SemanticsNode::scrollExtentMax, flutter::SemanticsNode::scrollExtentMin, flutter::SemanticsNode::scrollIndex, flutter::SemanticsNode::scrollPosition, flutter::SemanticsNode::textDirection, flutter::SemanticsNode::textSelectionBase, flutter::SemanticsNode::textSelectionExtent, flutter::SemanticsNode::tooltip, flutter::SemanticsNode::transform, flutter::SemanticsNode::traversalParent, value, flutter::SemanticsNode::value, and flutter::SemanticsNode::valueAttributes.

Member Data Documentation

◆ kBytesPerAction

constexpr size_t flutter::PlatformViewAndroidDelegate::kBytesPerAction = 4 * sizeof(int32_t)
staticconstexpr

Definition at line 23 of file platform_view_android_delegate.h.

Referenced by flutter::testing::TEST(), and UpdateSemantics().

◆ kBytesPerChild

constexpr size_t flutter::PlatformViewAndroidDelegate::kBytesPerChild = sizeof(int32_t)
staticconstexpr

Definition at line 21 of file platform_view_android_delegate.h.

Referenced by UpdateSemantics().

◆ kBytesPerCustomAction

constexpr size_t flutter::PlatformViewAndroidDelegate::kBytesPerCustomAction = sizeof(int32_t)
staticconstexpr

Definition at line 22 of file platform_view_android_delegate.h.

Referenced by UpdateSemantics().

◆ kBytesPerNode

constexpr size_t flutter::PlatformViewAndroidDelegate::kBytesPerNode
staticconstexpr

◆ kBytesPerStringAttribute

constexpr size_t flutter::PlatformViewAndroidDelegate::kBytesPerStringAttribute = 4 * sizeof(int32_t)
staticconstexpr

Definition at line 24 of file platform_view_android_delegate.h.

Referenced by flutter::testing::TEST(), and UpdateSemantics().

◆ kEmptyStringIndex

constexpr int flutter::PlatformViewAndroidDelegate::kEmptyStringIndex = -1
staticconstexpr

Definition at line 25 of file platform_view_android_delegate.h.


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