diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index 2a0cb13413367..508e001925866 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -805,7 +805,12 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { /// /// The returned object can be passed to [Window.updateSemantics] to actually /// update the semantics retained by the system. - SemanticsUpdate build() native 'SemanticsUpdateBuilder_build'; + SemanticsUpdate build() { + final SemanticsUpdate semanticsUpdate = SemanticsUpdate._(); + _build(semanticsUpdate); + return semanticsUpdate; + } + void _build(SemanticsUpdate outSemanticsUpdate) native 'SemanticsUpdateBuilder_build'; } /// An opaque object representing a batch of semantics updates. diff --git a/lib/ui/semantics/semantics_update.cc b/lib/ui/semantics/semantics_update.cc index e559af58aec61..c4ef22e34f7be 100644 --- a/lib/ui/semantics/semantics_update.cc +++ b/lib/ui/semantics/semantics_update.cc @@ -20,11 +20,12 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SemanticsUpdate); DART_BIND_ALL(SemanticsUpdate, FOR_EACH_BINDING) -fml::RefPtr SemanticsUpdate::create( - SemanticsNodeUpdates nodes, - CustomAccessibilityActionUpdates actions) { - return fml::MakeRefCounted(std::move(nodes), - std::move(actions)); +void SemanticsUpdate::create(Dart_Handle semantics_update_handle, + SemanticsNodeUpdates nodes, + CustomAccessibilityActionUpdates actions) { + auto semantics_update = fml::MakeRefCounted( + std::move(nodes), std::move(actions)); + semantics_update->AssociateWithDartWrapper(semantics_update_handle); } SemanticsUpdate::SemanticsUpdate(SemanticsNodeUpdates nodes, diff --git a/lib/ui/semantics/semantics_update.h b/lib/ui/semantics/semantics_update.h index 35ecbfbb9d510..c3411bb43bfaa 100644 --- a/lib/ui/semantics/semantics_update.h +++ b/lib/ui/semantics/semantics_update.h @@ -21,9 +21,9 @@ class SemanticsUpdate : public RefCountedDartWrappable { public: ~SemanticsUpdate() override; - static fml::RefPtr create( - SemanticsNodeUpdates nodes, - CustomAccessibilityActionUpdates actions); + static void create(Dart_Handle semantics_update_handle, + SemanticsNodeUpdates nodes, + CustomAccessibilityActionUpdates actions); SemanticsNodeUpdates takeNodes(); diff --git a/lib/ui/semantics/semantics_update_builder.cc b/lib/ui/semantics/semantics_update_builder.cc index 7048f6a45f44c..d3fc40deab19c 100644 --- a/lib/ui/semantics/semantics_update_builder.cc +++ b/lib/ui/semantics/semantics_update_builder.cc @@ -121,8 +121,9 @@ void SemanticsUpdateBuilder::updateCustomAction(int id, actions_[id] = action; } -fml::RefPtr SemanticsUpdateBuilder::build() { - return SemanticsUpdate::create(std::move(nodes_), std::move(actions_)); +void SemanticsUpdateBuilder::build(Dart_Handle semantics_update_handle) { + SemanticsUpdate::create(semantics_update_handle, std::move(nodes_), + std::move(actions_)); } } // namespace flutter diff --git a/lib/ui/semantics/semantics_update_builder.h b/lib/ui/semantics/semantics_update_builder.h index bbf595e631858..a183e1384b637 100644 --- a/lib/ui/semantics/semantics_update_builder.h +++ b/lib/ui/semantics/semantics_update_builder.h @@ -58,7 +58,7 @@ class SemanticsUpdateBuilder std::string hint, int overrideId); - fml::RefPtr build(); + void build(Dart_Handle semantics_update_handle); static void RegisterNatives(tonic::DartLibraryNatives* natives);