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

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

Issue 13963020: Resubmit: "With the collections deriving from ListBase, we no longer need to implement a numbe… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « tools/dom/templates/html/impl/impl_HTMLSelectElement.darttemplate ('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
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 throw new RangeError.range(index, 0, length); 76 throw new RangeError.range(index, 0, length);
77 } 77 }
78 if (index == length) { 78 if (index == length) {
79 _this.append(node); 79 _this.append(node);
80 } else { 80 } else {
81 _this.insertBefore(node, this[index]); 81 _this.insertBefore(node, this[index]);
82 } 82 }
83 } 83 }
84 84
85 void insertAll(int index, Iterable<Node> iterable) { 85 void insertAll(int index, Iterable<Node> iterable) {
86 throw new UnimplementedError(); 86 var item = this[index];
87 _this.insertAllBefore(iterable, item);
87 } 88 }
88 89
89 void setAll(int index, Iterable<Node> iterable) { 90 void setAll(int index, Iterable<Node> iterable) {
90 throw new UnimplementedError(); 91 throw new UnsupportedError("Cannot setAll on Node list");
91 } 92 }
92 93
93 Node removeLast() { 94 Node removeLast() {
94 final result = last; 95 final result = last;
95 if (result != null) { 96 if (result != null) {
96 _this.$dom_removeChild(result); 97 _this.$dom_removeChild(result);
97 } 98 }
98 return result; 99 return result;
99 } 100 }
100 101
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void clear() { 140 void clear() {
140 _this.text = ''; 141 _this.text = '';
141 } 142 }
142 143
143 void operator []=(int index, Node value) { 144 void operator []=(int index, Node value) {
144 _this.$dom_replaceChild(value, this[index]); 145 _this.$dom_replaceChild(value, this[index]);
145 } 146 }
146 147
147 Iterator<Node> get iterator => _this.$dom_childNodes.iterator; 148 Iterator<Node> get iterator => _this.$dom_childNodes.iterator;
148 149
149 List<Node> toList({ bool growable: true }) =>
150 new List<Node>.from(this, growable: growable);
151 Set<Node> toSet() => new Set<Node>.from(this);
152
153 bool get isEmpty => this.length == 0;
154
155 // From List<Node>: 150 // From List<Node>:
156 151
157 // TODO(jacobr): this could be implemented for child node lists. 152 // TODO(jacobr): this could be implemented for child node lists.
158 // The exception we throw here is misleading. 153 // The exception we throw here is misleading.
159 void sort([int compare(Node a, Node b)]) { 154 void sort([Comparator<Node> compare]) {
160 throw new UnsupportedError("Cannot sort immutable List."); 155 throw new UnsupportedError("Cannot sort Node list");
161 } 156 }
162 157
163 // FIXME: implement these. 158 // FIXME: implement these.
164 void setRange(int start, int end, Iterable<Node> iterable, 159 void setRange(int start, int end, Iterable<Node> iterable,
165 [int skipCount = 0]) { 160 [int skipCount = 0]) {
166 throw new UnsupportedError( 161 throw new UnsupportedError("Cannot setRange on Node list");
167 "Cannot setRange on immutable List.");
168 }
169 void removeRange(int start, int end) {
170 throw new UnsupportedError(
171 "Cannot removeRange on immutable List.");
172 } 162 }
173 163
174 Iterable<Node> getRange(int start, int end) { 164 void fillRange(int start, int end, [Node fill]) {
175 throw new UnimplementedError("NodeList.getRange"); 165 throw new UnsupportedError("Cannot fillRange on Node list");
176 }
177
178 void replaceRange(int start, int end, Iterable<Node> iterable) {
179 throw new UnimplementedError("NodeList.replaceRange");
180 }
181
182 void fillRange(int start, int end, [Node fillValue]) {
183 throw new UnimplementedError("NodeList.fillRange");
184 }
185
186 List<Node> sublist(int start, [int end]) {
187 if (end == null) end == length;
188 return Lists.getRange(this, start, end, <Node>[]);
189 }
190
191 String toString() {
192 StringBuffer buffer = new StringBuffer('[');
193 buffer.writeAll(this, ', ');
194 buffer.write(']');
195 return buffer.toString();
196 } 166 }
197 // -- end List<Node> mixins. 167 // -- end List<Node> mixins.
198 168
199 // TODO(jacobr): benchmark whether this is more efficient or whether caching 169 // TODO(jacobr): benchmark whether this is more efficient or whether caching
200 // a local copy of $dom_childNodes is more efficient. 170 // a local copy of $dom_childNodes is more efficient.
201 int get length => _this.$dom_childNodes.length; 171 int get length => _this.$dom_childNodes.length;
202 172
203 void set length(int value) { 173 void set length(int value) {
204 throw new UnsupportedError( 174 throw new UnsupportedError(
205 "Cannot set length on immutable List."); 175 "Cannot set length on immutable List.");
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 331 }
362 332
363 /** 333 /**
364 * Print out a String representation of this Node. 334 * Print out a String representation of this Node.
365 */ 335 */
366 String toString() => localName == null ? 336 String toString() => localName == null ?
367 (nodeValue == null ? super.toString() : nodeValue) : localName; 337 (nodeValue == null ? super.toString() : nodeValue) : localName;
368 338
369 $!MEMBERS 339 $!MEMBERS
370 } 340 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_HTMLSelectElement.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698