Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: sky/sdk/lib/rendering/box.dart

Issue 1209233002: Let's hide double.INFINITY a bit more, by providing cleaner APIs for the cases where we're currentl… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/rendering/block.dart ('k') | sky/sdk/lib/rendering/stack.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/box.dart
diff --git a/sky/sdk/lib/rendering/box.dart b/sky/sdk/lib/rendering/box.dart
index 21d1878ffe30d33de4a9e40f25a8f3cd1707f24e..94c2578a9185ed21050122aee9e81fa750bf9625 100644
--- a/sky/sdk/lib/rendering/box.dart
+++ b/sky/sdk/lib/rendering/box.dart
@@ -77,7 +77,7 @@ class BoxConstraints extends Constraints {
minHeight = size.height,
maxHeight = size.height;
- BoxConstraints.tightFor({
+ const BoxConstraints.tightFor({
double width,
double height
}): minWidth = width != null ? width : 0.0,
@@ -91,6 +91,25 @@ class BoxConstraints extends Constraints {
minHeight = 0.0,
maxHeight = size.height;
+ const BoxConstraints.expandWidth({
+ this.maxHeight: double.INFINITY
+ }): minWidth = double.INFINITY,
+ maxWidth = double.INFINITY,
+ minHeight = 0.0;
+
+ const BoxConstraints.expandHeight({
+ this.maxWidth: double.INFINITY
+ }): minWidth = 0.0,
+ minHeight = double.INFINITY,
+ maxHeight = double.INFINITY;
+
+ static const BoxConstraints expand = const BoxConstraints(
+ minWidth: double.INFINITY,
+ maxWidth: double.INFINITY,
+ minHeight: double.INFINITY,
+ maxHeight: double.INFINITY
+ );
+
BoxConstraints deflate(EdgeDims edges) {
assert(edges != null);
double horizontal = edges.left + edges.right;
@@ -172,11 +191,11 @@ class BoxConstraints extends Constraints {
final double minHeight;
final double maxHeight;
- double constrainWidth(double width) {
+ double constrainWidth([double width = double.INFINITY]) {
return clamp(min: minWidth, max: maxWidth, value: width);
}
- double constrainHeight(double height) {
+ double constrainHeight([double height = double.INFINITY]) {
return clamp(min: minHeight, max: maxHeight, value: height);
}
@@ -312,8 +331,7 @@ abstract class RenderBox extends RenderObject {
void performResize() {
// default behaviour for subclasses that have sizedByParent = true
size = constraints.constrain(Size.zero);
- assert(size.height < double.INFINITY);
- assert(size.width < double.INFINITY);
+ assert(!size.isInfinite);
}
void performLayout() {
// descendants have to either override performLayout() to set both
@@ -1131,8 +1149,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
_orientation = _rootConstraints.orientation;
}
_size = new Size(_rootConstraints.width, _rootConstraints.height);
- assert(_size.height < double.INFINITY);
- assert(_size.width < double.INFINITY);
+ assert(!_size.isInfinite);
if (child != null) {
child.layout(new BoxConstraints.tight(_size));
« no previous file with comments | « sky/sdk/lib/rendering/block.dart ('k') | sky/sdk/lib/rendering/stack.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698