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

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

Issue 1167293003: Split getIntrinsicDimensions into four pieces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: more worky 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/examples/lib/solid_color_box.dart ('k') | sky/sdk/lib/framework/rendering/box.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/rendering/block.dart
diff --git a/sky/sdk/lib/framework/rendering/block.dart b/sky/sdk/lib/framework/rendering/block.dart
index b56856073ff425510fb14eddfb65eecaa266bd55..2150299f762b2a834844b1bc03e10c53d8ea9dc6 100644
--- a/sky/sdk/lib/framework/rendering/block.dart
+++ b/sky/sdk/lib/framework/rendering/block.dart
@@ -25,25 +25,52 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
child.parentData = new BlockParentData();
}
- // override this to report what dimensions you would have if you
- // were laid out with the given constraints this can walk the tree
- // if it must, but it should be as cheap as possible; just get the
- // dimensions and nothing else (e.g. don't calculate hypothetical
- // child positions if they're not needed to determine dimensions)
- Size getIntrinsicDimensions(BoxConstraints constraints) {
+ double getMinIntrinsicWidth(BoxConstraints constraints) {
+ double width = 0.0;
+ BoxConstraints innerConstraints = new BoxConstraints(
+ minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
+ RenderBox child = firstChild;
+ while (child != null) {
+ width = math.max(width, child.getMinIntrinsicWidth(innerConstraints));
+ child = child.parentData.nextSibling;
+ }
+ return width;
+ }
+
+ double getMaxIntrinsicWidth(BoxConstraints constraints) {
+ double width = 0.0;
+ BoxConstraints innerConstraints = new BoxConstraints(
+ minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
+ RenderBox child = firstChild;
+ while (child != null) {
+ width = math.max(width, child.getMaxIntrinsicWidth(innerConstraints));
+ child = child.parentData.nextSibling;
+ }
+ return width;
+ }
+
+ double _getIntrinsicHeight(BoxConstraints constraints) {
double height = 0.0;
double width = constraints.constrainWidth(constraints.maxWidth);
assert(width < double.INFINITY);
- RenderBox child = firstChild;
BoxConstraints innerConstraints = new BoxConstraints(minWidth: width,
maxWidth: width);
+ RenderBox child = firstChild;
while (child != null) {
- height += child.getIntrinsicDimensions(innerConstraints).height;
- assert(child.parentData is BlockParentData);
+ double childHeight = child.getMinIntrinsicHeight(innerConstraints);
+ assert(childHeight == child.getMaxIntrinsicHeight(innerConstraints));
+ height += childHeight;
child = child.parentData.nextSibling;
}
+ return height;
+ }
+
+ double getMinIntrinsicHeight(BoxConstraints constraints) {
+ return _getIntrinsicHeight(constraints);
+ }
- return new Size(width, constraints.constrainHeight(height));
+ double getMaxIntrinsicHeight(BoxConstraints constraints) {
+ return _getIntrinsicHeight(constraints);
}
void performLayout() {
« no previous file with comments | « sky/examples/lib/solid_color_box.dart ('k') | sky/sdk/lib/framework/rendering/box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698