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 NodeList { |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 void addAll(Collection<_NodeImpl> collection) { | 33 void addAll(Collection<_NodeImpl> collection) { |
34 for (_NodeImpl node in collection) { | 34 for (_NodeImpl node in collection) { |
35 _this.$dom_appendChild(node); | 35 _this.$dom_appendChild(node); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 _NodeImpl removeLast() { | 39 _NodeImpl removeLast() { |
40 final last = last(); | 40 final result = last(); |
41 if (last != null) { | 41 if (result != null) { |
42 _this.$dom_removeChild(last); | 42 _this.$dom_removeChild(result); |
43 } | 43 } |
44 return last; | 44 return result; |
45 } | 45 } |
46 | 46 |
47 void clear() { | 47 void clear() { |
48 _this.text = ''; | 48 _this.text = ''; |
49 } | 49 } |
50 | 50 |
51 void operator []=(int index, _NodeImpl value) { | 51 void operator []=(int index, _NodeImpl value) { |
52 _this.$dom_replaceChild(value, this[index]); | 52 _this.$dom_replaceChild(value, this[index]); |
53 } | 53 } |
54 | 54 |
(...skipping 21 matching lines...) Expand all Loading... |
76 void sort(int compare(Node a, Node b)) { | 76 void sort(int compare(Node a, Node b)) { |
77 throw new UnsupportedOperationException("Cannot sort immutable List."); | 77 throw new UnsupportedOperationException("Cannot sort immutable List."); |
78 } | 78 } |
79 | 79 |
80 int indexOf(Node element, [int start = 0]) => | 80 int indexOf(Node element, [int start = 0]) => |
81 _Lists.indexOf(this, element, start, this.length); | 81 _Lists.indexOf(this, element, start, this.length); |
82 | 82 |
83 int lastIndexOf(Node element, [int start = 0]) => | 83 int lastIndexOf(Node element, [int start = 0]) => |
84 _Lists.lastIndexOf(this, element, start); | 84 _Lists.lastIndexOf(this, element, start); |
85 | 85 |
86 // FIXME: implement thesee. | 86 // FIXME: implement these. |
87 void setRange(int start, int length, List<Node> from, [int startFrom]) { | 87 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { |
88 throw new UnsupportedOperationException( | 88 throw new UnsupportedOperationException( |
89 "Cannot setRange on immutable List."); | 89 "Cannot setRange on immutable List."); |
90 } | 90 } |
91 void removeRange(int start, int length) { | 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 length, [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 length) => | 99 NodeList getRange(int start, int rangeLength) => |
100 new _NodeListWrapper(_Lists.getRange(this, start, length, <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 } |
110 | 110 |
(...skipping 26 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(var e) { | 139 } catch(var e) { |
140 | 140 |
141 }; | 141 }; |
142 return this; | 142 return this; |
143 } | 143 } |
144 | 144 |
145 $!MEMBERS | 145 $!MEMBERS |
146 } | 146 } |
OLD | NEW |