| OLD | NEW |
| 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 /** | 5 /** |
| 6 * Lazy implementation of the child nodes of an element that does not request | 6 * Lazy implementation of the child nodes of an element that does not request |
| 7 * the actual child nodes of an element until strictly necessary greatly | 7 * the actual child nodes of an element until strictly necessary greatly |
| 8 * improving performance for the typical cases where it is not required. | 8 * improving performance for the typical cases where it is not required. |
| 9 */ | 9 */ |
| 10 class _ChildNodeListLazy implements NodeList { | 10 class _ChildNodeListLazy implements List { |
| 11 final _NodeImpl _this; | 11 final _NodeImpl _this; |
| 12 | 12 |
| 13 _ChildNodeListLazy(this._this); | 13 _ChildNodeListLazy(this._this); |
| 14 | 14 |
| 15 | 15 |
| 16 $if DART2JS | 16 $if DART2JS |
| 17 _NodeImpl get first => JS('_NodeImpl', '#.firstChild', _this); | 17 _NodeImpl get first => JS('_NodeImpl', '#.firstChild', _this); |
| 18 _NodeImpl last() => JS('_NodeImpl', '#.lastChild', _this); | 18 _NodeImpl last() => JS('_NodeImpl', '#.lastChild', _this); |
| 19 $else | 19 $else |
| 20 _NodeImpl get first => _this.$dom_firstChild; | 20 _NodeImpl get first => _this.$dom_firstChild; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 "Cannot setRange on immutable List."); | 89 "Cannot setRange on immutable List."); |
| 90 } | 90 } |
| 91 void removeRange(int start, int rangeLength) { | 91 void removeRange(int start, int rangeLength) { |
| 92 throw new UnsupportedOperationException( | 92 throw new UnsupportedOperationException( |
| 93 "Cannot removeRange on immutable List."); | 93 "Cannot removeRange on immutable List."); |
| 94 } | 94 } |
| 95 void insertRange(int start, int rangeLength, [Node initialValue]) { | 95 void insertRange(int start, int rangeLength, [Node initialValue]) { |
| 96 throw new UnsupportedOperationException( | 96 throw new UnsupportedOperationException( |
| 97 "Cannot insertRange on immutable List."); | 97 "Cannot insertRange on immutable List."); |
| 98 } | 98 } |
| 99 NodeList getRange(int start, int rangeLength) => | 99 List<Node> getRange(int start, int rangeLength) => |
| 100 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); | 100 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); |
| 101 | 101 |
| 102 // -- end List<Node> mixins. | 102 // -- end List<Node> mixins. |
| 103 | 103 |
| 104 // TODO(jacobr): benchmark whether this is more efficient or whether caching | 104 // TODO(jacobr): benchmark whether this is more efficient or whether caching |
| 105 // a local copy of $dom_childNodes is more efficient. | 105 // a local copy of $dom_childNodes is more efficient. |
| 106 int get length => _this.$dom_childNodes.length; | 106 int get length => _this.$dom_childNodes.length; |
| 107 | 107 |
| 108 _NodeImpl operator[](int index) => _this.$dom_childNodes[index]; | 108 _NodeImpl operator[](int index) => _this.$dom_childNodes[index]; |
| 109 } | 109 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 final _NodeImpl parent = this.parent; | 137 final _NodeImpl parent = this.parent; |
| 138 parent.$dom_replaceChild(otherNode, this); | 138 parent.$dom_replaceChild(otherNode, this); |
| 139 } catch (e) { | 139 } catch (e) { |
| 140 | 140 |
| 141 }; | 141 }; |
| 142 return this; | 142 return this; |
| 143 } | 143 } |
| 144 | 144 |
| 145 $!MEMBERS | 145 $!MEMBERS |
| 146 } | 146 } |
| OLD | NEW |