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

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

Issue 1155303005: Fix logic in RenderPadding. (Closed) Base URL: https://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/rendering/block.dart ('k') | sky/tests/raw/box_layout.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 'node.dart'; 5 import 'node.dart';
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 import 'dart:math' as math;
7 8
8 // GENERIC BOX RENDERING 9 // GENERIC BOX RENDERING
9 // Anything that has a concept of x, y, width, height is going to derive from th is 10 // Anything that has a concept of x, y, width, height is going to derive from th is
10 11
11 class EdgeDims { 12 class EdgeDims {
12 // used for e.g. padding 13 // used for e.g. padding
13 const EdgeDims(this.top, this.right, this.bottom, this.left); 14 const EdgeDims(this.top, this.right, this.bottom, this.left);
14 const EdgeDims.all(double value) 15 const EdgeDims.all(double value)
15 : top = value, right = value, bottom = value, left = value; 16 : top = value, right = value, bottom = value, left = value;
16 17
(...skipping 16 matching lines...) Expand all
33 this.maxHeight: double.INFINITY}); 34 this.maxHeight: double.INFINITY});
34 35
35 BoxConstraints.tight(sky.Size size) 36 BoxConstraints.tight(sky.Size size)
36 : minWidth = size.width, 37 : minWidth = size.width,
37 maxWidth = size.width, 38 maxWidth = size.width,
38 minHeight = size.height, 39 minHeight = size.height,
39 maxHeight = size.height; 40 maxHeight = size.height;
40 41
41 BoxConstraints deflate(EdgeDims edges) { 42 BoxConstraints deflate(EdgeDims edges) {
42 assert(edges != null); 43 assert(edges != null);
44 var horizontal = edges.left + edges.right;
45 var vertical = edges.top + edges.bottom;
abarth-chromium 2015/06/03 17:22:33 s/var/double/
43 return new BoxConstraints( 46 return new BoxConstraints(
44 minWidth: minWidth, 47 minWidth: math.min(0.0, minWidth - horizontal),
45 maxWidth: maxWidth - (edges.left + edges.right), 48 maxWidth: maxWidth - horizontal,
46 minHeight: minHeight, 49 minHeight: math.min(0.0, minHeight - vertical),
47 maxHeight: maxHeight - (edges.top + edges.bottom) 50 maxHeight: maxHeight - vertical
48 ); 51 );
49 } 52 }
50 53
51 final double minWidth; 54 final double minWidth;
52 final double maxWidth; 55 final double maxWidth;
53 final double minHeight; 56 final double minHeight;
54 final double maxHeight; 57 final double maxHeight;
55 58
56 double constrainWidth(double width) { 59 double constrainWidth(double width) {
57 return clamp(min: minWidth, max: maxWidth, value: width); 60 return clamp(min: minWidth, max: maxWidth, value: width);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 _desiredSize = value; 167 _desiredSize = value;
165 markNeedsLayout(); 168 markNeedsLayout();
166 } 169 }
167 170
168 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { 171 sky.Size getIntrinsicDimensions(BoxConstraints constraints) {
169 return constraints.constrain(_desiredSize); 172 return constraints.constrain(_desiredSize);
170 } 173 }
171 174
172 void performLayout() { 175 void performLayout() {
173 size = constraints.constrain(_desiredSize); 176 size = constraints.constrain(_desiredSize);
174 child.layout(new BoxConstraints.tight(size)); 177 if (child != null)
178 child.layout(new BoxConstraints.tight(size));
175 } 179 }
176 } 180 }
177 181
178 class RenderPadding extends RenderBox with RenderNodeWithChildMixin<RenderBox> { 182 class RenderPadding extends RenderBox with RenderNodeWithChildMixin<RenderBox> {
179 183
180 RenderPadding({ EdgeDims padding, RenderBox child }) { 184 RenderPadding({ EdgeDims padding, RenderBox child }) {
181 assert(padding != null); 185 assert(padding != null);
182 this.padding = padding; 186 this.padding = padding;
183 this.child = child; 187 this.child = child;
184 } 188 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 382
379 void defaultPaint(RenderNodeDisplayList canvas) { 383 void defaultPaint(RenderNodeDisplayList canvas) {
380 RenderBox child = firstChild; 384 RenderBox child = firstChild;
381 while (child != null) { 385 while (child != null) {
382 assert(child.parentData is ParentDataType); 386 assert(child.parentData is ParentDataType);
383 canvas.paintChild(child, child.parentData.position); 387 canvas.paintChild(child, child.parentData.position);
384 child = child.parentData.nextSibling; 388 child = child.parentData.nextSibling;
385 } 389 }
386 } 390 }
387 } 391 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/rendering/block.dart ('k') | sky/tests/raw/box_layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698