Chromium Code Reviews| 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:math' as math; | 5 import 'dart:math' as math; |
| 6 | 6 |
| 7 import 'box.dart'; | 7 import 'box.dart'; |
| 8 import 'object.dart'; | 8 import 'object.dart'; |
| 9 | 9 |
| 10 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { } | 10 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { } |
| 11 | 11 |
| 12 class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B lockParentData>, | 12 class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B lockParentData>, |
| 13 RenderBoxContainerDefaultsMixin<RenderB ox, BlockParentData> { | 13 RenderBoxContainerDefaultsMixin<RenderB ox, BlockParentData> { |
| 14 // lays out RenderBox children in a vertical stack | 14 // lays out RenderBox children in a vertical stack |
| 15 // uses the maximum width provided by the parent | 15 // uses the maximum width provided by the parent |
| 16 // sizes itself to the height of its child stack | 16 // sizes itself to the height of its child stack |
| 17 | 17 |
| 18 RenderBlock({ | 18 RenderBlock({ |
| 19 List<RenderBox> children | 19 List<RenderBox> children |
| 20 }) { | 20 }) { |
| 21 if (children != null) | 21 if (children != null) |
| 22 children.forEach((child) { add(child); }); | 22 for (RenderBox child in children) |
|
hansmuller
2015/06/24 20:30:14
Maybe just define addAll(children) in ContainerRen
Hixie
2015/06/25 19:15:31
Good idea. Done.
| |
| 23 add(child); | |
|
hansmuller
2015/06/24 19:53:31
https://www.dartlang.org/articles/style-guide/#do-
Hixie
2015/06/25 19:15:31
I updated our style guide to disagree with this. A
| |
| 23 } | 24 } |
| 24 | 25 |
| 25 void setParentData(RenderBox child) { | 26 void setParentData(RenderBox child) { |
|
hansmuller
2015/06/24 20:32:49
Could setParentData() be defined in RenderBoxConta
Hixie
2015/06/25 19:15:32
Sadly not. You can't call "new" on a generic type
| |
| 26 if (child.parentData is! BlockParentData) | 27 if (child.parentData is! BlockParentData) |
| 27 child.parentData = new BlockParentData(); | 28 child.parentData = new BlockParentData(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 double getMinIntrinsicWidth(BoxConstraints constraints) { | 31 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| 31 double width = 0.0; | 32 double width = 0.0; |
| 32 BoxConstraints innerConstraints = new BoxConstraints( | 33 BoxConstraints innerConstraints = new BoxConstraints( |
| 33 minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); | 34 minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); |
| 34 RenderBox child = firstChild; | 35 RenderBox child = firstChild; |
| 35 while (child != null) { | 36 while (child != null) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 void hitTestChildren(HitTestResult result, { Point position }) { | 100 void hitTestChildren(HitTestResult result, { Point position }) { |
| 100 defaultHitTestChildren(result, position: position); | 101 defaultHitTestChildren(result, position: position); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void paint(RenderCanvas canvas) { | 104 void paint(RenderCanvas canvas) { |
| 104 defaultPaint(canvas); | 105 defaultPaint(canvas); |
| 105 } | 106 } |
| 106 | 107 |
| 107 } | 108 } |
| 108 | 109 |
| OLD | NEW |