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

Unified Diff: sky/sdk/lib/framework/layout2.dart

Issue 1152383002: A proof of concept for annular sector layout. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add the Path C++ and IDL files which I forgot before 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/examples/raw/sector-layout.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/layout2.dart
diff --git a/sky/sdk/lib/framework/layout2.dart b/sky/sdk/lib/framework/layout2.dart
index 4980f4cc6a897f118cc03aaa42b1e23561da865c..4d4baf25dcabaf416f809e9a8a2f5dd7a52bbbec 100644
--- a/sky/sdk/lib/framework/layout2.dart
+++ b/sky/sdk/lib/framework/layout2.dart
@@ -79,7 +79,7 @@ abstract class RenderNode extends AbstractNode {
void saveRelayoutSubtreeRoot(RenderNode relayoutSubtreeRoot) {
_relayoutSubtreeRoot = relayoutSubtreeRoot;
assert(_relayoutSubtreeRoot == null || _relayoutSubtreeRoot._relayoutSubtreeRoot == null);
- assert(_relayoutSubtreeRoot == null || _relayoutSubtreeRoot == parent || _relayoutSubtreeRoot == parent._relayoutSubtreeRoot);
+ assert(_relayoutSubtreeRoot == null || _relayoutSubtreeRoot == parent || (parent is RenderNode && _relayoutSubtreeRoot == parent._relayoutSubtreeRoot));
}
bool debugAncestorsAlreadyMarkedNeedsLayout() {
if (_relayoutSubtreeRoot == null)
@@ -103,6 +103,7 @@ abstract class RenderNode extends AbstractNode {
return;
}
_needsLayout = true;
+ assert(parent is RenderNode);
if (_relayoutSubtreeRoot != null)
parent.markNeedsLayout();
else
@@ -402,7 +403,7 @@ class BoxConstraints {
this.minHeight: 0.0,
this.maxHeight: double.INFINITY});
- const BoxConstraints.tight({ width: width, height: height })
+ const BoxConstraints.tight({ double width: 0.0, double height: 0.0 })
: minWidth = width,
maxWidth = width,
minHeight = height,
@@ -420,14 +421,17 @@ class BoxConstraints {
double constrainHeight(double height) {
return clamp(min: minHeight, max: maxHeight, value: height);
}
+
+ bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFINITY;
}
class BoxDimensions {
- const BoxDimensions({this.width, this.height});
+ const BoxDimensions({ this.width: 0.0, this.height: 0.0 });
BoxDimensions.withConstraints(
- BoxConstraints constraints, {double width: 0.0, double height: 0.0})
- : width = constraints.constrainWidth(width),
+ BoxConstraints constraints,
+ { double width: 0.0, double height: 0.0 }
+ ) : width = constraints.constrainWidth(width),
height = constraints.constrainHeight(height);
final double width;
@@ -661,7 +665,7 @@ class RenderBlock extends RenderDecoratedBox with ContainerRenderNodeMixin<Rende
double outerWidth = constraints.constrainWidth(constraints.maxWidth);
assert(outerWidth < double.INFINITY);
double innerWidth = outerWidth - (_padding.left + _padding.right);
- RenderBox child = _firstChild;
+ RenderBox child = firstChild;
BoxConstraints innerConstraints = new BoxConstraints(minWidth: innerWidth,
maxWidth: innerWidth);
while (child != null) {
@@ -696,7 +700,7 @@ class RenderBlock extends RenderDecoratedBox with ContainerRenderNodeMixin<Rende
assert(_maxHeight != null);
double y = _padding.top;
double innerWidth = width - (_padding.left + _padding.right);
- RenderBox child = _firstChild;
+ RenderBox child = firstChild;
while (child != null) {
child.layout(new BoxConstraints(minWidth: innerWidth, maxWidth: innerWidth),
relayoutSubtreeRoot: relayoutSubtreeRoot);
@@ -776,21 +780,19 @@ class RenderFlex extends RenderDecoratedBox with ContainerRenderNodeMixin<Render
int _getFlex(RenderBox child) {
assert(child.parentData is FlexBoxParentData);
- return (child.parentData.flex != null ? child.parentData.flex : 0);
+ return child.parentData.flex != null ? child.parentData.flex : 0;
}
void internalLayout(RenderNode relayoutSubtreeRoot) {
// Based on http://www.w3.org/TR/css-flexbox-1/ Section 9.7 Resolving Flexible Lengths
// Steps 1-3. Determine used flex factor, size inflexible items, calculate free space
- int numFlexibleChildren = 0;
int totalFlex = 0;
assert(_constraints != null);
double freeSpace = (_direction == FlexDirection.Horizontal) ? _constraints.maxWidth : _constraints.maxHeight;
- RenderBox child = _firstChild;
+ RenderBox child = firstChild;
while (child != null) {
int flex = _getFlex(child);
if (flex > 0) {
- numFlexibleChildren++;
totalFlex += child.parentData.flex;
} else {
BoxConstraints constraints = new BoxConstraints(maxHeight: _constraints.maxHeight,
@@ -805,7 +807,7 @@ class RenderFlex extends RenderDecoratedBox with ContainerRenderNodeMixin<Render
// Steps 4-5. Distribute remaining space to flexible children.
double spacePerFlex = totalFlex > 0 ? (freeSpace / totalFlex) : 0.0;
double usedSpace = 0.0;
- child = _firstChild;
+ child = firstChild;
while (child != null) {
int flex = _getFlex(child);
if (flex > 0) {
« no previous file with comments | « sky/examples/raw/sector-layout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698