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

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

Issue 1173493003: Extend Sky's RenderFlex with intrinsic sizes and compute cross-size height (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix bugs 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
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 5f3fc72c4547d13a088d11ba4fc27fbda6174b55..18f33456f26d30e862d83e7dc461233c76857bc9 100644
--- a/sky/sdk/lib/framework/rendering/box.dart
+++ b/sky/sdk/lib/framework/rendering/box.dart
@@ -556,13 +556,12 @@ class RenderImage extends RenderBox {
markNeedsLayout();
}
- void performLayout() {
+ Size _sizeForConstraints(BoxConstraints innerConstraints) {
// If there's no image, we can't size ourselves automatically
if (_image == null) {
double width = requestedSize.width == null ? 0.0 : requestedSize.width;
double height = requestedSize.height == null ? 0.0 : requestedSize.height;
- size = constraints.constrain(new Size(width, height));
- return;
+ return constraints.constrain(new Size(width, height));
}
// If neither height nor width are specified, use inherent image dimensions
@@ -570,19 +569,43 @@ class RenderImage extends RenderBox {
// maintain the aspect ratio
if (requestedSize.width == null) {
if (requestedSize.height == null) {
- size = constraints.constrain(new Size(_image.width.toDouble(), _image.height.toDouble()));
+ return constraints.constrain(new Size(_image.width.toDouble(), _image.height.toDouble()));
} else {
double width = requestedSize.height * _image.width / _image.height;
- size = constraints.constrain(new Size(width, requestedSize.height));
+ return constraints.constrain(new Size(width, requestedSize.height));
}
} else if (requestedSize.height == null) {
double height = requestedSize.width * _image.height / _image.width;
- size = constraints.constrain(new Size(requestedSize.width, height));
+ return constraints.constrain(new Size(requestedSize.width, height));
} else {
- size = constraints.constrain(requestedSize);
+ return constraints.constrain(requestedSize);
}
}
+ double getMinIntrinsicWidth(BoxConstraints constraints) {
+ if (requestedSize.width == null && requestedSize.height == null)
+ return constraints.constrainWidth(0.0);
+ return _sizeForConstraints(constraints).width;
+ }
+
+ double getMaxIntrinsicWidth(BoxConstraints constraints) {
+ return _sizeForConstraints(constraints).width;
+ }
+
+ double getMinIntrinsicHeight(BoxConstraints constraints) {
+ if (requestedSize.width == null && requestedSize.height == null)
+ return constraints.constrainHeight(0.0);
+ return _sizeForConstraints(constraints).width;
abarth-chromium 2015/06/10 04:23:19 .height
jackson 2015/06/10 04:44:46 Acknowledged.
+ }
+
+ double getMaxIntrinsicHeight(BoxConstraints constraints) {
+ return _sizeForConstraints(constraints).height;
+ }
+
+ void performLayout() {
+ size = _sizeForConstraints(constraints);
+ }
+
void paint(RenderObjectDisplayList canvas) {
if (_image == null) return;
bool needsScale = size.width != _image.width || size.height != _image.height;

Powered by Google App Engine
This is Rietveld 408576698