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 library layout; | 5 library layout; |
| 6 | 6 |
| 7 // This version of layout.dart is an update to the other one, this one using new APIs. | 7 // This version of layout.dart is an update to the other one, this one using new APIs. |
| 8 // It will not work in a stock Sky setup currently. | 8 // It will not work in a stock Sky setup currently. |
| 9 | 9 |
| 10 import 'node.dart'; | 10 import 'node.dart'; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 hitTestChildren(result, x: x, y: y); | 497 hitTestChildren(result, x: x, y: y); |
| 498 result.add(this); | 498 result.add(this); |
| 499 return true; | 499 return true; |
| 500 } | 500 } |
| 501 void hitTestChildren(HitTestResult result, { double x, double y }) { } | 501 void hitTestChildren(HitTestResult result, { double x, double y }) { } |
| 502 | 502 |
| 503 double width; | 503 double width; |
| 504 double height; | 504 double height; |
| 505 } | 505 } |
| 506 | 506 |
| 507 // This must be immutable, because we won't notice when it changes | |
| 507 class BoxDecoration { | 508 class BoxDecoration { |
| 508 const BoxDecoration({ | 509 const BoxDecoration({ |
| 509 this.backgroundColor | 510 this.backgroundColor |
| 510 }); | 511 }); |
| 511 | 512 |
| 512 final int backgroundColor; | 513 final int backgroundColor; |
| 513 } | 514 } |
| 514 | 515 |
| 515 class RenderDecoratedBox extends RenderBox { | 516 class RenderDecoratedBox extends RenderBox { |
| 516 BoxDecoration _decoration; | |
| 517 | 517 |
| 518 RenderDecoratedBox(BoxDecoration decoration) : _decoration = decoration; | 518 RenderDecoratedBox(BoxDecoration decoration) : _decoration = decoration; |
| 519 | 519 |
| 520 void setBoxDecoration(BoxDecoration decoration) { | 520 BoxDecoration _decoration; |
| 521 if (_decoration == decoration) | 521 BoxDecoration get decoration => _decoration; |
| 522 void set decoration (BoxDecoration value) { | |
| 523 if (value == _decoration) | |
| 522 return; | 524 return; |
| 523 _decoration = decoration; | 525 _decoration = value; |
| 524 markNeedsPaint(); | 526 markNeedsPaint(); |
| 525 } | 527 } |
| 526 | 528 |
| 527 void paint(RenderNodeDisplayList canvas) { | 529 void paint(RenderNodeDisplayList canvas) { |
| 528 assert(width != null); | 530 assert(width != null); |
| 529 assert(height != null); | 531 assert(height != null); |
| 530 | 532 |
| 531 if (_decoration == null) | 533 if (_decoration == null) |
| 532 return; | 534 return; |
| 533 | 535 |
| 534 if (_decoration.backgroundColor != null) { | 536 if (_decoration.backgroundColor != null) { |
| 535 sky.Paint paint = new sky.Paint()..color = _decoration.backgroundColor; | 537 sky.Paint paint = new sky.Paint()..color = _decoration.backgroundColor; |
| 536 canvas.drawRect(new sky.Rect()..setLTRB(0.0, 0.0, width, height), paint); | 538 canvas.drawRect(new sky.Rect()..setLTRB(0.0, 0.0, width, height), paint); |
| 537 } | 539 } |
| 538 } | 540 } |
| 541 | |
|
abarth-chromium
2015/05/27 16:29:39
extraneous change?
| |
| 539 } | 542 } |
| 540 | 543 |
| 541 | 544 |
| 542 // RENDER VIEW LAYOUT MANAGER | 545 // RENDER VIEW LAYOUT MANAGER |
| 543 | 546 |
| 544 class RenderView extends RenderNode { | 547 class RenderView extends RenderNode { |
| 545 | 548 |
| 546 RenderView({ | 549 RenderView({ |
| 547 RenderBox root, | 550 RenderBox root, |
| 548 this.timeForRotation: const Duration(microseconds: 83333) | 551 this.timeForRotation: const Duration(microseconds: 83333) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 // uses the maximum width provided by the parent | 676 // uses the maximum width provided by the parent |
| 674 // sizes itself to the height of its child stack | 677 // sizes itself to the height of its child stack |
| 675 | 678 |
| 676 RenderBlock({ | 679 RenderBlock({ |
| 677 BoxDecoration decoration, | 680 BoxDecoration decoration, |
| 678 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) | 681 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) |
| 679 }) : super(decoration), _padding = padding; | 682 }) : super(decoration), _padding = padding; |
| 680 | 683 |
| 681 EdgeDims _padding; | 684 EdgeDims _padding; |
| 682 EdgeDims get padding => _padding; | 685 EdgeDims get padding => _padding; |
| 683 void set padding(EdgeDims value) { | 686 void set padding (EdgeDims value) { |
|
abarth-chromium
2015/05/27 16:29:40
extraneous change?
| |
| 684 assert(value != null); | 687 assert(value != null); |
| 685 if (_padding != value) { | 688 if (_padding != value) { |
| 686 _padding = value; | 689 _padding = value; |
| 687 markNeedsLayout(); | 690 markNeedsLayout(); |
| 688 } | 691 } |
| 689 } | 692 } |
| 690 | 693 |
| 691 void setParentData(RenderBox child) { | 694 void setParentData(RenderBox child) { |
| 692 if (child.parentData is! BlockParentData) | 695 if (child.parentData is! BlockParentData) |
| 693 child.parentData = new BlockParentData(); | 696 child.parentData = new BlockParentData(); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y); | 959 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y); |
| 957 if (statusbar != null) | 960 if (statusbar != null) |
| 958 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); | 961 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); |
| 959 if (toolbar != null) | 962 if (toolbar != null) |
| 960 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); | 963 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); |
| 961 if (drawer != null) | 964 if (drawer != null) |
| 962 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y); | 965 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y); |
| 963 } | 966 } |
| 964 | 967 |
| 965 } | 968 } |
| OLD | NEW |