Commit e8a638ec authored by Adam Barth's avatar Adam Barth Committed by GitHub

Minor RenderBox improvements (#4837)

* Make the size setter on RenderBox protected to avoid setting from
   outside the class.
 * Make normalize on BoxConstraints always return an object that
   isNormalized.
parent 04dca44f
...@@ -392,6 +392,10 @@ class BoxConstraints extends Constraints { ...@@ -392,6 +392,10 @@ class BoxConstraints extends Constraints {
/// The returned [maxWidth] is at least as large as the [minWidth]. Similarly, /// The returned [maxWidth] is at least as large as the [minWidth]. Similarly,
/// the returned [maxHeight] is at least as large as the [minHeight]. /// the returned [maxHeight] is at least as large as the [minHeight].
BoxConstraints normalize() { BoxConstraints normalize() {
if (isNormalized)
return this;
final double minWidth = this.minWidth >= 0.0 ? this.minWidth : 0.0;
final double minHeight = this.minHeight >= 0.0 ? this.minHeight : 0.0;
return new BoxConstraints( return new BoxConstraints(
minWidth: minWidth, minWidth: minWidth,
maxWidth: minWidth > maxWidth ? minWidth : maxWidth, maxWidth: minWidth > maxWidth ? minWidth : maxWidth,
...@@ -829,6 +833,7 @@ abstract class RenderBox extends RenderObject { ...@@ -829,6 +833,7 @@ abstract class RenderBox extends RenderObject {
return _size; return _size;
} }
Size _size; Size _size;
@protected
set size(Size value) { set size(Size value) {
assert(!(debugDoingThisResize && debugDoingThisLayout)); assert(!(debugDoingThisResize && debugDoingThisLayout));
assert(sizedByParent || !debugDoingThisResize); assert(sizedByParent || !debugDoingThisResize);
......
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