@@ -15,7 +15,6 @@ import 'package:flutter/semantics.dart';
1515
1616import 'debug.dart' ;
1717import 'layer.dart' ;
18- import 'proxy_box.dart' ;
1918
2019export 'package:flutter/foundation.dart' show
2120 DiagnosticPropertiesBuilder,
@@ -3228,15 +3227,14 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
32283227 final SemanticsConfiguration config = _semanticsConfiguration;
32293228 bool dropSemanticsOfPreviousSiblings = config.isBlockingSemanticsOfPreviouslyPaintedNodes;
32303229
3231- bool producesForkingFragment = ! config.hasBeenAnnotated && ! config.isSemanticBoundary;
3230+ final bool producesForkingFragment = ! config.hasBeenAnnotated && ! config.isSemanticBoundary;
32323231 final bool childrenMergeIntoParent = mergeIntoParent || config.isMergingSemanticsOfDescendants;
32333232 final List <SemanticsConfiguration > childConfigurations = < SemanticsConfiguration > [];
32343233 final bool explicitChildNode = config.explicitChildNodes || parent is ! RenderObject ;
32353234 final bool hasChildConfigurationsDelegate = config.childConfigurationsDelegate != null ;
32363235 final Map <SemanticsConfiguration , _InterestingSemanticsFragment > configToFragment = < SemanticsConfiguration , _InterestingSemanticsFragment > {};
32373236 final List <_InterestingSemanticsFragment > mergeUpFragments = < _InterestingSemanticsFragment > [];
32383237 final List <List <_InterestingSemanticsFragment >> siblingMergeFragmentGroups = < List <_InterestingSemanticsFragment >> [];
3239- final bool hasTags = config.tagsForChildren? .isNotEmpty ?? false ;
32403238 visitChildrenForSemantics ((RenderObject renderChild) {
32413239 assert (! _needsLayout);
32423240 final _SemanticsFragment parentFragment = renderChild._getSemanticsForParent (
@@ -3252,9 +3250,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
32523250 }
32533251 for (final _InterestingSemanticsFragment fragment in parentFragment.mergeUpFragments) {
32543252 fragment.addAncestor (this );
3255- if (hasTags) {
3256- fragment.addTags (config.tagsForChildren! );
3257- }
3253+ fragment.addTags (config.tagsForChildren);
32583254 if (hasChildConfigurationsDelegate && fragment.config != null ) {
32593255 // This fragment need to go through delegate to determine whether it
32603256 // merge up or not.
@@ -3270,9 +3266,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
32703266 for (final List <_InterestingSemanticsFragment > siblingMergeGroup in parentFragment.siblingMergeGroups) {
32713267 for (final _InterestingSemanticsFragment siblingMergingFragment in siblingMergeGroup) {
32723268 siblingMergingFragment.addAncestor (this );
3273- if (hasTags) {
3274- siblingMergingFragment.addTags (config.tagsForChildren! );
3275- }
3269+ siblingMergingFragment.addTags (config.tagsForChildren);
32763270 }
32773271 siblingMergeFragmentGroups.add (siblingMergeGroup);
32783272 }
@@ -3285,25 +3279,14 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
32853279 for (final _InterestingSemanticsFragment fragment in mergeUpFragments) {
32863280 fragment.markAsExplicit ();
32873281 }
3288- } else if (hasChildConfigurationsDelegate) {
3282+ } else if (hasChildConfigurationsDelegate && childConfigurations.isNotEmpty ) {
32893283 final ChildSemanticsConfigurationsResult result = config.childConfigurationsDelegate !(childConfigurations);
32903284 mergeUpFragments.addAll (
3291- result.mergeUp.map <_InterestingSemanticsFragment >((SemanticsConfiguration config) {
3292- final _InterestingSemanticsFragment ? fragment = configToFragment[config];
3293- if (fragment == null ) {
3294- // Parent fragment of Incomplete fragments can't be a forking
3295- // fragment since they need to be merged.
3296- producesForkingFragment = false ;
3297- return _IncompleteSemanticsFragment (config: config, owner: this );
3298- }
3299- return fragment;
3300- }),
3285+ result.mergeUp.map <_InterestingSemanticsFragment >((SemanticsConfiguration config) => configToFragment[config]! ),
33013286 );
33023287 for (final Iterable <SemanticsConfiguration > group in result.siblingMergeGroups) {
33033288 siblingMergeFragmentGroups.add (
3304- group.map <_InterestingSemanticsFragment >((SemanticsConfiguration config) {
3305- return configToFragment[config] ?? _IncompleteSemanticsFragment (config: config, owner: this );
3306- }).toList (),
3289+ group.map <_InterestingSemanticsFragment >((SemanticsConfiguration config) => configToFragment[config]! ).toList ()
33073290 );
33083291 }
33093292 }
@@ -4184,10 +4167,10 @@ abstract class _InterestingSemanticsFragment extends _SemanticsFragment {
41844167 Set <SemanticsTag >? _tagsForChildren;
41854168
41864169 /// Tag all children produced by [compileChildren] with `tags` .
4187- ///
4188- /// ` tags` must not be empty.
4189- void addTags ( Iterable < SemanticsTag > tags) {
4190- assert (tags.isNotEmpty);
4170+ void addTags ( Iterable < SemanticsTag > ? tags) {
4171+ if ( tags == null || tags.isEmpty) {
4172+ return ;
4173+ }
41914174 _tagsForChildren ?? = < SemanticsTag > {};
41924175 _tagsForChildren! .addAll (tags);
41934176 }
@@ -4281,48 +4264,6 @@ class _RootSemanticsFragment extends _InterestingSemanticsFragment {
42814264 }
42824265}
42834266
4284- /// A fragment with partial information that must not form an explicit
4285- /// semantics node without merging into another _SwitchableSemanticsFragment.
4286- ///
4287- /// This fragment is generated from synthetic SemanticsConfiguration returned from
4288- /// [SemanticsConfiguration.childConfigurationsDelegate] .
4289- class _IncompleteSemanticsFragment extends _InterestingSemanticsFragment {
4290- _IncompleteSemanticsFragment ({
4291- required this .config,
4292- required super .owner,
4293- }) : super (dropsSemanticsOfPreviousSiblings: false );
4294-
4295- @override
4296- void addAll (Iterable <_InterestingSemanticsFragment > fragments) {
4297- assert (false , 'This fragment must be a leaf node' );
4298- }
4299-
4300- @override
4301- void compileChildren ({
4302- required Rect ? parentSemanticsClipRect,
4303- required Rect ? parentPaintClipRect,
4304- required double elevationAdjustment,
4305- required List <SemanticsNode > result,
4306- required List <SemanticsNode > siblingNodes,
4307- }) {
4308- // There is nothing to do because this fragment must be a leaf node and
4309- // must not be explicit.
4310- }
4311-
4312- @override
4313- final SemanticsConfiguration config;
4314-
4315- @override
4316- void markAsExplicit () {
4317- assert (
4318- false ,
4319- 'SemanticsConfiguration created in '
4320- 'SemanticsConfiguration.childConfigurationsDelegate must not produce '
4321- 'its own semantics node'
4322- );
4323- }
4324- }
4325-
43264267/// An [_InterestingSemanticsFragment] that can be told to only add explicit
43274268/// [SemanticsNode] s to the parent.
43284269///
@@ -4601,14 +4542,6 @@ class _SwitchableSemanticsFragment extends _InterestingSemanticsFragment {
46014542 }
46024543 }
46034544
4604- @override
4605- void addTags (Iterable <SemanticsTag > tags) {
4606- super .addTags (tags);
4607- // _ContainerSemanticsFragments add their tags to child fragments through
4608- // this method. This fragment must make sure its _config is in sync.
4609- tags.forEach (_config.addTagForChildren);
4610- }
4611-
46124545 void _ensureConfigIsWritable () {
46134546 if (! _isConfigWritable) {
46144547 _config = _config.copy ();
0 commit comments