| 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 '../node.dart'; | 5 import '../node.dart'; |
| 6 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 7 import 'dart:sky' as sky; |
| 7 | 8 |
| 8 class ParentData { | 9 class ParentData { |
| 9 void detach() { | 10 void detach() { |
| 10 detachSiblings(); | 11 detachSiblings(); |
| 11 } | 12 } |
| 12 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart | 13 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart |
| 13 void merge(ParentData other) { | 14 void merge(ParentData other) { |
| 14 // override this in subclasses to merge in data from other into this | 15 // override this in subclasses to merge in data from other into this |
| 15 assert(other.runtimeType == this.runtimeType); | 16 assert(other.runtimeType == this.runtimeType); |
| 16 } | 17 } |
| 17 } | 18 } |
| 18 | 19 |
| 19 const kLayoutDirections = 4; | 20 const kLayoutDirections = 4; |
| 20 | 21 |
| 21 double clamp({double min: 0.0, double value: 0.0, double max: double.INFINITY})
{ | 22 double clamp({double min: 0.0, double value: 0.0, double max: double.INFINITY})
{ |
| 22 assert(min != null); | 23 assert(min != null); |
| 23 assert(value != null); | 24 assert(value != null); |
| 24 assert(max != null); | 25 assert(max != null); |
| 25 | 26 return math.max(min, math.min(max, value)); |
| 26 if (value > max) | |
| 27 value = max; | |
| 28 if (value < min) | |
| 29 value = min; | |
| 30 return value; | |
| 31 } | 27 } |
| 32 | 28 |
| 33 class RenderNodeDisplayList extends sky.PictureRecorder { | 29 class RenderNodeDisplayList extends sky.PictureRecorder { |
| 34 RenderNodeDisplayList(double width, double height) : super(width, height); | 30 RenderNodeDisplayList(double width, double height) : super(width, height); |
| 35 void paintChild(RenderNode child, sky.Point position) { | 31 void paintChild(RenderNode child, sky.Point position) { |
| 36 save(); | |
| 37 translate(position.x, position.y); | 32 translate(position.x, position.y); |
| 38 child.paint(this); | 33 child.paint(this); |
| 39 restore(); | 34 translate(-position.x, -position.y); |
| 40 } | 35 } |
| 41 } | 36 } |
| 42 | 37 |
| 43 abstract class RenderNode extends AbstractNode { | 38 abstract class RenderNode extends AbstractNode { |
| 44 | 39 |
| 45 // LAYOUT | 40 // LAYOUT |
| 46 | 41 |
| 47 // parentData is only for use by the RenderNode that actually lays this | 42 // parentData is only for use by the RenderNode that actually lays this |
| 48 // node out, and any other nodes who happen to know exactly what | 43 // node out, and any other nodes who happen to know exactly what |
| 49 // kind of node that is. | 44 // kind of node that is. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 376 } |
| 382 } | 377 } |
| 383 | 378 |
| 384 ChildType get firstChild => _firstChild; | 379 ChildType get firstChild => _firstChild; |
| 385 ChildType get lastChild => _lastChild; | 380 ChildType get lastChild => _lastChild; |
| 386 ChildType childAfter(ChildType child) { | 381 ChildType childAfter(ChildType child) { |
| 387 assert(child.parentData is ParentDataType); | 382 assert(child.parentData is ParentDataType); |
| 388 return child.parentData.nextSibling; | 383 return child.parentData.nextSibling; |
| 389 } | 384 } |
| 390 } | 385 } |
| OLD | NEW |