Avoid sending zero transform semantic nodes to the engine (#111843)
This commit is contained in:
@@ -4433,7 +4433,7 @@ class _SemanticsGeometry {
|
|||||||
/// by this object can be dropped from the semantics tree without losing
|
/// by this object can be dropped from the semantics tree without losing
|
||||||
/// semantics information.
|
/// semantics information.
|
||||||
bool get dropFromTree {
|
bool get dropFromTree {
|
||||||
return _rect.isEmpty;
|
return _rect.isEmpty || _transform.isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the [SemanticsNode] annotated with the geometric information
|
/// Whether the [SemanticsNode] annotated with the geometric information
|
||||||
|
|||||||
@@ -1632,6 +1632,33 @@ void main() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Semantics with zero transform gets dropped', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/110671.
|
||||||
|
// Construct a widget tree that will end up with a fitted box that applies
|
||||||
|
// a zero transform because it does not actually draw its children.
|
||||||
|
// Assert that this subtree gets dropped (the root node has no children).
|
||||||
|
await tester.pumpWidget(Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 0,
|
||||||
|
width: 500,
|
||||||
|
child: FittedBox(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 55,
|
||||||
|
width: 266,
|
||||||
|
child: SingleChildScrollView(child: Column()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
|
||||||
|
final SemanticsNode node = RendererBinding.instance.renderView.debugSemantics!;
|
||||||
|
|
||||||
|
expect(node.transform, null); // Make sure the zero transform didn't end up on the root somehow.
|
||||||
|
expect(node.childrenCount, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomSortKey extends OrdinalSortKey {
|
class CustomSortKey extends OrdinalSortKey {
|
||||||
|
|||||||
Reference in New Issue
Block a user