@@ -15,7 +15,6 @@ import 'package:flutter/semantics.dart';
15
15
16
16
import 'debug.dart' ;
17
17
import 'layer.dart' ;
18
- import 'proxy_box.dart' ;
19
18
20
19
export 'package:flutter/foundation.dart' show
21
20
DiagnosticPropertiesBuilder,
@@ -3228,15 +3227,14 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3228
3227
final SemanticsConfiguration config = _semanticsConfiguration;
3229
3228
bool dropSemanticsOfPreviousSiblings = config.isBlockingSemanticsOfPreviouslyPaintedNodes;
3230
3229
3231
- bool producesForkingFragment = ! config.hasBeenAnnotated && ! config.isSemanticBoundary;
3230
+ final bool producesForkingFragment = ! config.hasBeenAnnotated && ! config.isSemanticBoundary;
3232
3231
final bool childrenMergeIntoParent = mergeIntoParent || config.isMergingSemanticsOfDescendants;
3233
3232
final List <SemanticsConfiguration > childConfigurations = < SemanticsConfiguration > [];
3234
3233
final bool explicitChildNode = config.explicitChildNodes || parent is ! RenderObject ;
3235
3234
final bool hasChildConfigurationsDelegate = config.childConfigurationsDelegate != null ;
3236
3235
final Map <SemanticsConfiguration , _InterestingSemanticsFragment > configToFragment = < SemanticsConfiguration , _InterestingSemanticsFragment > {};
3237
3236
final List <_InterestingSemanticsFragment > mergeUpFragments = < _InterestingSemanticsFragment > [];
3238
3237
final List <List <_InterestingSemanticsFragment >> siblingMergeFragmentGroups = < List <_InterestingSemanticsFragment >> [];
3239
- final bool hasTags = config.tagsForChildren? .isNotEmpty ?? false ;
3240
3238
visitChildrenForSemantics ((RenderObject renderChild) {
3241
3239
assert (! _needsLayout);
3242
3240
final _SemanticsFragment parentFragment = renderChild._getSemanticsForParent (
@@ -3252,9 +3250,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3252
3250
}
3253
3251
for (final _InterestingSemanticsFragment fragment in parentFragment.mergeUpFragments) {
3254
3252
fragment.addAncestor (this );
3255
- if (hasTags) {
3256
- fragment.addTags (config.tagsForChildren! );
3257
- }
3253
+ fragment.addTags (config.tagsForChildren);
3258
3254
if (hasChildConfigurationsDelegate && fragment.config != null ) {
3259
3255
// This fragment need to go through delegate to determine whether it
3260
3256
// merge up or not.
@@ -3270,9 +3266,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3270
3266
for (final List <_InterestingSemanticsFragment > siblingMergeGroup in parentFragment.siblingMergeGroups) {
3271
3267
for (final _InterestingSemanticsFragment siblingMergingFragment in siblingMergeGroup) {
3272
3268
siblingMergingFragment.addAncestor (this );
3273
- if (hasTags) {
3274
- siblingMergingFragment.addTags (config.tagsForChildren! );
3275
- }
3269
+ siblingMergingFragment.addTags (config.tagsForChildren);
3276
3270
}
3277
3271
siblingMergeFragmentGroups.add (siblingMergeGroup);
3278
3272
}
@@ -3285,25 +3279,14 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3285
3279
for (final _InterestingSemanticsFragment fragment in mergeUpFragments) {
3286
3280
fragment.markAsExplicit ();
3287
3281
}
3288
- } else if (hasChildConfigurationsDelegate) {
3282
+ } else if (hasChildConfigurationsDelegate && childConfigurations.isNotEmpty ) {
3289
3283
final ChildSemanticsConfigurationsResult result = config.childConfigurationsDelegate !(childConfigurations);
3290
3284
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]! ),
3301
3286
);
3302
3287
for (final Iterable <SemanticsConfiguration > group in result.siblingMergeGroups) {
3303
3288
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 ()
3307
3290
);
3308
3291
}
3309
3292
}
@@ -4184,10 +4167,10 @@ abstract class _InterestingSemanticsFragment extends _SemanticsFragment {
4184
4167
Set <SemanticsTag >? _tagsForChildren;
4185
4168
4186
4169
/// 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
+ }
4191
4174
_tagsForChildren ?? = < SemanticsTag > {};
4192
4175
_tagsForChildren! .addAll (tags);
4193
4176
}
@@ -4281,48 +4264,6 @@ class _RootSemanticsFragment extends _InterestingSemanticsFragment {
4281
4264
}
4282
4265
}
4283
4266
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
-
4326
4267
/// An [_InterestingSemanticsFragment] that can be told to only add explicit
4327
4268
/// [SemanticsNode] s to the parent.
4328
4269
///
@@ -4601,14 +4542,6 @@ class _SwitchableSemanticsFragment extends _InterestingSemanticsFragment {
4601
4542
}
4602
4543
}
4603
4544
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
-
4612
4545
void _ensureConfigIsWritable () {
4613
4546
if (! _isConfigWritable) {
4614
4547
_config = _config.copy ();
0 commit comments