| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. | 5 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. |
| 6 class _ChildrenElementList implements ElementList { | 6 class _ChildrenElementList implements ElementList { |
| 7 // Raw Element. | 7 // Raw Element. |
| 8 final _element; | 8 final _element; |
| 9 final _childElements; | 9 final _childElements; |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 Element get first() { | 23 Element get first() { |
| 24 return LevelDom.wrapElement(_element.firstElementChild); | 24 return LevelDom.wrapElement(_element.firstElementChild); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void forEach(void f(Element element)) => _toList().forEach(f); | 27 void forEach(void f(Element element)) => _toList().forEach(f); |
| 28 | 28 |
| 29 Collection map(f(Element element)) => _toList().map(f); | 29 Collection map(f(Element element)) => _toList().map(f); |
| 30 | 30 |
| 31 Collection<Element> filter(bool f(Element element)) => _toList().filter(f); | 31 ElementList filter(bool f(Element element)) => |
| 32 new _ElementList(_toList().filter(f)); |
| 32 | 33 |
| 33 bool every(bool f(Element element)) { | 34 bool every(bool f(Element element)) { |
| 34 for(Element element in this) { | 35 for(Element element in this) { |
| 35 if (!f(element)) { | 36 if (!f(element)) { |
| 36 return false; | 37 return false; |
| 37 } | 38 } |
| 38 }; | 39 }; |
| 39 return true; | 40 return true; |
| 40 } | 41 } |
| 41 | 42 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void setRange(int start, int length, List from, [int startFrom = 0]) => | 96 void setRange(int start, int length, List from, [int startFrom = 0]) => |
| 96 Lists.setRange(this, start, length, from, startFrom); | 97 Lists.setRange(this, start, length, from, startFrom); |
| 97 | 98 |
| 98 void removeRange(int start, int length) => | 99 void removeRange(int start, int length) => |
| 99 Lists.removeRange(this, start, length, (i) => this[i].remove()); | 100 Lists.removeRange(this, start, length, (i) => this[i].remove()); |
| 100 | 101 |
| 101 void insertRange(int start, int length, [initialValue = null]) { | 102 void insertRange(int start, int length, [initialValue = null]) { |
| 102 throw const NotImplementedException(); | 103 throw const NotImplementedException(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 List getRange(int start, int length) => Lists.getRange(this, start, length); | 106 ElementList getRange(int start, int length) => |
| 107 new _ElementList(Lists.getRange(this, start, length)); |
| 106 | 108 |
| 107 int indexOf(Element element, [int start = 0]) { | 109 int indexOf(Element element, [int start = 0]) { |
| 108 return Lists.indexOf(this, element, start, this.length); | 110 return Lists.indexOf(this, element, start, this.length); |
| 109 } | 111 } |
| 110 | 112 |
| 111 int lastIndexOf(Element element, [int start = null]) { | 113 int lastIndexOf(Element element, [int start = null]) { |
| 112 if (start === null) start = length - 1; | 114 if (start === null) start = length - 1; |
| 113 return Lists.lastIndexOf(this, element, start); | 115 return Lists.lastIndexOf(this, element, start); |
| 114 } | 116 } |
| 115 | 117 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 150 } |
| 149 | 151 |
| 150 Element get first() { | 152 Element get first() { |
| 151 return this[0]; | 153 return this[0]; |
| 152 } | 154 } |
| 153 | 155 |
| 154 void forEach(void f(Element element)) => _toList().forEach(f); | 156 void forEach(void f(Element element)) => _toList().forEach(f); |
| 155 | 157 |
| 156 Collection map(f(Element element)) => _toList().map(f); | 158 Collection map(f(Element element)) => _toList().map(f); |
| 157 | 159 |
| 158 Collection<Element> filter(bool f(Element element)) => _toList().filter(f); | 160 ElementList filter(bool f(Element element)) => |
| 161 new _ElementList(_toList().filter(f)); |
| 159 | 162 |
| 160 bool every(bool f(Element element)) { | 163 bool every(bool f(Element element)) { |
| 161 for(Element element in this) { | 164 for(Element element in this) { |
| 162 if (!f(element)) { | 165 if (!f(element)) { |
| 163 return false; | 166 return false; |
| 164 } | 167 } |
| 165 }; | 168 }; |
| 166 return true; | 169 return true; |
| 167 } | 170 } |
| 168 | 171 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 226 } |
| 224 | 227 |
| 225 void removeRange(int start, int length) { | 228 void removeRange(int start, int length) { |
| 226 throw const UnsupportedOperationException(''); | 229 throw const UnsupportedOperationException(''); |
| 227 } | 230 } |
| 228 | 231 |
| 229 void insertRange(int start, int length, [initialValue = null]) { | 232 void insertRange(int start, int length, [initialValue = null]) { |
| 230 throw const UnsupportedOperationException(''); | 233 throw const UnsupportedOperationException(''); |
| 231 } | 234 } |
| 232 | 235 |
| 233 List getRange(int start, int length) => Lists.getRange(this, start, length); | 236 ElementList getRange(int start, int length) => |
| 237 new _ElementList(Lists.getRange(this, start, length)); |
| 234 | 238 |
| 235 int indexOf(Element element, [int start = 0]) => | 239 int indexOf(Element element, [int start = 0]) => |
| 236 Lists.indexOf(this, element, start, this.length); | 240 Lists.indexOf(this, element, start, this.length); |
| 237 | 241 |
| 238 int lastIndexOf(Element element, [int start = null]) { | 242 int lastIndexOf(Element element, [int start = null]) { |
| 239 if (start === null) start = length - 1; | 243 if (start === null) start = length - 1; |
| 240 return Lists.lastIndexOf(this, element, start); | 244 return Lists.lastIndexOf(this, element, start); |
| 241 } | 245 } |
| 242 | 246 |
| 243 void clear() { | 247 void clear() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 270 | 274 |
| 271 return _list[_index++]; | 275 return _list[_index++]; |
| 272 } | 276 } |
| 273 | 277 |
| 274 /** | 278 /** |
| 275 * Returns whether the [Iterator] has elements left. | 279 * Returns whether the [Iterator] has elements left. |
| 276 */ | 280 */ |
| 277 bool hasNext() => _index < _list.length; | 281 bool hasNext() => _index < _list.length; |
| 278 } | 282 } |
| 279 | 283 |
| 284 class _ElementList extends _ListWrapper<Element> implements ElementList { |
| 285 _ElementList(List<Element> list) : super(list); |
| 286 |
| 287 ElementList filter(bool f(Element element)) => |
| 288 new _ElementList(super.filter(f)); |
| 289 |
| 290 ElementList getRange(int start, int length) => |
| 291 new _ElementList(super.getRange(start, length)); |
| 292 } |
| 293 |
| 280 class ElementAttributeMap implements Map<String, String> { | 294 class ElementAttributeMap implements Map<String, String> { |
| 281 | 295 |
| 282 final _element; | 296 final _element; |
| 283 | 297 |
| 284 ElementAttributeMap._wrap(this._element); | 298 ElementAttributeMap._wrap(this._element); |
| 285 | 299 |
| 286 bool containsValue(String value) { | 300 bool containsValue(String value) { |
| 287 final attributes = _element.attributes; | 301 final attributes = _element.attributes; |
| 288 for (int i = 0, len = attributes.length; i < len; i++) { | 302 for (int i = 0, len = attributes.length; i < len; i++) { |
| 289 if(value == attributes.item(i).value) { | 303 if(value == attributes.item(i).value) { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 | 775 |
| 762 ElementEvents get on() { | 776 ElementEvents get on() { |
| 763 if (_on === null) { | 777 if (_on === null) { |
| 764 _on = new ElementEventsImplementation._wrap(_ptr); | 778 _on = new ElementEventsImplementation._wrap(_ptr); |
| 765 } | 779 } |
| 766 return _on; | 780 return _on; |
| 767 } | 781 } |
| 768 | 782 |
| 769 Element clone(bool deep) => super.clone(deep); | 783 Element clone(bool deep) => super.clone(deep); |
| 770 } | 784 } |
| OLD | NEW |