Commit 47f5c6f2 authored by Ian Hickson's avatar Ian Hickson

Add even more careful checks around BoxConstraints (#3243)

I ran into a case where I was setting minHeight=∞ and then calling
layout() with that constraint, which is all kinds of bad. To try to
catch this earlier, this patch now provides a way to catch constraints
that are requiring infinite values.

We don't _always_ check this because there are valid uses for
BoxConstraints.biggest, e.g. as an additionalConstraint.
parent f43e1dfa
...@@ -43,7 +43,7 @@ class SectorConstraints extends Constraints { ...@@ -43,7 +43,7 @@ class SectorConstraints extends Constraints {
bool get isNormalized => minDeltaRadius <= maxDeltaRadius && minDeltaTheta <= maxDeltaTheta; bool get isNormalized => minDeltaRadius <= maxDeltaRadius && minDeltaTheta <= maxDeltaTheta;
@override @override
bool get debugAssertIsNormalized { bool debugAssertIsValid({ bool isAppliedConstraint: false }) {
assert(isNormalized); assert(isNormalized);
return isNormalized; return isNormalized;
} }
......
...@@ -171,7 +171,7 @@ class RenderBlock extends RenderBox ...@@ -171,7 +171,7 @@ class RenderBlock extends RenderBox
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.horizontal: case Axis.horizontal:
return _getIntrinsicMainAxis(constraints, constraints.constrainWidth); return _getIntrinsicMainAxis(constraints, constraints.constrainWidth);
...@@ -186,7 +186,7 @@ class RenderBlock extends RenderBox ...@@ -186,7 +186,7 @@ class RenderBlock extends RenderBox
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.horizontal: case Axis.horizontal:
return _getIntrinsicMainAxis(constraints, constraints.constrainWidth); return _getIntrinsicMainAxis(constraints, constraints.constrainWidth);
...@@ -201,7 +201,7 @@ class RenderBlock extends RenderBox ...@@ -201,7 +201,7 @@ class RenderBlock extends RenderBox
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.horizontal: case Axis.horizontal:
return _getIntrinsicCrossAxis( return _getIntrinsicCrossAxis(
...@@ -216,7 +216,7 @@ class RenderBlock extends RenderBox ...@@ -216,7 +216,7 @@ class RenderBlock extends RenderBox
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.horizontal: case Axis.horizontal:
return _getIntrinsicCrossAxis( return _getIntrinsicCrossAxis(
......
...@@ -109,7 +109,7 @@ class BoxConstraints extends Constraints { ...@@ -109,7 +109,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that are smaller by the given edge dimensions. /// Returns new box constraints that are smaller by the given edge dimensions.
BoxConstraints deflate(EdgeInsets edges) { BoxConstraints deflate(EdgeInsets edges) {
assert(edges != null); assert(edges != null);
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
double horizontal = edges.left + edges.right; double horizontal = edges.left + edges.right;
double vertical = edges.top + edges.bottom; double vertical = edges.top + edges.bottom;
double deflatedMinWidth = math.max(0.0, minWidth - horizontal); double deflatedMinWidth = math.max(0.0, minWidth - horizontal);
...@@ -124,7 +124,7 @@ class BoxConstraints extends Constraints { ...@@ -124,7 +124,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that remove the minimum width and height requirements. /// Returns new box constraints that remove the minimum width and height requirements.
BoxConstraints loosen() { BoxConstraints loosen() {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
return new BoxConstraints( return new BoxConstraints(
minWidth: 0.0, minWidth: 0.0,
maxWidth: maxWidth, maxWidth: maxWidth,
...@@ -175,14 +175,14 @@ class BoxConstraints extends Constraints { ...@@ -175,14 +175,14 @@ class BoxConstraints extends Constraints {
/// Returns the width that both satisfies the constraints and is as close as /// Returns the width that both satisfies the constraints and is as close as
/// possible to the given width. /// possible to the given width.
double constrainWidth([double width = double.INFINITY]) { double constrainWidth([double width = double.INFINITY]) {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
return width.clamp(minWidth, maxWidth); return width.clamp(minWidth, maxWidth);
} }
/// Returns the height that both satisfies the constraints and is as close as /// Returns the height that both satisfies the constraints and is as close as
/// possible to the given height. /// possible to the given height.
double constrainHeight([double height = double.INFINITY]) { double constrainHeight([double height = double.INFINITY]) {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
return height.clamp(minHeight, maxHeight); return height.clamp(minHeight, maxHeight);
} }
...@@ -222,7 +222,7 @@ class BoxConstraints extends Constraints { ...@@ -222,7 +222,7 @@ class BoxConstraints extends Constraints {
/// Whether the given size satisfies the constraints. /// Whether the given size satisfies the constraints.
bool isSatisfiedBy(Size size) { bool isSatisfiedBy(Size size) {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
return (minWidth <= size.width) && (size.width <= maxWidth) && return (minWidth <= size.width) && (size.width <= maxWidth) &&
(minHeight <= size.height) && (size.height <= maxHeight); (minHeight <= size.height) && (size.height <= maxHeight);
} }
...@@ -273,8 +273,8 @@ class BoxConstraints extends Constraints { ...@@ -273,8 +273,8 @@ class BoxConstraints extends Constraints {
return b * t; return b * t;
if (b == null) if (b == null)
return a * (1.0 - t); return a * (1.0 - t);
assert(a.debugAssertIsNormalized); assert(a.debugAssertIsValid());
assert(b.debugAssertIsNormalized); assert(b.debugAssertIsValid());
return new BoxConstraints( return new BoxConstraints(
minWidth: ui.lerpDouble(a.minWidth, b.minWidth, t), minWidth: ui.lerpDouble(a.minWidth, b.minWidth, t),
maxWidth: ui.lerpDouble(a.maxWidth, b.maxWidth, t), maxWidth: ui.lerpDouble(a.maxWidth, b.maxWidth, t),
...@@ -303,7 +303,7 @@ class BoxConstraints extends Constraints { ...@@ -303,7 +303,7 @@ class BoxConstraints extends Constraints {
} }
@override @override
bool get debugAssertIsNormalized { bool debugAssertIsValid({ bool isAppliedConstraint: false }) {
assert(() { assert(() {
if (minWidth.isNaN || maxWidth.isNaN || minHeight.isNaN || maxHeight.isNaN) { if (minWidth.isNaN || maxWidth.isNaN || minHeight.isNaN || maxHeight.isNaN) {
List<String> affectedFieldsList = <String>[]; List<String> affectedFieldsList = <String>[];
...@@ -340,7 +340,16 @@ class BoxConstraints extends Constraints { ...@@ -340,7 +340,16 @@ class BoxConstraints extends Constraints {
throw new FlutterError('BoxConstraints has non-normalized width constraints.\n$this'); throw new FlutterError('BoxConstraints has non-normalized width constraints.\n$this');
if (maxHeight < minHeight) if (maxHeight < minHeight)
throw new FlutterError('BoxConstraints has non-normalized height constraints.\n$this'); throw new FlutterError('BoxConstraints has non-normalized height constraints.\n$this');
return isNormalized; if (isAppliedConstraint) {
if (minWidth.isInfinite && minHeight.isInfinite)
throw new FlutterError('BoxConstraints requires infinite width and infinite height.\n$this');
if (minWidth.isInfinite)
throw new FlutterError('BoxConstraints requires infinite width.\n$this');
if (minHeight.isInfinite)
throw new FlutterError('BoxConstraints requires infinite height.\n$this');
}
assert(isNormalized);
return true;
}); });
return isNormalized; return isNormalized;
} }
...@@ -356,13 +365,13 @@ class BoxConstraints extends Constraints { ...@@ -356,13 +365,13 @@ class BoxConstraints extends Constraints {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
if (identical(this, other)) if (identical(this, other))
return true; return true;
if (other is! BoxConstraints) if (other is! BoxConstraints)
return false; return false;
final BoxConstraints typedOther = other; final BoxConstraints typedOther = other;
assert(typedOther.debugAssertIsNormalized); assert(typedOther.debugAssertIsValid());
return minWidth == typedOther.minWidth && return minWidth == typedOther.minWidth &&
maxWidth == typedOther.maxWidth && maxWidth == typedOther.maxWidth &&
minHeight == typedOther.minHeight && minHeight == typedOther.minHeight &&
...@@ -371,7 +380,7 @@ class BoxConstraints extends Constraints { ...@@ -371,7 +380,7 @@ class BoxConstraints extends Constraints {
@override @override
int get hashCode { int get hashCode {
assert(debugAssertIsNormalized); assert(debugAssertIsValid());
return hashValues(minWidth, maxWidth, minHeight, maxHeight); return hashValues(minWidth, maxWidth, minHeight, maxHeight);
} }
...@@ -451,7 +460,7 @@ abstract class RenderBox extends RenderObject { ...@@ -451,7 +460,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Override in subclasses that implement [performLayout]. /// Override in subclasses that implement [performLayout].
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
} }
...@@ -460,7 +469,7 @@ abstract class RenderBox extends RenderObject { ...@@ -460,7 +469,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Override in subclasses that implement [performLayout]. /// Override in subclasses that implement [performLayout].
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
} }
...@@ -469,7 +478,7 @@ abstract class RenderBox extends RenderObject { ...@@ -469,7 +478,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Override in subclasses that implement [performLayout]. /// Override in subclasses that implement [performLayout].
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
} }
...@@ -482,7 +491,7 @@ abstract class RenderBox extends RenderObject { ...@@ -482,7 +491,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Override in subclasses that implement [performLayout]. /// Override in subclasses that implement [performLayout].
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
} }
......
...@@ -57,7 +57,7 @@ abstract class MultiChildLayoutDelegate { ...@@ -57,7 +57,7 @@ abstract class MultiChildLayoutDelegate {
); );
} }
try { try {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
} on AssertionError catch (exception) { } on AssertionError catch (exception) {
throw new FlutterError( throw new FlutterError(
'The $this custom multichild layout delegate provided invalid box constraints for the child with id "$childId".\n' 'The $this custom multichild layout delegate provided invalid box constraints for the child with id "$childId".\n'
...@@ -232,7 +232,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox ...@@ -232,7 +232,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
} }
Size _getSize(BoxConstraints constraints) { Size _getSize(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrain(_delegate.getSize(constraints)); return constraints.constrain(_delegate.getSize(constraints));
} }
......
...@@ -133,25 +133,25 @@ class RenderEditableLine extends RenderBox { ...@@ -133,25 +133,25 @@ class RenderEditableLine extends RenderBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(_preferredHeight); return constraints.constrainHeight(_preferredHeight);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(_preferredHeight); return constraints.constrainHeight(_preferredHeight);
} }
...@@ -190,7 +190,7 @@ class RenderEditableLine extends RenderBox { ...@@ -190,7 +190,7 @@ class RenderEditableLine extends RenderBox {
// TODO(abarth): This logic should live in TextPainter and be shared with RenderParagraph. // TODO(abarth): This logic should live in TextPainter and be shared with RenderParagraph.
void _layoutText(BoxConstraints constraints) { void _layoutText(BoxConstraints constraints) {
assert(constraints != null); assert(constraints != null);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (_constraintsForCurrentLayout == constraints) if (_constraintsForCurrentLayout == constraints)
return; // already cached this layout return; // already cached this layout
_textPainter.maxWidth = constraints.maxWidth; _textPainter.maxWidth = constraints.maxWidth;
......
...@@ -144,7 +144,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -144,7 +144,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
double _getIntrinsicSize({ BoxConstraints constraints, double _getIntrinsicSize({ BoxConstraints constraints,
FlexDirection sizingDirection, FlexDirection sizingDirection,
_ChildSizingFunction childSize }) { _ChildSizingFunction childSize }) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
// http://www.w3.org/TR/2015/WD-css-flexbox-1-20150514/#intrinsic-sizes // http://www.w3.org/TR/2015/WD-css-flexbox-1-20150514/#intrinsic-sizes
if (_direction == sizingDirection) { if (_direction == sizingDirection) {
// INTRINSIC MAIN SIZE // INTRINSIC MAIN SIZE
......
...@@ -430,25 +430,25 @@ class RenderGrid extends RenderVirtualViewport<GridParentData> { ...@@ -430,25 +430,25 @@ class RenderGrid extends RenderVirtualViewport<GridParentData> {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _delegate.getMinIntrinsicWidth(constraints, virtualChildCount); return _delegate.getMinIntrinsicWidth(constraints, virtualChildCount);
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _delegate.getMaxIntrinsicWidth(constraints, virtualChildCount); return _delegate.getMaxIntrinsicWidth(constraints, virtualChildCount);
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _delegate.getMinIntrinsicHeight(constraints, virtualChildCount); return _delegate.getMinIntrinsicHeight(constraints, virtualChildCount);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _delegate.getMaxIntrinsicHeight(constraints, virtualChildCount); return _delegate.getMaxIntrinsicHeight(constraints, virtualChildCount);
} }
......
...@@ -205,7 +205,7 @@ class RenderImage extends RenderBox { ...@@ -205,7 +205,7 @@ class RenderImage extends RenderBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (_width == null && _height == null) if (_width == null && _height == null)
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
return _sizeForConstraints(constraints).width; return _sizeForConstraints(constraints).width;
...@@ -213,13 +213,13 @@ class RenderImage extends RenderBox { ...@@ -213,13 +213,13 @@ class RenderImage extends RenderBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _sizeForConstraints(constraints).width; return _sizeForConstraints(constraints).width;
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (_width == null && _height == null) if (_width == null && _height == null)
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
return _sizeForConstraints(constraints).height; return _sizeForConstraints(constraints).height;
...@@ -227,7 +227,7 @@ class RenderImage extends RenderBox { ...@@ -227,7 +227,7 @@ class RenderImage extends RenderBox {
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _sizeForConstraints(constraints).height; return _sizeForConstraints(constraints).height;
} }
......
...@@ -82,7 +82,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> { ...@@ -82,7 +82,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
} }
double _getIntrinsicWidth(BoxConstraints constraints) { double _getIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.vertical: case Axis.vertical:
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
...@@ -102,7 +102,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> { ...@@ -102,7 +102,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
} }
double _getIntrinsicHeight(BoxConstraints constraints) { double _getIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
switch (mainAxis) { switch (mainAxis) {
case Axis.vertical: case Axis.vertical:
return constraints.constrainHeight(_preferredExtent); return constraints.constrainHeight(_preferredExtent);
......
...@@ -382,9 +382,25 @@ abstract class Constraints { ...@@ -382,9 +382,25 @@ abstract class Constraints {
/// Whether the constraint is expressed in a consistent manner. /// Whether the constraint is expressed in a consistent manner.
bool get isNormalized; bool get isNormalized;
/// Same as [isNormalized] but, in checked mode, throws an exception /// Asserts that the constraints are valid.
/// if isNormalized is false. ///
bool get debugAssertIsNormalized; /// This might involve checks more detailed than [isNormalized].
///
/// For example, the [BoxConstraints] subclass verifies that the
/// constraints are not [NaN].
///
/// If the [isAppliedConstraint] argument is true, then even
/// stricter rules are enforced. This argument is set to true when
/// checking constraints that are about to be applied to a
/// [RenderObject] during layout, as opposed to constraints that may
/// be further affected by other constraints. For example, the
/// asserts for verifying the validity of
/// [RenderConstrainedBox.additionalConstraints] do not set this
/// argument, but the asserts for verifying the argument passed to
/// the [layout] method do.
///
/// Returns the same as [isNormalized] if asserts are disabled.
bool debugAssertIsValid({ bool isAppliedConstraint: false });
} }
typedef void RenderObjectVisitor(RenderObject child); typedef void RenderObjectVisitor(RenderObject child);
...@@ -1136,7 +1152,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1136,7 +1152,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// work to update its layout information. /// work to update its layout information.
void layout(Constraints constraints, { bool parentUsesSize: false }) { void layout(Constraints constraints, { bool parentUsesSize: false }) {
assert(constraints != null); assert(constraints != null);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
assert(!_debugDoingThisResize); assert(!_debugDoingThisResize);
assert(!_debugDoingThisLayout); assert(!_debugDoingThisLayout);
final RenderObject parent = this.parent; final RenderObject parent = this.parent;
......
...@@ -36,7 +36,7 @@ class RenderParagraph extends RenderBox { ...@@ -36,7 +36,7 @@ class RenderParagraph extends RenderBox {
// TODO(abarth): This logic should live in TextPainter and be shared with RenderEditableLine. // TODO(abarth): This logic should live in TextPainter and be shared with RenderEditableLine.
void _layoutText(BoxConstraints constraints) { void _layoutText(BoxConstraints constraints) {
assert(constraints != null); assert(constraints != null);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (_constraintsForCurrentLayout == constraints) if (_constraintsForCurrentLayout == constraints)
return; // already cached this layout return; // already cached this layout
_textPainter.maxWidth = constraints.maxWidth; _textPainter.maxWidth = constraints.maxWidth;
...@@ -71,13 +71,13 @@ class RenderParagraph extends RenderBox { ...@@ -71,13 +71,13 @@ class RenderParagraph extends RenderBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getIntrinsicHeight(constraints); return _getIntrinsicHeight(constraints);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getIntrinsicHeight(constraints); return _getIntrinsicHeight(constraints);
} }
......
...@@ -37,7 +37,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -37,7 +37,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicWidth(constraints); return child.getMinIntrinsicWidth(constraints);
return super.getMinIntrinsicWidth(constraints); return super.getMinIntrinsicWidth(constraints);
...@@ -45,7 +45,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -45,7 +45,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicWidth(constraints); return child.getMaxIntrinsicWidth(constraints);
return super.getMaxIntrinsicWidth(constraints); return super.getMaxIntrinsicWidth(constraints);
...@@ -53,7 +53,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -53,7 +53,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicHeight(constraints); return child.getMinIntrinsicHeight(constraints);
return super.getMinIntrinsicHeight(constraints); return super.getMinIntrinsicHeight(constraints);
...@@ -61,7 +61,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -61,7 +61,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicHeight(constraints); return child.getMaxIntrinsicHeight(constraints);
return super.getMaxIntrinsicHeight(constraints); return super.getMaxIntrinsicHeight(constraints);
...@@ -170,7 +170,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -170,7 +170,7 @@ class RenderConstrainedBox extends RenderProxyBox {
BoxConstraints additionalConstraints BoxConstraints additionalConstraints
}) : _additionalConstraints = additionalConstraints, super(child) { }) : _additionalConstraints = additionalConstraints, super(child) {
assert(additionalConstraints != null); assert(additionalConstraints != null);
assert(additionalConstraints.debugAssertIsNormalized); assert(additionalConstraints.debugAssertIsValid());
} }
/// Additional constraints to apply to [child] during layout /// Additional constraints to apply to [child] during layout
...@@ -178,7 +178,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -178,7 +178,7 @@ class RenderConstrainedBox extends RenderProxyBox {
BoxConstraints _additionalConstraints; BoxConstraints _additionalConstraints;
void set additionalConstraints (BoxConstraints newConstraints) { void set additionalConstraints (BoxConstraints newConstraints) {
assert(newConstraints != null); assert(newConstraints != null);
assert(newConstraints.debugAssertIsNormalized); assert(newConstraints.debugAssertIsValid());
if (_additionalConstraints == newConstraints) if (_additionalConstraints == newConstraints)
return; return;
_additionalConstraints = newConstraints; _additionalConstraints = newConstraints;
...@@ -187,7 +187,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -187,7 +187,7 @@ class RenderConstrainedBox extends RenderProxyBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicWidth(_additionalConstraints.enforce(constraints)); return child.getMinIntrinsicWidth(_additionalConstraints.enforce(constraints));
return _additionalConstraints.enforce(constraints).constrainWidth(0.0); return _additionalConstraints.enforce(constraints).constrainWidth(0.0);
...@@ -195,7 +195,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -195,7 +195,7 @@ class RenderConstrainedBox extends RenderProxyBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicWidth(_additionalConstraints.enforce(constraints)); return child.getMaxIntrinsicWidth(_additionalConstraints.enforce(constraints));
return _additionalConstraints.enforce(constraints).constrainWidth(0.0); return _additionalConstraints.enforce(constraints).constrainWidth(0.0);
...@@ -203,7 +203,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -203,7 +203,7 @@ class RenderConstrainedBox extends RenderProxyBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicHeight(_additionalConstraints.enforce(constraints)); return child.getMinIntrinsicHeight(_additionalConstraints.enforce(constraints));
return _additionalConstraints.enforce(constraints).constrainHeight(0.0); return _additionalConstraints.enforce(constraints).constrainHeight(0.0);
...@@ -211,7 +211,7 @@ class RenderConstrainedBox extends RenderProxyBox { ...@@ -211,7 +211,7 @@ class RenderConstrainedBox extends RenderProxyBox {
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicHeight(_additionalConstraints.enforce(constraints)); return child.getMaxIntrinsicHeight(_additionalConstraints.enforce(constraints));
return _additionalConstraints.enforce(constraints).constrainHeight(0.0); return _additionalConstraints.enforce(constraints).constrainHeight(0.0);
...@@ -317,7 +317,7 @@ class RenderAspectRatio extends RenderProxyBox { ...@@ -317,7 +317,7 @@ class RenderAspectRatio extends RenderProxyBox {
} }
Size _applyAspectRatio(BoxConstraints constraints) { Size _applyAspectRatio(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
assert(() { assert(() {
if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) { if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) {
throw new FlutterError( throw new FlutterError(
...@@ -446,13 +446,13 @@ class RenderIntrinsicWidth extends RenderProxyBox { ...@@ -446,13 +446,13 @@ class RenderIntrinsicWidth extends RenderProxyBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getMaxIntrinsicWidth(constraints); return getMaxIntrinsicWidth(constraints);
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
double childResult = child.getMaxIntrinsicWidth(constraints); double childResult = child.getMaxIntrinsicWidth(constraints);
...@@ -461,7 +461,7 @@ class RenderIntrinsicWidth extends RenderProxyBox { ...@@ -461,7 +461,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constraints)); double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constraints));
...@@ -470,7 +470,7 @@ class RenderIntrinsicWidth extends RenderProxyBox { ...@@ -470,7 +470,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constraints)); double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constraints));
...@@ -522,7 +522,7 @@ class RenderIntrinsicHeight extends RenderProxyBox { ...@@ -522,7 +522,7 @@ class RenderIntrinsicHeight extends RenderProxyBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
return child.getMinIntrinsicWidth(_getInnerConstraints(constraints)); return child.getMinIntrinsicWidth(_getInnerConstraints(constraints));
...@@ -530,7 +530,7 @@ class RenderIntrinsicHeight extends RenderProxyBox { ...@@ -530,7 +530,7 @@ class RenderIntrinsicHeight extends RenderProxyBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainWidth(0.0); return constraints.constrainWidth(0.0);
return child.getMaxIntrinsicWidth(_getInnerConstraints(constraints)); return child.getMaxIntrinsicWidth(_getInnerConstraints(constraints));
...@@ -538,13 +538,13 @@ class RenderIntrinsicHeight extends RenderProxyBox { ...@@ -538,13 +538,13 @@ class RenderIntrinsicHeight extends RenderProxyBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getMaxIntrinsicHeight(constraints); return getMaxIntrinsicHeight(constraints);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child == null) if (child == null)
return constraints.constrainHeight(0.0); return constraints.constrainHeight(0.0);
return child.getMaxIntrinsicHeight(constraints); return child.getMaxIntrinsicHeight(constraints);
......
...@@ -41,7 +41,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB ...@@ -41,7 +41,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return _isVertical ? child.getMinIntrinsicHeight(constraints.flipped) : child.getMinIntrinsicWidth(constraints); return _isVertical ? child.getMinIntrinsicHeight(constraints.flipped) : child.getMinIntrinsicWidth(constraints);
return super.getMinIntrinsicWidth(constraints); return super.getMinIntrinsicWidth(constraints);
...@@ -49,7 +49,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB ...@@ -49,7 +49,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return _isVertical ? child.getMaxIntrinsicHeight(constraints.flipped) : child.getMaxIntrinsicWidth(constraints); return _isVertical ? child.getMaxIntrinsicHeight(constraints.flipped) : child.getMaxIntrinsicWidth(constraints);
return super.getMaxIntrinsicWidth(constraints); return super.getMaxIntrinsicWidth(constraints);
...@@ -57,7 +57,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB ...@@ -57,7 +57,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return _isVertical ? child.getMinIntrinsicWidth(constraints.flipped) : child.getMinIntrinsicHeight(constraints); return _isVertical ? child.getMinIntrinsicWidth(constraints.flipped) : child.getMinIntrinsicHeight(constraints);
return super.getMinIntrinsicHeight(constraints); return super.getMinIntrinsicHeight(constraints);
...@@ -65,7 +65,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB ...@@ -65,7 +65,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return _isVertical ? child.getMaxIntrinsicWidth(constraints.flipped) : child.getMaxIntrinsicHeight(constraints); return _isVertical ? child.getMaxIntrinsicWidth(constraints.flipped) : child.getMaxIntrinsicHeight(constraints);
return super.getMaxIntrinsicHeight(constraints); return super.getMaxIntrinsicHeight(constraints);
......
...@@ -17,7 +17,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi ...@@ -17,7 +17,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicWidth(constraints); return child.getMinIntrinsicWidth(constraints);
return super.getMinIntrinsicWidth(constraints); return super.getMinIntrinsicWidth(constraints);
...@@ -25,7 +25,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi ...@@ -25,7 +25,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicWidth(constraints); return child.getMaxIntrinsicWidth(constraints);
return super.getMaxIntrinsicWidth(constraints); return super.getMaxIntrinsicWidth(constraints);
...@@ -33,7 +33,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi ...@@ -33,7 +33,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMinIntrinsicHeight(constraints); return child.getMinIntrinsicHeight(constraints);
return super.getMinIntrinsicHeight(constraints); return super.getMinIntrinsicHeight(constraints);
...@@ -41,7 +41,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi ...@@ -41,7 +41,7 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return child.getMaxIntrinsicHeight(constraints); return child.getMaxIntrinsicHeight(constraints);
return super.getMaxIntrinsicHeight(constraints); return super.getMaxIntrinsicHeight(constraints);
...@@ -112,7 +112,7 @@ class RenderPadding extends RenderShiftedBox { ...@@ -112,7 +112,7 @@ class RenderPadding extends RenderShiftedBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double totalPadding = padding.left + padding.right; double totalPadding = padding.left + padding.right;
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMinIntrinsicWidth(constraints.deflate(padding)) + totalPadding); return constraints.constrainWidth(child.getMinIntrinsicWidth(constraints.deflate(padding)) + totalPadding);
...@@ -121,7 +121,7 @@ class RenderPadding extends RenderShiftedBox { ...@@ -121,7 +121,7 @@ class RenderPadding extends RenderShiftedBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double totalPadding = padding.left + padding.right; double totalPadding = padding.left + padding.right;
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMaxIntrinsicWidth(constraints.deflate(padding)) + totalPadding); return constraints.constrainWidth(child.getMaxIntrinsicWidth(constraints.deflate(padding)) + totalPadding);
...@@ -130,7 +130,7 @@ class RenderPadding extends RenderShiftedBox { ...@@ -130,7 +130,7 @@ class RenderPadding extends RenderShiftedBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double totalPadding = padding.top + padding.bottom; double totalPadding = padding.top + padding.bottom;
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMinIntrinsicHeight(constraints.deflate(padding)) + totalPadding); return constraints.constrainHeight(child.getMinIntrinsicHeight(constraints.deflate(padding)) + totalPadding);
...@@ -139,7 +139,7 @@ class RenderPadding extends RenderShiftedBox { ...@@ -139,7 +139,7 @@ class RenderPadding extends RenderShiftedBox {
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double totalPadding = padding.top + padding.bottom; double totalPadding = padding.top + padding.bottom;
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPadding); return constraints.constrainHeight(child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPadding);
...@@ -494,25 +494,25 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox { ...@@ -494,25 +494,25 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.minWidth; return constraints.minWidth;
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.minWidth; return constraints.minWidth;
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.minHeight; return constraints.minHeight;
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.minHeight; return constraints.minHeight;
} }
...@@ -567,25 +567,25 @@ class RenderSizedOverflowBox extends RenderAligningShiftedBox { ...@@ -567,25 +567,25 @@ class RenderSizedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(_requestedSize.width); return constraints.constrainWidth(_requestedSize.width);
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainWidth(_requestedSize.width); return constraints.constrainWidth(_requestedSize.width);
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(_requestedSize.height); return constraints.constrainHeight(_requestedSize.height);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return constraints.constrainHeight(_requestedSize.height); return constraints.constrainHeight(_requestedSize.height);
} }
...@@ -683,7 +683,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { ...@@ -683,7 +683,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMinIntrinsicWidth(_getInnerConstraints(constraints))); return constraints.constrainWidth(child.getMinIntrinsicWidth(_getInnerConstraints(constraints)));
return constraints.constrainWidth(_getInnerConstraints(constraints).constrainWidth(0.0)); return constraints.constrainWidth(_getInnerConstraints(constraints).constrainWidth(0.0));
...@@ -691,7 +691,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { ...@@ -691,7 +691,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMaxIntrinsicWidth(_getInnerConstraints(constraints))); return constraints.constrainWidth(child.getMaxIntrinsicWidth(_getInnerConstraints(constraints)));
return constraints.constrainWidth(_getInnerConstraints(constraints).constrainWidth(0.0)); return constraints.constrainWidth(_getInnerConstraints(constraints).constrainWidth(0.0));
...@@ -699,7 +699,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { ...@@ -699,7 +699,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMinIntrinsicHeight(_getInnerConstraints(constraints))); return constraints.constrainHeight(child.getMinIntrinsicHeight(_getInnerConstraints(constraints)));
return constraints.constrainHeight(_getInnerConstraints(constraints).constrainHeight(0.0)); return constraints.constrainHeight(_getInnerConstraints(constraints).constrainHeight(0.0));
...@@ -707,7 +707,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { ...@@ -707,7 +707,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox {
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMaxIntrinsicHeight(_getInnerConstraints(constraints))); return constraints.constrainHeight(child.getMaxIntrinsicHeight(_getInnerConstraints(constraints)));
return constraints.constrainHeight(_getInnerConstraints(constraints).constrainHeight(0.0)); return constraints.constrainHeight(_getInnerConstraints(constraints).constrainHeight(0.0));
...@@ -779,25 +779,25 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { ...@@ -779,25 +779,25 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getSize(constraints).width; return _getSize(constraints).width;
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getSize(constraints).width; return _getSize(constraints).width;
} }
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getSize(constraints).height; return _getSize(constraints).height;
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return _getSize(constraints).height; return _getSize(constraints).height;
} }
...@@ -813,7 +813,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { ...@@ -813,7 +813,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox {
void performLayout() { void performLayout() {
if (child != null) { if (child != null) {
BoxConstraints childConstraints = delegate.getConstraintsForChild(constraints); BoxConstraints childConstraints = delegate.getConstraintsForChild(constraints);
assert(childConstraints.debugAssertIsNormalized); assert(childConstraints.debugAssertIsValid(isAppliedConstraint: true));
child.layout(childConstraints, parentUsesSize: !childConstraints.isTight); child.layout(childConstraints, parentUsesSize: !childConstraints.isTight);
final BoxParentData childParentData = child.parentData; final BoxParentData childParentData = child.parentData;
childParentData.offset = delegate.getPositionForChild(size, childConstraints.isTight ? childConstraints.smallest : child.size); childParentData.offset = delegate.getPositionForChild(size, childConstraints.isTight ? childConstraints.smallest : child.size);
......
...@@ -225,7 +225,7 @@ abstract class RenderStackBase extends RenderBox ...@@ -225,7 +225,7 @@ abstract class RenderStackBase extends RenderBox
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double width = constraints.minWidth; double width = constraints.minWidth;
RenderBox child = firstChild; RenderBox child = firstChild;
while (child != null) { while (child != null) {
...@@ -241,7 +241,7 @@ abstract class RenderStackBase extends RenderBox ...@@ -241,7 +241,7 @@ abstract class RenderStackBase extends RenderBox
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
bool hasNonPositionedChildren = false; bool hasNonPositionedChildren = false;
double width = constraints.minWidth; double width = constraints.minWidth;
RenderBox child = firstChild; RenderBox child = firstChild;
...@@ -262,7 +262,7 @@ abstract class RenderStackBase extends RenderBox ...@@ -262,7 +262,7 @@ abstract class RenderStackBase extends RenderBox
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
double height = constraints.minHeight; double height = constraints.minHeight;
RenderBox child = firstChild; RenderBox child = firstChild;
while (child != null) { while (child != null) {
...@@ -278,7 +278,7 @@ abstract class RenderStackBase extends RenderBox ...@@ -278,7 +278,7 @@ abstract class RenderStackBase extends RenderBox
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
bool hasNonPositionedChildren = false; bool hasNonPositionedChildren = false;
double height = constraints.minHeight; double height = constraints.minHeight;
RenderBox child = firstChild; RenderBox child = firstChild;
......
...@@ -636,7 +636,7 @@ class RenderTable extends RenderBox { ...@@ -636,7 +636,7 @@ class RenderTable extends RenderBox {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
assert(_children.length == rows * columns); assert(_children.length == rows * columns);
double totalMinWidth = 0.0; double totalMinWidth = 0.0;
for (int x = 0; x < columns; x += 1) { for (int x = 0; x < columns; x += 1) {
...@@ -649,7 +649,7 @@ class RenderTable extends RenderBox { ...@@ -649,7 +649,7 @@ class RenderTable extends RenderBox {
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
assert(_children.length == rows * columns); assert(_children.length == rows * columns);
double totalMaxWidth = 0.0; double totalMaxWidth = 0.0;
for (int x = 0; x < columns; x += 1) { for (int x = 0; x < columns; x += 1) {
...@@ -664,7 +664,7 @@ class RenderTable extends RenderBox { ...@@ -664,7 +664,7 @@ class RenderTable extends RenderBox {
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
// winner of the 2016 world's most expensive intrinsic dimension function award // winner of the 2016 world's most expensive intrinsic dimension function award
// honorable mention, most likely to improve if taught about memoization award // honorable mention, most likely to improve if taught about memoization award
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
assert(_children.length == rows * columns); assert(_children.length == rows * columns);
final List<double> widths = computeColumnWidths(constraints); final List<double> widths = computeColumnWidths(constraints);
double rowTop = 0.0; double rowTop = 0.0;
......
...@@ -246,7 +246,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin< ...@@ -246,7 +246,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMinIntrinsicWidth(_getInnerConstraints(constraints))); return constraints.constrainWidth(child.getMinIntrinsicWidth(_getInnerConstraints(constraints)));
return super.getMinIntrinsicWidth(constraints); return super.getMinIntrinsicWidth(constraints);
...@@ -254,7 +254,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin< ...@@ -254,7 +254,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainWidth(child.getMaxIntrinsicWidth(_getInnerConstraints(constraints))); return constraints.constrainWidth(child.getMaxIntrinsicWidth(_getInnerConstraints(constraints)));
return super.getMaxIntrinsicWidth(constraints); return super.getMaxIntrinsicWidth(constraints);
...@@ -262,7 +262,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin< ...@@ -262,7 +262,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMinIntrinsicHeight(_getInnerConstraints(constraints))); return constraints.constrainHeight(child.getMinIntrinsicHeight(_getInnerConstraints(constraints)));
return super.getMinIntrinsicHeight(constraints); return super.getMinIntrinsicHeight(constraints);
...@@ -270,7 +270,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin< ...@@ -270,7 +270,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
if (child != null) if (child != null)
return constraints.constrainHeight(child.getMaxIntrinsicHeight(_getInnerConstraints(constraints))); return constraints.constrainHeight(child.getMaxIntrinsicHeight(_getInnerConstraints(constraints)));
return super.getMaxIntrinsicHeight(constraints); return super.getMaxIntrinsicHeight(constraints);
......
...@@ -264,13 +264,13 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { ...@@ -264,13 +264,13 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> {
@override @override
double getMinIntrinsicWidth(BoxConstraints constraints) { double getMinIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getIntrinsicWidth(constraints); return getIntrinsicWidth(constraints);
} }
@override @override
double getMaxIntrinsicWidth(BoxConstraints constraints) { double getMaxIntrinsicWidth(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getIntrinsicWidth(constraints); return getIntrinsicWidth(constraints);
} }
...@@ -286,13 +286,13 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { ...@@ -286,13 +286,13 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> {
@override @override
double getMinIntrinsicHeight(BoxConstraints constraints) { double getMinIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getIntrinsicHeight(constraints); return getIntrinsicHeight(constraints);
} }
@override @override
double getMaxIntrinsicHeight(BoxConstraints constraints) { double getMaxIntrinsicHeight(BoxConstraints constraints) {
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
return getIntrinsicHeight(constraints); return getIntrinsicHeight(constraints);
} }
......
...@@ -37,7 +37,7 @@ void main() { ...@@ -37,7 +37,7 @@ void main() {
result = 'no exception'; result = 'no exception';
try { try {
BoxConstraints constraints = new BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN); BoxConstraints constraints = new BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) { } on FlutterError catch (e) {
result = '$e'; result = '$e';
} }
...@@ -49,7 +49,7 @@ void main() { ...@@ -49,7 +49,7 @@ void main() {
result = 'no exception'; result = 'no exception';
try { try {
BoxConstraints constraints = new BoxConstraints(minHeight: double.NAN); BoxConstraints constraints = new BoxConstraints(minHeight: double.NAN);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) { } on FlutterError catch (e) {
result = '$e'; result = '$e';
} }
...@@ -61,7 +61,7 @@ void main() { ...@@ -61,7 +61,7 @@ void main() {
result = 'no exception'; result = 'no exception';
try { try {
BoxConstraints constraints = new BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0); BoxConstraints constraints = new BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0);
assert(constraints.debugAssertIsNormalized); assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) { } on FlutterError catch (e) {
result = '$e'; result = '$e';
} }
......
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