Fix crash in debugDumpSemanticsTree when transform == null (#11807)
This commit is contained in:
committed by
GitHub
parent
8ecf19d8a0
commit
2a01097a23
@@ -736,8 +736,8 @@ class SemanticsNode extends AbstractNode {
|
||||
}
|
||||
|
||||
static int _geometryComparator(SemanticsNode a, SemanticsNode b) {
|
||||
final Rect rectA = MatrixUtils.transformRect(a.transform, a.rect);
|
||||
final Rect rectB = MatrixUtils.transformRect(b.transform, b.rect);
|
||||
final Rect rectA = a.transform == null ? a.rect : MatrixUtils.transformRect(a.transform, a.rect);
|
||||
final Rect rectB = b.transform == null ? b.rect : MatrixUtils.transformRect(b.transform, b.rect);
|
||||
final int top = rectA.top.compareTo(rectB.top);
|
||||
return top == 0 ? rectA.left.compareTo(rectB.left) : top;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,24 @@ void main() {
|
||||
expect(root.debugSemantics.getSemanticsData().actions, expectedActions);
|
||||
});
|
||||
});
|
||||
|
||||
test('toStringDeep() does not throw with transform == null', () {
|
||||
final SemanticsNode child2 = new SemanticsNode();
|
||||
final SemanticsNode child1 = new SemanticsNode();
|
||||
final SemanticsNode root = new SemanticsNode();
|
||||
root.addChildren(<SemanticsNode>[child1, child2]);
|
||||
root.finalizeChildren();
|
||||
|
||||
expect(root.transform, isNull);
|
||||
expect(child1.transform, isNull);
|
||||
expect(child2.transform, isNull);
|
||||
|
||||
expect(root.toStringDeep(DebugSemanticsDumpOrder.traversal),
|
||||
'SemanticsNode(8 (STALE; owner=null); Rect.fromLTRB(0.0, 0.0, 0.0, 0.0))\n'
|
||||
' ├SemanticsNode(7; Rect.fromLTRB(0.0, 0.0, 0.0, 0.0))\n'
|
||||
' └SemanticsNode(6; Rect.fromLTRB(0.0, 0.0, 0.0, 0.0))\n'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class TestRender extends RenderProxyBox {
|
||||
|
||||
Reference in New Issue
Block a user