Skip to content

Commit

Permalink
Revert "Introduce the PipelineOwner tree (flutter#122231)" (flutter#1…
Browse files Browse the repository at this point in the history
…22425)

This reverts commit f73c358.
  • Loading branch information
flar authored and hangyujin committed Mar 11, 2023
1 parent 9165d12 commit 145f811
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1,341 deletions.
40 changes: 14 additions & 26 deletions packages/flutter/lib/src/rendering/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
super.initInstances();
_instance = this;
_pipelineOwner = PipelineOwner(
onNeedVisualUpdate: ensureVisualUpdate,
onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
onSemanticsUpdate: _handleSemanticsUpdate,
onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
Expand All @@ -44,7 +45,8 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
if (kIsWeb) {
addPostFrameCallback(_handleWebFirstFrame);
}
_pipelineOwner.attach(_manifold);
addSemanticsEnabledListener(_handleSemanticsEnabledChanged);
_handleSemanticsEnabledChanged();
}

/// The current [RendererBinding], if one has been created.
Expand Down Expand Up @@ -199,8 +201,6 @@ 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,6 +330,17 @@ 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 @@ -610,26 +621,3 @@ 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 145f811

Please sign in to comment.