Adam Barth 903ef07abb Split getIntrinsicDimensions into four pieces
This CL splits getIntrinsicDimensions into getMinIntrinsicWidth,
getMaxIntrinsicWidth, getMinIntrinsicHeight, and getMaxIntrinsicHeight so that
we can properly shrink-wrap the stocks app menu. This CL just contains the
refactoring. The use in stocks app will come in a later CL.

R=ianh@google.com

Review URL: https://codereview.chromium.org/1167293003
2015-06-08 14:40:34 -07:00

63 lines
1.9 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'box.dart';
import 'object.dart';
class StackParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> { }
class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, StackParentData>,
RenderBoxContainerDefaultsMixin<RenderBox, StackParentData> {
RenderStack({
List<RenderBox> children
}) {
if (children != null)
children.forEach((child) { add(child); });
}
void setParentData(RenderBox child) {
if (child.parentData is! StackParentData)
child.parentData = new StackParentData();
}
double getMinIntrinsicWidth(BoxConstraints constraints) {
return constraints.constrainWidth(double.INFINITY);
}
double getMaxIntrinsicWidth(BoxConstraints constraints) {
return constraints.constrainWidth(double.INFINITY);
}
double getMinIntrinsicHeight(BoxConstraints constraints) {
return constraints.constrainHeight(double.INFINITY);
}
double getMaxIntrinsicHeight(BoxConstraints constraints) {
return constraints.constrainHeight(double.INFINITY);
}
void performLayout() {
size = constraints.constrain(Size.infinite);
assert(size.width < double.INFINITY);
assert(size.height < double.INFINITY);
BoxConstraints innerConstraints = new BoxConstraints.loose(size);
RenderBox child = firstChild;
while (child != null) {
child.layout(innerConstraints);
assert(child.parentData is StackParentData);
child.parentData.position = Point.origin;
child = child.parentData.nextSibling;
}
}
void hitTestChildren(HitTestResult result, { Point position }) {
defaultHitTestChildren(result, position: position);
}
void paint(RenderObjectDisplayList canvas) {
defaultPaint(canvas);
}
}