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

Side by Side Diff: sky/sdk/lib/rendering/stack.dart

Issue 1213473003: Add asserts to catch potential misuses of the rendering framework. (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 unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/rendering/object.dart ('k') | sky/sdk/lib/widgets/scaffold.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 6
7 import 'box.dart'; 7 import 'box.dart';
8 import 'object.dart'; 8 import 'object.dart';
9 9
10 class StackParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { 10 class StackParentData extends BoxParentData with ContainerParentDataMixin<Render Box> {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 assert(size.width < double.INFINITY); 143 assert(size.width < double.INFINITY);
144 assert(size.height < double.INFINITY); 144 assert(size.height < double.INFINITY);
145 assert(size.width == constraints.constrainWidth(width)); 145 assert(size.width == constraints.constrainWidth(width));
146 assert(size.height == constraints.constrainHeight(height)); 146 assert(size.height == constraints.constrainHeight(height));
147 147
148 BoxConstraints innerConstraints = new BoxConstraints.loose(size); 148 BoxConstraints innerConstraints = new BoxConstraints.loose(size);
149 149
150 child = firstChild; 150 child = firstChild;
151 while (child != null) { 151 while (child != null) {
152 assert(child.parentData is StackParentData); 152 assert(child.parentData is StackParentData);
153 final StackParentData parentData = child.parentData; 153 final StackParentData childData = child.parentData;
154 154
155 if (parentData.isPositioned) { 155 if (childData.isPositioned) {
156 BoxConstraints childConstraints = innerConstraints; 156 BoxConstraints childConstraints = innerConstraints;
157 157
158 if (parentData.left != null && parentData.right != null) 158 if (childData.left != null && childData.right != null)
159 childConstraints = childConstraints.applyWidth(parentData.right - pare ntData.left); 159 childConstraints = childConstraints.applyWidth(childData.right - child Data.left);
160 else if (parentData.left != null) 160 else if (childData.left != null)
161 childConstraints = childConstraints.applyMaxWidth(size.width - parentD ata.left); 161 childConstraints = childConstraints.applyMaxWidth(size.width - childDa ta.left);
162 else if (parentData.right != null) 162 else if (childData.right != null)
163 childConstraints = childConstraints.applyMaxWidth(size.width - parentD ata.right); 163 childConstraints = childConstraints.applyMaxWidth(size.width - childDa ta.right);
164 164
165 if (parentData.top != null && parentData.bottom != null) 165 if (childData.top != null && childData.bottom != null)
166 childConstraints = childConstraints.applyHeight(parentData.bottom - pa rentData.top); 166 childConstraints = childConstraints.applyHeight(childData.bottom - chi ldData.top);
167 else if (parentData.top != null) 167 else if (childData.top != null)
168 childConstraints = childConstraints.applyMaxHeight(size.height - paren tData.top); 168 childConstraints = childConstraints.applyMaxHeight(size.height - child Data.top);
169 else if (parentData.bottom != null) 169 else if (childData.bottom != null)
170 childConstraints = childConstraints.applyMaxHeight(size.width - parent Data.bottom); 170 childConstraints = childConstraints.applyMaxHeight(size.width - childD ata.bottom);
171 171
172 child.layout(childConstraints); 172 child.layout(childConstraints, parentUsesSize: true);
173 173
174 double x = 0.0; 174 double x = 0.0;
175 if (parentData.left != null) 175 if (childData.left != null)
176 x = parentData.left; 176 x = childData.left;
177 else if (parentData.right != null) 177 else if (childData.right != null)
178 x = size.width - parentData.right - child.size.width; 178 x = size.width - childData.right - child.size.width;
179 assert(x >= 0.0 && x + child.size.width <= size.width); 179 assert(x >= 0.0 && x + child.size.width <= size.width);
180 180
181 double y = 0.0; 181 double y = 0.0;
182 if (parentData.top != null) 182 if (childData.top != null)
183 y = parentData.top; 183 y = childData.top;
184 else if (parentData.bottom != null) 184 else if (childData.bottom != null)
185 y = size.height - parentData.bottom - child.size.height; 185 y = size.height - childData.bottom - child.size.height;
186 assert(y >= 0.0 && y + child.size.height <= size.height); 186 assert(y >= 0.0 && y + child.size.height <= size.height);
187 187
188 parentData.position = new Point(x, y); 188 childData.position = new Point(x, y);
189 } 189 }
190 190
191 child = parentData.nextSibling; 191 child = childData.nextSibling;
192 } 192 }
193 } 193 }
194 194
195 void hitTestChildren(HitTestResult result, { Point position }) { 195 void hitTestChildren(HitTestResult result, { Point position }) {
196 defaultHitTestChildren(result, position: position); 196 defaultHitTestChildren(result, position: position);
197 } 197 }
198 198
199 void paint(RenderCanvas canvas) { 199 void paint(RenderCanvas canvas) {
200 defaultPaint(canvas); 200 defaultPaint(canvas);
201 } 201 }
202 } 202 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/rendering/object.dart ('k') | sky/sdk/lib/widgets/scaffold.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698