Skip to content

Commit f73c358

Browse files
authored
Introduce the PipelineOwner tree (#122231)
Introduce the PipelineOwner tree
1 parent b4019f9 commit f73c358

File tree

6 files changed

+1341
-34
lines changed

6 files changed

+1341
-34
lines changed

packages/flutter/lib/src/rendering/binding.dart

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
3030
super.initInstances();
3131
_instance = this;
3232
_pipelineOwner = PipelineOwner(
33-
onNeedVisualUpdate: ensureVisualUpdate,
3433
onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
3534
onSemanticsUpdate: _handleSemanticsUpdate,
3635
onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
@@ -45,8 +44,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
4544
if (kIsWeb) {
4645
addPostFrameCallback(_handleWebFirstFrame);
4746
}
48-
addSemanticsEnabledListener(_handleSemanticsEnabledChanged);
49-
_handleSemanticsEnabledChanged();
47+
_pipelineOwner.attach(_manifold);
5048
}
5149

5250
/// The current [RendererBinding], if one has been created.
@@ -201,6 +199,8 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
201199
}
202200
}
203201

202+
late final PipelineManifold _manifold = _BindingPipelineManifold(this);
203+
204204
/// Creates a [RenderView] object to be the root of the
205205
/// [RenderObject] rendering tree, and initializes it so that it
206206
/// will be rendered when the next frame is requested.
@@ -330,17 +330,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
330330
super.dispatchEvent(event, hitTestResult);
331331
}
332332

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-
344333
@override
345334
void performSemanticsAction(SemanticsActionEvent action) {
346335
_pipelineOwner.semanticsOwner?.performAction(action.nodeId, action.type, action.arguments);
@@ -621,3 +610,26 @@ class RenderingFlutterBinding extends BindingBase with GestureBinding, Scheduler
621610
return RendererBinding.instance;
622611
}
623612
}
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

Comments
 (0)