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

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: Address comments. 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
« no previous file with comments | « tools/dom/src/CssClassSet.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | 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 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 Element operator [](int index) { 112 Element operator [](int index) {
113 return _childElements[index]; 113 return _childElements[index];
114 } 114 }
115 115
116 void operator []=(int index, Element value) { 116 void operator []=(int index, Element value) {
117 _element.$dom_replaceChild(value, _childElements[index]); 117 _element.$dom_replaceChild(value, _childElements[index]);
118 } 118 }
119 119
120 void set length(int newLength) { 120 void set length(int newLength) {
121 // TODO(jacobr): remove children when length is reduced. 121 // TODO(jacobr): remove children when length is reduced.
122 throw new UnsupportedError(''); 122 throw new UnsupportedError('');
123 } 123 }
124 124
125 Element add(Element value) { 125 Element add(Element value) {
126 _element.$dom_appendChild(value); 126 _element.$dom_appendChild(value);
127 return value; 127 return value;
128 } 128 }
129 129
130 Element addLast(Element value) => add(value); 130 Element addLast(Element value) => add(value);
131 131
132 Iterator<Element> get iterator => toList().iterator; 132 Iterator<Element> get iterator => toList().iterator;
133 133
134 void addAll(Iterable<Element> iterable) { 134 void addAll(Iterable<Element> iterable) {
135 for (Element element in iterable) { 135 for (Element element in iterable) {
136 _element.$dom_appendChild(element); 136 _element.$dom_appendChild(element);
137 } 137 }
138 } 138 }
139 139
140 void sort([int compare(Element a, Element b)]) { 140 void sort([int compare(Element a, Element b)]) {
141 throw new UnsupportedError('TODO(jacobr): should we impl?'); 141 throw new UnsupportedError('TODO(jacobr): should we impl?');
142 } 142 }
143 143
144 dynamic reduce(dynamic initialValue, 144 dynamic reduce(dynamic initialValue,
145 dynamic combine(dynamic previousValue, Element element)) { 145 dynamic combine(dynamic previousValue, Element element)) {
146 return IterableMixinWorkaround.reduce(this, initialValue, combine); 146 return IterableMixinWorkaround.reduce(this, initialValue, combine);
147 } 147 }
148 148
149 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { 149 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
150 throw new UnimplementedError(); 150 throw new UnimplementedError();
151 } 151 }
152 152
153 void remove(Object object) {
154 if (object is Element) {
155 Element element = object;
156 if (identical(element.parentNode, this)) {
157 _element.$dom_removeChild(element);
158 }
159 }
160 }
161
162 void removeAll(Iterable elements) {
163 Collections.removeAll(this, elements);
164 }
165
166 void retainAll(Iterable elements) {
167 Collections.retainAll(this, elements);
168 }
169
170 void removeMatching(bool test(Element element)) {
171 Collections.removeMatching(this, test);
172 }
173
174 void retainMatching(bool test(Element element)) {
175 Collections.retainMatching(this, test);
176 }
177
153 void removeRange(int start, int rangeLength) { 178 void removeRange(int start, int rangeLength) {
154 throw new UnimplementedError(); 179 throw new UnimplementedError();
155 } 180 }
156 181
157 void insertRange(int start, int rangeLength, [initialValue = null]) { 182 void insertRange(int start, int rangeLength, [initialValue = null]) {
158 throw new UnimplementedError(); 183 throw new UnimplementedError();
159 } 184 }
160 185
161 List getRange(int start, int rangeLength) => 186 List getRange(int start, int rangeLength) =>
162 new _FrozenElementList._wrap(Lists.getRange(this, start, rangeLength, 187 new _FrozenElementList._wrap(Lists.getRange(this, start, rangeLength,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 394 }
370 395
371 Element removeAt(int index) { 396 Element removeAt(int index) {
372 throw new UnsupportedError(''); 397 throw new UnsupportedError('');
373 } 398 }
374 399
375 Element removeLast() { 400 Element removeLast() {
376 throw new UnsupportedError(''); 401 throw new UnsupportedError('');
377 } 402 }
378 403
404 void remove(Object element) {
405 throw new UnsupportedError('');
406 }
407
408 void removeAll(Iterable elements) {
409 throw new UnsupportedError('');
410 }
411
412 void retainAll(Iterable elements) {
413 throw new UnsupportedError('');
414 }
415
416 void removeMatching(bool test(Element element)) {
417 throw new UnsupportedError('');
418 }
419
420 void retainMatching(bool test(Element element)) {
421 throw new UnsupportedError('');
422 }
423
379 Element get first => _nodeList.first; 424 Element get first => _nodeList.first;
380 425
381 Element get last => _nodeList.last; 426 Element get last => _nodeList.last;
382 427
383 Element get single => _nodeList.single; 428 Element get single => _nodeList.single;
384 429
385 Element min([int compare(Element a, Element b)]) { 430 Element min([int compare(Element a, Element b)]) {
386 return IterableMixinWorkaround.min(this, compare); 431 return IterableMixinWorkaround.min(this, compare);
387 } 432 }
388 433
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 $if DART2JS 1038 $if DART2JS
994 // Optimization to improve performance until the dart2js compiler inlines this 1039 // Optimization to improve performance until the dart2js compiler inlines this
995 // method. 1040 // method.
996 static dynamic createElement_tag(String tag) => 1041 static dynamic createElement_tag(String tag) =>
997 JS('Element', 'document.createElement(#)', tag); 1042 JS('Element', 'document.createElement(#)', tag);
998 $else 1043 $else
999 static Element createElement_tag(String tag) => 1044 static Element createElement_tag(String tag) =>
1000 document.$dom_createElement(tag); 1045 document.$dom_createElement(tag);
1001 $endif 1046 $endif
1002 } 1047 }
OLDNEW
« no previous file with comments | « tools/dom/src/CssClassSet.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698