Make RenderParagraph mutable, and make it fit the new RenderNode protocols
R=abarth@chromium.org, eseidel@chromium.org Review URL: https://codereview.chromium.org/1165463002
This commit is contained in:
@@ -12,7 +12,10 @@ void main() {
|
|||||||
|
|
||||||
test("should size to render view", () {
|
test("should size to render view", () {
|
||||||
RenderSizedBox root = new RenderSizedBox(
|
RenderSizedBox root = new RenderSizedBox(
|
||||||
new RenderDecoratedBox(new BoxDecoration(backgroundColor: 0xFF00FF00)));
|
child: new RenderDecoratedBox(
|
||||||
|
decoration: new BoxDecoration(backgroundColor: 0xFF00FF00)
|
||||||
|
)
|
||||||
|
);
|
||||||
RenderView renderView = new RenderView(child: root);
|
RenderView renderView = new RenderView(child: root);
|
||||||
renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
|
renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
|
||||||
expect(root.size.width, equals(sky.view.width));
|
expect(root.size.width, equals(sky.view.width));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class RenderSolidColor extends RenderDecoratedBox {
|
|||||||
|
|
||||||
RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infinite() })
|
RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infinite() })
|
||||||
: backgroundColor = backgroundColor,
|
: backgroundColor = backgroundColor,
|
||||||
super(new BoxDecoration(backgroundColor: backgroundColor)) {
|
super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sky.Size getIntrinsicDimensions(BoxConstraints constraints) {
|
sky.Size getIntrinsicDimensions(BoxConstraints constraints) {
|
||||||
@@ -39,45 +39,57 @@ void main() {
|
|||||||
initUnit();
|
initUnit();
|
||||||
|
|
||||||
test("should flex", () {
|
test("should flex", () {
|
||||||
var root = new RenderFlex(
|
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
|
||||||
direction: FlexDirection.Vertical,
|
|
||||||
decoration: new BoxDecoration(backgroundColor: 0xFF000000));
|
|
||||||
|
|
||||||
void addFlexChild(RenderFlex parent, int backgroundColor, { int flex: 0 }) {
|
RenderNode root = new RenderDecoratedBox(
|
||||||
|
decoration: new BoxDecoration(backgroundColor: 0xFF000000),
|
||||||
|
child: flexRoot
|
||||||
|
);
|
||||||
|
|
||||||
|
void addFlexChildSolidColor(RenderFlex parent, int backgroundColor, { int flex: 0 }) {
|
||||||
RenderNode child = new RenderSolidColor(backgroundColor);
|
RenderNode child = new RenderSolidColor(backgroundColor);
|
||||||
parent.add(child);
|
parent.add(child);
|
||||||
child.parentData.flex = flex;
|
child.parentData.flex = flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yellow bar at top
|
// Yellow bar at top
|
||||||
addFlexChild(root, 0xFFFFFF00, flex: 1);
|
addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1);
|
||||||
|
|
||||||
// Turquoise box
|
// Turquoise box
|
||||||
root.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.0, 100.0)));
|
flexRoot.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.0, 100.0)));
|
||||||
|
|
||||||
// Green and cyan render block with padding
|
// Green and cyan render block with padding
|
||||||
var renderBlock = new RenderBlock(decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF));
|
var renderBlock = new RenderBlock();
|
||||||
|
|
||||||
renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new sky.Size(100.0, 50.0)));
|
renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new sky.Size(100.0, 50.0)));
|
||||||
renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(50.0, 100.0)));
|
renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(50.0, 100.0)));
|
||||||
|
|
||||||
root.add(new RenderPadding(const EdgeDims(10.0, 10.0, 10.0, 10.0), renderBlock));
|
var renderDecoratedBlock = new RenderDecoratedBox(
|
||||||
|
decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF),
|
||||||
|
child: renderBlock
|
||||||
|
);
|
||||||
|
|
||||||
var row = new RenderFlex(
|
flexRoot.add(new RenderPadding(const EdgeDims(10.0, 10.0, 10.0, 10.0), renderDecoratedBlock));
|
||||||
direction: FlexDirection.Horizontal,
|
|
||||||
decoration: new BoxDecoration(backgroundColor: 0xFF333333));
|
var row = new RenderFlex(direction: FlexDirection.Horizontal);
|
||||||
|
|
||||||
// Purple and blue cells
|
// Purple and blue cells
|
||||||
addFlexChild(row, 0x77FF00FF, flex: 1);
|
addFlexChildSolidColor(row, 0x77FF00FF, flex: 1);
|
||||||
addFlexChild(row, 0xFF0000FF, flex: 2);
|
addFlexChildSolidColor(row, 0xFF0000FF, flex: 2);
|
||||||
|
|
||||||
root.add(row);
|
var decoratedRow = new RenderDecoratedBox(
|
||||||
row.parentData.flex = 3;
|
decoration: new BoxDecoration(backgroundColor: 0xFF333333),
|
||||||
|
child: row
|
||||||
|
);
|
||||||
|
|
||||||
|
flexRoot.add(decoratedRow);
|
||||||
|
decoratedRow.parentData.flex = 3;
|
||||||
|
|
||||||
app = new AppView(root);
|
app = new AppView(root);
|
||||||
|
|
||||||
expect(root.size.width, equals(sky.view.width));
|
expect(root.size.width, equals(sky.view.width));
|
||||||
expect(root.size.height, equals(sky.view.height));
|
expect(root.size.height, equals(sky.view.height));
|
||||||
expect(renderBlock.size.width, equals(sky.view.width - 20.0));
|
expect(renderBlock.size.width, equals(sky.view.width - 20.0));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user