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

Side by Side Diff: tools/dom/templates/html/impl/impl_Node.darttemplate

Issue 1330163010: Revert "Dartium w/ JsInterop enabled" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 /** 7 /**
8 * Lazy implementation of the child nodes of an element that does not request 8 * Lazy implementation of the child nodes of an element that does not request
9 * the actual child nodes of an element until strictly necessary greatly 9 * the actual child nodes of an element until strictly necessary greatly
10 * improving performance for the typical cases where it is not required. 10 * improving performance for the typical cases where it is not required.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 var result = this[index]; 107 var result = this[index];
108 if (result != null) { 108 if (result != null) {
109 _this._removeChild(result); 109 _this._removeChild(result);
110 } 110 }
111 return result; 111 return result;
112 } 112 }
113 113
114 bool remove(Object object) { 114 bool remove(Object object) {
115 if (object is! Node) return false; 115 if (object is! Node) return false;
116 Node node = object; 116 Node node = object;
117 $if JSINTEROP
118 // We aren't preserving identity of nodes in JSINTEROP mode
119 if (_this != node.parentNode) return false;
120 $else
121 if (!identical(_this, node.parentNode)) return false; 117 if (!identical(_this, node.parentNode)) return false;
122 $endif
123 _this._removeChild(node); 118 _this._removeChild(node);
124 return true; 119 return true;
125 } 120 }
126 121
127 void _filter(bool test(Node node), bool removeMatching) { 122 void _filter(bool test(Node node), bool removeMatching) {
128 // This implementation of removeWhere/retainWhere is more efficient 123 // This implementation of removeWhere/retainWhere is more efficient
129 // than the default in ListBase. Child nodes can be removed in constant 124 // than the default in ListBase. Child nodes can be removed in constant
130 // time. 125 // time.
131 Node child = _this.firstChild; 126 Node child = _this.firstChild;
132 while (child != null) { 127 while (child != null) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 171
177 void fillRange(int start, int end, [Node fill]) { 172 void fillRange(int start, int end, [Node fill]) {
178 throw new UnsupportedError("Cannot fillRange on Node list"); 173 throw new UnsupportedError("Cannot fillRange on Node list");
179 } 174 }
180 // -- end List<Node> mixins. 175 // -- end List<Node> mixins.
181 176
182 // TODO(jacobr): benchmark whether this is more efficient or whether caching 177 // TODO(jacobr): benchmark whether this is more efficient or whether caching
183 // a local copy of childNodes is more efficient. 178 // a local copy of childNodes is more efficient.
184 int get length => _this.childNodes.length; 179 int get length => _this.childNodes.length;
185 180
186 set length(int value) { 181 void set length(int value) {
187 throw new UnsupportedError( 182 throw new UnsupportedError(
188 "Cannot set length on immutable List."); 183 "Cannot set length on immutable List.");
189 } 184 }
190 185
191 Node operator[](int index) => _this.childNodes[index]; 186 Node operator[](int index) => _this.childNodes[index];
192 187
193 List<Node> get rawList => _this.childNodes; 188 List<Node> get rawList => _this.childNodes;
194 } 189 }
195 190
196 191
197 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { 192 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
198 193
199 // Custom element created callback. 194 // Custom element created callback.
200 Node._created() : super._created(); 195 Node._created() : super._created();
201 196
202 /** 197 /**
203 * A modifiable list of this node's children. 198 * A modifiable list of this node's children.
204 */ 199 */
205 List<Node> get nodes { 200 List<Node> get nodes {
206 return new _ChildNodeListLazy(this); 201 return new _ChildNodeListLazy(this);
207 } 202 }
208 203
209 set nodes(Iterable<Node> value) { 204 void set nodes(Iterable<Node> value) {
210 // Copy list first since we don't want liveness during iteration. 205 // Copy list first since we don't want liveness during iteration.
211 // TODO(jacobr): there is a better way to do this. 206 // TODO(jacobr): there is a better way to do this.
212 List copy = new List.from(value); 207 List copy = new List.from(value);
213 text = ''; 208 text = '';
214 for (Node node in copy) { 209 for (Node node in copy) {
215 append(node); 210 append(node);
216 } 211 }
217 } 212 }
218 213
219 /** 214 /**
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 270 }
276 271
277 /** 272 /**
278 * Print out a String representation of this Node. 273 * Print out a String representation of this Node.
279 */ 274 */
280 String toString() { 275 String toString() {
281 String value = nodeValue; // Fetch DOM Node property once. 276 String value = nodeValue; // Fetch DOM Node property once.
282 return value == null ? super.toString() : value; 277 return value == null ? super.toString() : value;
283 } 278 }
284 279
285 $if DARTIUM 280 $if JSINTEROP
281 List<Node> _childNodes;
282
286 /** 283 /**
287 * A list of this node's children. 284 * A list of this node's children.
288 * 285 *
289 * ## Other resources 286 * ## Other resources
290 * 287 *
291 * * [Node.childNodes] 288 * * [Node.childNodes]
292 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes) 289 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes)
293 * from MDN. 290 * from MDN.
294 */ 291 */
295 @DomName('Node.childNodes') 292 @DomName('Node.childNodes')
296 @DocsEditable() 293 @DocsEditable()
297 List<Node> get childNodes => wrap_jso(_blink.BlinkNode.instance.childNodes_Get ter_(unwrap_jso(this))); 294 List<Node> get childNodes {
295 if (_childNodes == null) {
296 List<Node> nodes = new List<Node>();
297 var jsCollection = _blink.BlinkNode.instance.childNodes_Getter_(unwrap_js o(this));
298 var collectionLen = jsCollection['length'];
299 for (var i = 0; i < collectionLen; i++) {
300 nodes.add(wrap_jso(jsCollection.callMethod('item', [i])));
301 }
302 _childNodes = nodes;
303 }
304 return _childNodes;
305 }
298 $else 306 $else
307 $if DARTIUM
299 /** 308 /**
300 * A list of this node's children. 309 * A list of this node's children.
301 * 310 *
311 * ## Other resources
312 *
313 * * [Node.childNodes]
314 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes)
315 * from MDN.
316 */
317 @DomName('Node.childNodes')
318 @DocsEditable()
319 List<Node> get childNodes => _blink.BlinkNode.instance.childNodes_Getter_(this );
320 $else
321 /**
322 * A list of this node's children.
323 *
302 * ## Other resources 324 * ## Other resources
303 * 325 *
304 * * [Node.childNodes] 326 * * [Node.childNodes]
305 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes) 327 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes)
306 * from MDN. 328 * from MDN.
307 */ 329 */
308 @DomName('Node.childNodes') 330 @DomName('Node.childNodes')
309 @DocsEditable() 331 @DocsEditable()
332 @Returns('NodeList')
333 @Creates('NodeList')
310 final List<Node> childNodes; 334 final List<Node> childNodes;
311 335
336 $endif
312 $endif 337 $endif
313 $!MEMBERS 338 $!MEMBERS
314 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698