Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7a23da1

Browse files
committed
Migrate the Windows embedder
1 parent f58d596 commit 7a23da1

File tree

4 files changed

+122
-4
lines changed

4 files changed

+122
-4
lines changed

shell/platform/common/accessibility_bridge.cc

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ AccessibilityBridge::~AccessibilityBridge() {
3636
tree_->RemoveObserver(static_cast<ui::AXTreeObserver*>(this));
3737
}
3838

39+
void AccessibilityBridge::AddFlutterSemanticsNodeUpdate(
40+
const FlutterSemanticsNode2* node) {
41+
pending_semantics_node_updates_[node->id] = FromFlutterSemanticsNode(node);
42+
}
43+
44+
void AccessibilityBridge::AddFlutterSemanticsCustomActionUpdate(
45+
const FlutterSemanticsCustomAction2* action) {
46+
pending_semantics_custom_action_updates_[action->id] =
47+
FromFlutterSemanticsCustomAction(action);
48+
}
49+
3950
void AccessibilityBridge::AddFlutterSemanticsNodeUpdate(
4051
const FlutterSemanticsNode* node) {
4152
pending_semantics_node_updates_[node->id] = FromFlutterSemanticsNode(node);
@@ -576,6 +587,74 @@ void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
576587
}
577588
}
578589

590+
AccessibilityBridge::SemanticsNode
591+
AccessibilityBridge::FromFlutterSemanticsNode(
592+
const FlutterSemanticsNode2* flutter_node) {
593+
SemanticsNode result;
594+
result.id = flutter_node->id;
595+
result.flags = flutter_node->flags;
596+
result.actions = flutter_node->actions;
597+
result.text_selection_base = flutter_node->text_selection_base;
598+
result.text_selection_extent = flutter_node->text_selection_extent;
599+
result.scroll_child_count = flutter_node->scroll_child_count;
600+
result.scroll_index = flutter_node->scroll_index;
601+
result.scroll_position = flutter_node->scroll_position;
602+
result.scroll_extent_max = flutter_node->scroll_extent_max;
603+
result.scroll_extent_min = flutter_node->scroll_extent_min;
604+
result.elevation = flutter_node->elevation;
605+
result.thickness = flutter_node->thickness;
606+
if (flutter_node->label) {
607+
result.label = std::string(flutter_node->label);
608+
}
609+
if (flutter_node->hint) {
610+
result.hint = std::string(flutter_node->hint);
611+
}
612+
if (flutter_node->value) {
613+
result.value = std::string(flutter_node->value);
614+
}
615+
if (flutter_node->increased_value) {
616+
result.increased_value = std::string(flutter_node->increased_value);
617+
}
618+
if (flutter_node->decreased_value) {
619+
result.decreased_value = std::string(flutter_node->decreased_value);
620+
}
621+
if (flutter_node->tooltip) {
622+
result.tooltip = std::string(flutter_node->tooltip);
623+
}
624+
result.text_direction = flutter_node->text_direction;
625+
result.rect = flutter_node->rect;
626+
result.transform = flutter_node->transform;
627+
if (flutter_node->child_count > 0) {
628+
result.children_in_traversal_order = std::vector<int32_t>(
629+
flutter_node->children_in_traversal_order,
630+
flutter_node->children_in_traversal_order + flutter_node->child_count);
631+
}
632+
if (flutter_node->custom_accessibility_actions_count > 0) {
633+
result.custom_accessibility_actions = std::vector<int32_t>(
634+
flutter_node->custom_accessibility_actions,
635+
flutter_node->custom_accessibility_actions +
636+
flutter_node->custom_accessibility_actions_count);
637+
}
638+
return result;
639+
}
640+
641+
AccessibilityBridge::SemanticsCustomAction
642+
AccessibilityBridge::FromFlutterSemanticsCustomAction(
643+
const FlutterSemanticsCustomAction2* flutter_custom_action) {
644+
SemanticsCustomAction result;
645+
result.id = flutter_custom_action->id;
646+
result.override_action = flutter_custom_action->override_action;
647+
if (flutter_custom_action->label) {
648+
result.label = std::string(flutter_custom_action->label);
649+
}
650+
if (flutter_custom_action->hint) {
651+
result.hint = std::string(flutter_custom_action->hint);
652+
}
653+
return result;
654+
}
655+
656+
// TODO(loicsharma): Remove this as FlutterSemanticsNode is deprecated.
657+
// See: https://github.com/flutter/flutter/issues/121176
579658
AccessibilityBridge::SemanticsNode
580659
AccessibilityBridge::FromFlutterSemanticsNode(
581660
const FlutterSemanticsNode* flutter_node) {
@@ -627,6 +706,9 @@ AccessibilityBridge::FromFlutterSemanticsNode(
627706
return result;
628707
}
629708

709+
// TODO(loicsharma): Remove this as FlutterSemanticsCustomAction is
710+
// deprecated.
711+
// See: https://github.com/flutter/flutter/issues/121176
630712
AccessibilityBridge::SemanticsCustomAction
631713
AccessibilityBridge::FromFlutterSemanticsCustomAction(
632714
const FlutterSemanticsCustomAction* flutter_custom_action) {

shell/platform/common/accessibility_bridge.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ class AccessibilityBridge
6161
/// To flush the pending updates, call the CommitUpdates().
6262
///
6363
/// @param[in] node A pointer to the semantics node update.
64+
void AddFlutterSemanticsNodeUpdate(const FlutterSemanticsNode2* node);
65+
66+
//------------------------------------------------------------------------------
67+
/// @brief Adds a custom semantics action update to the pending semantics
68+
/// update. Calling this method alone will NOT update the
69+
/// semantics tree. To flush the pending updates, call the
70+
/// CommitUpdates().
71+
///
72+
/// @param[in] action A pointer to the custom semantics action
73+
/// update.
74+
void AddFlutterSemanticsCustomActionUpdate(
75+
const FlutterSemanticsCustomAction2* action);
76+
77+
//------------------------------------------------------------------------------
78+
/// @brief Adds a semantics node update to the pending semantics update.
79+
/// Calling this method alone will NOT update the semantics tree.
80+
/// To flush the pending updates, call the CommitUpdates().
81+
///
82+
/// @param[in] node A pointer to the semantics node update.
83+
// TODO(loicsharma): Remove this as FlutterSemanticsNode is deprecated.
84+
// See: https://github.com/flutter/flutter/issues/121176
6485
void AddFlutterSemanticsNodeUpdate(const FlutterSemanticsNode* node);
6586

6687
//------------------------------------------------------------------------------
@@ -71,6 +92,9 @@ class AccessibilityBridge
7192
///
7293
/// @param[in] action A pointer to the custom semantics action
7394
/// update.
95+
// TODO(loicsharma): Remove this as FlutterSemanticsCustomAction is
96+
// deprecated.
97+
// See: https://github.com/flutter/flutter/issues/121176
7498
void AddFlutterSemanticsCustomActionUpdate(
7599
const FlutterSemanticsCustomAction* action);
76100

@@ -251,8 +275,19 @@ class AccessibilityBridge
251275
void SetTooltipFromFlutterUpdate(ui::AXNodeData& node_data,
252276
const SemanticsNode& node);
253277
void SetTreeData(const SemanticsNode& node, ui::AXTreeUpdate& tree_update);
278+
SemanticsNode FromFlutterSemanticsNode(
279+
const FlutterSemanticsNode2* flutter_node);
280+
SemanticsCustomAction FromFlutterSemanticsCustomAction(
281+
const FlutterSemanticsCustomAction2* flutter_custom_action);
282+
283+
// TODO(loicsharma): Remove this as FlutterSemanticsNode is deprecated.
284+
// See: https://github.com/flutter/flutter/issues/121176
254285
SemanticsNode FromFlutterSemanticsNode(
255286
const FlutterSemanticsNode* flutter_node);
287+
288+
// TODO(loicsharma): Remove this as FlutterSemanticsCustomAction is
289+
// deprecated.
290+
// See: https://github.com/flutter/flutter/issues/121176
256291
SemanticsCustomAction FromFlutterSemanticsCustomAction(
257292
const FlutterSemanticsCustomAction* flutter_custom_action);
258293

shell/platform/windows/flutter_windows_engine.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,17 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
327327
auto host = static_cast<FlutterWindowsEngine*>(user_data);
328328
host->OnPreEngineRestart();
329329
};
330-
args.update_semantics_callback = [](const FlutterSemanticsUpdate* update,
330+
args.update_semantics_callback2 = [](const FlutterSemanticsUpdate2* update,
331331
void* user_data) {
332332
auto host = static_cast<FlutterWindowsEngine*>(user_data);
333333

334334
for (size_t i = 0; i < update->nodes_count; i++) {
335-
const FlutterSemanticsNode* node = &update->nodes[i];
335+
const FlutterSemanticsNode2* node = update->nodes[i];
336336
host->accessibility_bridge_->AddFlutterSemanticsNodeUpdate(node);
337337
}
338338

339339
for (size_t i = 0; i < update->custom_actions_count; i++) {
340-
const FlutterSemanticsCustomAction* action = &update->custom_actions[i];
340+
const FlutterSemanticsCustomAction2* action = update->custom_actions[i];
341341
host->accessibility_bridge_->AddFlutterSemanticsCustomActionUpdate(
342342
action);
343343
}

shell/platform/windows/flutter_windows_engine_unittests.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ TEST_F(FlutterWindowsEngineTest, RunDoesExpectedInitialization) {
6060
EXPECT_NE(args->custom_task_runners->thread_priority_setter, nullptr);
6161
EXPECT_EQ(args->custom_dart_entrypoint, nullptr);
6262
EXPECT_NE(args->vsync_callback, nullptr);
63-
EXPECT_NE(args->update_semantics_callback, nullptr);
63+
EXPECT_EQ(args->update_semantics_callback, nullptr);
64+
EXPECT_NE(args->update_semantics_callback2, nullptr);
6465
EXPECT_EQ(args->update_semantics_node_callback, nullptr);
6566
EXPECT_EQ(args->update_semantics_custom_action_callback, nullptr);
6667

0 commit comments

Comments
 (0)