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

Side by Side Diff: sky/sdk/lib/framework/layout.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 | « no previous file | sky/sdk/lib/framework/node.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library layout; 1 library layout;
2 2
3 import 'node.dart'; 3 import 'node.dart';
4 import 'dart:sky' as sky; 4 import 'dart:sky' as sky;
5 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 // UTILS 7 // UTILS
8 8
9 // Bridge to legacy CSS-like style specification 9 // Bridge to legacy CSS-like style specification
10 // Eventually we'll replace this with something else 10 // Eventually we'll replace this with something else
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // parentData is only for use by the RenderNode that actually lays this 71 // parentData is only for use by the RenderNode that actually lays this
72 // node out, and any other nodes who happen to know exactly what 72 // node out, and any other nodes who happen to know exactly what
73 // kind of node that is. 73 // kind of node that is.
74 ParentData parentData; 74 ParentData parentData;
75 void setupPos(RenderNode child) { 75 void setupPos(RenderNode child) {
76 // override this to setup .parentData correctly for your class 76 // override this to setup .parentData correctly for your class
77 if (child.parentData is! ParentData) 77 if (child.parentData is! ParentData)
78 child.parentData = new ParentData(); 78 child.parentData = new ParentData();
79 } 79 }
80 80
81 void setAsChild(RenderNode child) { // only for use by subclasses 81 void adoptChild(RenderNode child) { // only for use by subclasses
82 // call this whenever you decide a node is a child 82 // call this whenever you decide a node is a child
83 assert(child != null); 83 assert(child != null);
84 setupPos(child); 84 setupPos(child);
85 super.setAsChild(child); 85 super.adoptChild(child);
86 } 86 }
87 void dropChild(RenderNode child) { // only for use by subclasses 87 void dropChild(RenderNode child) { // only for use by subclasses
88 assert(child != null); 88 assert(child != null);
89 assert(child.parentData != null); 89 assert(child.parentData != null);
90 child.parentData.detach(); 90 child.parentData.detach();
91 super.dropChild(child); 91 super.dropChild(child);
92 } 92 }
93 93
94 } 94 }
95 95
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 ChildType _firstChild; 144 ChildType _firstChild;
145 ChildType _lastChild; 145 ChildType _lastChild;
146 void add(ChildType child, { ChildType before }) { 146 void add(ChildType child, { ChildType before }) {
147 assert(child != this); 147 assert(child != this);
148 assert(before != this); 148 assert(before != this);
149 assert(child != before); 149 assert(child != before);
150 assert(child != _firstChild); 150 assert(child != _firstChild);
151 assert(child != _lastChild); 151 assert(child != _lastChild);
152 setAsChild(child); 152 adoptChild(child);
153 assert(child.parentData is ParentDataType); 153 assert(child.parentData is ParentDataType);
154 assert(child.parentData.nextSibling == null); 154 assert(child.parentData.nextSibling == null);
155 assert(child.parentData.previousSibling == null); 155 assert(child.parentData.previousSibling == null);
156 if (before == null) { 156 if (before == null) {
157 // append at the end (_lastChild) 157 // append at the end (_lastChild)
158 child.parentData.previousSibling = _lastChild; 158 child.parentData.previousSibling = _lastChild;
159 if (_lastChild != null) { 159 if (_lastChild != null) {
160 assert(_lastChild.parentData is ParentDataType); 160 assert(_lastChild.parentData is ParentDataType);
161 _lastChild.parentData.nextSibling = child; 161 _lastChild.parentData.nextSibling = child;
162 } 162 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 print(prefix + node.toString() + _attributes(node)); 551 print(prefix + node.toString() + _attributes(node));
552 var children = node.getChildNodes(); 552 var children = node.getChildNodes();
553 prefix = prefix + ' '; 553 prefix = prefix + ' ';
554 for (var child in children) 554 for (var child in children)
555 _serialiseDOM(child, prefix); 555 _serialiseDOM(child, prefix);
556 } 556 }
557 557
558 void dumpState() { 558 void dumpState() {
559 _serialiseDOM(sky.document); 559 _serialiseDOM(sky.document);
560 } 560 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/framework/node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698