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 f40d2bc6e0b123f5ee766fdfd3d4a96d2e53be9d..ea39ddd3a4703489e1c835d21668cd52396bfbfe 100644 |
| --- a/sky/sdk/lib/framework/rendering/box.dart |
| +++ b/sky/sdk/lib/framework/rendering/box.dart |
| @@ -127,13 +127,20 @@ abstract class RenderBox extends RenderObject { |
| child.parentData = new BoxParentData(); |
| } |
| - // override this to report what dimensions you would have if you |
| - // were laid out with the given constraints this can walk the tree |
| - // if it must, but it should be as cheap as possible; just get the |
| - // dimensions and nothing else (e.g. don't calculate hypothetical |
| - // child positions if they're not needed to determine dimensions) |
| - Size getIntrinsicDimensions(BoxConstraints constraints) { |
| - return constraints.constrain(Size.zero); |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
|
Hixie
2015/06/08 21:35:32
Let's define these here.
// getMinIntrinsicWidth(
|
| + return constraints.constrainWidth(0.0); |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
|
Hixie
2015/06/08 21:35:32
// getMaxIntrinsicWidth() should return the smalle
|
| + return constraints.constrainWidth(0.0); |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
|
Hixie
2015/06/08 21:35:32
// getMinIntrinsicHeight() should return the minim
|
| + return constraints.constrainHeight(0.0); |
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
|
Hixie
2015/06/08 21:35:32
// getMaxIntrinsicHeight should return the smalles
|
| + return constraints.constrainHeight(0.0); |
| } |
| BoxConstraints get constraints => super.constraints as BoxConstraints; |
| @@ -167,10 +174,28 @@ abstract class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin< |
| this.child = child; |
| } |
| - Size getIntrinsicDimensions(BoxConstraints constraints) { |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
| if (child != null) |
| - return child.getIntrinsicDimensions(constraints); |
| - return super.getIntrinsicDimensions(constraints); |
| + return child.getMinIntrinsicWidth(constraints); |
| + return super.getMinIntrinsicWidth(constraints); |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicWidth(constraints); |
| + return super.getMaxIntrinsicWidth(constraints); |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMinIntrinsicHeight(constraints); |
| + return super.getMinIntrinsicHeight(constraints); |
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicHeight(constraints); |
| + return super.getMaxIntrinsicHeight(constraints); |
| } |
| void performLayout() { |
| @@ -214,8 +239,20 @@ class RenderSizedBox extends RenderProxyBox { |
| markNeedsLayout(); |
| } |
| - Size getIntrinsicDimensions(BoxConstraints constraints) { |
| - return constraints.constrain(_desiredSize); |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
| + return constraints.constrain(_desiredSize.width); |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| + return constraints.constrain(_desiredSize.width); |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
| + return constraints.constrain(_desiredSize.height); |
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| + return constraints.constrain(_desiredSize.height); |
| } |
| void performLayout() { |
| @@ -245,10 +282,28 @@ class RenderConstrainedBox extends RenderProxyBox { |
| markNeedsLayout(); |
| } |
| - Size getIntrinsicDimensions(BoxConstraints constraints) { |
| - if (child == null) |
| - return constraints.constrain(Size.zero); |
| - return child.getIntrinsicDimensions(constraints.apply(_additionalConstraints)); |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMinIntrinsicWidth(constraints.apply(_additionalConstraints)); |
| + return constraints.constrainWidth(0.0); |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicWidth(constraints.apply(_additionalConstraints)); |
| + return constraints.constrainWidth(0.0); |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMinIntrinsicHeight(constraints.apply(_additionalConstraints)); |
| + return constraints.constrainHeight(0.0); |
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicHeight(constraints.apply(_additionalConstraints)); |
| + return constraints.constrainHeight(0.0); |
| } |
| void performLayout() { |
| @@ -294,12 +349,28 @@ class RenderPadding extends RenderBox with RenderObjectWithChildMixin<RenderBox> |
| markNeedsLayout(); |
| } |
| - Size getIntrinsicDimensions(BoxConstraints constraints) { |
| - assert(padding != null); |
| - constraints = constraints.deflate(padding); |
| - if (child == null) |
| - return super.getIntrinsicDimensions(constraints); |
| - return child.getIntrinsicDimensions(constraints); |
| + double getMinIntrinsicWidth(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMinIntrinsicWidth(constraints.deflate(padding)); |
| + return constraints.constrainWidth(padding.left + padding.right); |
| + } |
| + |
| + double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicWidth(constraints.deflate(padding)); |
| + return constraints.constrainWidth(padding.left + padding.right); |
| + } |
| + |
| + double getMinIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMinIntrinsicHeight(constraints.deflate(padding)); |
| + return constraints.constrainHeight(padding.top + padding.bottom); |
| + } |
| + |
| + double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| + if (child != null) |
| + return child.getMaxIntrinsicHeight(constraints.deflate(padding)); |
| + return constraints.constrainHeight(padding.top + padding.bottom); |
| } |
| void performLayout() { |