| 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 class FilteredElementList implements ElementList { | 5 class FilteredElementList implements ElementList { |
| 6 final Node _node; | 6 final Node _node; |
| 7 final NodeList _childNodes; | 7 final NodeList _childNodes; |
| 8 | 8 |
| 9 FilteredElementList(Node node): _childNodes = node.nodes, _node = node; | 9 FilteredElementList(Node node): _childNodes = node.nodes, _node = node; |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 void sort(int compare(Element a, Element b)) { | 59 void sort(int compare(Element a, Element b)) { |
| 60 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 60 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 63 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 64 throw const NotImplementedException(); | 64 throw const NotImplementedException(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void setRange(int start, int length, List from, [int startFrom = 0]) { | 67 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { |
| 68 throw const NotImplementedException(); | 68 throw const NotImplementedException(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void removeRange(int start, int length) { | 71 void removeRange(int start, int rangeLength) { |
| 72 _filtered.getRange(start, length).forEach((el) => el.remove()); | 72 _filtered.getRange(start, rangeLength).forEach((el) => el.remove()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void insertRange(int start, int length, [initialValue = null]) { | 75 void insertRange(int start, int rangeLength, [initialValue = null]) { |
| 76 throw const NotImplementedException(); | 76 throw const NotImplementedException(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void clear() { | 79 void clear() { |
| 80 // Currently, ElementList#clear clears even non-element nodes, so we follow | 80 // Currently, ElementList#clear clears even non-element nodes, so we follow |
| 81 // that behavior. | 81 // that behavior. |
| 82 _childNodes.clear(); | 82 _childNodes.clear(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 Element removeLast() { | 85 Element removeLast() { |
| 86 final last = this.last(); | 86 final result = this.last(); |
| 87 if (last != null) { | 87 if (result != null) { |
| 88 last.remove(); | 88 result.remove(); |
| 89 } | 89 } |
| 90 return last; | 90 return result; |
| 91 } | 91 } |
| 92 | 92 |
| 93 Collection map(f(Element element)) => _filtered.map(f); | 93 Collection map(f(Element element)) => _filtered.map(f); |
| 94 Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); | 94 Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); |
| 95 bool every(bool f(Element element)) => _filtered.every(f); | 95 bool every(bool f(Element element)) => _filtered.every(f); |
| 96 bool some(bool f(Element element)) => _filtered.some(f); | 96 bool some(bool f(Element element)) => _filtered.some(f); |
| 97 bool isEmpty() => _filtered.isEmpty(); | 97 bool isEmpty() => _filtered.isEmpty(); |
| 98 int get length() => _filtered.length; | 98 int get length() => _filtered.length; |
| 99 Element operator [](int index) => _filtered[index]; | 99 Element operator [](int index) => _filtered[index]; |
| 100 Iterator<Element> iterator() => _filtered.iterator(); | 100 Iterator<Element> iterator() => _filtered.iterator(); |
| 101 List<Element> getRange(int start, int length) => | 101 List<Element> getRange(int start, int rangeLength) => |
| 102 _filtered.getRange(start, length); | 102 _filtered.getRange(start, rangeLength); |
| 103 int indexOf(Element element, [int start = 0]) => | 103 int indexOf(Element element, [int start = 0]) => |
| 104 _filtered.indexOf(element, start); | 104 _filtered.indexOf(element, start); |
| 105 | 105 |
| 106 int lastIndexOf(Element element, [int start = null]) { | 106 int lastIndexOf(Element element, [int start = null]) { |
| 107 if (start === null) start = length - 1; | 107 if (start === null) start = length - 1; |
| 108 return _filtered.lastIndexOf(element, start); | 108 return _filtered.lastIndexOf(element, start); |
| 109 } | 109 } |
| 110 | 110 |
| 111 Element last() => _filtered.last(); | 111 Element last() => _filtered.last(); |
| 112 } | 112 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 "WebKit drop zone can't be set for document fragments."); | 335 "WebKit drop zone can't be set for document fragments."); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void set webkitRegionOverflow(String value) { | 338 void set webkitRegionOverflow(String value) { |
| 339 throw new UnsupportedOperationException( | 339 throw new UnsupportedOperationException( |
| 340 "WebKit region overflow can't be set for document fragments."); | 340 "WebKit region overflow can't be set for document fragments."); |
| 341 } | 341 } |
| 342 | 342 |
| 343 $!MEMBERS | 343 $!MEMBERS |
| 344 } | 344 } |
| OLD | NEW |