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

Side by Side Diff: sky/sdk/lib/framework/node.dart

Issue 1134593007: [Effen] Add a "parent" pointer to Node. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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/framework/layout.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library node; 1 library node;
2 2
3 class Node { 3 class Node {
4 4
5 // Nodes always have a 'depth' greater than their ancestors'. 5 // Nodes always have a 'depth' greater than their ancestors'.
6 // There's no guarantee regarding depth between siblings. The depth 6 // There's no guarantee regarding depth between siblings. The depth
7 // of a node is used to ensure that nodes are processed in depth 7 // of a node is used to ensure that nodes are processed in depth
8 // order. The 'depth' of a child can be more than one greater than 8 // order. The 'depth' of a child can be more than one greater than
9 // the 'depth' of the parent, because the 'depth' values are never 9 // the 'depth' of the parent, because the 'depth' values are never
10 // decreased: all that matters is that it's greater than the parent. 10 // decreased: all that matters is that it's greater than the parent.
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 attachChildren() { } // workaround for lack of inter-class mixins in Dart 38 attachChildren() { } // workaround for lack of inter-class mixins in Dart
39 void detach() { 39 void detach() {
40 // override this in subclasses with child nodes 40 // override this in subclasses with child nodes
41 // simply call detach() for each child then call your superclass 41 // simply call detach() for each child then call your superclass
42 _attached = false; 42 _attached = false;
43 detachChildren(); 43 detachChildren();
44 } 44 }
45 detachChildren() { } // workaround for lack of inter-class mixins in Dart 45 detachChildren() { } // workaround for lack of inter-class mixins in Dart
46 46
47 void setAsChild(Node child) { // only for use by subclasses 47 Node _parent;
48 Node get parent => _parent;
49 void adoptChild(Node child) { // only for use by subclasses
48 assert(child != null); 50 assert(child != null);
51 assert(child._parent == null);
52 child._parent = this;
49 if (attached) 53 if (attached)
50 child.attach(); 54 child.attach();
51 redepthChild(child); 55 redepthChild(child);
52 } 56 }
53 void dropChild(Node child) { // only for use by subclasses 57 void dropChild(Node child) { // only for use by subclasses
54 assert(child != null); 58 assert(child != null);
59 assert(child._parent == this);
55 assert(child.attached == attached); 60 assert(child.attached == attached);
61 child._parent = null;
56 if (attached) 62 if (attached)
57 child.detach(); 63 child.detach();
58 } 64 }
59 65
60 } 66 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/layout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698