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

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

Issue 11931034: Add methods to Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also on DoubleLinkedQueue. Created 7 years, 11 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
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 html; 5 part of html;
6 6
7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList implements List { 9 class _ChildrenElementList implements List {
10 // Raw Element. 10 // Raw Element.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 Element operator [](int index) { 111 Element operator [](int index) {
112 return _childElements[index]; 112 return _childElements[index];
113 } 113 }
114 114
115 void operator []=(int index, Element value) { 115 void operator []=(int index, Element value) {
116 _element.$dom_replaceChild(value, _childElements[index]); 116 _element.$dom_replaceChild(value, _childElements[index]);
117 } 117 }
118 118
119 void set length(int newLength) { 119 void set length(int newLength) {
120 // TODO(jacobr): remove children when length is reduced. 120 // TODO(jacobr): remove children when length is reduced.
121 throw new UnsupportedError(''); 121 throw new UnsupportedError('');
122 } 122 }
123 123
124 Element add(Element value) { 124 Element add(Element value) {
125 _element.$dom_appendChild(value); 125 _element.$dom_appendChild(value);
126 return value; 126 return value;
127 } 127 }
128 128
129 Element addLast(Element value) => add(value); 129 Element addLast(Element value) => add(value);
130 130
131 Iterator<Element> get iterator => toList().iterator; 131 Iterator<Element> get iterator => toList().iterator;
132 132
133 void addAll(Iterable<Element> iterable) { 133 void addAll(Iterable<Element> iterable) {
134 for (Element element in iterable) { 134 for (Element element in iterable) {
135 _element.$dom_appendChild(element); 135 _element.$dom_appendChild(element);
136 } 136 }
137 } 137 }
138 138
139 void sort([int compare(Element a, Element b)]) { 139 void sort([int compare(Element a, Element b)]) {
140 throw new UnsupportedError('TODO(jacobr): should we impl?'); 140 throw new UnsupportedError('TODO(jacobr): should we impl?');
141 } 141 }
142 142
143 dynamic reduce(dynamic initialValue, 143 dynamic reduce(dynamic initialValue,
144 dynamic combine(dynamic previousValue, Element element)) { 144 dynamic combine(dynamic previousValue, Element element)) {
145 return Collections.reduce(this, initialValue, combine); 145 return Collections.reduce(this, initialValue, combine);
146 } 146 }
147 147
148 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { 148 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
149 throw new UnimplementedError(); 149 throw new UnimplementedError();
150 } 150 }
151 151
152 void remove(Object object) {
153 if (object is Element) {
154 Element element = object;
155 if (identical(element.parentNode, this)) {
156 _element.$dom_removeChild(element);
157 }
158 }
159 }
160
161 void removeAll(Iterable elements) {
162 Collections.removeAll(this, elements);
163 }
164
165 void retainAll(Iterable elements) {
166 Collections.retainAll(this, elements);
167 }
168
169 void removeMatching(bool test(Element element)) {
170 Collections.removeMatching(this, test);
171 }
172
173 void retainMatching(bool test(Element element)) {
174 Collections.retainMatching(this, test);
175 }
176
152 void removeRange(int start, int rangeLength) { 177 void removeRange(int start, int rangeLength) {
153 throw new UnimplementedError(); 178 throw new UnimplementedError();
154 } 179 }
155 180
156 void insertRange(int start, int rangeLength, [initialValue = null]) { 181 void insertRange(int start, int rangeLength, [initialValue = null]) {
157 throw new UnimplementedError(); 182 throw new UnimplementedError();
158 } 183 }
159 184
160 List getRange(int start, int rangeLength) => 185 List getRange(int start, int rangeLength) =>
161 new _FrozenElementList._wrap(Lists.getRange(this, start, rangeLength, 186 new _FrozenElementList._wrap(Lists.getRange(this, start, rangeLength,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 392 }
368 393
369 Element removeAt(int index) { 394 Element removeAt(int index) {
370 throw new UnsupportedError(''); 395 throw new UnsupportedError('');
371 } 396 }
372 397
373 Element removeLast() { 398 Element removeLast() {
374 throw new UnsupportedError(''); 399 throw new UnsupportedError('');
375 } 400 }
376 401
402 void remove(Object element) {
403 throw new UnsupportedError('');
404 }
405
406 void removeAll(Iterable elements) {
407 throw new UnsupportedError('');
408 }
409
410 void retainAll(Iterable elements) {
411 throw new UnsupportedError('');
412 }
413
414 void removeMatching(bool test(Element element)) {
415 throw new UnsupportedError('');
416 }
417
418 void retainMatching(bool test(Element element)) {
419 throw new UnsupportedError('');
420 }
421
377 Element get first => _nodeList.first; 422 Element get first => _nodeList.first;
378 423
379 Element get last => _nodeList.last; 424 Element get last => _nodeList.last;
380 425
381 Element get single => _nodeList.single; 426 Element get single => _nodeList.single;
382 427
383 Element min([int compare(Element a, Element b)]) { 428 Element min([int compare(Element a, Element b)]) {
384 return Collections.min(this, compare); 429 return Collections.min(this, compare);
385 } 430 }
386 431
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 $if DART2JS 1019 $if DART2JS
975 // Optimization to improve performance until the dart2js compiler inlines this 1020 // Optimization to improve performance until the dart2js compiler inlines this
976 // method. 1021 // method.
977 static dynamic createElement_tag(String tag) => 1022 static dynamic createElement_tag(String tag) =>
978 JS('Element', 'document.createElement(#)', tag); 1023 JS('Element', 'document.createElement(#)', tag);
979 $else 1024 $else
980 static Element createElement_tag(String tag) => 1025 static Element createElement_tag(String tag) =>
981 document.$dom_createElement(tag); 1026 document.$dom_createElement(tag);
982 $endif 1027 $endif
983 } 1028 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698