Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: sky/sdk/lib/framework/rendering/render_block.dart

Issue 1161003002: Split layout2.dart into several files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/framework/layout2.dart ('k') | sky/sdk/lib/framework/rendering/render_box.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:sky' as sky;
6 import 'render_box.dart';
7 import 'render_node.dart';
8
9 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { }
10
11 class RenderBlock extends RenderBox with ContainerRenderNodeMixin<RenderBox, Blo ckParentData>,
12 RenderBoxContainerDefaultsMixin<RenderB ox, BlockParentData> {
13 // lays out RenderBox children in a vertical stack
14 // uses the maximum width provided by the parent
15 // sizes itself to the height of its child stack
16
17 void setParentData(RenderBox child) {
18 if (child.parentData is! BlockParentData)
19 child.parentData = new BlockParentData();
20 }
21
22 // override this to report what dimensions you would have if you
23 // were laid out with the given constraints this can walk the tree
24 // if it must, but it should be as cheap as possible; just get the
25 // dimensions and nothing else (e.g. don't calculate hypothetical
26 // child positions if they're not needed to determine dimensions)
27 sky.Size getIntrinsicDimensions(BoxConstraints constraints) {
28 double height = 0.0;
29 double width = constraints.constrainWidth(constraints.maxWidth);
30 assert(width < double.INFINITY);
31 RenderBox child = firstChild;
32 BoxConstraints innerConstraints = new BoxConstraints(minWidth: width,
33 maxWidth: width);
34 while (child != null) {
35 height += child.getIntrinsicDimensions(innerConstraints).height;
36 assert(child.parentData is BlockParentData);
37 child = child.parentData.nextSibling;
38 }
39
40 return new sky.Size(width, constraints.constrainHeight(height));
41 }
42
43 void performLayout() {
44 assert(constraints is BoxConstraints);
45 double width = constraints.constrainWidth(constraints.maxWidth);
46 double y = 0.0;
47 RenderBox child = firstChild;
48 while (child != null) {
49 child.layout(new BoxConstraints(minWidth: width, maxWidth: width), parentU sesSize: true);
50 assert(child.parentData is BlockParentData);
51 child.parentData.position = new sky.Point(0.0, y);
52 y += child.size.height;
53 child = child.parentData.nextSibling;
54 }
55 size = new sky.Size(width, constraints.constrainHeight(y));
56 assert(size.width < double.INFINITY);
57 assert(size.height < double.INFINITY);
58 }
59
60 void hitTestChildren(HitTestResult result, { sky.Point position }) {
61 defaultHitTestChildren(result, position: position);
62 }
63
64 void paint(RenderNodeDisplayList canvas) {
65 defaultPaint(canvas);
66 }
67
68 }
69
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/layout2.dart ('k') | sky/sdk/lib/framework/rendering/render_box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698