mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
[flutter] elide semantic information from certain widget spans (#65857)
This commit is contained in:
parent
a48e14308e
commit
13fcedc7dc
|
@ -918,16 +918,18 @@ class RenderParagraph extends RenderBox
|
|||
);
|
||||
|
||||
if (info.isPlaceholder) {
|
||||
final SemanticsNode childNode = children.elementAt(placeholderIndex++);
|
||||
final TextParentData parentData = child!.parentData as TextParentData;
|
||||
childNode.rect = Rect.fromLTWH(
|
||||
childNode.rect.left,
|
||||
childNode.rect.top,
|
||||
childNode.rect.width * parentData.scale!,
|
||||
childNode.rect.height * parentData.scale!,
|
||||
);
|
||||
newChildren.add(childNode);
|
||||
child = childAfter(child);
|
||||
if (children.isNotEmpty) {
|
||||
final SemanticsNode childNode = children.elementAt(placeholderIndex++);
|
||||
final TextParentData parentData = child!.parentData as TextParentData;
|
||||
childNode.rect = Rect.fromLTWH(
|
||||
childNode.rect.left,
|
||||
childNode.rect.top,
|
||||
childNode.rect.width * parentData.scale!,
|
||||
childNode.rect.height * parentData.scale!,
|
||||
);
|
||||
newChildren.add(childNode);
|
||||
child = childAfter(child);
|
||||
}
|
||||
} else {
|
||||
final SemanticsConfiguration configuration = SemanticsConfiguration()
|
||||
..sortKey = OrdinalSortKey(ordinal++)
|
||||
|
|
|
@ -958,6 +958,53 @@ void main() {
|
|||
paragraph.layout(const ui.ParagraphConstraints(width: 1000));
|
||||
expect(paragraph.getBoxesForRange(2, 2), isEmpty);
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/65818
|
||||
testWidgets('WidgetSpans with no semantic information are elided from semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
// Without the fix for this bug the pump widget will throw a RangeError.
|
||||
await tester.pumpWidget(
|
||||
RichText(
|
||||
textDirection: TextDirection.ltr,
|
||||
text: TextSpan(children: <InlineSpan>[
|
||||
const WidgetSpan(child: SizedBox.shrink()),
|
||||
TextSpan(
|
||||
text: 'HELLO',
|
||||
style: const TextStyle(color: Colors.black),
|
||||
recognizer: TapGestureRecognizer()..onTap = () {},
|
||||
)
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics, hasSemantics(TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
id: 1,
|
||||
rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0),
|
||||
transform: Matrix4(
|
||||
3.0,0.0,0.0,0.0,
|
||||
0.0,3.0,0.0,0.0,
|
||||
0.0,0.0,1.0,0.0,
|
||||
0.0,0.0,0.0,1.0,
|
||||
),
|
||||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
rect: const Rect.fromLTRB(-4.0, -4.0, 74.0, 18.0),
|
||||
id: 2,
|
||||
label: 'HELLO',
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isLink,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)));
|
||||
}, semanticsEnabled: true, skip: isBrowser); // Browser semantics have different sizes.
|
||||
}
|
||||
|
||||
Future<void> _pumpTextWidget({ WidgetTester tester, String text, TextOverflow overflow }) {
|
||||
|
|
Loading…
Reference in a new issue