| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky' as sky; | |
| 6 import 'box.dart'; | 5 import 'box.dart'; |
| 7 import 'object.dart'; | 6 import 'object.dart'; |
| 8 | 7 |
| 9 class StackParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } | 8 class StackParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } |
| 10 | 9 |
| 11 class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, S
tackParentData>, | 10 class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, S
tackParentData>, |
| 12 RenderBoxContainerDefaultsMixin<RenderB
ox, StackParentData> { | 11 RenderBoxContainerDefaultsMixin<RenderB
ox, StackParentData> { |
| 13 RenderStack({ | 12 RenderStack({ |
| 14 List<RenderBox> children | 13 List<RenderBox> children |
| 15 }) { | 14 }) { |
| 16 if (children != null) | 15 if (children != null) |
| 17 children.forEach((child) { add(child); }); | 16 children.forEach((child) { add(child); }); |
| 18 } | 17 } |
| 19 | 18 |
| 20 void setParentData(RenderBox child) { | 19 void setParentData(RenderBox child) { |
| 21 if (child.parentData is! StackParentData) | 20 if (child.parentData is! StackParentData) |
| 22 child.parentData = new StackParentData(); | 21 child.parentData = new StackParentData(); |
| 23 } | 22 } |
| 24 | 23 |
| 25 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 24 Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 26 return constraints.constrain(sky.Size.infinite); | 25 return constraints.constrain(Size.infinite); |
| 27 } | 26 } |
| 28 | 27 |
| 29 void performLayout() { | 28 void performLayout() { |
| 30 size = constraints.constrain(sky.Size.infinite); | 29 size = constraints.constrain(Size.infinite); |
| 31 assert(size.width < double.INFINITY); | 30 assert(size.width < double.INFINITY); |
| 32 assert(size.height < double.INFINITY); | 31 assert(size.height < double.INFINITY); |
| 33 BoxConstraints innerConstraints = new BoxConstraints.loose(size); | 32 BoxConstraints innerConstraints = new BoxConstraints.loose(size); |
| 34 | 33 |
| 35 sky.Point origin = new sky.Point(0.0, 0.0); | 34 Point origin = new Point(0.0, 0.0); |
| 36 RenderBox child = firstChild; | 35 RenderBox child = firstChild; |
| 37 while (child != null) { | 36 while (child != null) { |
| 38 child.layout(innerConstraints); | 37 child.layout(innerConstraints); |
| 39 assert(child.parentData is StackParentData); | 38 assert(child.parentData is StackParentData); |
| 40 child.parentData.position = origin; | 39 child.parentData.position = origin; |
| 41 child = child.parentData.nextSibling; | 40 child = child.parentData.nextSibling; |
| 42 } | 41 } |
| 43 } | 42 } |
| 44 | 43 |
| 45 void hitTestChildren(HitTestResult result, { sky.Point position }) { | 44 void hitTestChildren(HitTestResult result, { Point position }) { |
| 46 defaultHitTestChildren(result, position: position); | 45 defaultHitTestChildren(result, position: position); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void paint(RenderObjectDisplayList canvas) { | 48 void paint(RenderObjectDisplayList canvas) { |
| 50 defaultPaint(canvas); | 49 defaultPaint(canvas); |
| 51 } | 50 } |
| 52 } | 51 } |
| OLD | NEW |