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

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

Issue 1215163003: Random cleanup of various Dart things in our tree. (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/mojo/asset_bundle.dart ('k') | no next file » | 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 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import 'package:vector_math/vector_math.dart'; 8 import 'package:vector_math/vector_math.dart';
9 9
10 import '../base/debug.dart'; 10 import '../base/debug.dart';
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 double getDistanceToActualBaseline(TextBaseline baseline) { 314 double getDistanceToActualBaseline(TextBaseline baseline) {
315 assert(!needsLayout); 315 assert(!needsLayout);
316 return null; 316 return null;
317 } 317 }
318 318
319 BoxConstraints get constraints => super.constraints; 319 BoxConstraints get constraints => super.constraints;
320 bool debugDoesMeetConstraints() { 320 bool debugDoesMeetConstraints() {
321 assert(constraints != null); 321 assert(constraints != null);
322 assert(_size != null); 322 assert(_size != null);
323 assert(!_size.isInfinite); 323 assert(!_size.isInfinite);
324 return constraints.contains(_size); 324 bool result = constraints.contains(_size);
325 if (!result)
326 print("${this.runtimeType} does not meet its constraints. Constraints: $co nstraints, size: $_size");
327 return result;
325 } 328 }
326 void performResize() { 329 void performResize() {
327 // default behaviour for subclasses that have sizedByParent = true 330 // default behaviour for subclasses that have sizedByParent = true
328 size = constraints.constrain(Size.zero); 331 size = constraints.constrain(Size.zero);
329 assert(!size.isInfinite); 332 assert(!size.isInfinite);
330 } 333 }
331 void performLayout() { 334 void performLayout() {
332 // descendants have to either override performLayout() to set both 335 // descendants have to either override performLayout() to set both
333 // width and height and lay out children, or, set sizedByParent to 336 // width and height and lay out children, or, set sizedByParent to
334 // true so that performResize()'s logic above does its thing. 337 // true so that performResize()'s logic above does its thing.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 759
757 double getMaxIntrinsicHeight(BoxConstraints constraints) { 760 double getMaxIntrinsicHeight(BoxConstraints constraints) {
758 double totalPadding = padding.top + padding.bottom; 761 double totalPadding = padding.top + padding.bottom;
759 if (child != null) 762 if (child != null)
760 return child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPa dding; 763 return child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPa dding;
761 return constraints.constrainHeight(totalPadding); 764 return constraints.constrainHeight(totalPadding);
762 } 765 }
763 766
764 void performLayout() { 767 void performLayout() {
765 assert(padding != null); 768 assert(padding != null);
766 BoxConstraints innerConstraints = constraints.deflate(padding);
767 if (child == null) { 769 if (child == null) {
768 size = innerConstraints.constrain( 770 size = constraints.constrain(new Size(
769 new Size(padding.left + padding.right, padding.top + padding.bottom)); 771 padding.left + padding.right,
772 padding.top + padding.bottom
773 ));
770 return; 774 return;
771 } 775 }
776 BoxConstraints innerConstraints = constraints.deflate(padding);
772 child.layout(innerConstraints, parentUsesSize: true); 777 child.layout(innerConstraints, parentUsesSize: true);
773 assert(child.parentData is BoxParentData); 778 assert(child.parentData is BoxParentData);
774 child.parentData.position = new Point(padding.left, padding.top); 779 child.parentData.position = new Point(padding.left, padding.top);
775 size = constraints.constrain(new Size(padding.left + child.size.width + padd ing.right, 780 size = constraints.constrain(new Size(
776 padding.top + child.size.height + padding.bottom)); 781 padding.left + child.size.width + padding.right,
782 padding.top + child.size.height + padding.bottom
783 ));
777 } 784 }
778 785
779 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}padding: ${padding}\n'; 786 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}padding: ${padding}\n';
780 } 787 }
781 788
782 class RenderPositionedBox extends RenderShiftedBox { 789 class RenderPositionedBox extends RenderShiftedBox {
783 790
784 RenderPositionedBox({ 791 RenderPositionedBox({
785 RenderBox child, 792 RenderBox child,
786 double horizontal: 0.5, 793 double horizontal: 0.5,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1154
1148 ViewConstraints _rootConstraints; 1155 ViewConstraints _rootConstraints;
1149 ViewConstraints get rootConstraints => _rootConstraints; 1156 ViewConstraints get rootConstraints => _rootConstraints;
1150 void set rootConstraints(ViewConstraints value) { 1157 void set rootConstraints(ViewConstraints value) {
1151 if (_rootConstraints == value) 1158 if (_rootConstraints == value)
1152 return; 1159 return;
1153 _rootConstraints = value; 1160 _rootConstraints = value;
1154 markNeedsLayout(); 1161 markNeedsLayout();
1155 } 1162 }
1156 1163
1164 // We never call layout() on this class, so this should never get
1165 // checked. (This class is laid out using scheduleInitialLayout().)
1166 bool debugDoesMeetConstraints() { assert(false); return false; }
1167
1157 void performResize() { 1168 void performResize() {
1158 assert(false); 1169 assert(false);
1159 } 1170 }
1160 1171
1161 void performLayout() { 1172 void performLayout() {
1162 if (_rootConstraints.orientation != _orientation) { 1173 if (_rootConstraints.orientation != _orientation) {
1163 if (_orientation != null && child != null) 1174 if (_orientation != null && child != null)
1164 child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientat ion, time: timeForRotation); 1175 child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientat ion, time: timeForRotation);
1165 _orientation = _rootConstraints.orientation; 1176 _orientation = _rootConstraints.orientation;
1166 } 1177 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 1272
1262 void defaultPaint(PaintingCanvas canvas, Offset offset) { 1273 void defaultPaint(PaintingCanvas canvas, Offset offset) {
1263 RenderBox child = firstChild; 1274 RenderBox child = firstChild;
1264 while (child != null) { 1275 while (child != null) {
1265 assert(child.parentData is ParentDataType); 1276 assert(child.parentData is ParentDataType);
1266 canvas.paintChild(child, child.parentData.position + offset); 1277 canvas.paintChild(child, child.parentData.position + offset);
1267 child = child.parentData.nextSibling; 1278 child = child.parentData.nextSibling;
1268 } 1279 }
1269 } 1280 }
1270 } 1281 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/mojo/asset_bundle.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698