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

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

Issue 1205953002: Version 0 of TabLabel, Tab, and TabBar components (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/BUILD.gn ('k') | sky/sdk/lib/rendering/box.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 BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { } 10 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { }
(...skipping 10 matching lines...) Expand all
21 addAll(children); 21 addAll(children);
22 } 22 }
23 23
24 void setParentData(RenderBox child) { 24 void setParentData(RenderBox child) {
25 if (child.parentData is! BlockParentData) 25 if (child.parentData is! BlockParentData)
26 child.parentData = new BlockParentData(); 26 child.parentData = new BlockParentData();
27 } 27 }
28 28
29 double getMinIntrinsicWidth(BoxConstraints constraints) { 29 double getMinIntrinsicWidth(BoxConstraints constraints) {
30 double width = 0.0; 30 double width = 0.0;
31 BoxConstraints innerConstraints = new BoxConstraints( 31 BoxConstraints innerConstraints = constraints.widthConstraints();
32 minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
33 RenderBox child = firstChild; 32 RenderBox child = firstChild;
34 while (child != null) { 33 while (child != null) {
35 width = math.max(width, child.getMinIntrinsicWidth(innerConstraints)); 34 width = math.max(width, child.getMinIntrinsicWidth(innerConstraints));
35 assert(child.parentData is BlockParentData);
36 child = child.parentData.nextSibling; 36 child = child.parentData.nextSibling;
37 } 37 }
38 return width; 38 return width;
39 } 39 }
40 40
41 double getMaxIntrinsicWidth(BoxConstraints constraints) { 41 double getMaxIntrinsicWidth(BoxConstraints constraints) {
42 double width = 0.0; 42 double width = 0.0;
43 BoxConstraints innerConstraints = new BoxConstraints( 43 BoxConstraints innerConstraints = constraints.widthConstraints();
44 minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
45 RenderBox child = firstChild; 44 RenderBox child = firstChild;
46 while (child != null) { 45 while (child != null) {
47 width = math.max(width, child.getMaxIntrinsicWidth(innerConstraints)); 46 width = math.max(width, child.getMaxIntrinsicWidth(innerConstraints));
47 assert(child.parentData is BlockParentData);
48 child = child.parentData.nextSibling; 48 child = child.parentData.nextSibling;
49 } 49 }
50 return width; 50 return width;
51 } 51 }
52 52
53 BoxConstraints _getInnerConstraintsForWidth(double width) { 53 BoxConstraints _getInnerConstraintsForWidth(double width) {
54 return new BoxConstraints(minWidth: width, maxWidth: width); 54 return new BoxConstraints(minWidth: width, maxWidth: width);
55 } 55 }
56 56
57 double _getIntrinsicHeight(BoxConstraints constraints) { 57 double _getIntrinsicHeight(BoxConstraints constraints) {
58 double height = 0.0; 58 double height = 0.0;
59 double width = constraints.constrainWidth(constraints.maxWidth); 59 double width = constraints.constrainWidth(constraints.maxWidth);
60 BoxConstraints innerConstraints = _getInnerConstraintsForWidth(width); 60 BoxConstraints innerConstraints = _getInnerConstraintsForWidth(width);
61 RenderBox child = firstChild; 61 RenderBox child = firstChild;
62 while (child != null) { 62 while (child != null) {
63 double childHeight = child.getMinIntrinsicHeight(innerConstraints); 63 double childHeight = child.getMinIntrinsicHeight(innerConstraints);
64 assert(childHeight == child.getMaxIntrinsicHeight(innerConstraints)); 64 assert(childHeight == child.getMaxIntrinsicHeight(innerConstraints));
65 height += childHeight; 65 height += childHeight;
66 assert(child.parentData is BlockParentData);
66 child = child.parentData.nextSibling; 67 child = child.parentData.nextSibling;
67 } 68 }
68 return height; 69 return height;
69 } 70 }
70 71
71 double getMinIntrinsicHeight(BoxConstraints constraints) { 72 double getMinIntrinsicHeight(BoxConstraints constraints) {
72 return _getIntrinsicHeight(constraints); 73 return _getIntrinsicHeight(constraints);
73 } 74 }
74 75
75 double getMaxIntrinsicHeight(BoxConstraints constraints) { 76 double getMaxIntrinsicHeight(BoxConstraints constraints) {
(...skipping 26 matching lines...) Expand all
102 void hitTestChildren(HitTestResult result, { Point position }) { 103 void hitTestChildren(HitTestResult result, { Point position }) {
103 defaultHitTestChildren(result, position: position); 104 defaultHitTestChildren(result, position: position);
104 } 105 }
105 106
106 void paint(RenderCanvas canvas) { 107 void paint(RenderCanvas canvas) {
107 defaultPaint(canvas); 108 defaultPaint(canvas);
108 } 109 }
109 110
110 } 111 }
111 112
OLDNEW
« no previous file with comments | « sky/sdk/BUILD.gn ('k') | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698