| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 import 'dart:math' as math; | 5 import 'dart:math' as math; | 
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; | 
| 7 import 'object.dart'; | 7 import 'object.dart'; | 
| 8 import '../painting/box_painter.dart'; | 8 import '../painting/box_painter.dart'; | 
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; | 
| 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; | 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 127                               maxWidth: maxWidth, | 127                               maxWidth: maxWidth, | 
| 128                               minHeight: minHeight, | 128                               minHeight: minHeight, | 
| 129                               maxHeight: math.min(maxHeight, height)); | 129                               maxHeight: math.min(maxHeight, height)); | 
| 130   } | 130   } | 
| 131 | 131 | 
| 132   final double minWidth; | 132   final double minWidth; | 
| 133   final double maxWidth; | 133   final double maxWidth; | 
| 134   final double minHeight; | 134   final double minHeight; | 
| 135   final double maxHeight; | 135   final double maxHeight; | 
| 136 | 136 | 
| 137   static double _clamp({double min: 0.0, double value: 0.0, double max: double.I
     NFINITY}) { |  | 
| 138     assert(min != null); |  | 
| 139     assert(value != null); |  | 
| 140     assert(max != null); |  | 
| 141     return math.max(min, math.min(max, value)); |  | 
| 142   } |  | 
| 143 |  | 
| 144   double constrainWidth(double width) { | 137   double constrainWidth(double width) { | 
| 145     return _clamp(min: minWidth, max: maxWidth, value: width); | 138     return clamp(min: minWidth, max: maxWidth, value: width); | 
| 146   } | 139   } | 
| 147 | 140 | 
| 148   double constrainHeight(double height) { | 141   double constrainHeight(double height) { | 
| 149     return _clamp(min: minHeight, max: maxHeight, value: height); | 142     return clamp(min: minHeight, max: maxHeight, value: height); | 
| 150   } | 143   } | 
| 151 | 144 | 
| 152   Size constrain(Size size) { | 145   Size constrain(Size size) { | 
| 153     return new Size(constrainWidth(size.width), constrainHeight(size.height)); | 146     return new Size(constrainWidth(size.width), constrainHeight(size.height)); | 
| 154   } | 147   } | 
| 155 | 148 | 
| 156   bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI
     NITY; | 149   bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI
     NITY; | 
| 157 | 150 | 
| 158   int get hashCode { | 151   int get hashCode { | 
| 159     int value = 373; | 152     int value = 373; | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 183   String toString() => 'position=$position'; | 176   String toString() => 'position=$position'; | 
| 184 } | 177 } | 
| 185 | 178 | 
| 186 abstract class RenderBox extends RenderObject { | 179 abstract class RenderBox extends RenderObject { | 
| 187 | 180 | 
| 188   void setParentData(RenderObject child) { | 181   void setParentData(RenderObject child) { | 
| 189     if (child.parentData is! BoxParentData) | 182     if (child.parentData is! BoxParentData) | 
| 190       child.parentData = new BoxParentData(); | 183       child.parentData = new BoxParentData(); | 
| 191   } | 184   } | 
| 192 | 185 | 
| 193   // getMinIntrinsicWidth() should return the minimum width that this box could | 186   // getMinIntrinsicWidth() should return the minimum width that this box could | 
| 194   // be without failing to render its contents within itself. | 187   // be without failing to render its contents within itself. | 
| 195   double getMinIntrinsicWidth(BoxConstraints constraints) { | 188   double getMinIntrinsicWidth(BoxConstraints constraints) { | 
| 196     return constraints.constrainWidth(0.0); | 189     return constraints.constrainWidth(0.0); | 
| 197   } | 190   } | 
| 198 | 191 | 
| 199   // getMaxIntrinsicWidth() should return the smallest width beyond which | 192   // getMaxIntrinsicWidth() should return the smallest width beyond which | 
| 200   // increasing the width never decreases the height. | 193   // increasing the width never decreases the height. | 
| 201   double getMaxIntrinsicWidth(BoxConstraints constraints) { | 194   double getMaxIntrinsicWidth(BoxConstraints constraints) { | 
| 202     return constraints.constrainWidth(0.0); | 195     return constraints.constrainWidth(0.0); | 
| 203   } | 196   } | 
| 204 | 197 | 
| 205   // getMinIntrinsicHeight() should return the minimum height that this box coul
     d | 198   // getMinIntrinsicHeight() should return the minimum height that this box coul
     d | 
| 206   // be without failing to render its contents within itself. | 199   // be without failing to render its contents within itself. | 
| 207   double getMinIntrinsicHeight(BoxConstraints constraints) { | 200   double getMinIntrinsicHeight(BoxConstraints constraints) { | 
| 208     return constraints.constrainHeight(0.0); | 201     return constraints.constrainHeight(0.0); | 
| 209   } | 202   } | 
| 210 | 203 | 
| 211   // getMaxIntrinsicHeight should return the smallest height beyond which | 204   // getMaxIntrinsicHeight should return the smallest height beyond which | 
| 212   // increasing the height never decreases the width. | 205   // increasing the height never decreases the width. | 
| 213   // If the layout algorithm used is width-in-height-out, i.e. the height | 206   // If the layout algorithm used is width-in-height-out, i.e. the height | 
| 214   // depends on the width and not vice versa, then this will return the same | 207   // depends on the width and not vice versa, then this will return the same | 
| 215   // as getMinIntrinsicHeight(). | 208   // as getMinIntrinsicHeight(). | 
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 951 | 944 | 
| 952   void defaultPaint(RenderObjectDisplayList canvas) { | 945   void defaultPaint(RenderObjectDisplayList canvas) { | 
| 953     RenderBox child = firstChild; | 946     RenderBox child = firstChild; | 
| 954     while (child != null) { | 947     while (child != null) { | 
| 955       assert(child.parentData is ParentDataType); | 948       assert(child.parentData is ParentDataType); | 
| 956       canvas.paintChild(child, child.parentData.position); | 949       canvas.paintChild(child, child.parentData.position); | 
| 957       child = child.parentData.nextSibling; | 950       child = child.parentData.nextSibling; | 
| 958     } | 951     } | 
| 959   } | 952   } | 
| 960 } | 953 } | 
| OLD | NEW | 
|---|