Fix paintBounds/semanticBounds of RenderSliver (#11781)
* Fix paintBounds/semanticsBounds of RenderSliver * another test
This commit is contained in:
parent
631eaa4563
commit
c1bd6f87ae
@ -951,14 +951,14 @@ abstract class RenderSliver extends RenderObject {
|
|||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
return new Rect.fromLTWH(
|
return new Rect.fromLTWH(
|
||||||
0.0, 0.0,
|
0.0, 0.0,
|
||||||
|
geometry.paintExtent,
|
||||||
constraints.crossAxisExtent,
|
constraints.crossAxisExtent,
|
||||||
geometry.paintExtent
|
|
||||||
);
|
);
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
return new Rect.fromLTWH(
|
return new Rect.fromLTWH(
|
||||||
0.0, 0.0,
|
0.0, 0.0,
|
||||||
|
constraints.crossAxisExtent,
|
||||||
geometry.paintExtent,
|
geometry.paintExtent,
|
||||||
constraints.crossAxisExtent
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -678,4 +678,46 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Sliver paintBounds and semanticBounds - vertical', () {
|
||||||
|
const double height = 150.0;
|
||||||
|
|
||||||
|
final RenderSliver sliver = new RenderSliverToBoxAdapter(
|
||||||
|
child: new RenderSizedBox(const Size(400.0, height)),
|
||||||
|
);
|
||||||
|
final RenderViewport root = new RenderViewport(
|
||||||
|
axisDirection: AxisDirection.down,
|
||||||
|
offset: new ViewportOffset.zero(),
|
||||||
|
children: <RenderSliver>[
|
||||||
|
sliver,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
layout(root);
|
||||||
|
|
||||||
|
final Rect expectedRect = new Rect.fromLTWH(0.0, 0.0, root.size.width, height);
|
||||||
|
|
||||||
|
expect(sliver.paintBounds, expectedRect);
|
||||||
|
expect(sliver.semanticBounds, expectedRect);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Sliver paintBounds and semanticBounds - horizontal', () {
|
||||||
|
const double width = 150.0;
|
||||||
|
|
||||||
|
final RenderSliver sliver = new RenderSliverToBoxAdapter(
|
||||||
|
child: new RenderSizedBox(const Size(width, 400.0)),
|
||||||
|
);
|
||||||
|
final RenderViewport root = new RenderViewport(
|
||||||
|
axisDirection: AxisDirection.right,
|
||||||
|
offset: new ViewportOffset.zero(),
|
||||||
|
children: <RenderSliver>[
|
||||||
|
sliver,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
layout(root);
|
||||||
|
|
||||||
|
final Rect expectedRect = new Rect.fromLTWH(0.0, 0.0, width, root.size.height);
|
||||||
|
|
||||||
|
expect(sliver.paintBounds, expectedRect);
|
||||||
|
expect(sliver.semanticBounds, expectedRect);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user