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

Unified 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, 7 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/rendering/render_block.dart
diff --git a/sky/sdk/lib/framework/rendering/render_block.dart b/sky/sdk/lib/framework/rendering/render_block.dart
new file mode 100644
index 0000000000000000000000000000000000000000..065e2110fd69fdf1fb15f681760a7ab3bef17fd9
--- /dev/null
+++ b/sky/sdk/lib/framework/rendering/render_block.dart
@@ -0,0 +1,69 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'dart:sky' as sky;
+import 'render_box.dart';
+import 'render_node.dart';
+
+class BlockParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> { }
+
+class RenderBlock extends RenderBox with ContainerRenderNodeMixin<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
+
+ void setParentData(RenderBox child) {
+ if (child.parentData is! BlockParentData)
+ child.parentData = new BlockParentData();
+ }
+
+ // override this to report what dimensions you would have if you
+ // were laid out with the given constraints this can walk the tree
+ // if it must, but it should be as cheap as possible; just get the
+ // dimensions and nothing else (e.g. don't calculate hypothetical
+ // child positions if they're not needed to determine dimensions)
+ sky.Size getIntrinsicDimensions(BoxConstraints constraints) {
+ double height = 0.0;
+ double width = constraints.constrainWidth(constraints.maxWidth);
+ assert(width < double.INFINITY);
+ RenderBox child = firstChild;
+ BoxConstraints innerConstraints = new BoxConstraints(minWidth: width,
+ maxWidth: width);
+ while (child != null) {
+ height += child.getIntrinsicDimensions(innerConstraints).height;
+ assert(child.parentData is BlockParentData);
+ child = child.parentData.nextSibling;
+ }
+
+ return new sky.Size(width, constraints.constrainHeight(height));
+ }
+
+ void performLayout() {
+ assert(constraints is BoxConstraints);
+ double width = constraints.constrainWidth(constraints.maxWidth);
+ double y = 0.0;
+ RenderBox child = firstChild;
+ while (child != null) {
+ child.layout(new BoxConstraints(minWidth: width, maxWidth: width), parentUsesSize: true);
+ assert(child.parentData is BlockParentData);
+ child.parentData.position = new sky.Point(0.0, y);
+ y += child.size.height;
+ child = child.parentData.nextSibling;
+ }
+ size = new sky.Size(width, constraints.constrainHeight(y));
+ assert(size.width < double.INFINITY);
+ assert(size.height < double.INFINITY);
+ }
+
+ void hitTestChildren(HitTestResult result, { sky.Point position }) {
+ defaultHitTestChildren(result, position: position);
+ }
+
+ void paint(RenderNodeDisplayList canvas) {
+ defaultPaint(canvas);
+ }
+
+}
+
« 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