Flutter Engine
flutter::PlatformViewAndroidDelegate Class Reference

#include <platform_view_android_delegate.h>

Public Member Functions

 PlatformViewAndroidDelegate (std::shared_ptr< PlatformViewAndroidJNI > jni_facade)
 
void UpdateSemantics (flutter::SemanticsNodeUpdates update, 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 38 of file platform_view_android_delegate.cc.

40  : jni_facade_(jni_facade){};

Member Function Documentation

◆ UpdateSemantics()

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

Definition at line 42 of file platform_view_android_delegate.cc.

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::CustomAccessibilityAction::hint, flutter::SemanticsNode::hint, flutter::SemanticsNode::hintAttributes, flutter::CustomAccessibilityAction::id, flutter::SemanticsNode::id, flutter::SemanticsNode::increasedValue, flutter::SemanticsNode::increasedValueAttributes, flutter::CustomAccessibilityAction::label, flutter::SemanticsNode::label, flutter::SemanticsNode::labelAttributes, flutter::SemanticsNode::maxValueLength, node, flutter::CustomAccessibilityAction::overrideId, flutter::SemanticsNode::platformViewId, flutter::putStringAttributesIntoBuffer(), flutter::SemanticsNode::rect, 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, value, flutter::SemanticsNode::value, and flutter::SemanticsNode::valueAttributes.

Referenced by flutter::PlatformViewAndroid::DispatchSemanticsAction().

44  {
45  constexpr size_t kBytesPerNode = 47 * sizeof(int32_t);
46  constexpr size_t kBytesPerChild = sizeof(int32_t);
47  constexpr size_t kBytesPerCustomAction = sizeof(int32_t);
48  constexpr size_t kBytesPerAction = 4 * sizeof(int32_t);
49  constexpr size_t kBytesPerStringAttribute = 4 * sizeof(int32_t);
50 
51  {
52  size_t num_bytes = 0;
53  for (const auto& value : update) {
54  num_bytes += kBytesPerNode;
55  num_bytes +=
56  value.second.childrenInTraversalOrder.size() * kBytesPerChild;
57  num_bytes += value.second.childrenInHitTestOrder.size() * kBytesPerChild;
58  num_bytes += value.second.customAccessibilityActions.size() *
59  kBytesPerCustomAction;
60  num_bytes +=
61  value.second.labelAttributes.size() * kBytesPerStringAttribute;
62  num_bytes +=
63  value.second.valueAttributes.size() * kBytesPerStringAttribute;
64  num_bytes += value.second.increasedValueAttributes.size() *
65  kBytesPerStringAttribute;
66  num_bytes += value.second.decreasedValueAttributes.size() *
67  kBytesPerStringAttribute;
68  num_bytes +=
69  value.second.hintAttributes.size() * kBytesPerStringAttribute;
70  }
71  // The encoding defined here is used in:
72  //
73  // * AccessibilityBridge.java
74  // * AccessibilityBridgeTest.java
75  // * accessibility_bridge.mm
76  //
77  // If any of the encoding structure or length is changed, those locations
78  // must be updated (at a minimum).
79  std::vector<uint8_t> buffer(num_bytes);
80  int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&buffer[0]);
81  float* buffer_float32 = reinterpret_cast<float*>(&buffer[0]);
82 
83  std::vector<std::string> strings;
84  std::vector<std::vector<uint8_t>> string_attribute_args;
85  size_t position = 0;
86  for (const auto& value : update) {
87  // If you edit this code, make sure you update kBytesPerNode
88  // and/or kBytesPerChild above to match the number of values you are
89  // sending.
90  const flutter::SemanticsNode& node = value.second;
91  buffer_int32[position++] = node.id;
92  buffer_int32[position++] = node.flags;
93  buffer_int32[position++] = node.actions;
94  buffer_int32[position++] = node.maxValueLength;
95  buffer_int32[position++] = node.currentValueLength;
96  buffer_int32[position++] = node.textSelectionBase;
97  buffer_int32[position++] = node.textSelectionExtent;
98  buffer_int32[position++] = node.platformViewId;
99  buffer_int32[position++] = node.scrollChildren;
100  buffer_int32[position++] = node.scrollIndex;
101  buffer_float32[position++] = static_cast<float>(node.scrollPosition);
102  buffer_float32[position++] = static_cast<float>(node.scrollExtentMax);
103  buffer_float32[position++] = static_cast<float>(node.scrollExtentMin);
104  if (node.label.empty()) {
105  buffer_int32[position++] = -1;
106  } else {
107  buffer_int32[position++] = strings.size();
108  strings.push_back(node.label);
109  }
110 
112  position, string_attribute_args);
113  if (node.value.empty()) {
114  buffer_int32[position++] = -1;
115  } else {
116  buffer_int32[position++] = strings.size();
117  strings.push_back(node.value);
118  }
119 
121  position, string_attribute_args);
122  if (node.increasedValue.empty()) {
123  buffer_int32[position++] = -1;
124  } else {
125  buffer_int32[position++] = strings.size();
126  strings.push_back(node.increasedValue);
127  }
128 
130  position, string_attribute_args);
131  if (node.decreasedValue.empty()) {
132  buffer_int32[position++] = -1;
133  } else {
134  buffer_int32[position++] = strings.size();
135  strings.push_back(node.decreasedValue);
136  }
137 
139  position, string_attribute_args);
140 
141  if (node.hint.empty()) {
142  buffer_int32[position++] = -1;
143  } else {
144  buffer_int32[position++] = strings.size();
145  strings.push_back(node.hint);
146  }
147 
148  putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position,
149  string_attribute_args);
150 
151  if (node.tooltip.empty()) {
152  buffer_int32[position++] = -1;
153  } else {
154  buffer_int32[position++] = strings.size();
155  strings.push_back(node.tooltip);
156  }
157 
158  buffer_int32[position++] = node.textDirection;
159  buffer_float32[position++] = node.rect.left();
160  buffer_float32[position++] = node.rect.top();
161  buffer_float32[position++] = node.rect.right();
162  buffer_float32[position++] = node.rect.bottom();
163  node.transform.getColMajor(&buffer_float32[position]);
164  position += 16;
165 
166  buffer_int32[position++] = node.childrenInTraversalOrder.size();
167  for (int32_t child : node.childrenInTraversalOrder) {
168  buffer_int32[position++] = child;
169  }
170 
171  for (int32_t child : node.childrenInHitTestOrder) {
172  buffer_int32[position++] = child;
173  }
174 
175  buffer_int32[position++] = node.customAccessibilityActions.size();
176  for (int32_t child : node.customAccessibilityActions) {
177  buffer_int32[position++] = child;
178  }
179  }
180 
181  // custom accessibility actions.
182  size_t num_action_bytes = actions.size() * kBytesPerAction;
183  std::vector<uint8_t> actions_buffer(num_action_bytes);
184  int32_t* actions_buffer_int32 =
185  reinterpret_cast<int32_t*>(&actions_buffer[0]);
186 
187  std::vector<std::string> action_strings;
188  size_t actions_position = 0;
189  for (const auto& value : actions) {
190  // If you edit this code, make sure you update kBytesPerAction
191  // to match the number of values you are
192  // sending.
194  actions_buffer_int32[actions_position++] = action.id;
195  actions_buffer_int32[actions_position++] = action.overrideId;
196  if (action.label.empty()) {
197  actions_buffer_int32[actions_position++] = -1;
198  } else {
199  actions_buffer_int32[actions_position++] = action_strings.size();
200  action_strings.push_back(action.label);
201  }
202  if (action.hint.empty()) {
203  actions_buffer_int32[actions_position++] = -1;
204  } else {
205  actions_buffer_int32[actions_position++] = action_strings.size();
206  action_strings.push_back(action.hint);
207  }
208  }
209 
210  // Calling NewDirectByteBuffer in API level 22 and below with a size of zero
211  // will cause a JNI crash.
212  if (actions_buffer.size() > 0) {
213  jni_facade_->FlutterViewUpdateCustomAccessibilityActions(actions_buffer,
214  action_strings);
215  }
216 
217  if (buffer.size() > 0) {
218  jni_facade_->FlutterViewUpdateSemantics(buffer, strings,
219  string_attribute_args);
220  }
221  }
222 }
StringAttributes increasedValueAttributes
std::vector< int32_t > childrenInHitTestOrder
StringAttributes decreasedValueAttributes
std::vector< int32_t > customAccessibilityActions
std::vector< int32_t > childrenInTraversalOrder
uint8_t value
StringAttributes valueAttributes
SemanticsAction action
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 observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory host is set endless trace buffer
Definition: switches.h:98
StringAttributes hintAttributes
void putStringAttributesIntoBuffer(const StringAttributes &attributes, int32_t *buffer_int32, size_t &position, std::vector< std::vector< uint8_t >> &string_attribute_args)
StringAttributes labelAttributes

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