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 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; | 7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; |
8 | 8 |
9 import '../base/hit_test.dart'; | 9 import '../base/hit_test.dart'; |
10 import '../base/node.dart'; | 10 import '../base/node.dart'; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 abstract class RenderObject extends AbstractNode implements HitTestTarget { | 44 abstract class RenderObject extends AbstractNode implements HitTestTarget { |
45 | 45 |
46 // LAYOUT | 46 // LAYOUT |
47 | 47 |
48 // parentData is only for use by the RenderObject that actually lays this | 48 // parentData is only for use by the RenderObject that actually lays this |
49 // node out, and any other nodes who happen to know exactly what | 49 // node out, and any other nodes who happen to know exactly what |
50 // kind of node that is. | 50 // kind of node that is. |
51 dynamic parentData; // TODO(ianh): change the type of this back to ParentData
once the analyzer is cleverer | 51 dynamic parentData; // TODO(ianh): change the type of this back to ParentData
once the analyzer is cleverer |
52 void setParentData(RenderObject child) { | 52 void setupParentData(RenderObject child) { |
53 // override this to setup .parentData correctly for your class | 53 // override this to setup .parentData correctly for your class |
54 assert(!debugDoingLayout); | 54 assert(!debugDoingLayout); |
55 assert(!debugDoingPaint); | 55 assert(!debugDoingPaint); |
56 if (child.parentData is! ParentData) | 56 if (child.parentData is! ParentData) |
57 child.parentData = new ParentData(); | 57 child.parentData = new ParentData(); |
58 } | 58 } |
59 | 59 |
60 void adoptChild(RenderObject child) { // only for use by subclasses | 60 void adoptChild(RenderObject child) { // only for use by subclasses |
61 // call this whenever you decide a node is a child | 61 // call this whenever you decide a node is a child |
62 assert(!debugDoingLayout); | 62 assert(!debugDoingLayout); |
63 assert(!debugDoingPaint); | 63 assert(!debugDoingPaint); |
64 assert(child != null); | 64 assert(child != null); |
65 setParentData(child); | 65 setupParentData(child); |
66 super.adoptChild(child); | 66 super.adoptChild(child); |
67 markNeedsLayout(); | 67 markNeedsLayout(); |
68 } | 68 } |
69 void dropChild(RenderObject child) { // only for use by subclasses | 69 void dropChild(RenderObject child) { // only for use by subclasses |
70 assert(!debugDoingLayout); | 70 assert(!debugDoingLayout); |
71 assert(!debugDoingPaint); | 71 assert(!debugDoingPaint); |
72 assert(child != null); | 72 assert(child != null); |
73 assert(child.parentData != null); | 73 assert(child.parentData != null); |
74 child.parentData.detach(); | 74 child.parentData.detach(); |
75 child._cleanRelayoutSubtreeRoot(); | 75 child._cleanRelayoutSubtreeRoot(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 int count = 1; | 494 int count = 1; |
495 ChildType child = _firstChild; | 495 ChildType child = _firstChild; |
496 while (child != null) { | 496 while (child != null) { |
497 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 497 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
498 count += 1; | 498 count += 1; |
499 child = child.parentData.nextSibling; | 499 child = child.parentData.nextSibling; |
500 } | 500 } |
501 return result; | 501 return result; |
502 } | 502 } |
503 } | 503 } |
OLD | NEW |