Skip to content

Commit e9d7bf8

Browse files
authored
Revert "Send nextId in addition to previousId for traversal order" (flutter#14691)
1 parent 3023fe2 commit e9d7bf8

File tree

6 files changed

+13
-97
lines changed

6 files changed

+13
-97
lines changed

bin/internal/engine.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
36a9c343b7c5ec361b60c37d154071146daeeea7
1+
f5a4a9378740c3d5996583a9ed1f7e28ff08ee85

packages/flutter/lib/src/semantics/semantics.dart

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class SemanticsData extends Diagnosticable {
9292
@required this.decreasedValue,
9393
@required this.hint,
9494
@required this.textDirection,
95-
@required this.nextNodeId,
9695
@required this.previousNodeId,
9796
@required this.rect,
9897
@required this.textSelection,
@@ -152,10 +151,6 @@ class SemanticsData extends Diagnosticable {
152151
/// [increasedValue], and [decreasedValue].
153152
final TextDirection textDirection;
154153

155-
/// The index indicating the ID of the next node in the traversal order after
156-
/// this node for the platform's accessibility services.
157-
final int nextNodeId;
158-
159154
/// The index indicating the ID of the previous node in the traversal order before
160155
/// this node for the platform's accessibility services.
161156
final int previousNodeId;
@@ -242,7 +237,6 @@ class SemanticsData extends Diagnosticable {
242237
properties.add(new StringProperty('decreasedValue', decreasedValue, defaultValue: ''));
243238
properties.add(new StringProperty('hint', hint, defaultValue: ''));
244239
properties.add(new EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
245-
properties.add(new IntProperty('nextNodeId', nextNodeId, defaultValue: null));
246240
properties.add(new IntProperty('previousNodeId', previousNodeId, defaultValue: null));
247241
if (textSelection?.isValid == true)
248242
properties.add(new MessageProperty('textSelection', '[${textSelection.start}, ${textSelection.end}]'));
@@ -264,7 +258,6 @@ class SemanticsData extends Diagnosticable {
264258
&& typedOther.decreasedValue == decreasedValue
265259
&& typedOther.hint == hint
266260
&& typedOther.textDirection == textDirection
267-
&& typedOther.nextNodeId == nextNodeId
268261
&& typedOther.previousNodeId == previousNodeId
269262
&& typedOther.rect == rect
270263
&& setEquals(typedOther.tags, tags)
@@ -276,7 +269,7 @@ class SemanticsData extends Diagnosticable {
276269
}
277270

278271
@override
279-
int get hashCode => ui.hashValues(flags, actions, label, value, increasedValue, decreasedValue, hint, textDirection, nextNodeId, previousNodeId, rect, tags, textSelection, scrollPosition, scrollExtentMax, scrollExtentMin, transform);
272+
int get hashCode => ui.hashValues(flags, actions, label, value, increasedValue, decreasedValue, hint, textDirection, previousNodeId, rect, tags, textSelection, scrollPosition, scrollExtentMax, scrollExtentMin, transform);
280273
}
281274

282275
class _SemanticsDiagnosticableNode extends DiagnosticableNode<SemanticsNode> {
@@ -1074,30 +1067,10 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
10741067

10751068
/// The sort order for ordering the traversal of [SemanticsNode]s by the
10761069
/// platform's accessibility services (e.g. VoiceOver on iOS and TalkBack on
1077-
/// Android). This is used to determine the [nextNodeId] and [previousNodeId]
1078-
/// during a semantics update.
1070+
/// Android). This is used to determine the [previousNodeId] during a semantics update.
10791071
SemanticsSortOrder _sortOrder;
10801072
SemanticsSortOrder get sortOrder => _sortOrder;
10811073

1082-
/// The ID of the next node in the traversal order after this node.
1083-
///
1084-
/// Only valid after at least one semantics update has been built.
1085-
///
1086-
/// This is the value passed to the engine to tell it what the order
1087-
/// should be for traversing semantics nodes.
1088-
///
1089-
/// If this is set to -1, it will indicate that there is no next node to
1090-
/// the engine (i.e. this is the last node in the sort order). When it is
1091-
/// null, it means that no semantics update has been built yet.
1092-
int _nextNodeId;
1093-
void _updateNextNodeId(int value) {
1094-
if (value == _nextNodeId)
1095-
return;
1096-
_nextNodeId = value;
1097-
_markDirty();
1098-
}
1099-
int get nextNodeId => _nextNodeId;
1100-
11011074
/// The ID of the previous node in the traversal order before this node.
11021075
///
11031076
/// Only valid after at least one semantics update has been built.
@@ -1221,7 +1194,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
12211194
String increasedValue = _increasedValue;
12221195
String decreasedValue = _decreasedValue;
12231196
TextDirection textDirection = _textDirection;
1224-
int nextNodeId = _nextNodeId;
12251197
int previousNodeId = _previousNodeId;
12261198
Set<SemanticsTag> mergedTags = tags == null ? null : new Set<SemanticsTag>.from(tags);
12271199
TextSelection textSelection = _textSelection;
@@ -1235,7 +1207,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
12351207
flags |= node._flags;
12361208
actions |= node._actionsAsBits;
12371209
textDirection ??= node._textDirection;
1238-
nextNodeId ??= node._nextNodeId;
12391210
previousNodeId ??= node._previousNodeId;
12401211
textSelection ??= node._textSelection;
12411212
scrollPosition ??= node._scrollPosition;
@@ -1276,7 +1247,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
12761247
decreasedValue: decreasedValue,
12771248
hint: hint,
12781249
textDirection: textDirection,
1279-
nextNodeId: nextNodeId,
12801250
previousNodeId: previousNodeId,
12811251
rect: rect,
12821252
transform: transform,
@@ -1319,7 +1289,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
13191289
increasedValue: data.increasedValue,
13201290
hint: data.hint,
13211291
textDirection: data.textDirection,
1322-
nextNodeId: data.nextNodeId,
13231292
previousNodeId: data.previousNodeId,
13241293
textSelectionBase: data.textSelection != null ? data.textSelection.baseOffset : -1,
13251294
textSelectionExtent: data.textSelection != null ? data.textSelection.extentOffset : -1,
@@ -1394,7 +1363,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
13941363
properties.add(new StringProperty('decreasedValue', _decreasedValue, defaultValue: ''));
13951364
properties.add(new StringProperty('hint', _hint, defaultValue: ''));
13961365
properties.add(new EnumProperty<TextDirection>('textDirection', _textDirection, defaultValue: null));
1397-
properties.add(new IntProperty('nextNodeId', _nextNodeId, defaultValue: null));
13981366
properties.add(new IntProperty('previousNodeId', _previousNodeId, defaultValue: null));
13991367
properties.add(new DiagnosticsProperty<SemanticsSortOrder>('sortOrder', sortOrder, defaultValue: null));
14001368
if (_textSelection?.isValid == true)
@@ -1571,10 +1539,10 @@ class SemanticsOwner extends ChangeNotifier {
15711539
super.dispose();
15721540
}
15731541

1574-
// Updates the nextNodeId and previousNodeId IDs on the semantics nodes. These
1575-
// IDs are used on the platform side to order the nodes for traversal by the
1576-
// accessibility services. If the nextNodeId or previousNodeId for a node
1577-
// changes, the node will be marked as dirty.
1542+
// Updates the previousNodeId IDs on the semantics nodes. These IDs are used
1543+
// on the platform side to order the nodes for traversal by the accessibility
1544+
// services. If the previousNodeId for a node changes, the node will be marked as
1545+
// dirty.
15781546
void _updateTraversalOrder() {
15791547
final List<_TraversalSortNode> nodesInSemanticsTraversalOrder = <_TraversalSortNode>[];
15801548
SemanticsSortOrder currentSortOrder = new SemanticsSortOrder(keys: <SemanticsSortKey>[]);
@@ -1609,20 +1577,12 @@ class SemanticsOwner extends ChangeNotifier {
16091577
return true;
16101578
}
16111579
rootSemanticsNode.visitChildren(visitor);
1612-
1613-
if (nodesInSemanticsTraversalOrder.isEmpty)
1614-
return;
1615-
16161580
nodesInSemanticsTraversalOrder.sort();
1617-
_TraversalSortNode node = nodesInSemanticsTraversalOrder.removeLast();
1618-
node.node._updateNextNodeId(-1);
1619-
while (nodesInSemanticsTraversalOrder.isNotEmpty) {
1620-
final _TraversalSortNode previousNode = nodesInSemanticsTraversalOrder.removeLast();
1621-
node.node._updatePreviousNodeId(previousNode.node.id);
1622-
previousNode.node._updateNextNodeId(node.node.id);
1623-
node = previousNode;
1581+
int previousNodeId = -1;
1582+
for (_TraversalSortNode node in nodesInSemanticsTraversalOrder) {
1583+
node.node._updatePreviousNodeId(previousNodeId);
1584+
previousNodeId = node.node.id;
16241585
}
1625-
node.node._updatePreviousNodeId(-1);
16261586
}
16271587

16281588
/// Update the semantics using [Window.updateSemantics].

packages/flutter/test/semantics/semantics_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void main() {
348348

349349
expect(
350350
minimalProperties.toStringDeep(minLevel: DiagnosticLevel.hidden),
351-
'SemanticsNode#1(owner: null, isMergedIntoParent: false, mergeAllDescendantsIntoThisNode: false, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), actions: [], isInMutuallyExcusiveGroup: false, isSelected: false, isFocused: false, isButton: false, isTextField: false, invisible, label: "", value: "", increasedValue: "", decreasedValue: "", hint: "", textDirection: null, nextNodeId: null, previousNodeId: null, sortOrder: null, scrollExtentMin: null, scrollPosition: null, scrollExtentMax: null)\n'
351+
'SemanticsNode#1(owner: null, isMergedIntoParent: false, mergeAllDescendantsIntoThisNode: false, Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), actions: [], isInMutuallyExcusiveGroup: false, isSelected: false, isFocused: false, isButton: false, isTextField: false, invisible, label: "", value: "", increasedValue: "", decreasedValue: "", hint: "", textDirection: null, previousNodeId: null, sortOrder: null, scrollExtentMin: null, scrollPosition: null, scrollExtentMax: null)\n'
352352
);
353353

354354
final SemanticsConfiguration config = new SemanticsConfiguration()

packages/flutter/test/widgets/semantics_test.dart

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ void main() {
417417
rect: TestSemantics.fullScreen,
418418
actions: allActions.fold(0, (int previous, SemanticsAction action) => previous | action.index),
419419
previousNodeId: -1,
420-
nextNodeId: -1,
421420
),
422421
],
423422
);
@@ -614,59 +613,44 @@ void main() {
614613
expect(semanticsUpdateCount, 1);
615614
expect(semantics, hasSemantics(
616615
new TestSemantics(
617-
id: 0,
618616
children: <TestSemantics>[
619617
new TestSemantics(
620-
id: 2,
621-
nextNodeId: 5,
622618
previousNodeId: -1,
623619
children: <TestSemantics>[
624620
new TestSemantics(
625-
id: 3,
626621
label: r'Label 1',
627622
textDirection: TextDirection.ltr,
628-
nextNodeId: -1,
629623
previousNodeId: 4,
630624
),
631625
new TestSemantics(
632-
id: 4,
633626
label: r'Label 2',
634627
textDirection: TextDirection.ltr,
635-
nextNodeId: 3,
636628
previousNodeId: 6,
637629
),
638630
new TestSemantics(
639-
id: 5,
640-
nextNodeId: 8,
641631
previousNodeId: 2,
642632
children: <TestSemantics>[
643633
new TestSemantics(
644-
id: 6,
645634
label: r'Label 3',
646635
textDirection: TextDirection.ltr,
647-
nextNodeId: 4,
648636
previousNodeId: 7,
649637
),
650638
new TestSemantics(
651-
id: 7,
652639
label: r'Label 4',
653640
textDirection: TextDirection.ltr,
654-
nextNodeId: 6,
655641
previousNodeId: 8,
656642
),
657643
new TestSemantics(
658-
id: 8,
659644
label: r'Label 5',
660645
textDirection: TextDirection.ltr,
661-
nextNodeId: 7,
662646
previousNodeId: 5,
663647
),
664648
],
665649
),
666650
],
667651
),
668652
],
669-
), ignoreTransform: true, ignoreRect: true),
653+
), ignoreTransform: true, ignoreRect: true, ignoreId: true),
670654
);
671655
semantics.dispose();
672656
});
@@ -729,31 +713,26 @@ void main() {
729713
new TestSemantics(
730714
label: r'Label 1',
731715
textDirection: TextDirection.ltr,
732-
nextNodeId: -1,
733716
previousNodeId: 3,
734717
),
735718
new TestSemantics(
736719
label: r'Label 2',
737720
textDirection: TextDirection.ltr,
738-
nextNodeId: 2,
739721
previousNodeId: 4,
740722
),
741723
new TestSemantics(
742724
label: r'Label 3',
743725
textDirection: TextDirection.ltr,
744-
nextNodeId: 3,
745726
previousNodeId: 5,
746727
),
747728
new TestSemantics(
748729
label: r'Label 4',
749730
textDirection: TextDirection.ltr,
750-
nextNodeId: 4,
751731
previousNodeId: 6,
752732
),
753733
new TestSemantics(
754734
label: r'Label 5',
755735
textDirection: TextDirection.ltr,
756-
nextNodeId: 5,
757736
previousNodeId: -1,
758737
),
759738
],
@@ -823,37 +802,31 @@ void main() {
823802
new TestSemantics(
824803
children: <TestSemantics>[
825804
new TestSemantics(
826-
nextNodeId: 5,
827805
previousNodeId: -1,
828806
children: <TestSemantics>[
829807
new TestSemantics(
830808
label: r'Label 1',
831809
textDirection: TextDirection.ltr,
832-
nextNodeId: 7,
833810
previousNodeId: 5,
834811
),
835812
new TestSemantics(
836813
label: r'Label 2',
837814
textDirection: TextDirection.ltr,
838-
nextNodeId: -1,
839815
previousNodeId: 6,
840816
),
841817
new TestSemantics(
842818
label: r'Label 3',
843819
textDirection: TextDirection.ltr,
844-
nextNodeId: 3,
845820
previousNodeId: 2,
846821
),
847822
new TestSemantics(
848823
label: r'Label 4',
849824
textDirection: TextDirection.ltr,
850-
nextNodeId: 4,
851825
previousNodeId: 7,
852826
),
853827
new TestSemantics(
854828
label: r'Label 5',
855829
textDirection: TextDirection.ltr,
856-
nextNodeId: 6,
857830
previousNodeId: 3,
858831
),
859832
],

packages/flutter/test/widgets/semantics_tester.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class TestSemantics {
4343
this.decreasedValue: '',
4444
this.hint: '',
4545
this.textDirection,
46-
this.nextNodeId,
4746
this.previousNodeId,
4847
this.rect,
4948
this.transform,
@@ -72,7 +71,6 @@ class TestSemantics {
7271
this.hint: '',
7372
this.textDirection,
7473
this.previousNodeId,
75-
this.nextNodeId,
7674
this.transform,
7775
this.textSelection,
7876
this.children: const <TestSemantics>[],
@@ -108,7 +106,6 @@ class TestSemantics {
108106
this.increasedValue: '',
109107
this.decreasedValue: '',
110108
this.textDirection,
111-
this.nextNodeId,
112109
this.previousNodeId,
113110
this.rect,
114111
Matrix4 transform,
@@ -176,10 +173,6 @@ class TestSemantics {
176173
/// is also set.
177174
final TextDirection textDirection;
178175

179-
/// The ID of the node that is next in the semantics traversal order after
180-
/// this node.
181-
final int nextNodeId;
182-
183176
/// The ID of the node that is previous in the semantics traversal order before
184177
/// this node.
185178
final int previousNodeId;
@@ -265,8 +258,6 @@ class TestSemantics {
265258
return fail('expected node id $id to have hint "$hint" but found hint "${nodeData.hint}".');
266259
if (textDirection != null && textDirection != nodeData.textDirection)
267260
return fail('expected node id $id to have textDirection "$textDirection" but found "${nodeData.textDirection}".');
268-
if (nextNodeId != null && nextNodeId != nodeData.nextNodeId)
269-
return fail('expected node id $id to have nextNodeId "$nextNodeId" but found "${nodeData.nextNodeId}".');
270261
if (previousNodeId != null && previousNodeId != nodeData.previousNodeId)
271262
return fail('expected node id $id to have previousNodeId "$previousNodeId" but found "${nodeData.previousNodeId}".');
272263
if ((nodeData.label != '' || nodeData.value != '' || nodeData.hint != '' || node.increasedValue != '' || node.decreasedValue != '') && nodeData.textDirection == null)
@@ -320,8 +311,6 @@ class TestSemantics {
320311
buf.writeln('$indent hint: \'$hint\',');
321312
if (textDirection != null)
322313
buf.writeln('$indent textDirection: $textDirection,');
323-
if (nextNodeId != null)
324-
buf.writeln('$indent nextNodeId: $nextNodeId,');
325314
if (previousNodeId != null)
326315
buf.writeln('$indent previousNodeId: $previousNodeId,');
327316
if (textSelection?.isValid == true)
@@ -533,8 +522,6 @@ class SemanticsTester {
533522
buf.writeln(' hint: r\'${node.hint}\',');
534523
if (node.textDirection != null)
535524
buf.writeln(' textDirection: ${node.textDirection},');
536-
if (node.nextNodeId != null)
537-
buf.writeln(' nextNodeId: ${node.nextNodeId},');
538525
if (node.previousNodeId != null)
539526
buf.writeln(' previousNodeId: ${node.previousNodeId},');
540527

packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,14 @@ void _tests() {
105105
new TestSemantics(
106106
children: <TestSemantics>[
107107
new TestSemantics(
108-
nextNodeId: 4,
109108
previousNodeId: -1,
110109
children: <TestSemantics>[
111110
new TestSemantics(
112-
nextNodeId: 2,
113111
previousNodeId: 1,
114112
children: <TestSemantics>[
115113
new TestSemantics(
116114
label: r'Plain text',
117115
textDirection: TextDirection.ltr,
118-
nextNodeId: 3,
119116
previousNodeId: 4,
120117
),
121118
new TestSemantics(
@@ -127,7 +124,6 @@ void _tests() {
127124
decreasedValue: r'test-decreasedValue',
128125
hint: r'test-hint',
129126
textDirection: TextDirection.rtl,
130-
nextNodeId: -1,
131127
previousNodeId: 2,
132128
),
133129
],

0 commit comments

Comments
 (0)