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

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 typos 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/framework/components2/popup_menu_item.dart ('k') | sky/sdk/lib/framework/rendering/flex.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0393554b5629863d423d4a55f05c4e6845f2e3f4..ddbd78e63c41f7a5e9153a53d83fe5d6b5ef3c8e 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).height;
+ }
+
+ 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;
@@ -797,7 +820,7 @@ class RenderDecoratedBox extends RenderProxyBox {
assert(size.height != null);
if (_decoration.backgroundColor != null || _decoration.boxShadow != null ||
- _deocration.gradient != null) {
+ _decoration.gradient != null) {
Rect rect = new Rect.fromLTRB(0.0, 0.0, size.width, size.height);
if (_decoration.borderRadius == null)
canvas.drawRect(rect, _backgroundPaint);
« no previous file with comments | « sky/sdk/lib/framework/components2/popup_menu_item.dart ('k') | sky/sdk/lib/framework/rendering/flex.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698