Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/platform/darwin/macos/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
flutterArguments.command_line_argc = static_cast<int>(argv.size());
flutterArguments.command_line_argv = argv.empty() ? nullptr : argv.data();
flutterArguments.platform_message_callback = (FlutterPlatformMessageCallback)OnPlatformMessage;
flutterArguments.update_semantics_callback = [](const FlutterSemanticsUpdate* update,
void* user_data) {
flutterArguments.update_semantics_callback2 = [](const FlutterSemanticsUpdate2* update,
void* user_data) {
// TODO(dkwingsmt): This callback only supports single-view, therefore it
// only operates on the default view. To support multi-view, we need a
// way to pass in the ID (probably through FlutterSemanticsUpdate).
Expand Down
32 changes: 16 additions & 16 deletions shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
FlutterEngine* engine = GetFlutterEngine();
// Capture the update callbacks before the embedder API initializes.
auto original_init = engine.embedderAPI.Initialize;
std::function<void(const FlutterSemanticsUpdate*, void*)> update_semantics_callback;
std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
Initialize, ([&update_semantics_callback, &original_init](
size_t version, const FlutterRendererConfig* config,
const FlutterProjectArgs* args, void* user_data, auto engine_out) {
update_semantics_callback = args->update_semantics_callback;
update_semantics_callback = args->update_semantics_callback2;
return original_init(version, config, args, user_data, engine_out);
}));
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
Expand All @@ -222,7 +222,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
engine.semanticsEnabled = YES;
EXPECT_TRUE(enabled_called);
// Send flutter semantics updates.
FlutterSemanticsNode root;
FlutterSemanticsNode2 root;
Comment thread
cbracken marked this conversation as resolved.
root.id = 0;
root.flags = static_cast<FlutterSemanticsFlag>(0);
root.actions = static_cast<FlutterSemanticsAction>(0);
Expand All @@ -239,7 +239,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
root.children_in_traversal_order = children;
root.custom_accessibility_actions_count = 0;

FlutterSemanticsNode child1;
FlutterSemanticsNode2 child1;
child1.id = 1;
child1.flags = static_cast<FlutterSemanticsFlag>(0);
child1.actions = static_cast<FlutterSemanticsAction>(0);
Expand All @@ -254,11 +254,11 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
child1.child_count = 0;
child1.custom_accessibility_actions_count = 0;

FlutterSemanticsUpdate update;
update.nodes_count = 2;
FlutterSemanticsNode nodes[] = {root, child1};
FlutterSemanticsUpdate2 update;
update.node_count = 2;
FlutterSemanticsNode2* nodes[] = {&root, &child1};
update.nodes = nodes;
update.custom_actions_count = 0;
update.custom_action_count = 0;
update_semantics_callback(&update, (__bridge void*)engine);

// Verify the accessibility tree is attached to the flutter view.
Expand Down Expand Up @@ -292,12 +292,12 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
FlutterEngine* engine = GetFlutterEngine();
// Capture the update callbacks before the embedder API initializes.
auto original_init = engine.embedderAPI.Initialize;
std::function<void(const FlutterSemanticsUpdate*, void*)> update_semantics_callback;
std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
engine.embedderAPI.Initialize = MOCK_ENGINE_PROC(
Initialize, ([&update_semantics_callback, &original_init](
size_t version, const FlutterRendererConfig* config,
const FlutterProjectArgs* args, void* user_data, auto engine_out) {
update_semantics_callback = args->update_semantics_callback;
update_semantics_callback = args->update_semantics_callback2;
return original_init(version, config, args, user_data, engine_out);
}));
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
Expand All @@ -312,7 +312,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
engine.semanticsEnabled = YES;
EXPECT_TRUE(enabled_called);
// Send flutter semantics updates.
FlutterSemanticsNode root;
FlutterSemanticsNode2 root;
root.id = 0;
root.flags = static_cast<FlutterSemanticsFlag>(0);
root.actions = static_cast<FlutterSemanticsAction>(0);
Expand All @@ -329,7 +329,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
root.children_in_traversal_order = children;
root.custom_accessibility_actions_count = 0;

FlutterSemanticsNode child1;
FlutterSemanticsNode2 child1;
child1.id = 1;
child1.flags = static_cast<FlutterSemanticsFlag>(0);
child1.actions = static_cast<FlutterSemanticsAction>(0);
Expand All @@ -344,11 +344,11 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
child1.child_count = 0;
child1.custom_accessibility_actions_count = 0;

FlutterSemanticsUpdate update;
update.nodes_count = 2;
FlutterSemanticsNode nodes[] = {root, child1};
FlutterSemanticsUpdate2 update;
update.node_count = 2;
FlutterSemanticsNode2* nodes[] = {&root, &child1};
update.nodes = nodes;
update.custom_actions_count = 0;
update.custom_action_count = 0;
// This call updates semantics for the default view, which does not exist,
// and therefore this call is invalid. But the engine should not crash.
update_semantics_callback(&update, (__bridge void*)engine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,17 +498,19 @@ - (BOOL)attached {
return _engine != nil;
}

- (void)updateSemantics:(const FlutterSemanticsUpdate*)update {
- (void)updateSemantics:(const FlutterSemanticsUpdate2*)update {
NSAssert(_engine.semanticsEnabled, @"Semantics must be enabled.");
if (!_engine.semanticsEnabled) {
return;
}
for (size_t i = 0; i < update->nodes_count; i++) {
_bridge->AddFlutterSemanticsNodeUpdate(update->nodes[i]);
for (size_t i = 0; i < update->node_count; i++) {
const FlutterSemanticsNode2* node = update->nodes[i];
_bridge->AddFlutterSemanticsNodeUpdate((*node));
Comment thread
loic-sharma marked this conversation as resolved.
Outdated
}

for (size_t i = 0; i < update->custom_actions_count; i++) {
_bridge->AddFlutterSemanticsCustomActionUpdate(update->custom_actions[i]);
for (size_t i = 0; i < update->custom_action_count; i++) {
const FlutterSemanticsCustomAction2* action = update->custom_actions[i];
_bridge->AddFlutterSemanticsCustomActionUpdate(*action);
}

_bridge->CommitUpdates();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Notify from the framework that the semantics for this view needs to be
* updated.
*/
- (void)updateSemantics:(nonnull const FlutterSemanticsUpdate*)update;
- (void)updateSemantics:(nonnull const FlutterSemanticsUpdate2*)update;

@end

Expand Down