Commit 2a01097a authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix crash in debugDumpSemanticsTree when transform == null (#11807)

parent 8ecf19d8
......@@ -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 {
......
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