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

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

Issue 1093633002: Layout API prototype, for discussion (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Abstract out some logic from RenderNode since it's not really RenderNode-specific, it could be used… Created 5 years, 8 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
« sky/framework/layout.dart ('K') | « sky/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
(Empty)
1 library node;
2
3 class Node {
4
5 // nodes always have an order greater than their ancestors'.
6 // there's no guarantee regarding order between siblings
7
8 int _order = 0;
ojan 2015/04/23 20:28:32 bikeshed: I might call this _treeDepth. It took me
Hixie 2015/04/23 20:45:13 Makes sense. It's not quite the depth (e.g. if you
ojan 2015/04/23 21:12:36 Hmmm...then I think I don't understand what this d
9 int get order => _order;
10 void reorderChild(Node child) { // internal, do not call
11 assert(child._attached == _attached);
12 if (child._order <= _order) {
13 child._order = _order + 1;
14 child.reorderChildren();
15 }
16 }
17 void reorderChildren() { // internal, do not call
18 // override this in subclasses with child nodes
19 // simply call reorderChild(child) for each child
20 }
21
22 bool _attached = false;
23 bool get attached => _attached;
24 void attach() {
25 // override this in subclasses with child nodes
26 // simply call attach() for each child then call your superclass
27 _attached = true;
28 attachChildren();
29 }
30 attachChildren() { } // workaround for lack of inter-class mixins in Dart
31 void detach() {
32 // override this in subclasses with child nodes
33 // simply call detach() for each child then call your superclass
34 _attached = false;
35 detachChildren();
36 }
37 detachChildren() { } // workaround for lack of inter-class mixins in Dart
38
39 void setAsChild(RenderNode child) { // only for use by subclasses
40 assert(child != null);
41 if (attached)
42 child.attach();
43 reorderChild(child);
44 }
45 void dropChild(RenderNode child) { // only for use by subclasses
46 assert(child != null);
47 assert(child.attached == attached);
48 if (attached)
49 child.detach();
50 }
51
52 }
OLDNEW
« sky/framework/layout.dart ('K') | « sky/framework/layout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698