Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 size = child.size; | 487 size = child.size; |
| 488 } else { | 488 } else { |
| 489 size = _additionalConstraints.apply(constraints).constrain(Size.zero); | 489 size = _additionalConstraints.apply(constraints).constrain(Size.zero); |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n'; | 493 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n'; |
| 494 } | 494 } |
| 495 | 495 |
| 496 class RenderShrinkWrapWidth extends RenderProxyBox { | 496 class RenderShrinkWrapWidth extends RenderProxyBox { |
| 497 RenderShrinkWrapWidth({ RenderBox child }) : super(child); | 497 RenderShrinkWrapWidth({ |
| 498 stepWidth, | |
| 499 stepHeight, | |
|
abarth-chromium
2015/06/30 20:51:44
Types?
Also, I wonder if we can think of a better
| |
| 500 RenderBox child | |
| 501 }) : _stepWidth = stepWidth, _stepHeight = stepHeight, super(child); | |
| 502 | |
| 503 double _stepWidth; | |
| 504 double get stepWidth => _stepWidth; | |
| 505 void set stepWidth(double value) { | |
| 506 if (value == _stepWidth) | |
| 507 return; | |
| 508 _stepWidth = value; | |
| 509 markNeedsLayout(); | |
| 510 } | |
| 511 | |
| 512 double _stepHeight; | |
| 513 double get stepHeight => _stepHeight; | |
| 514 void set stepHeight(double value) { | |
| 515 if (value == _stepHeight) | |
| 516 return; | |
| 517 _stepHeight = value; | |
| 518 markNeedsLayout(); | |
| 519 } | |
| 520 | |
| 521 static double applyStep(double input, double step) { | |
| 522 if (step == null) | |
| 523 return input; | |
| 524 return (input / step).ceil() * step; | |
| 525 } | |
| 498 | 526 |
| 499 BoxConstraints _getInnerConstraints(BoxConstraints constraints) { | 527 BoxConstraints _getInnerConstraints(BoxConstraints constraints) { |
| 500 double width = child.getMaxIntrinsicWidth(constraints); | 528 double width = child.getMaxIntrinsicWidth(constraints); |
| 501 assert(width == constraints.constrainWidth(width)); | 529 assert(width == constraints.constrainWidth(width)); |
| 502 return constraints.applyWidth(width); | 530 return constraints.applyWidth(width); |
| 503 } | 531 } |
| 504 | 532 |
| 505 double getMinIntrinsicWidth(BoxConstraints constraints) { | 533 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| 506 if (child != null) | 534 if (child == null) |
| 507 return child.getMaxIntrinsicWidth(constraints); | 535 return constraints.constrainWidth(0.0); |
| 508 return constraints.constrainWidth(0.0); | 536 double childResult = child.getMinIntrinsicWidth(constraints); |
| 537 return constraints.constrainWidth(applyStep(childResult, _stepWidth)); | |
| 509 } | 538 } |
| 510 | 539 |
| 511 double getMaxIntrinsicWidth(BoxConstraints constraints) { | 540 double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| 512 if (child != null) | 541 if (child == null) |
| 513 return child.getMaxIntrinsicWidth(constraints); | 542 return constraints.constrainWidth(0.0); |
| 514 return constraints.constrainWidth(0.0); | 543 double childResult = child.getMaxIntrinsicWidth(constraints); |
| 544 return constraints.constrainWidth(applyStep(childResult, _stepWidth)); | |
| 515 } | 545 } |
| 516 | 546 |
| 517 double getMinIntrinsicHeight(BoxConstraints constraints) { | 547 double getMinIntrinsicHeight(BoxConstraints constraints) { |
| 518 if (child != null) | 548 if (child == null) |
| 519 return child.getMinIntrinsicHeight(_getInnerConstraints(constraints)); | 549 return constraints.constrainWidth(0.0); |
| 520 return constraints.constrainWidth(0.0); | 550 double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constr aints)); |
| 551 return constraints.constrainHeight(applyStep(childResult, _stepHeight)); | |
| 521 } | 552 } |
| 522 | 553 |
| 523 double getMaxIntrinsicHeight(BoxConstraints constraints) { | 554 double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| 524 if (child != null) | 555 if (child == null) |
| 525 return child.getMaxIntrinsicHeight(_getInnerConstraints(constraints)); | 556 return constraints.constrainWidth(0.0); |
| 526 return constraints.constrainWidth(0.0); | 557 double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constr aints)); |
| 558 return constraints.constrainHeight(applyStep(childResult, _stepHeight)); | |
| 527 } | 559 } |
| 528 | 560 |
| 529 void performLayout() { | 561 void performLayout() { |
| 530 if (child != null) { | 562 if (child != null) { |
| 531 child.layout(_getInnerConstraints(constraints), parentUsesSize: true); | 563 child.layout(_getInnerConstraints(constraints), parentUsesSize: true); |
| 532 size = child.size; | 564 size = new Size(applyStep(child.size.width, _stepWidth), applyStep(child.s ize.height, _stepHeight)); |
| 533 } else { | 565 } else { |
| 534 performResize(); | 566 performResize(); |
| 535 } | 567 } |
| 536 } | 568 } |
| 537 } | 569 } |
| 538 | 570 |
| 539 class RenderOpacity extends RenderProxyBox { | 571 class RenderOpacity extends RenderProxyBox { |
| 540 RenderOpacity({ RenderBox child, double opacity }) | 572 RenderOpacity({ RenderBox child, double opacity }) |
| 541 : this._opacity = opacity, super(child) { | 573 : this._opacity = opacity, super(child) { |
| 542 assert(opacity >= 0.0 && opacity <= 1.0); | 574 assert(opacity >= 0.0 && opacity <= 1.0); |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1272 | 1304 |
| 1273 void defaultPaint(PaintingCanvas canvas, Offset offset) { | 1305 void defaultPaint(PaintingCanvas canvas, Offset offset) { |
| 1274 RenderBox child = firstChild; | 1306 RenderBox child = firstChild; |
| 1275 while (child != null) { | 1307 while (child != null) { |
| 1276 assert(child.parentData is ParentDataType); | 1308 assert(child.parentData is ParentDataType); |
| 1277 canvas.paintChild(child, child.parentData.position + offset); | 1309 canvas.paintChild(child, child.parentData.position + offset); |
| 1278 child = child.parentData.nextSibling; | 1310 child = child.parentData.nextSibling; |
| 1279 } | 1311 } |
| 1280 } | 1312 } |
| 1281 } | 1313 } |
| OLD | NEW |