@@ -30,7 +30,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
30
30
super .initInstances ();
31
31
_instance = this ;
32
32
_pipelineOwner = PipelineOwner (
33
- onNeedVisualUpdate: ensureVisualUpdate,
34
33
onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
35
34
onSemanticsUpdate: _handleSemanticsUpdate,
36
35
onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
@@ -45,8 +44,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
45
44
if (kIsWeb) {
46
45
addPostFrameCallback (_handleWebFirstFrame);
47
46
}
48
- addSemanticsEnabledListener (_handleSemanticsEnabledChanged);
49
- _handleSemanticsEnabledChanged ();
47
+ _pipelineOwner.attach (_manifold);
50
48
}
51
49
52
50
/// The current [RendererBinding] , if one has been created.
@@ -201,6 +199,8 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
201
199
}
202
200
}
203
201
202
+ late final PipelineManifold _manifold = _BindingPipelineManifold (this );
203
+
204
204
/// Creates a [RenderView] object to be the root of the
205
205
/// [RenderObject] rendering tree, and initializes it so that it
206
206
/// will be rendered when the next frame is requested.
@@ -330,17 +330,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
330
330
super .dispatchEvent (event, hitTestResult);
331
331
}
332
332
333
- SemanticsHandle ? _semanticsHandle;
334
-
335
- void _handleSemanticsEnabledChanged () {
336
- if (semanticsEnabled) {
337
- _semanticsHandle ?? = _pipelineOwner.ensureSemantics ();
338
- } else {
339
- _semanticsHandle? .dispose ();
340
- _semanticsHandle = null ;
341
- }
342
- }
343
-
344
333
@override
345
334
void performSemanticsAction (SemanticsActionEvent action) {
346
335
_pipelineOwner.semanticsOwner? .performAction (action.nodeId, action.type, action.arguments);
@@ -621,3 +610,26 @@ class RenderingFlutterBinding extends BindingBase with GestureBinding, Scheduler
621
610
return RendererBinding .instance;
622
611
}
623
612
}
613
+
614
+ /// A [PipelineManifold] implementation that is backed by the [RendererBinding] .
615
+ class _BindingPipelineManifold extends ChangeNotifier implements PipelineManifold {
616
+ _BindingPipelineManifold (this ._binding) {
617
+ _binding.addSemanticsEnabledListener (notifyListeners);
618
+ }
619
+
620
+ final RendererBinding _binding;
621
+
622
+ @override
623
+ void requestVisualUpdate () {
624
+ _binding.ensureVisualUpdate ();
625
+ }
626
+
627
+ @override
628
+ bool get semanticsEnabled => _binding.semanticsEnabled;
629
+
630
+ @override
631
+ void dispose () {
632
+ _binding.removeSemanticsEnabledListener (notifyListeners);
633
+ super .dispose ();
634
+ }
635
+ }
0 commit comments