Unverified Commit 5322c6f8 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix RenderCustomPaint intrinsics (#72103)

Make RenderCustomPaint consult its preferred size for intrinsics when it has no child. Currently, it returns 0 for its intrinsics, even if it has a non-zero preferred size.
parent 80f88a79
......@@ -487,6 +487,34 @@ class RenderCustomPaint extends RenderProxyBox {
/// to change in the next frame.
bool willChange;
@override
double computeMinIntrinsicWidth(double height) {
if (child == null)
return preferredSize.width.isFinite ? preferredSize.width : 0;
return super.computeMinIntrinsicWidth(height);
}
@override
double computeMaxIntrinsicWidth(double height) {
if (child == null)
return preferredSize.width.isFinite ? preferredSize.width : 0;
return super.computeMaxIntrinsicWidth(height);
}
@override
double computeMinIntrinsicHeight(double width) {
if (child == null)
return preferredSize.height.isFinite ? preferredSize.height : 0;
return super.computeMinIntrinsicHeight(width);
}
@override
double computeMaxIntrinsicHeight(double width) {
if (child == null)
return preferredSize.height.isFinite ? preferredSize.height : 0;
return super.computeMaxIntrinsicHeight(width);
}
@override
void attach(PipelineOwner owner) {
super.attach(owner);
......
......@@ -198,4 +198,20 @@ void main() {
expect(() => CustomPaint(isComplex: true), throwsAssertionError);
expect(() => CustomPaint(willChange: true), throwsAssertionError);
});
test('RenderCustomPaint consults preferred size for intrinsics when it has no child', () {
final RenderCustomPaint inner = RenderCustomPaint(preferredSize: const Size(20, 30));
expect(inner.getMinIntrinsicWidth(double.infinity), 20);
expect(inner.getMaxIntrinsicWidth(double.infinity), 20);
expect(inner.getMinIntrinsicHeight(double.infinity), 30);
expect(inner.getMaxIntrinsicHeight(double.infinity), 30);
});
test('RenderCustomPaint does not return infinity for its intrinsics', () {
final RenderCustomPaint inner = RenderCustomPaint(preferredSize: const Size.square(double.infinity));
expect(inner.getMinIntrinsicWidth(double.infinity), 0);
expect(inner.getMaxIntrinsicWidth(double.infinity), 0);
expect(inner.getMinIntrinsicHeight(double.infinity), 0);
expect(inner.getMaxIntrinsicHeight(double.infinity), 0);
});
}
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