Chromium Code Reviews| Index: sky/sdk/lib/framework/rendering/box.dart |
| diff --git a/sky/sdk/lib/framework/rendering/box.dart b/sky/sdk/lib/framework/rendering/box.dart |
| index 5f3fc72c4547d13a088d11ba4fc27fbda6174b55..18f33456f26d30e862d83e7dc461233c76857bc9 100644 |
| --- a/sky/sdk/lib/framework/rendering/box.dart |
| +++ b/sky/sdk/lib/framework/rendering/box.dart |
| @@ -556,13 +556,12 @@ class RenderImage extends RenderBox { |
| markNeedsLayout(); |
| } |
| - void performLayout() { |
| + Size _sizeForConstraints(BoxConstraints innerConstraints) { |
| // If there's no image, we can't size ourselves automatically |
| if (_image == null) { |
| double width = requestedSize.width == null ? 0.0 : requestedSize.width; |
| double height = requestedSize.height == null ? 0.0 : requestedSize.height; |
| - size = constraints.constrain(new Size(width, height)); |
| - return; |
| + return constraints.constrain(new Size(width, height)); |
| } |
| // If neither height nor width are specified, use inherent image dimensions |
| @@ -570,19 +569,43 @@ class RenderImage extends RenderBox { |
| // maintain the aspect ratio |
| if (requestedSize.width == null) { |
| if (requestedSize.height == null) { |
| - size = constraints.constrain(new Size(_image.width.toDouble(), _image.height.toDouble())); |
| + return constraints.constrain(new Size(_image.width.toDouble(), _image.height.toDouble())); |
| } else { |
| double width = requestedSize.height * _image.width / _image.height; |
| - size = constraints.constrain(new Size(width, requestedSize.height)); |
| + return constraints.constrain(new Size(width, requestedSize.height)); |
| } |
| } else if (requestedSize.height == null) { |
| double height = requestedSize.width * _image.height / _image.width; |
| - size = constraints.constrain(new Size(requestedSize.width, height)); |
| + return constraints.constrain(new Size(requestedSize.width, height)); |
| } else { |
| - size = constraints.constrain(requestedSize); |
| + return constraints.constrain(requestedSize); |
| } |
| } |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
| + if (requestedSize.width == null && requestedSize.height == null) |
| + return constraints.constrainWidth(0.0); |
| + return _sizeForConstraints(constraints).width; |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| + return _sizeForConstraints(constraints).width; |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
| + if (requestedSize.width == null && requestedSize.height == null) |
| + return constraints.constrainHeight(0.0); |
| + return _sizeForConstraints(constraints).width; |
|
abarth-chromium
2015/06/10 04:23:19
.height
jackson
2015/06/10 04:44:46
Acknowledged.
|
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| + return _sizeForConstraints(constraints).height; |
| + } |
| + |
| + void performLayout() { |
| + size = _sizeForConstraints(constraints); |
| + } |
| + |
| void paint(RenderObjectDisplayList canvas) { |
| if (_image == null) return; |
| bool needsScale = size.width != _image.width || size.height != _image.height; |