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

Unified Diff: sky/sdk/lib/rendering/block.dart

Issue 1226103003: Factor RenderBlock out into a base class and a subclass. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/block.dart
diff --git a/sky/sdk/lib/rendering/block.dart b/sky/sdk/lib/rendering/block.dart
index 11f20ef30abb6a1539b03c365ed827abc169a0c3..b14e16962de717a449427a1c13b98e34830dace7 100644
--- a/sky/sdk/lib/rendering/block.dart
+++ b/sky/sdk/lib/rendering/block.dart
@@ -9,15 +9,15 @@ import 'object.dart';
class BlockParentData extends BoxParentData with ContainerParentDataMixin<RenderBox> { }
-class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, BlockParentData>,
- RenderBoxContainerDefaultsMixin<RenderBox, BlockParentData> {
+abstract class RenderBlockBase extends RenderBox with ContainerRenderObjectMixin<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
bool _hasVisualOverflow = false;
- RenderBlock({
+ RenderBlockBase({
List<RenderBox> children
}) {
addAll(children);
@@ -83,6 +83,14 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
return defaultComputeDistanceToFirstActualBaseline(baseline);
}
+ double _childrenHeight;
+ double get childrenHeight => _childrenHeight;
+
+ void markNeedsLayout() {
+ _childrenHeight = null;
+ super.markNeedsLayout();
+ }
+
void performLayout() {
assert(constraints is BoxConstraints);
double width = constraints.constrainWidth(constraints.maxWidth);
@@ -96,25 +104,42 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
y += child.size.height;
child = child.parentData.nextSibling;
}
+ _childrenHeight = y;
+ }
+
+ void hitTestChildren(HitTestResult result, { Point position }) {
+ defaultHitTestChildren(result, position: position);
+ }
+
+ void paint(PaintingCanvas canvas, Offset offset) {
+ defaultPaint(canvas, offset);
+ }
+
+}
+
+class RenderBlock extends RenderBlockBase {
+
+ // sizes itself to the height of its child stack
+
+ RenderBlock({ List<RenderBox> children }) : super(children: children);
+
+ void performLayout() {
+ super.performLayout();
// FIXME(eseidel): Block lays out its children with unconstrained height
// yet itself remains constrained. Remember that our children wanted to
// be taller than we are so we know to clip them (and not cause confusing
// mismatch of painting vs. hittesting).
- size = new Size(width, constraints.constrainHeight(y));
- _hasVisualOverflow = y > size.height;
+ _hasVisualOverflow = childrenHeight > size.height;
+ size = constraints.constrain(new Size(constraints.maxWidth, childrenHeight));
assert(!size.isInfinite);
}
- void hitTestChildren(HitTestResult result, { Point position }) {
- defaultHitTestChildren(result, position: position);
- }
-
void paint(PaintingCanvas canvas, Offset offset) {
if (_hasVisualOverflow) {
canvas.save();
canvas.clipRect(offset & size);
}
- defaultPaint(canvas, offset);
+ super.paint(canvas, offset);
if (_hasVisualOverflow) {
canvas.restore();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698