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

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

Issue 1226113007: Add @override annotation to known overriden methods (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/block.dart ('k') | sky/sdk/lib/rendering/flex.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 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 23 matching lines...) Expand all
34 this.left: 0.0 }); 34 this.left: 0.0 });
35 const EdgeDims.symmetric({ double vertical: 0.0, 35 const EdgeDims.symmetric({ double vertical: 0.0,
36 double horizontal: 0.0 }) 36 double horizontal: 0.0 })
37 : top = vertical, left = horizontal, bottom = vertical, right = horizontal; 37 : top = vertical, left = horizontal, bottom = vertical, right = horizontal;
38 38
39 final double top; 39 final double top;
40 final double right; 40 final double right;
41 final double bottom; 41 final double bottom;
42 final double left; 42 final double left;
43 43
44 @override
44 bool operator ==(other) { 45 bool operator ==(other) {
45 if (identical(this, other)) 46 if (identical(this, other))
46 return true; 47 return true;
47 return other is EdgeDims 48 return other is EdgeDims
48 && top == other.top 49 && top == other.top
49 && right == other.right 50 && right == other.right
50 && bottom == other.bottom 51 && bottom == other.bottom
51 && left == other.left; 52 && left == other.left;
52 } 53 }
53 54
55 @override
54 int get hashCode { 56 int get hashCode {
55 int value = 373; 57 int value = 373;
56 value = 37 * value + top.hashCode; 58 value = 37 * value + top.hashCode;
57 value = 37 * value + left.hashCode; 59 value = 37 * value + left.hashCode;
58 value = 37 * value + bottom.hashCode; 60 value = 37 * value + bottom.hashCode;
59 value = 37 * value + right.hashCode; 61 value = 37 * value + right.hashCode;
60 return value; 62 return value;
61 } 63 }
64
65 @override
62 String toString() => "EdgeDims($top, $right, $bottom, $left)"; 66 String toString() => "EdgeDims($top, $right, $bottom, $left)";
63 } 67 }
64 68
65 class BoxConstraints extends Constraints { 69 class BoxConstraints extends Constraints {
66 const BoxConstraints({ 70 const BoxConstraints({
67 this.minWidth: 0.0, 71 this.minWidth: 0.0,
68 this.maxWidth: double.INFINITY, 72 this.maxWidth: double.INFINITY,
69 this.minHeight: 0.0, 73 this.minHeight: 0.0,
70 this.maxHeight: double.INFINITY 74 this.maxHeight: double.INFINITY
71 }); 75 });
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 result = new _DebugSize(result, size._owner, size._canBeUsedByParent); 208 result = new _DebugSize(result, size._owner, size._canBeUsedByParent);
205 return result; 209 return result;
206 } 210 }
207 Size get biggest => new Size(constrainWidth(), constrainHeight()); 211 Size get biggest => new Size(constrainWidth(), constrainHeight());
208 Size get smallest => new Size(constrainWidth(0.0), constrainHeight(0.0)); 212 Size get smallest => new Size(constrainWidth(0.0), constrainHeight(0.0));
209 213
210 bool get isInfinite => maxWidth >= double.INFINITY && maxHeight >= double.INFI NITY; 214 bool get isInfinite => maxWidth >= double.INFINITY && maxHeight >= double.INFI NITY;
211 215
212 bool get hasTightWidth => minWidth >= maxWidth; 216 bool get hasTightWidth => minWidth >= maxWidth;
213 bool get hasTightHeight => minHeight >= maxHeight; 217 bool get hasTightHeight => minHeight >= maxHeight;
218
219 @override
214 bool get isTight => hasTightWidth && hasTightHeight; 220 bool get isTight => hasTightWidth && hasTightHeight;
215 221
216 bool contains(Size size) { 222 bool contains(Size size) {
217 return (minWidth <= size.width) && (size.width <= math.max(minWidth, maxWidt h)) && 223 return (minWidth <= size.width) && (size.width <= math.max(minWidth, maxWidt h)) &&
218 (minHeight <= size.height) && (size.height <= math.max(minHeight, max Height)); 224 (minHeight <= size.height) && (size.height <= math.max(minHeight, max Height));
219 } 225 }
220 226
227 @override
221 bool operator ==(other) { 228 bool operator ==(other) {
222 if (identical(this, other)) 229 if (identical(this, other))
223 return true; 230 return true;
224 return other is BoxConstraints && 231 return other is BoxConstraints &&
225 minWidth == other.minWidth && 232 minWidth == other.minWidth &&
226 maxWidth == other.maxWidth && 233 maxWidth == other.maxWidth &&
227 minHeight == other.minHeight && 234 minHeight == other.minHeight &&
228 maxHeight == other.maxHeight; 235 maxHeight == other.maxHeight;
229 } 236 }
237
238 @override
230 int get hashCode { 239 int get hashCode {
231 int value = 373; 240 int value = 373;
232 value = 37 * value + minWidth.hashCode; 241 value = 37 * value + minWidth.hashCode;
233 value = 37 * value + maxWidth.hashCode; 242 value = 37 * value + maxWidth.hashCode;
234 value = 37 * value + minHeight.hashCode; 243 value = 37 * value + minHeight.hashCode;
235 value = 37 * value + maxHeight.hashCode; 244 value = 37 * value + maxHeight.hashCode;
236 return value; 245 return value;
237 } 246 }
238 247
248 @override
239 String toString() => "BoxConstraints($minWidth<=w<$maxWidth, $minHeight<=h<$ma xHeight)"; 249 String toString() => "BoxConstraints($minWidth<=w<$maxWidth, $minHeight<=h<$ma xHeight)";
240 } 250 }
241 251
242 class BoxHitTestEntry extends HitTestEntry { 252 class BoxHitTestEntry extends HitTestEntry {
243 const BoxHitTestEntry(HitTestTarget target, this.localPosition) : super(target ); 253 const BoxHitTestEntry(HitTestTarget target, this.localPosition) : super(target );
244 final Point localPosition; 254 final Point localPosition;
245 } 255 }
246 256
247 class BoxParentData extends ParentData { 257 class BoxParentData extends ParentData {
248 Point _position = Point.origin; 258 Point _position = Point.origin;
249 Point get position => _position; 259 Point get position => _position;
250 void set position(Point value) { 260 void set position(Point value) {
251 assert(RenderObject.debugDoingLayout); 261 assert(RenderObject.debugDoingLayout);
252 _position = value; 262 _position = value;
253 } 263 }
264
265 @override
254 String toString() => 'position=$position'; 266 String toString() => 'position=$position';
255 } 267 }
256 268
257 enum TextBaseline { alphabetic, ideographic } 269 enum TextBaseline { alphabetic, ideographic }
258 270
259 abstract class RenderBox extends RenderObject { 271 abstract class RenderBox extends RenderObject {
260 272
273 @override
261 void setupParentData(RenderObject child) { 274 void setupParentData(RenderObject child) {
262 if (child.parentData is! BoxParentData) 275 if (child.parentData is! BoxParentData)
263 child.parentData = new BoxParentData(); 276 child.parentData = new BoxParentData();
264 } 277 }
265 278
266 // getMinIntrinsicWidth() should return the minimum width that this box could 279 // getMinIntrinsicWidth() should return the minimum width that this box could
267 // be without failing to render its contents within itself. 280 // be without failing to render its contents within itself.
268 double getMinIntrinsicWidth(BoxConstraints constraints) { 281 double getMinIntrinsicWidth(BoxConstraints constraints) {
269 return constraints.constrainWidth(0.0); 282 return constraints.constrainWidth(0.0);
270 } 283 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // should not be called directly. Use getDistanceToBaseline() if you 356 // should not be called directly. Use getDistanceToBaseline() if you
344 // need to know the baseline of a child from performLayout(). If you 357 // need to know the baseline of a child from performLayout(). If you
345 // need the baseline during paint, cache it during performLayout(). 358 // need the baseline during paint, cache it during performLayout().
346 // Use getDistanceToActualBaseline() if you are implementing 359 // Use getDistanceToActualBaseline() if you are implementing
347 // computeDistanceToActualBaseline() and need to defer to a child. 360 // computeDistanceToActualBaseline() and need to defer to a child.
348 double computeDistanceToActualBaseline(TextBaseline baseline) { 361 double computeDistanceToActualBaseline(TextBaseline baseline) {
349 assert(_debugDoingBaseline); 362 assert(_debugDoingBaseline);
350 return null; 363 return null;
351 } 364 }
352 365
366 @override
353 BoxConstraints get constraints => super.constraints; 367 BoxConstraints get constraints => super.constraints;
368
369 @override
354 bool debugDoesMeetConstraints() { 370 bool debugDoesMeetConstraints() {
355 assert(constraints != null); 371 assert(constraints != null);
356 assert(_size != null); 372 assert(_size != null);
357 assert(!_size.isInfinite); 373 assert(!_size.isInfinite);
358 bool result = constraints.contains(_size); 374 bool result = constraints.contains(_size);
359 if (!result) 375 if (!result)
360 print("${this.runtimeType} does not meet its constraints. Constraints: $co nstraints, size: $_size"); 376 print("${this.runtimeType} does not meet its constraints. Constraints: $co nstraints, size: $_size");
361 return result; 377 return result;
362 } 378 }
363 379
380 @override
364 void markNeedsLayout() { 381 void markNeedsLayout() {
365 if (_cachedBaselines != null && _cachedBaselines.isNotEmpty) { 382 if (_cachedBaselines != null && _cachedBaselines.isNotEmpty) {
366 // if we have cached data, then someone must have used our data 383 // if we have cached data, then someone must have used our data
367 assert(_ancestorUsesBaseline); 384 assert(_ancestorUsesBaseline);
368 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i s cleverer 385 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i s cleverer
369 assert(parent is RenderObject); 386 assert(parent is RenderObject);
370 parent.markNeedsLayout(); 387 parent.markNeedsLayout();
371 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze r is cleverer 388 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze r is cleverer
372 // Now that they're dirty, we can forget that they used the 389 // Now that they're dirty, we can forget that they used the
373 // baseline. If they use it again, then we'll set the bit 390 // baseline. If they use it again, then we'll set the bit
374 // again, and if we get dirty again, we'll notify them again. 391 // again, and if we get dirty again, we'll notify them again.
375 _ancestorUsesBaseline = false; 392 _ancestorUsesBaseline = false;
376 _cachedBaselines.clear(); 393 _cachedBaselines.clear();
377 } else { 394 } else {
378 // if we've never cached any data, then nobody can have used it 395 // if we've never cached any data, then nobody can have used it
379 assert(!_ancestorUsesBaseline); 396 assert(!_ancestorUsesBaseline);
380 } 397 }
381 super.markNeedsLayout(); 398 super.markNeedsLayout();
382 } 399 }
400
401 @override
383 void performResize() { 402 void performResize() {
384 // default behaviour for subclasses that have sizedByParent = true 403 // default behaviour for subclasses that have sizedByParent = true
385 size = constraints.constrain(Size.zero); 404 size = constraints.constrain(Size.zero);
386 assert(!size.isInfinite); 405 assert(!size.isInfinite);
387 } 406 }
407
408 @override
388 void performLayout() { 409 void performLayout() {
389 // descendants have to either override performLayout() to set both 410 // descendants have to either override performLayout() to set both
390 // width and height and lay out children, or, set sizedByParent to 411 // width and height and lay out children, or, set sizedByParent to
391 // true so that performResize()'s logic above does its thing. 412 // true so that performResize()'s logic above does its thing.
392 assert(sizedByParent); 413 assert(sizedByParent);
393 } 414 }
394 415
395 bool hitTest(HitTestResult result, { Point position }) { 416 bool hitTest(HitTestResult result, { Point position }) {
396 hitTestChildren(result, position: position); 417 hitTestChildren(result, position: position);
397 result.add(new BoxHitTestEntry(this, position)); 418 result.add(new BoxHitTestEntry(this, position));
(...skipping 24 matching lines...) Expand all
422 void set size(Size value) { 443 void set size(Size value) {
423 assert((sizedByParent && debugDoingThisResize) || 444 assert((sizedByParent && debugDoingThisResize) ||
424 (!sizedByParent && debugDoingThisLayout)); 445 (!sizedByParent && debugDoingThisLayout));
425 if (value is _DebugSize) { 446 if (value is _DebugSize) {
426 assert(value._canBeUsedByParent); 447 assert(value._canBeUsedByParent);
427 assert(value._owner.parent == this); 448 assert(value._owner.parent == this);
428 } 449 }
429 _size = inDebugBuild ? new _DebugSize(value, this, debugCanParentUseSize) : value; 450 _size = inDebugBuild ? new _DebugSize(value, this, debugCanParentUseSize) : value;
430 } 451 }
431 452
453 @override
432 Rect get paintBounds => Point.origin & size; 454 Rect get paintBounds => Point.origin & size;
433 455
456 @override
434 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n'; 457 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n';
435 } 458 }
436 459
437 class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox > { 460 class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox > {
438 461
439 // ProxyBox assumes the child will be at 0,0 and will have the same size 462 // ProxyBox assumes the child will be at 0,0 and will have the same size
440 463
441 RenderProxyBox([RenderBox child = null]) { 464 RenderProxyBox([RenderBox child = null]) {
442 this.child = child; 465 this.child = child;
443 } 466 }
444 467
468 @override
445 double getMinIntrinsicWidth(BoxConstraints constraints) { 469 double getMinIntrinsicWidth(BoxConstraints constraints) {
446 if (child != null) 470 if (child != null)
447 return child.getMinIntrinsicWidth(constraints); 471 return child.getMinIntrinsicWidth(constraints);
448 return super.getMinIntrinsicWidth(constraints); 472 return super.getMinIntrinsicWidth(constraints);
449 } 473 }
450 474
475 @override
451 double getMaxIntrinsicWidth(BoxConstraints constraints) { 476 double getMaxIntrinsicWidth(BoxConstraints constraints) {
452 if (child != null) 477 if (child != null)
453 return child.getMaxIntrinsicWidth(constraints); 478 return child.getMaxIntrinsicWidth(constraints);
454 return super.getMaxIntrinsicWidth(constraints); 479 return super.getMaxIntrinsicWidth(constraints);
455 } 480 }
456 481
482 @override
457 double getMinIntrinsicHeight(BoxConstraints constraints) { 483 double getMinIntrinsicHeight(BoxConstraints constraints) {
458 if (child != null) 484 if (child != null)
459 return child.getMinIntrinsicHeight(constraints); 485 return child.getMinIntrinsicHeight(constraints);
460 return super.getMinIntrinsicHeight(constraints); 486 return super.getMinIntrinsicHeight(constraints);
461 } 487 }
462 488
489 @override
463 double getMaxIntrinsicHeight(BoxConstraints constraints) { 490 double getMaxIntrinsicHeight(BoxConstraints constraints) {
464 if (child != null) 491 if (child != null)
465 return child.getMaxIntrinsicHeight(constraints); 492 return child.getMaxIntrinsicHeight(constraints);
466 return super.getMaxIntrinsicHeight(constraints); 493 return super.getMaxIntrinsicHeight(constraints);
467 } 494 }
468 495
496 @override
469 double computeDistanceToActualBaseline(TextBaseline baseline) { 497 double computeDistanceToActualBaseline(TextBaseline baseline) {
470 if (child != null) 498 if (child != null)
471 return child.getDistanceToActualBaseline(baseline); 499 return child.getDistanceToActualBaseline(baseline);
472 return super.computeDistanceToActualBaseline(baseline); 500 return super.computeDistanceToActualBaseline(baseline);
473 } 501 }
474 502
503 @override
475 void performLayout() { 504 void performLayout() {
476 if (child != null) { 505 if (child != null) {
477 child.layout(constraints, parentUsesSize: true); 506 child.layout(constraints, parentUsesSize: true);
478 size = child.size; 507 size = child.size;
479 } else { 508 } else {
480 performResize(); 509 performResize();
481 } 510 }
482 } 511 }
483 512
513 @override
484 void hitTestChildren(HitTestResult result, { Point position }) { 514 void hitTestChildren(HitTestResult result, { Point position }) {
485 if (child != null) 515 if (child != null)
486 child.hitTest(result, position: position); 516 child.hitTest(result, position: position);
487 else 517 else
488 super.hitTestChildren(result, position: position); 518 super.hitTestChildren(result, position: position);
489 } 519 }
490 520
521 @override
491 void paint(PaintingCanvas canvas, Offset offset) { 522 void paint(PaintingCanvas canvas, Offset offset) {
492 if (child != null) 523 if (child != null)
493 canvas.paintChild(child, offset.toPoint()); 524 canvas.paintChild(child, offset.toPoint());
494 } 525 }
495 526
496 } 527 }
497 528
498 class RenderConstrainedBox extends RenderProxyBox { 529 class RenderConstrainedBox extends RenderProxyBox {
499 RenderConstrainedBox({ 530 RenderConstrainedBox({
500 RenderBox child, 531 RenderBox child,
501 BoxConstraints additionalConstraints 532 BoxConstraints additionalConstraints
502 }) : super(child), _additionalConstraints = additionalConstraints { 533 }) : super(child), _additionalConstraints = additionalConstraints {
503 assert(additionalConstraints != null); 534 assert(additionalConstraints != null);
504 } 535 }
505 536
506 BoxConstraints _additionalConstraints; 537 BoxConstraints _additionalConstraints;
507 BoxConstraints get additionalConstraints => _additionalConstraints; 538 BoxConstraints get additionalConstraints => _additionalConstraints;
508 void set additionalConstraints (BoxConstraints value) { 539 void set additionalConstraints (BoxConstraints value) {
509 assert(value != null); 540 assert(value != null);
510 if (_additionalConstraints == value) 541 if (_additionalConstraints == value)
511 return; 542 return;
512 _additionalConstraints = value; 543 _additionalConstraints = value;
513 markNeedsLayout(); 544 markNeedsLayout();
514 } 545 }
515 546
547 @override
516 double getMinIntrinsicWidth(BoxConstraints constraints) { 548 double getMinIntrinsicWidth(BoxConstraints constraints) {
517 if (child != null) 549 if (child != null)
518 return child.getMinIntrinsicWidth(_additionalConstraints.apply(constraints )); 550 return child.getMinIntrinsicWidth(_additionalConstraints.apply(constraints ));
519 return constraints.constrainWidth(0.0); 551 return constraints.constrainWidth(0.0);
520 } 552 }
521 553
554 @override
522 double getMaxIntrinsicWidth(BoxConstraints constraints) { 555 double getMaxIntrinsicWidth(BoxConstraints constraints) {
523 if (child != null) 556 if (child != null)
524 return child.getMaxIntrinsicWidth(_additionalConstraints.apply(constraints )); 557 return child.getMaxIntrinsicWidth(_additionalConstraints.apply(constraints ));
525 return constraints.constrainWidth(0.0); 558 return constraints.constrainWidth(0.0);
526 } 559 }
527 560
561 @override
528 double getMinIntrinsicHeight(BoxConstraints constraints) { 562 double getMinIntrinsicHeight(BoxConstraints constraints) {
529 if (child != null) 563 if (child != null)
530 return child.getMinIntrinsicHeight(_additionalConstraints.apply(constraint s)); 564 return child.getMinIntrinsicHeight(_additionalConstraints.apply(constraint s));
531 return constraints.constrainHeight(0.0); 565 return constraints.constrainHeight(0.0);
532 } 566 }
533 567
568 @override
534 double getMaxIntrinsicHeight(BoxConstraints constraints) { 569 double getMaxIntrinsicHeight(BoxConstraints constraints) {
535 if (child != null) 570 if (child != null)
536 return child.getMaxIntrinsicHeight(_additionalConstraints.apply(constraint s)); 571 return child.getMaxIntrinsicHeight(_additionalConstraints.apply(constraint s));
537 return constraints.constrainHeight(0.0); 572 return constraints.constrainHeight(0.0);
538 } 573 }
539 574
575 @override
540 void performLayout() { 576 void performLayout() {
541 if (child != null) { 577 if (child != null) {
542 child.layout(_additionalConstraints.apply(constraints), parentUsesSize: tr ue); 578 child.layout(_additionalConstraints.apply(constraints), parentUsesSize: tr ue);
543 size = child.size; 579 size = child.size;
544 } else { 580 } else {
545 size = _additionalConstraints.apply(constraints).constrain(Size.zero); 581 size = _additionalConstraints.apply(constraints).constrain(Size.zero);
546 } 582 }
547 } 583 }
548 584
585 @override
549 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n'; 586 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n';
550 } 587 }
551 588
552 class RenderShrinkWrapWidth extends RenderProxyBox { 589 class RenderShrinkWrapWidth extends RenderProxyBox {
553 590
554 // This class will attempt to size its child to the child's maximum 591 // This class will attempt to size its child to the child's maximum
555 // intrinsic width, snapped to a multiple of the stepWidth, if one 592 // intrinsic width, snapped to a multiple of the stepWidth, if one
556 // is provided, and given the provided constraints; and will then 593 // is provided, and given the provided constraints; and will then
557 // adopt the child's resulting dimensions. 594 // adopt the child's resulting dimensions.
558 595
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 627 }
591 628
592 BoxConstraints _getInnerConstraints(BoxConstraints constraints) { 629 BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
593 if (constraints.hasTightWidth) 630 if (constraints.hasTightWidth)
594 return constraints; 631 return constraints;
595 double width = child.getMaxIntrinsicWidth(constraints); 632 double width = child.getMaxIntrinsicWidth(constraints);
596 assert(width == constraints.constrainWidth(width)); 633 assert(width == constraints.constrainWidth(width));
597 return constraints.applyWidth(applyStep(width, _stepWidth)); 634 return constraints.applyWidth(applyStep(width, _stepWidth));
598 } 635 }
599 636
637 @override
600 double getMinIntrinsicWidth(BoxConstraints constraints) { 638 double getMinIntrinsicWidth(BoxConstraints constraints) {
601 return getMaxIntrinsicWidth(constraints); 639 return getMaxIntrinsicWidth(constraints);
602 } 640 }
603 641
642 @override
604 double getMaxIntrinsicWidth(BoxConstraints constraints) { 643 double getMaxIntrinsicWidth(BoxConstraints constraints) {
605 if (child == null) 644 if (child == null)
606 return constraints.constrainWidth(0.0); 645 return constraints.constrainWidth(0.0);
607 double childResult = child.getMaxIntrinsicWidth(constraints); 646 double childResult = child.getMaxIntrinsicWidth(constraints);
608 return constraints.constrainWidth(applyStep(childResult, _stepWidth)); 647 return constraints.constrainWidth(applyStep(childResult, _stepWidth));
609 } 648 }
610 649
650 @override
611 double getMinIntrinsicHeight(BoxConstraints constraints) { 651 double getMinIntrinsicHeight(BoxConstraints constraints) {
612 if (child == null) 652 if (child == null)
613 return constraints.constrainWidth(0.0); 653 return constraints.constrainWidth(0.0);
614 double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constr aints)); 654 double childResult = child.getMinIntrinsicHeight(_getInnerConstraints(constr aints));
615 return constraints.constrainHeight(applyStep(childResult, _stepHeight)); 655 return constraints.constrainHeight(applyStep(childResult, _stepHeight));
616 } 656 }
617 657
658 @override
618 double getMaxIntrinsicHeight(BoxConstraints constraints) { 659 double getMaxIntrinsicHeight(BoxConstraints constraints) {
619 if (child == null) 660 if (child == null)
620 return constraints.constrainWidth(0.0); 661 return constraints.constrainWidth(0.0);
621 double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constr aints)); 662 double childResult = child.getMaxIntrinsicHeight(_getInnerConstraints(constr aints));
622 return constraints.constrainHeight(applyStep(childResult, _stepHeight)); 663 return constraints.constrainHeight(applyStep(childResult, _stepHeight));
623 } 664 }
624 665
666 @override
625 void performLayout() { 667 void performLayout() {
626 if (child != null) { 668 if (child != null) {
627 BoxConstraints childConstraints = _getInnerConstraints(constraints); 669 BoxConstraints childConstraints = _getInnerConstraints(constraints);
628 if (_stepHeight != null) 670 if (_stepHeight != null)
629 childConstraints.applyHeight(getMaxIntrinsicHeight(childConstraints)); 671 childConstraints.applyHeight(getMaxIntrinsicHeight(childConstraints));
630 child.layout(childConstraints, parentUsesSize: true); 672 child.layout(childConstraints, parentUsesSize: true);
631 size = child.size; 673 size = child.size;
632 } else { 674 } else {
633 performResize(); 675 performResize();
634 } 676 }
635 } 677 }
636 678
679 @override
637 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}stepWidth: ${stepWidth}\n${prefix}stepHeight: ${stepHeight}\n'; 680 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}stepWidth: ${stepWidth}\n${prefix}stepHeight: ${stepHeight}\n';
638 681
639 } 682 }
640 683
641 class RenderOpacity extends RenderProxyBox { 684 class RenderOpacity extends RenderProxyBox {
642 RenderOpacity({ RenderBox child, double opacity }) 685 RenderOpacity({ RenderBox child, double opacity })
643 : this._opacity = opacity, super(child) { 686 : this._opacity = opacity, super(child) {
644 assert(opacity >= 0.0 && opacity <= 1.0); 687 assert(opacity >= 0.0 && opacity <= 1.0);
645 } 688 }
646 689
647 double _opacity; 690 double _opacity;
648 double get opacity => _opacity; 691 double get opacity => _opacity;
649 void set opacity (double value) { 692 void set opacity (double value) {
650 assert(value != null); 693 assert(value != null);
651 assert(value >= 0.0 && value <= 1.0); 694 assert(value >= 0.0 && value <= 1.0);
652 if (_opacity == value) 695 if (_opacity == value)
653 return; 696 return;
654 _opacity = value; 697 _opacity = value;
655 markNeedsPaint(); 698 markNeedsPaint();
656 } 699 }
657 700
701 @override
658 void paint(PaintingCanvas canvas, Offset offset) { 702 void paint(PaintingCanvas canvas, Offset offset) {
659 if (child != null) { 703 if (child != null) {
660 int a = (_opacity * 255).round(); 704 int a = (_opacity * 255).round();
661 705
662 if (a == 0) 706 if (a == 0)
663 return; 707 return;
664 708
665 if (a == 255) { 709 if (a == 255) {
666 canvas.paintChild(child, offset.toPoint()); 710 canvas.paintChild(child, offset.toPoint());
667 return; 711 return;
(...skipping 27 matching lines...) Expand all
695 sky.TransferMode _transferMode; 739 sky.TransferMode _transferMode;
696 sky.TransferMode get transferMode => _transferMode; 740 sky.TransferMode get transferMode => _transferMode;
697 void set transferMode (sky.TransferMode value) { 741 void set transferMode (sky.TransferMode value) {
698 assert(value != null); 742 assert(value != null);
699 if (_transferMode == value) 743 if (_transferMode == value)
700 return; 744 return;
701 _transferMode = value; 745 _transferMode = value;
702 markNeedsPaint(); 746 markNeedsPaint();
703 } 747 }
704 748
749 @override
705 void paint(PaintingCanvas canvas, Offset offset) { 750 void paint(PaintingCanvas canvas, Offset offset) {
706 if (child != null) { 751 if (child != null) {
707 Paint paint = new Paint() 752 Paint paint = new Paint()
708 ..setColorFilter(new sky.ColorFilter.mode(_color, _transferMode)); 753 ..setColorFilter(new sky.ColorFilter.mode(_color, _transferMode));
709 canvas.saveLayer(null, paint); 754 canvas.saveLayer(null, paint);
710 canvas.paintChild(child, offset.toPoint()); 755 canvas.paintChild(child, offset.toPoint());
711 canvas.restore(); 756 canvas.restore();
712 } 757 }
713 } 758 }
714 } 759 }
715 760
716 class RenderClipRect extends RenderProxyBox { 761 class RenderClipRect extends RenderProxyBox {
717 RenderClipRect({ RenderBox child }) : super(child); 762 RenderClipRect({ RenderBox child }) : super(child);
718 763
764 @override
719 void paint(PaintingCanvas canvas, Offset offset) { 765 void paint(PaintingCanvas canvas, Offset offset) {
720 if (child != null) { 766 if (child != null) {
721 canvas.save(); 767 canvas.save();
722 canvas.clipRect(offset & size); 768 canvas.clipRect(offset & size);
723 canvas.paintChild(child, offset.toPoint()); 769 canvas.paintChild(child, offset.toPoint());
724 canvas.restore(); 770 canvas.restore();
725 } 771 }
726 } 772 }
727 } 773 }
728 774
(...skipping 17 matching lines...) Expand all
746 double _yRadius; 792 double _yRadius;
747 double get yRadius => _yRadius; 793 double get yRadius => _yRadius;
748 void set yRadius (double value) { 794 void set yRadius (double value) {
749 assert(value != null); 795 assert(value != null);
750 if (_yRadius == value) 796 if (_yRadius == value)
751 return; 797 return;
752 _yRadius = value; 798 _yRadius = value;
753 markNeedsPaint(); 799 markNeedsPaint();
754 } 800 }
755 801
802 @override
756 void paint(PaintingCanvas canvas, Offset offset) { 803 void paint(PaintingCanvas canvas, Offset offset) {
757 if (child != null) { 804 if (child != null) {
758 Rect rect = offset & size; 805 Rect rect = offset & size;
759 canvas.saveLayer(rect, new Paint()); 806 canvas.saveLayer(rect, new Paint());
760 sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius); 807 sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius);
761 canvas.clipRRect(rrect); 808 canvas.clipRRect(rrect);
762 canvas.paintChild(child, offset.toPoint()); 809 canvas.paintChild(child, offset.toPoint());
763 canvas.restore(); 810 canvas.restore();
764 } 811 }
765 } 812 }
766 } 813 }
767 814
768 class RenderClipOval extends RenderProxyBox { 815 class RenderClipOval extends RenderProxyBox {
769 RenderClipOval({ RenderBox child }) : super(child); 816 RenderClipOval({ RenderBox child }) : super(child);
770 817
818 @override
771 void paint(PaintingCanvas canvas, Offset offset) { 819 void paint(PaintingCanvas canvas, Offset offset) {
772 if (child != null) { 820 if (child != null) {
773 Rect rect = offset & size; 821 Rect rect = offset & size;
774 canvas.saveLayer(rect, new Paint()); 822 canvas.saveLayer(rect, new Paint());
775 Path path = new Path(); 823 Path path = new Path();
776 path.addOval(rect); 824 path.addOval(rect);
777 canvas.clipPath(path); 825 canvas.clipPath(path);
778 canvas.paintChild(child, offset.toPoint()); 826 canvas.paintChild(child, offset.toPoint());
779 canvas.restore(); 827 canvas.restore();
780 } 828 }
781 } 829 }
782 } 830 }
783 831
784 abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi n<RenderBox> { 832 abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi n<RenderBox> {
785 833
786 // Abstract class for one-child-layout render boxes 834 // Abstract class for one-child-layout render boxes
787 835
788 RenderShiftedBox(RenderBox child) { 836 RenderShiftedBox(RenderBox child) {
789 this.child = child; 837 this.child = child;
790 } 838 }
791 839
840 @override
792 double getMinIntrinsicWidth(BoxConstraints constraints) { 841 double getMinIntrinsicWidth(BoxConstraints constraints) {
793 if (child != null) 842 if (child != null)
794 return child.getMinIntrinsicWidth(constraints); 843 return child.getMinIntrinsicWidth(constraints);
795 return super.getMinIntrinsicWidth(constraints); 844 return super.getMinIntrinsicWidth(constraints);
796 } 845 }
797 846
847 @override
798 double getMaxIntrinsicWidth(BoxConstraints constraints) { 848 double getMaxIntrinsicWidth(BoxConstraints constraints) {
799 if (child != null) 849 if (child != null)
800 return child.getMaxIntrinsicWidth(constraints); 850 return child.getMaxIntrinsicWidth(constraints);
801 return super.getMaxIntrinsicWidth(constraints); 851 return super.getMaxIntrinsicWidth(constraints);
802 } 852 }
803 853
854 @override
804 double getMinIntrinsicHeight(BoxConstraints constraints) { 855 double getMinIntrinsicHeight(BoxConstraints constraints) {
805 if (child != null) 856 if (child != null)
806 return child.getMinIntrinsicHeight(constraints); 857 return child.getMinIntrinsicHeight(constraints);
807 return super.getMinIntrinsicHeight(constraints); 858 return super.getMinIntrinsicHeight(constraints);
808 } 859 }
809 860
861 @override
810 double getMaxIntrinsicHeight(BoxConstraints constraints) { 862 double getMaxIntrinsicHeight(BoxConstraints constraints) {
811 if (child != null) 863 if (child != null)
812 return child.getMaxIntrinsicHeight(constraints); 864 return child.getMaxIntrinsicHeight(constraints);
813 return super.getMaxIntrinsicHeight(constraints); 865 return super.getMaxIntrinsicHeight(constraints);
814 } 866 }
815 867
868 @override
816 double computeDistanceToActualBaseline(TextBaseline baseline) { 869 double computeDistanceToActualBaseline(TextBaseline baseline) {
817 double result; 870 double result;
818 if (child != null) { 871 if (child != null) {
819 assert(!needsLayout); 872 assert(!needsLayout);
820 result = child.getDistanceToActualBaseline(baseline); 873 result = child.getDistanceToActualBaseline(baseline);
821 assert(child.parentData is BoxParentData); 874 assert(child.parentData is BoxParentData);
822 if (result != null) 875 if (result != null)
823 result += child.parentData.position.y; 876 result += child.parentData.position.y;
824 } else { 877 } else {
825 result = super.computeDistanceToActualBaseline(baseline); 878 result = super.computeDistanceToActualBaseline(baseline);
826 } 879 }
827 return result; 880 return result;
828 } 881 }
829 882
883 @override
830 void paint(PaintingCanvas canvas, Offset offset) { 884 void paint(PaintingCanvas canvas, Offset offset) {
831 if (child != null) 885 if (child != null)
832 canvas.paintChild(child, child.parentData.position + offset); 886 canvas.paintChild(child, child.parentData.position + offset);
833 } 887 }
834 888
889 @override
835 void hitTestChildren(HitTestResult result, { Point position }) { 890 void hitTestChildren(HitTestResult result, { Point position }) {
836 if (child != null) { 891 if (child != null) {
837 assert(child.parentData is BoxParentData); 892 assert(child.parentData is BoxParentData);
838 Rect childBounds = child.parentData.position & child.size; 893 Rect childBounds = child.parentData.position & child.size;
839 if (childBounds.contains(position)) { 894 if (childBounds.contains(position)) {
840 child.hitTest(result, position: new Point(position.x - child.parentData. position.x, 895 child.hitTest(result, position: new Point(position.x - child.parentData. position.x,
841 position.y - child.parentD ata.position.y)); 896 position.y - child.parentD ata.position.y));
842 } 897 }
843 } 898 }
844 } 899 }
(...skipping 10 matching lines...) Expand all
855 EdgeDims _padding; 910 EdgeDims _padding;
856 EdgeDims get padding => _padding; 911 EdgeDims get padding => _padding;
857 void set padding (EdgeDims value) { 912 void set padding (EdgeDims value) {
858 assert(value != null); 913 assert(value != null);
859 if (_padding == value) 914 if (_padding == value)
860 return; 915 return;
861 _padding = value; 916 _padding = value;
862 markNeedsLayout(); 917 markNeedsLayout();
863 } 918 }
864 919
920 @override
865 double getMinIntrinsicWidth(BoxConstraints constraints) { 921 double getMinIntrinsicWidth(BoxConstraints constraints) {
866 double totalPadding = padding.left + padding.right; 922 double totalPadding = padding.left + padding.right;
867 if (child != null) 923 if (child != null)
868 return child.getMinIntrinsicWidth(constraints.deflate(padding)) + totalPad ding; 924 return child.getMinIntrinsicWidth(constraints.deflate(padding)) + totalPad ding;
869 return constraints.constrainWidth(totalPadding); 925 return constraints.constrainWidth(totalPadding);
870 } 926 }
871 927
928 @override
872 double getMaxIntrinsicWidth(BoxConstraints constraints) { 929 double getMaxIntrinsicWidth(BoxConstraints constraints) {
873 double totalPadding = padding.left + padding.right; 930 double totalPadding = padding.left + padding.right;
874 if (child != null) 931 if (child != null)
875 return child.getMaxIntrinsicWidth(constraints.deflate(padding)) + totalPad ding; 932 return child.getMaxIntrinsicWidth(constraints.deflate(padding)) + totalPad ding;
876 return constraints.constrainWidth(totalPadding); 933 return constraints.constrainWidth(totalPadding);
877 } 934 }
878 935
936 @override
879 double getMinIntrinsicHeight(BoxConstraints constraints) { 937 double getMinIntrinsicHeight(BoxConstraints constraints) {
880 double totalPadding = padding.top + padding.bottom; 938 double totalPadding = padding.top + padding.bottom;
881 if (child != null) 939 if (child != null)
882 return child.getMinIntrinsicHeight(constraints.deflate(padding)) + totalPa dding; 940 return child.getMinIntrinsicHeight(constraints.deflate(padding)) + totalPa dding;
883 return constraints.constrainHeight(totalPadding); 941 return constraints.constrainHeight(totalPadding);
884 } 942 }
885 943
944 @override
886 double getMaxIntrinsicHeight(BoxConstraints constraints) { 945 double getMaxIntrinsicHeight(BoxConstraints constraints) {
887 double totalPadding = padding.top + padding.bottom; 946 double totalPadding = padding.top + padding.bottom;
888 if (child != null) 947 if (child != null)
889 return child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPa dding; 948 return child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPa dding;
890 return constraints.constrainHeight(totalPadding); 949 return constraints.constrainHeight(totalPadding);
891 } 950 }
892 951
952 @override
893 void performLayout() { 953 void performLayout() {
894 assert(padding != null); 954 assert(padding != null);
895 if (child == null) { 955 if (child == null) {
896 size = constraints.constrain(new Size( 956 size = constraints.constrain(new Size(
897 padding.left + padding.right, 957 padding.left + padding.right,
898 padding.top + padding.bottom 958 padding.top + padding.bottom
899 )); 959 ));
900 return; 960 return;
901 } 961 }
902 BoxConstraints innerConstraints = constraints.deflate(padding); 962 BoxConstraints innerConstraints = constraints.deflate(padding);
903 child.layout(innerConstraints, parentUsesSize: true); 963 child.layout(innerConstraints, parentUsesSize: true);
904 assert(child.parentData is BoxParentData); 964 assert(child.parentData is BoxParentData);
905 child.parentData.position = new Point(padding.left, padding.top); 965 child.parentData.position = new Point(padding.left, padding.top);
906 size = constraints.constrain(new Size( 966 size = constraints.constrain(new Size(
907 padding.left + child.size.width + padding.right, 967 padding.left + child.size.width + padding.right,
908 padding.top + child.size.height + padding.bottom 968 padding.top + child.size.height + padding.bottom
909 )); 969 ));
910 } 970 }
911 971
972 @override
912 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}padding: ${padding}\n'; 973 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}padding: ${padding}\n';
913 } 974 }
914 975
915 class RenderPositionedBox extends RenderShiftedBox { 976 class RenderPositionedBox extends RenderShiftedBox {
916 977
917 // This box aligns a child box within itself. It's only useful for 978 // This box aligns a child box within itself. It's only useful for
918 // children that don't always size to fit their parent. For example, 979 // children that don't always size to fit their parent. For example,
919 // to align a box at the bottom right, you would pass this box a 980 // to align a box at the bottom right, you would pass this box a
920 // tight constraint that is bigger than the child's natural size, 981 // tight constraint that is bigger than the child's natural size,
921 // with horizontal and vertical set to 1.0. 982 // with horizontal and vertical set to 1.0.
(...skipping 22 matching lines...) Expand all
944 double _vertical; 1005 double _vertical;
945 double get vertical => _vertical; 1006 double get vertical => _vertical;
946 void set vertical (double value) { 1007 void set vertical (double value) {
947 assert(value != null); 1008 assert(value != null);
948 if (_vertical == value) 1009 if (_vertical == value)
949 return; 1010 return;
950 _vertical = value; 1011 _vertical = value;
951 markNeedsLayout(); 1012 markNeedsLayout();
952 } 1013 }
953 1014
1015 @override
954 void performLayout() { 1016 void performLayout() {
955 if (child != null) { 1017 if (child != null) {
956 child.layout(constraints.loosen(), parentUsesSize: true); 1018 child.layout(constraints.loosen(), parentUsesSize: true);
957 size = constraints.constrain(child.size); 1019 size = constraints.constrain(child.size);
958 assert(child.parentData is BoxParentData); 1020 assert(child.parentData is BoxParentData);
959 Offset delta = size - child.size; 1021 Offset delta = size - child.size;
960 child.parentData.position = (delta.scale(horizontal, vertical)).toPoint(); 1022 child.parentData.position = (delta.scale(horizontal, vertical)).toPoint();
961 } else { 1023 } else {
962 performResize(); 1024 performResize();
963 } 1025 }
964 } 1026 }
965 1027
1028 @override
966 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}horizontal: ${horizontal}\n${prefix}vertical: ${vertical}\n'; 1029 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}horizontal: ${horizontal}\n${prefix}vertical: ${vertical}\n';
967 } 1030 }
968 1031
969 class RenderBaseline extends RenderShiftedBox { 1032 class RenderBaseline extends RenderShiftedBox {
970 1033
971 RenderBaseline({ 1034 RenderBaseline({
972 RenderBox child, 1035 RenderBox child,
973 double baseline, 1036 double baseline,
974 TextBaseline baselineType 1037 TextBaseline baselineType
975 }) : _baseline = baseline, 1038 }) : _baseline = baseline,
(...skipping 16 matching lines...) Expand all
992 TextBaseline _baselineType; 1055 TextBaseline _baselineType;
993 TextBaseline get baselineType => _baselineType; 1056 TextBaseline get baselineType => _baselineType;
994 void set baselineType (TextBaseline value) { 1057 void set baselineType (TextBaseline value) {
995 assert(value != null); 1058 assert(value != null);
996 if (_baselineType == value) 1059 if (_baselineType == value)
997 return; 1060 return;
998 _baselineType = value; 1061 _baselineType = value;
999 markNeedsLayout(); 1062 markNeedsLayout();
1000 } 1063 }
1001 1064
1065 @override
1002 void performLayout() { 1066 void performLayout() {
1003 if (child != null) { 1067 if (child != null) {
1004 child.layout(constraints.loosen(), parentUsesSize: true); 1068 child.layout(constraints.loosen(), parentUsesSize: true);
1005 size = constraints.constrain(child.size); 1069 size = constraints.constrain(child.size);
1006 assert(child.parentData is BoxParentData); 1070 assert(child.parentData is BoxParentData);
1007 double delta = baseline - child.getDistanceToBaseline(baselineType); 1071 double delta = baseline - child.getDistanceToBaseline(baselineType);
1008 child.parentData.position = new Point(0.0, delta); 1072 child.parentData.position = new Point(0.0, delta);
1009 } else { 1073 } else {
1010 performResize(); 1074 performResize();
1011 } 1075 }
1012 } 1076 }
1013 1077
1078 @override
1014 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}baseline: ${baseline}\nbaselineType: ${baselineType}'; 1079 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}baseline: ${baseline}\nbaselineType: ${baselineType}';
1015 } 1080 }
1016 1081
1017 class RenderImage extends RenderBox { 1082 class RenderImage extends RenderBox {
1018 1083
1019 RenderImage(sky.Image image, Size requestedSize) 1084 RenderImage(sky.Image image, Size requestedSize)
1020 : _image = image, _requestedSize = requestedSize; 1085 : _image = image, _requestedSize = requestedSize;
1021 1086
1022 sky.Image _image; 1087 sky.Image _image;
1023 sky.Image get image => _image; 1088 sky.Image get image => _image;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1139 }
1075 if (requestedSize.height == null) { 1140 if (requestedSize.height == null) {
1076 // determine height from width 1141 // determine height from width
1077 double height = requestedSize.width * _image.height / _image.width; 1142 double height = requestedSize.width * _image.height / _image.width;
1078 return constraints.constrain(new Size(requestedSize.width, height)); 1143 return constraints.constrain(new Size(requestedSize.width, height));
1079 } 1144 }
1080 } 1145 }
1081 return constraints.constrain(requestedSize); 1146 return constraints.constrain(requestedSize);
1082 } 1147 }
1083 1148
1149 @override
1084 double getMinIntrinsicWidth(BoxConstraints constraints) { 1150 double getMinIntrinsicWidth(BoxConstraints constraints) {
1085 if (requestedSize.width == null && requestedSize.height == null) 1151 if (requestedSize.width == null && requestedSize.height == null)
1086 return constraints.constrainWidth(0.0); 1152 return constraints.constrainWidth(0.0);
1087 return _sizeForConstraints(constraints).width; 1153 return _sizeForConstraints(constraints).width;
1088 } 1154 }
1089 1155
1156 @override
1090 double getMaxIntrinsicWidth(BoxConstraints constraints) { 1157 double getMaxIntrinsicWidth(BoxConstraints constraints) {
1091 return _sizeForConstraints(constraints).width; 1158 return _sizeForConstraints(constraints).width;
1092 } 1159 }
1093 1160
1161 @override
1094 double getMinIntrinsicHeight(BoxConstraints constraints) { 1162 double getMinIntrinsicHeight(BoxConstraints constraints) {
1095 if (requestedSize.width == null && requestedSize.height == null) 1163 if (requestedSize.width == null && requestedSize.height == null)
1096 return constraints.constrainHeight(0.0); 1164 return constraints.constrainHeight(0.0);
1097 return _sizeForConstraints(constraints).height; 1165 return _sizeForConstraints(constraints).height;
1098 } 1166 }
1099 1167
1168 @override
1100 double getMaxIntrinsicHeight(BoxConstraints constraints) { 1169 double getMaxIntrinsicHeight(BoxConstraints constraints) {
1101 return _sizeForConstraints(constraints).height; 1170 return _sizeForConstraints(constraints).height;
1102 } 1171 }
1103 1172
1173 @override
1104 void performLayout() { 1174 void performLayout() {
1105 size = _sizeForConstraints(constraints); 1175 size = _sizeForConstraints(constraints);
1106 } 1176 }
1107 1177
1178 @override
1108 void paint(PaintingCanvas canvas, Offset offset) { 1179 void paint(PaintingCanvas canvas, Offset offset) {
1109 if (_image == null) 1180 if (_image == null)
1110 return; 1181 return;
1111 bool needsScale = size.width != _image.width || size.height != _image.height ; 1182 bool needsScale = size.width != _image.width || size.height != _image.height ;
1112 if (needsScale) { 1183 if (needsScale) {
1113 double widthScale = size.width / _image.width; 1184 double widthScale = size.width / _image.width;
1114 double heightScale = size.height / _image.height; 1185 double heightScale = size.height / _image.height;
1115 canvas.save(); 1186 canvas.save();
1116 canvas.translate(offset.dx, offset.dy); 1187 canvas.translate(offset.dx, offset.dy);
1117 canvas.scale(widthScale, heightScale); 1188 canvas.scale(widthScale, heightScale);
1118 offset = Offset.zero; 1189 offset = Offset.zero;
1119 } 1190 }
1120 Paint paint = new Paint(); 1191 Paint paint = new Paint();
1121 canvas.drawImage(_image, offset.toPoint(), paint); 1192 canvas.drawImage(_image, offset.toPoint(), paint);
1122 if (needsScale) 1193 if (needsScale)
1123 canvas.restore(); 1194 canvas.restore();
1124 } 1195 }
1125 1196
1197 @override
1126 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}dimensions: ${requestedSize}\n'; 1198 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}dimensions: ${requestedSize}\n';
1127 } 1199 }
1128 1200
1129 class RenderDecoratedBox extends RenderProxyBox { 1201 class RenderDecoratedBox extends RenderProxyBox {
1130 1202
1131 RenderDecoratedBox({ 1203 RenderDecoratedBox({
1132 BoxDecoration decoration, 1204 BoxDecoration decoration,
1133 RenderBox child 1205 RenderBox child
1134 }) : _painter = new BoxPainter(decoration), super(child); 1206 }) : _painter = new BoxPainter(decoration), super(child);
1135 1207
1136 BoxPainter _painter; 1208 BoxPainter _painter;
1137 BoxDecoration get decoration => _painter.decoration; 1209 BoxDecoration get decoration => _painter.decoration;
1138 void set decoration (BoxDecoration value) { 1210 void set decoration (BoxDecoration value) {
1139 assert(value != null); 1211 assert(value != null);
1140 if (_painter.decoration.backgroundImage != null) 1212 if (_painter.decoration.backgroundImage != null)
1141 _painter.decoration.backgroundImage.removeChangeListener(markNeedsPaint); 1213 _painter.decoration.backgroundImage.removeChangeListener(markNeedsPaint);
1142 if (value.backgroundImage != null) 1214 if (value.backgroundImage != null)
1143 value.backgroundImage.addChangeListener(markNeedsPaint); 1215 value.backgroundImage.addChangeListener(markNeedsPaint);
1144 if (value == _painter.decoration) 1216 if (value == _painter.decoration)
1145 return; 1217 return;
1146 _painter.decoration = value; 1218 _painter.decoration = value;
1147 markNeedsPaint(); 1219 markNeedsPaint();
1148 } 1220 }
1149 1221
1222 @override
1150 void paint(PaintingCanvas canvas, Offset offset) { 1223 void paint(PaintingCanvas canvas, Offset offset) {
1151 assert(size.width != null); 1224 assert(size.width != null);
1152 assert(size.height != null); 1225 assert(size.height != null);
1153 _painter.paint(canvas, offset & size); 1226 _painter.paint(canvas, offset & size);
1154 super.paint(canvas, offset); 1227 super.paint(canvas, offset);
1155 } 1228 }
1156 1229
1230 @override
1157 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}decoration:\n${_painter.decoration.toString(prefix + " ")}\n'; 1231 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}decoration:\n${_painter.decoration.toString(prefix + " ")}\n';
1158 } 1232 }
1159 1233
1160 class RenderTransform extends RenderProxyBox { 1234 class RenderTransform extends RenderProxyBox {
1235 @override
1161 bool get createNewDisplayList => true; 1236 bool get createNewDisplayList => true;
1162 1237
1163 RenderTransform({ 1238 RenderTransform({
1164 Matrix4 transform, 1239 Matrix4 transform,
1165 RenderBox child 1240 RenderBox child
1166 }) : super(child) { 1241 }) : super(child) {
1167 assert(transform != null); 1242 assert(transform != null);
1168 this.transform = transform; 1243 this.transform = transform;
1169 } 1244 }
1170 1245
(...skipping 30 matching lines...) Expand all
1201 void translate(x, [double y = 0.0, double z = 0.0]) { 1276 void translate(x, [double y = 0.0, double z = 0.0]) {
1202 _transform.translate(x, y, z); 1277 _transform.translate(x, y, z);
1203 markNeedsPaint(); 1278 markNeedsPaint();
1204 } 1279 }
1205 1280
1206 void scale(x, [double y, double z]) { 1281 void scale(x, [double y, double z]) {
1207 _transform.scale(x, y, z); 1282 _transform.scale(x, y, z);
1208 markNeedsPaint(); 1283 markNeedsPaint();
1209 } 1284 }
1210 1285
1286 @override
1211 void hitTestChildren(HitTestResult result, { Point position }) { 1287 void hitTestChildren(HitTestResult result, { Point position }) {
1212 Matrix4 inverse = new Matrix4.zero(); 1288 Matrix4 inverse = new Matrix4.zero();
1213 /* double det = */ inverse.copyInverse(_transform); 1289 /* double det = */ inverse.copyInverse(_transform);
1214 // TODO(abarth): Check the determinant for degeneracy. 1290 // TODO(abarth): Check the determinant for degeneracy.
1215 1291
1216 Vector3 position3 = new Vector3(position.x, position.y, 0.0); 1292 Vector3 position3 = new Vector3(position.x, position.y, 0.0);
1217 Vector3 transformed3 = inverse.transform3(position3); 1293 Vector3 transformed3 = inverse.transform3(position3);
1218 Point transformed = new Point(transformed3.x, transformed3.y); 1294 Point transformed = new Point(transformed3.x, transformed3.y);
1219 super.hitTestChildren(result, position: transformed); 1295 super.hitTestChildren(result, position: transformed);
1220 } 1296 }
1221 1297
1298 @override
1222 void paint(PaintingCanvas canvas, Offset offset) { 1299 void paint(PaintingCanvas canvas, Offset offset) {
1223 canvas.save(); 1300 canvas.save();
1224 canvas.translate(offset.dx, offset.dy); 1301 canvas.translate(offset.dx, offset.dy);
1225 canvas.concat(_transform.storage); 1302 canvas.concat(_transform.storage);
1226 super.paint(canvas, Offset.zero); 1303 super.paint(canvas, Offset.zero);
1227 canvas.restore(); 1304 canvas.restore();
1228 } 1305 }
1229 1306
1307 @override
1230 String debugDescribeSettings(String prefix) { 1308 String debugDescribeSettings(String prefix) {
1231 List<String> result = _transform.toString().split('\n').map((s) => '$prefix $s\n').toList(); 1309 List<String> result = _transform.toString().split('\n').map((s) => '$prefix $s\n').toList();
1232 result.removeLast(); 1310 result.removeLast();
1233 return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${ result.join()}'; 1311 return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${ result.join()}';
1234 } 1312 }
1235 } 1313 }
1236 1314
1237 typedef void SizeChangedCallback(Size newSize); 1315 typedef void SizeChangedCallback(Size newSize);
1238 1316
1239 class RenderSizeObserver extends RenderProxyBox { 1317 class RenderSizeObserver extends RenderProxyBox {
1240 RenderSizeObserver({ 1318 RenderSizeObserver({
1241 this.callback, 1319 this.callback,
1242 RenderBox child 1320 RenderBox child
1243 }) : super(child) { 1321 }) : super(child) {
1244 assert(callback != null); 1322 assert(callback != null);
1245 } 1323 }
1246 1324
1247 SizeChangedCallback callback; 1325 SizeChangedCallback callback;
1248 1326
1327 @override
1249 void performLayout() { 1328 void performLayout() {
1250 Size oldSize = size; 1329 Size oldSize = size;
1251 1330
1252 super.performLayout(); 1331 super.performLayout();
1253 1332
1254 if (oldSize != size) 1333 if (oldSize != size)
1255 callback(size); 1334 callback(size);
1256 } 1335 }
1257 } 1336 }
1258 1337
(...skipping 11 matching lines...) Expand all
1270 1349
1271 CustomPaintCallback _callback; 1350 CustomPaintCallback _callback;
1272 void set callback (CustomPaintCallback value) { 1351 void set callback (CustomPaintCallback value) {
1273 assert(value != null || !attached); 1352 assert(value != null || !attached);
1274 if (_callback == value) 1353 if (_callback == value)
1275 return; 1354 return;
1276 _callback = value; 1355 _callback = value;
1277 markNeedsPaint(); 1356 markNeedsPaint();
1278 } 1357 }
1279 1358
1359 @override
1280 void attach() { 1360 void attach() {
1281 assert(_callback != null); 1361 assert(_callback != null);
1282 super.attach(); 1362 super.attach();
1283 } 1363 }
1284 1364
1365 @override
1285 void paint(PaintingCanvas canvas, Offset offset) { 1366 void paint(PaintingCanvas canvas, Offset offset) {
1286 assert(_callback != null); 1367 assert(_callback != null);
1287 canvas.translate(offset.dx, offset.dy); 1368 canvas.translate(offset.dx, offset.dy);
1288 _callback(canvas, size); 1369 _callback(canvas, size);
1289 super.paint(canvas, Offset.zero); 1370 super.paint(canvas, Offset.zero);
1290 canvas.translate(-offset.dx, -offset.dy); 1371 canvas.translate(-offset.dx, -offset.dy);
1291 } 1372 }
1292 } 1373 }
1293 1374
1294 // RENDER VIEW LAYOUT MANAGER 1375 // RENDER VIEW LAYOUT MANAGER
1295 1376
1296 class ViewConstraints { 1377 class ViewConstraints {
1297 const ViewConstraints({ 1378 const ViewConstraints({
1298 this.size: Size.zero, 1379 this.size: Size.zero,
1299 this.orientation 1380 this.orientation
1300 }); 1381 });
1301 final Size size; 1382 final Size size;
1302 final int orientation; 1383 final int orientation;
1303 } 1384 }
1304 1385
1305 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> { 1386 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> {
1387 @override
1306 bool get createNewDisplayList => true; 1388 bool get createNewDisplayList => true;
1307 1389
1308 RenderView({ 1390 RenderView({
1309 RenderBox child, 1391 RenderBox child,
1310 this.timeForRotation: const Duration(microseconds: 83333) 1392 this.timeForRotation: const Duration(microseconds: 83333)
1311 }) { 1393 }) {
1312 this.child = child; 1394 this.child = child;
1313 } 1395 }
1314 1396
1315 Size _size = Size.zero; 1397 Size _size = Size.zero;
1316 Size get size => _size; 1398 Size get size => _size;
1317 1399
1318 int _orientation; // 0..3 1400 int _orientation; // 0..3
1319 int get orientation => _orientation; 1401 int get orientation => _orientation;
1320 Duration timeForRotation; 1402 Duration timeForRotation;
1321 1403
1322 ViewConstraints _rootConstraints; 1404 ViewConstraints _rootConstraints;
1323 ViewConstraints get rootConstraints => _rootConstraints; 1405 ViewConstraints get rootConstraints => _rootConstraints;
1324 void set rootConstraints(ViewConstraints value) { 1406 void set rootConstraints(ViewConstraints value) {
1325 if (_rootConstraints == value) 1407 if (_rootConstraints == value)
1326 return; 1408 return;
1327 _rootConstraints = value; 1409 _rootConstraints = value;
1328 markNeedsLayout(); 1410 markNeedsLayout();
1329 } 1411 }
1330 1412
1331 // We never call layout() on this class, so this should never get 1413 // We never call layout() on this class, so this should never get
1332 // checked. (This class is laid out using scheduleInitialLayout().) 1414 // checked. (This class is laid out using scheduleInitialLayout().)
1415 @override
1333 bool debugDoesMeetConstraints() { assert(false); return false; } 1416 bool debugDoesMeetConstraints() { assert(false); return false; }
1334 1417
1418 @override
1335 void performResize() { 1419 void performResize() {
1336 assert(false); 1420 assert(false);
1337 } 1421 }
1338 1422
1423 @override
1339 void performLayout() { 1424 void performLayout() {
1340 if (_rootConstraints.orientation != _orientation) { 1425 if (_rootConstraints.orientation != _orientation) {
1341 if (_orientation != null && child != null) 1426 if (_orientation != null && child != null)
1342 child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientat ion, time: timeForRotation); 1427 child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientat ion, time: timeForRotation);
1343 _orientation = _rootConstraints.orientation; 1428 _orientation = _rootConstraints.orientation;
1344 } 1429 }
1345 _size = _rootConstraints.size; 1430 _size = _rootConstraints.size;
1346 assert(!_size.isInfinite); 1431 assert(!_size.isInfinite);
1347 1432
1348 if (child != null) 1433 if (child != null)
1349 child.layout(new BoxConstraints.tight(_size)); 1434 child.layout(new BoxConstraints.tight(_size));
1350 } 1435 }
1351 1436
1437 @override
1352 void rotate({ int oldAngle, int newAngle, Duration time }) { 1438 void rotate({ int oldAngle, int newAngle, Duration time }) {
1353 assert(false); // nobody tells the screen to rotate, the whole rotate() danc e is started from our performResize() 1439 assert(false); // nobody tells the screen to rotate, the whole rotate() danc e is started from our performResize()
1354 } 1440 }
1355 1441
1356 bool hitTest(HitTestResult result, { Point position }) { 1442 bool hitTest(HitTestResult result, { Point position }) {
1357 if (child != null) { 1443 if (child != null) {
1358 Rect childBounds = Point.origin & child.size; 1444 Rect childBounds = Point.origin & child.size;
1359 if (childBounds.contains(position)) 1445 if (childBounds.contains(position))
1360 child.hitTest(result, position: position); 1446 child.hitTest(result, position: position);
1361 } 1447 }
1362 result.add(new HitTestEntry(this)); 1448 result.add(new HitTestEntry(this));
1363 return true; 1449 return true;
1364 } 1450 }
1365 1451
1452 @override
1366 void paint(PaintingCanvas canvas, Offset offset) { 1453 void paint(PaintingCanvas canvas, Offset offset) {
1367 if (child != null) 1454 if (child != null)
1368 canvas.paintChild(child, offset.toPoint()); 1455 canvas.paintChild(child, offset.toPoint());
1369 } 1456 }
1370 1457
1371 void paintFrame() { 1458 void paintFrame() {
1372 sky.tracing.begin('RenderView.paintFrame'); 1459 sky.tracing.begin('RenderView.paintFrame');
1373 try { 1460 try {
1374 sky.PictureRecorder recorder = new sky.PictureRecorder(); 1461 sky.PictureRecorder recorder = new sky.PictureRecorder();
1375 PaintingCanvas canvas = new PaintingCanvas(recorder, paintBounds); 1462 PaintingCanvas canvas = new PaintingCanvas(recorder, paintBounds);
1376 canvas.drawPaintingNode(paintingNode, Point.origin); 1463 canvas.drawPaintingNode(paintingNode, Point.origin);
1377 sky.view.picture = recorder.endRecording(); 1464 sky.view.picture = recorder.endRecording();
1378 } finally { 1465 } finally {
1379 sky.tracing.end('RenderView.paintFrame'); 1466 sky.tracing.end('RenderView.paintFrame');
1380 } 1467 }
1381 } 1468 }
1382 1469
1470 @override
1383 Rect get paintBounds => Point.origin & size; 1471 Rect get paintBounds => Point.origin & size;
1384 } 1472 }
1385 1473
1386 // HELPER METHODS FOR RENDERBOX CONTAINERS 1474 // HELPER METHODS FOR RENDERBOX CONTAINERS
1387 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend erObjectMixin<ChildType, ParentDataType> { 1475 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend erObjectMixin<ChildType, ParentDataType> {
1388 1476
1389 // This class, by convention, doesn't override any members of the superclass. 1477 // This class, by convention, doesn't override any members of the superclass.
1390 // It only provides helper functions that subclasses can call. 1478 // It only provides helper functions that subclasses can call.
1391 1479
1392 double defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) { 1480 double defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1526
1439 void defaultPaint(PaintingCanvas canvas, Offset offset) { 1527 void defaultPaint(PaintingCanvas canvas, Offset offset) {
1440 RenderBox child = firstChild; 1528 RenderBox child = firstChild;
1441 while (child != null) { 1529 while (child != null) {
1442 assert(child.parentData is ParentDataType); 1530 assert(child.parentData is ParentDataType);
1443 canvas.paintChild(child, child.parentData.position + offset); 1531 canvas.paintChild(child, child.parentData.position + offset);
1444 child = child.parentData.nextSibling; 1532 child = child.parentData.nextSibling;
1445 } 1533 }
1446 } 1534 }
1447 } 1535 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/rendering/block.dart ('k') | sky/sdk/lib/rendering/flex.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698