| Index: sky/sdk/lib/rendering/block.dart
|
| diff --git a/sky/sdk/lib/rendering/block.dart b/sky/sdk/lib/rendering/block.dart
|
| index 939e62ceaba54c2b196f47d817076d9ae78507dc..be11c57f4b542815970ade6ad80c6d6806f752f1 100644
|
| --- a/sky/sdk/lib/rendering/block.dart
|
| +++ b/sky/sdk/lib/rendering/block.dart
|
| @@ -9,13 +9,13 @@ import 'object.dart';
|
|
|
| class BlockParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> { }
|
|
|
| -class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, BlockParentData>,
|
| - RenderBoxContainerDefaultsMixin<RenderBox, BlockParentData> {
|
| +abstract class RenderBlockBase extends RenderBox with ContainerRenderObjectMixin<RenderBox, BlockParentData>,
|
| + RenderBoxContainerDefaultsMixin<RenderBox, BlockParentData> {
|
| +
|
| // lays out RenderBox children in a vertical stack
|
| // uses the maximum width provided by the parent
|
| - // sizes itself to the height of its child stack
|
|
|
| - RenderBlock({
|
| + RenderBlockBase({
|
| List<RenderBox> children
|
| }) {
|
| addAll(children);
|
| @@ -81,6 +81,14 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
| return defaultComputeDistanceToFirstActualBaseline(baseline);
|
| }
|
|
|
| + double _childrenHeight;
|
| + double get childrenHeight => _childrenHeight;
|
| +
|
| + void markNeedsLayout() {
|
| + _childrenHeight = null;
|
| + super.markNeedsLayout();
|
| + }
|
| +
|
| void performLayout() {
|
| assert(constraints is BoxConstraints);
|
| double width = constraints.constrainWidth(constraints.maxWidth);
|
| @@ -94,8 +102,7 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
| y += child.size.height;
|
| child = child.parentData.nextSibling;
|
| }
|
| - size = new Size(width, constraints.constrainHeight(y));
|
| - assert(!size.isInfinite);
|
| + _childrenHeight = y;
|
| }
|
|
|
| void hitTestChildren(HitTestResult result, { Point position }) {
|
| @@ -108,3 +115,79 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
|
|
| }
|
|
|
| +class RenderBlock extends RenderBlockBase {
|
| +
|
| + // sizes itself to the height of its child stack
|
| +
|
| + RenderBlock({ List<RenderBox> children }) : super(children: children);
|
| +
|
| + void performLayout() {
|
| + super.performLayout();
|
| + size = constraints.constrain(new Size(constraints.maxWidth, childrenHeight));
|
| + assert(!size.isInfinite);
|
| + }
|
| +
|
| +}
|
| +
|
| +class RenderBlockViewport extends RenderBlockBase {
|
| +
|
| + // sizes itself to the given constraints
|
| + // at the start of layout, calls callback
|
| +
|
| + RenderBlockViewport({
|
| + LayoutCallback callback,
|
| + List<RenderBox> children,
|
| + double startOffset: 0.0
|
| + }) : _callback = callback, _startOffset = startOffset, super(children: children);
|
| +
|
| + bool _inCallback = false;
|
| +
|
| + LayoutCallback _callback;
|
| + LayoutCallback get callback => _callback;
|
| + void set callback(LayoutCallback value) {
|
| + assert(!_inCallback);
|
| + if (value == _callback)
|
| + return;
|
| + _callback = value;
|
| + markNeedsLayout();
|
| + }
|
| +
|
| + // you can set this from within the callback if necessary
|
| + double _startOffset;
|
| + double get startOffset => _startOffset;
|
| + void set startOffset(double value) {
|
| + if (value == _startOffset)
|
| + return;
|
| + _startOffset = value;
|
| + if (!_inCallback)
|
| + markNeedsLayout();
|
| + }
|
| +
|
| + bool get sizedByParent => true;
|
| +
|
| + void performResize() {
|
| + size = constraints.biggest;
|
| + assert(!size.isInfinite);
|
| + }
|
| +
|
| + bool get debugDoesLayoutWithCallback => true;
|
| + void performLayout() {
|
| + if (_callback != null) {
|
| + try {
|
| + _inCallback = true;
|
| + invokeLayoutCallback(_callback);
|
| + } finally {
|
| + _inCallback = false;
|
| + }
|
| + }
|
| + super.performLayout();
|
| + }
|
| +
|
| + void paint(PaintingCanvas canvas, Offset offset) {
|
| + canvas.save();
|
| + canvas.clipRect(offset & size);
|
| + super.paint(canvas, offset.translate(0.0, _startOffset));
|
| + canvas.restore();
|
| + }
|
| +
|
| +}
|
|
|