Skip to content

Commit

Permalink
Reland "Introduce the PipelineOwner tree (#122231)" (#122452)
Browse files Browse the repository at this point in the history
Reland "Introduce the PipelineOwner tree (#122231)"
  • Loading branch information
goderbauer committed Mar 13, 2023
1 parent 53a1823 commit 12ef753
Show file tree
Hide file tree
Showing 6 changed files with 1,241 additions and 34 deletions.
40 changes: 26 additions & 14 deletions packages/flutter/lib/src/rendering/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
super.initInstances();
_instance = this;
_pipelineOwner = PipelineOwner(
onNeedVisualUpdate: ensureVisualUpdate,
onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
onSemanticsUpdate: _handleSemanticsUpdate,
onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
Expand All @@ -45,8 +44,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
if (kIsWeb) {
addPostFrameCallback(_handleWebFirstFrame);
}
addSemanticsEnabledListener(_handleSemanticsEnabledChanged);
_handleSemanticsEnabledChanged();
_pipelineOwner.attach(_manifold);
}

/// The current [RendererBinding], if one has been created.
Expand Down Expand Up @@ -201,6 +199,8 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}
}

late final PipelineManifold _manifold = _BindingPipelineManifold(this);

/// Creates a [RenderView] object to be the root of the
/// [RenderObject] rendering tree, and initializes it so that it
/// will be rendered when the next frame is requested.
Expand Down Expand Up @@ -330,17 +330,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
super.dispatchEvent(event, hitTestResult);
}

SemanticsHandle? _semanticsHandle;

void _handleSemanticsEnabledChanged() {
if (semanticsEnabled) {
_semanticsHandle ??= _pipelineOwner.ensureSemantics();
} else {
_semanticsHandle?.dispose();
_semanticsHandle = null;
}
}

@override
void performSemanticsAction(SemanticsActionEvent action) {
_pipelineOwner.semanticsOwner?.performAction(action.nodeId, action.type, action.arguments);
Expand Down Expand Up @@ -621,3 +610,26 @@ class RenderingFlutterBinding extends BindingBase with GestureBinding, Scheduler
return RendererBinding.instance;
}
}

/// A [PipelineManifold] implementation that is backed by the [RendererBinding].
class _BindingPipelineManifold extends ChangeNotifier implements PipelineManifold {
_BindingPipelineManifold(this._binding) {
_binding.addSemanticsEnabledListener(notifyListeners);
}

final RendererBinding _binding;

@override
void requestVisualUpdate() {
_binding.ensureVisualUpdate();
}

@override
bool get semanticsEnabled => _binding.semanticsEnabled;

@override
void dispose() {
_binding.removeSemanticsEnabledListener(notifyListeners);
super.dispose();
}
}
Loading

0 comments on commit 12ef753

Please sign in to comment.