32std::unique_ptr<FlutterSemanticsFlags> ConvertToFlutterSemanticsFlags(
36 .is_selected = ToFlutterTristate(source.
isSelected),
37 .is_enabled = ToFlutterTristate(source.
isEnabled),
38 .is_toggled = ToFlutterTristate(source.
isToggled),
39 .is_expanded = ToFlutterTristate(source.
isExpanded),
40 .is_required = ToFlutterTristate(source.
isRequired),
41 .is_focused = ToFlutterTristate(source.
isFocused),
69 for (
const auto&
value : nodes) {
70 AddNode(
value.second);
73 for (
const auto&
value : actions) {
74 AddAction(
value.second);
79 .nodes_count = nodes_.size(),
80 .nodes = nodes_.data(),
81 .custom_actions_count = actions_.size(),
82 .custom_actions = actions_.data(),
189void EmbedderSemanticsUpdate::AddNode(
const SemanticsNode& node) {
190 SkMatrix
transform = node.transform.asM33();
206 node.textSelectionBase,
207 node.textSelectionExtent,
211 node.scrollExtentMax,
212 node.scrollExtentMin,
218 node.increasedValue.c_str(),
219 node.decreasedValue.c_str(),
221 FlutterRect{node.rect.fLeft, node.rect.fTop, node.rect.fRight,
224 node.childrenInTraversalOrder.size(),
225 node.childrenInTraversalOrder.data(),
226 node.childrenInHitTestOrder.data(),
227 node.customAccessibilityActions.size(),
228 node.customAccessibilityActions.data(),
230 node.tooltip.c_str(),
234void EmbedderSemanticsUpdate::AddAction(
235 const CustomAccessibilityAction&
action) {
254 nodes_.reserve(nodes.size());
255 flags_.reserve(nodes.size());
256 node_pointers_.reserve(nodes.size());
257 actions_.reserve(actions.size());
258 action_pointers_.reserve(actions.size());
260 for (
const auto&
value : nodes) {
261 AddNode(
value.second);
264 for (
const auto&
value : actions) {
265 AddAction(
value.second);
268 for (
size_t i = 0;
i < nodes_.size();
i++) {
269 node_pointers_.push_back(&nodes_[
i]);
272 for (
size_t i = 0;
i < actions_.size();
i++) {
273 action_pointers_.push_back(&actions_[
i]);
277 .node_count = node_pointers_.size(),
278 .nodes = node_pointers_.data(),
279 .custom_action_count = action_pointers_.size(),
280 .custom_actions = action_pointers_.data(),
286void EmbedderSemanticsUpdate2::AddNode(
const SemanticsNode& node) {
296 auto hint_attributes = CreateStringAttributes(node.
hintAttributes);
298 auto increased_value_attributes =
300 auto decreased_value_attributes =
302 flags_.emplace_back(ConvertToFlutterSemanticsFlags(node.
flags));
334 label_attributes.count,
335 label_attributes.attributes,
336 hint_attributes.count,
337 hint_attributes.attributes,
338 value_attributes.count,
339 value_attributes.attributes,
340 increased_value_attributes.count,
341 increased_value_attributes.attributes,
342 decreased_value_attributes.count,
343 decreased_value_attributes.attributes,
350void EmbedderSemanticsUpdate2::AddAction(
351 const CustomAccessibilityAction&
action) {
361EmbedderSemanticsUpdate2::EmbedderStringAttributes
362EmbedderSemanticsUpdate2::CreateStringAttributes(
365 if (attributes.empty()) {
366 return {.count = 0, .attributes =
nullptr};
375 auto result = std::make_unique<std::vector<const FlutterStringAttribute*>>();
376 result->reserve(attributes.size());
378 for (
const auto& attribute : attributes) {
379 auto embedder_attribute = std::make_unique<FlutterStringAttribute>();
381 embedder_attribute->start = attribute->start;
382 embedder_attribute->end = attribute->end;
384 switch (attribute->type) {
386 std::shared_ptr<flutter::LocaleStringAttribute> locale_attribute =
387 std::static_pointer_cast<flutter::LocaleStringAttribute>(attribute);
389 auto embedder_locale = std::make_unique<FlutterLocaleStringAttribute>();
391 embedder_locale->locale = locale_attribute->locale.c_str();
392 locale_attributes_.push_back(std::move(embedder_locale));
395 embedder_attribute->locale = locale_attributes_.back().get();
401 if (!spell_out_attribute_) {
402 auto spell_out_attribute_ =
403 std::make_unique<FlutterSpellOutStringAttribute>();
404 spell_out_attribute_->struct_size =
409 embedder_attribute->spell_out = spell_out_attribute_.get();
414 string_attributes_.push_back(std::move(embedder_attribute));
415 result->push_back(string_attributes_.back().get());
418 node_string_attributes_.push_back(std::move(result));
421 .count = node_string_attributes_.back()->size(),
422 .attributes = node_string_attributes_.back()->data(),
EmbedderSemanticsUpdate2(int64_t view_id, const SemanticsNodeUpdates &nodes, const CustomAccessibilityActionUpdates &actions)
~EmbedderSemanticsUpdate2()
EmbedderSemanticsUpdate(const SemanticsNodeUpdates &nodes, const CustomAccessibilityActionUpdates &actions)
~EmbedderSemanticsUpdate()
@ kFlutterCheckStateNone
The semantics node does not have check state.
@ kFlutterCheckStateTrue
The semantics node is checked.
@ kFlutterCheckStateFalse
The semantics node is not checked.
@ kFlutterCheckStateMixed
The semantics node represents a checkbox in mixed state.
@ kFlutterTristateTrue
The property is applicable and its state is "true" or "on".
@ kFlutterTristateFalse
The property is applicable and its state is "false" or "off".
@ kFlutterTristateNone
The property is not applicable to this semantics node.
G_BEGIN_DECLS FlutterViewId view_id
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
FlutterSemanticsFlag SemanticsFlagsToInt(const SemanticsFlags &flags)
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
std::vector< StringAttributePtr > StringAttributes
A structure to represent a rectangle.
FlutterCheckState is_checked
Whether a semantics node is checked.
A batch of updates to semantics nodes and custom actions.
size_t struct_size
The size of the struct. Must be sizeof(FlutterSemanticsUpdate2).
size_t struct_size
The size of the struct. Must be sizeof(FlutterSemanticsUpdate).
SemanticsTristate isExpanded
SemanticsCheckState isChecked
SemanticsTristate isRequired
bool isAccessibilityFocusBlocked
SemanticsTristate isFocused
SemanticsTristate isSelected
SemanticsTristate isToggled
SemanticsTristate isEnabled
bool isInMutuallyExclusiveGroup
bool hasImplicitScrolling
StringAttributes decreasedValueAttributes
std::string increasedValue
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInHitTestOrder
int32_t textSelectionExtent
std::vector< int32_t > customAccessibilityActions
std::string decreasedValue
std::vector< int32_t > childrenInTraversalOrder
int32_t textSelectionBase