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 '../scheduler.dart' as scheduler; | 6 import '../scheduler.dart' as scheduler; |
7 import 'dart:math' as math; | |
Hixie
2015/06/11 22:14:10
see note above about conventions for import order
| |
7 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
8 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; | 9 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; |
9 export 'dart:sky' show Point, Size, Rect, Color, Paint, Path; | 10 export 'dart:sky' show Point, Size, Rect, Color, Paint, Path; |
10 | 11 |
11 class ParentData { | 12 class ParentData { |
12 void detach() { | 13 void detach() { |
13 detachSiblings(); | 14 detachSiblings(); |
14 } | 15 } |
15 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart | 16 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart |
16 void merge(ParentData other) { | 17 void merge(ParentData other) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 } | 260 } |
260 | 261 |
261 class HitTestResult { | 262 class HitTestResult { |
262 final List<HitTestEntry> path = new List<HitTestEntry>(); | 263 final List<HitTestEntry> path = new List<HitTestEntry>(); |
263 | 264 |
264 void add(HitTestEntry data) { | 265 void add(HitTestEntry data) { |
265 path.add(data); | 266 path.add(data); |
266 } | 267 } |
267 } | 268 } |
268 | 269 |
270 double clamp({double min: 0.0, double value: 0.0, double max: double.INFINITY}) { | |
Hixie
2015/06/11 22:14:10
see note above about spaces around arguments
| |
271 assert(min != null); | |
272 assert(value != null); | |
273 assert(max != null); | |
274 return math.max(min, math.min(max, value)); | |
275 } | |
276 | |
269 | 277 |
270 // GENERIC MIXIN FOR RENDER NODES WITH ONE CHILD | 278 // GENERIC MIXIN FOR RENDER NODES WITH ONE CHILD |
271 | 279 |
272 abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> implem ents RenderObject { | 280 abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> implem ents RenderObject { |
273 ChildType _child; | 281 ChildType _child; |
274 ChildType get child => _child; | 282 ChildType get child => _child; |
275 void set child (ChildType value) { | 283 void set child (ChildType value) { |
276 if (_child != null) | 284 if (_child != null) |
277 dropChild(_child); | 285 dropChild(_child); |
278 _child = value; | 286 _child = value; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 int count = 1; | 455 int count = 1; |
448 ChildType child = _firstChild; | 456 ChildType child = _firstChild; |
449 while (child != null) { | 457 while (child != null) { |
450 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 458 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
451 count += 1; | 459 count += 1; |
452 child = child.parentData.nextSibling; | 460 child = child.parentData.nextSibling; |
453 } | 461 } |
454 return result; | 462 return result; |
455 } | 463 } |
456 } | 464 } |
OLD | NEW |