@@ -1400,88 +1400,110 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
14001400 settings.log_tag = SAFE_ACCESS (args, log_tag, nullptr );
14011401 }
14021402
1403- flutter::PlatformViewEmbedder::UpdateSemanticsNodesCallback
1404- update_semantics_nodes_callback = nullptr ;
1403+ FlutterUpdateSemanticsNodeCallback update_semantics_node_callback = nullptr ;
14051404 if (SAFE_ACCESS (args, update_semantics_node_callback, nullptr ) != nullptr ) {
1406- update_semantics_nodes_callback =
1407- [ptr = args->update_semantics_node_callback ,
1408- user_data](flutter::SemanticsNodeUpdates update) {
1409- for (const auto & value : update) {
1410- const auto & node = value.second ;
1411- SkMatrix transform = node.transform .asM33 ();
1412- FlutterTransformation flutter_transform{
1413- transform.get (SkMatrix::kMScaleX ),
1414- transform.get (SkMatrix::kMSkewX ),
1415- transform.get (SkMatrix::kMTransX ),
1416- transform.get (SkMatrix::kMSkewY ),
1417- transform.get (SkMatrix::kMScaleY ),
1418- transform.get (SkMatrix::kMTransY ),
1419- transform.get (SkMatrix::kMPersp0 ),
1420- transform.get (SkMatrix::kMPersp1 ),
1421- transform.get (SkMatrix::kMPersp2 )};
1422- const FlutterSemanticsNode embedder_node{
1423- sizeof (FlutterSemanticsNode),
1424- node.id ,
1425- static_cast <FlutterSemanticsFlag>(node.flags ),
1426- static_cast <FlutterSemanticsAction>(node.actions ),
1427- node.textSelectionBase ,
1428- node.textSelectionExtent ,
1429- node.scrollChildren ,
1430- node.scrollIndex ,
1431- node.scrollPosition ,
1432- node.scrollExtentMax ,
1433- node.scrollExtentMin ,
1434- node.elevation ,
1435- node.thickness ,
1436- node.label .c_str (),
1437- node.hint .c_str (),
1438- node.value .c_str (),
1439- node.increasedValue .c_str (),
1440- node.decreasedValue .c_str (),
1441- static_cast <FlutterTextDirection>(node.textDirection ),
1442- FlutterRect{node.rect .fLeft , node.rect .fTop , node.rect .fRight ,
1443- node.rect .fBottom },
1444- flutter_transform,
1445- node.childrenInTraversalOrder .size (),
1446- node.childrenInTraversalOrder .data (),
1447- node.childrenInHitTestOrder .data (),
1448- node.customAccessibilityActions .size (),
1449- node.customAccessibilityActions .data (),
1450- node.platformViewId ,
1451- };
1452- ptr (&embedder_node, user_data);
1453- }
1454- const FlutterSemanticsNode batch_end_sentinel = {
1455- sizeof (FlutterSemanticsNode),
1456- kFlutterSemanticsNodeIdBatchEnd ,
1457- };
1458- ptr (&batch_end_sentinel, user_data);
1459- };
1405+ update_semantics_node_callback = args->update_semantics_node_callback ;
14601406 }
14611407
1462- flutter::PlatformViewEmbedder::UpdateSemanticsCustomActionsCallback
1463- update_semantics_custom_actions_callback = nullptr ;
1408+ FlutterUpdateSemanticsCustomActionCallback
1409+ update_semantics_custom_action_callback = nullptr ;
14641410 if (SAFE_ACCESS (args, update_semantics_custom_action_callback, nullptr ) !=
14651411 nullptr ) {
1466- update_semantics_custom_actions_callback =
1467- [ptr = args->update_semantics_custom_action_callback ,
1468- user_data](flutter::CustomAccessibilityActionUpdates actions) {
1469- for (const auto & value : actions) {
1470- const auto & action = value.second ;
1471- const FlutterSemanticsCustomAction embedder_action = {
1412+ update_semantics_custom_action_callback =
1413+ args->update_semantics_custom_action_callback ;
1414+ }
1415+
1416+ flutter::PlatformViewEmbedder::UpdateSemanticsCallback
1417+ update_semantics_callback = nullptr ;
1418+ if (update_semantics_node_callback != nullptr ||
1419+ update_semantics_custom_action_callback != nullptr ) {
1420+ update_semantics_callback =
1421+ [update_semantics_node_callback,
1422+ update_semantics_custom_action_callback,
1423+ user_data](flutter::SemanticsNodeUpdates update,
1424+ flutter::CustomAccessibilityActionUpdates actions) {
1425+ // First, queue all node and custom action updates.
1426+ if (update_semantics_node_callback != nullptr ) {
1427+ for (const auto & value : update) {
1428+ const auto & node = value.second ;
1429+ SkMatrix transform = node.transform .asM33 ();
1430+ FlutterTransformation flutter_transform{
1431+ transform.get (SkMatrix::kMScaleX ),
1432+ transform.get (SkMatrix::kMSkewX ),
1433+ transform.get (SkMatrix::kMTransX ),
1434+ transform.get (SkMatrix::kMSkewY ),
1435+ transform.get (SkMatrix::kMScaleY ),
1436+ transform.get (SkMatrix::kMTransY ),
1437+ transform.get (SkMatrix::kMPersp0 ),
1438+ transform.get (SkMatrix::kMPersp1 ),
1439+ transform.get (SkMatrix::kMPersp2 )};
1440+ const FlutterSemanticsNode embedder_node{
1441+ sizeof (FlutterSemanticsNode),
1442+ node.id ,
1443+ static_cast <FlutterSemanticsFlag>(node.flags ),
1444+ static_cast <FlutterSemanticsAction>(node.actions ),
1445+ node.textSelectionBase ,
1446+ node.textSelectionExtent ,
1447+ node.scrollChildren ,
1448+ node.scrollIndex ,
1449+ node.scrollPosition ,
1450+ node.scrollExtentMax ,
1451+ node.scrollExtentMin ,
1452+ node.elevation ,
1453+ node.thickness ,
1454+ node.label .c_str (),
1455+ node.hint .c_str (),
1456+ node.value .c_str (),
1457+ node.increasedValue .c_str (),
1458+ node.decreasedValue .c_str (),
1459+ static_cast <FlutterTextDirection>(node.textDirection ),
1460+ FlutterRect{node.rect .fLeft , node.rect .fTop , node.rect .fRight ,
1461+ node.rect .fBottom },
1462+ flutter_transform,
1463+ node.childrenInTraversalOrder .size (),
1464+ node.childrenInTraversalOrder .data (),
1465+ node.childrenInHitTestOrder .data (),
1466+ node.customAccessibilityActions .size (),
1467+ node.customAccessibilityActions .data (),
1468+ node.platformViewId ,
1469+ };
1470+ update_semantics_node_callback (&embedder_node, user_data);
1471+ }
1472+ }
1473+
1474+ if (update_semantics_custom_action_callback != nullptr ) {
1475+ for (const auto & value : actions) {
1476+ const auto & action = value.second ;
1477+ const FlutterSemanticsCustomAction embedder_action = {
1478+ sizeof (FlutterSemanticsCustomAction),
1479+ action.id ,
1480+ static_cast <FlutterSemanticsAction>(action.overrideId ),
1481+ action.label .c_str (),
1482+ action.hint .c_str (),
1483+ };
1484+ update_semantics_custom_action_callback (&embedder_action,
1485+ user_data);
1486+ }
1487+ }
1488+
1489+ // Second, mark node and action batches completed now that all
1490+ // updates are queued.
1491+ if (update_semantics_node_callback != nullptr ) {
1492+ const FlutterSemanticsNode batch_end_sentinel = {
1493+ sizeof (FlutterSemanticsNode),
1494+ kFlutterSemanticsNodeIdBatchEnd ,
1495+ };
1496+ update_semantics_node_callback (&batch_end_sentinel, user_data);
1497+ }
1498+
1499+ if (update_semantics_custom_action_callback != nullptr ) {
1500+ const FlutterSemanticsCustomAction batch_end_sentinel = {
14721501 sizeof (FlutterSemanticsCustomAction),
1473- action.id ,
1474- static_cast <FlutterSemanticsAction>(action.overrideId ),
1475- action.label .c_str (),
1476- action.hint .c_str (),
1502+ kFlutterSemanticsCustomActionIdBatchEnd ,
14771503 };
1478- ptr (&embedder_action, user_data);
1504+ update_semantics_custom_action_callback (&batch_end_sentinel,
1505+ user_data);
14791506 }
1480- const FlutterSemanticsCustomAction batch_end_sentinel = {
1481- sizeof (FlutterSemanticsCustomAction),
1482- kFlutterSemanticsCustomActionIdBatchEnd ,
1483- };
1484- ptr (&batch_end_sentinel, user_data);
14851507 };
14861508 }
14871509
@@ -1576,8 +1598,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
15761598
15771599 flutter::PlatformViewEmbedder::PlatformDispatchTable platform_dispatch_table =
15781600 {
1579- update_semantics_nodes_callback, //
1580- update_semantics_custom_actions_callback, //
1601+ update_semantics_callback, //
15811602 platform_message_response_callback, //
15821603 vsync_callback, //
15831604 compute_platform_resolved_locale_callback, //
0 commit comments