Unverified Commit 6a74be53 authored by Anthony's avatar Anthony Committed by GitHub

[a11y] Re-land Make sure RenderFractionalTranslation updates its semantics...

[a11y] Re-land Make sure RenderFractionalTranslation updates its semantics after the translation field is set (#49708)

Re-land Make sure RenderFractionalTranslation updates its semantics after the translation field is set
parent 1b4d321b
...@@ -2472,6 +2472,7 @@ class RenderFractionalTranslation extends RenderProxyBox { ...@@ -2472,6 +2472,7 @@ class RenderFractionalTranslation extends RenderProxyBox {
return; return;
_translation = value; _translation = value;
markNeedsPaint(); markNeedsPaint();
markNeedsSemanticsUpdate();
} }
@override @override
......
...@@ -481,6 +481,18 @@ void main() { ...@@ -481,6 +481,18 @@ void main() {
..onHover = (_) {}; ..onHover = (_) {};
// Passes if no error is thrown // Passes if no error is thrown
}); });
test('RenderFractionalTranslation updates its semantics after its translation value is set', () {
final _TestSemanticsUpdateRenderFractionalTranslation box = _TestSemanticsUpdateRenderFractionalTranslation(
translation: const Offset(0.5, 0.5),
);
layout(box, constraints: BoxConstraints.tight(const Size(200.0, 200.0)));
expect(box.markNeedsSemanticsUpdateCallCount, 1);
box.translation = const Offset(0.4, 0.4);
expect(box.markNeedsSemanticsUpdateCallCount, 2);
box.translation = const Offset(0.3, 0.3);
expect(box.markNeedsSemanticsUpdateCallCount, 3);
});
} }
class _TestRectClipper extends CustomClipper<Rect> { class _TestRectClipper extends CustomClipper<Rect> {
...@@ -537,3 +549,18 @@ class _TestPathClipper extends CustomClipper<Path> { ...@@ -537,3 +549,18 @@ class _TestPathClipper extends CustomClipper<Path> {
@override @override
bool shouldReclip(_TestPathClipper oldClipper) => false; bool shouldReclip(_TestPathClipper oldClipper) => false;
} }
class _TestSemanticsUpdateRenderFractionalTranslation extends RenderFractionalTranslation {
_TestSemanticsUpdateRenderFractionalTranslation({
@required Offset translation,
RenderBox child,
}) : super(translation: translation, child: child);
int markNeedsSemanticsUpdateCallCount = 0;
@override
void markNeedsSemanticsUpdate() {
markNeedsSemanticsUpdateCallCount++;
super.markNeedsSemanticsUpdate();
}
}
...@@ -145,6 +145,69 @@ void main() { ...@@ -145,6 +145,69 @@ void main() {
await tester.tap(find.byKey(key1)); await tester.tap(find.byKey(key1));
expect(_pointerDown, isTrue); expect(_pointerDown, isTrue);
}); });
testWidgets('semantics bounds are updated', (WidgetTester tester) async {
final GlobalKey fractionalTranslationKey = GlobalKey();
final GlobalKey textKey = GlobalKey();
Offset offset = const Offset(0.4, 0.4);
await tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Semantics(
explicitChildNodes: true,
child: FractionalTranslation(
key: fractionalTranslationKey,
translation: offset,
transformHitTests: true,
child: GestureDetector(
onTap: () {
setState(() {
offset = const Offset(0.8, 0.8);
});
},
child: SizedBox(
width: 100.0,
height: 100.0,
child: Text(
'foo',
key: textKey,
),
),
),
),
),
),
);
},
)
);
expect(
tester.getSemantics(find.byKey(textKey)).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,
1170.0, 870.0, 0.0, 1.0,
),
);
await tester.tap(find.byKey(fractionalTranslationKey));
await tester.pump();
expect(
tester.getSemantics(find.byKey(textKey)).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,
1290.0, 990.0, 0.0, 1.0,
),
);
});
}); });
group('Row', () { group('Row', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment