Index: tools/dom/templates/html/impl/impl_Element.darttemplate |
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate |
index d76b46b0036bb2aef78adb5b5b284be9aecf2ef9..bdfd4c91c210d28165424a3a1d2a471ae490849d 100644 |
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate |
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate |
@@ -6,7 +6,7 @@ part of $LIBRARYNAME; |
// TODO(jacobr): use _Lists.dart to remove some of the duplicated |
// functionality. |
-class _ChildrenElementList implements List<Element> { |
+class _ChildrenElementList extends ListBase<Element> { |
// Raw Element. |
final Element _element; |
final HtmlCollection _childElements; |
@@ -84,31 +84,31 @@ class _ChildrenElementList implements List<Element> { |
} |
Iterable<Element> take(int n) { |
- return IterableMixinWorkaround.takeList(this, n); |
+ return _childElements.take(n); |
} |
Iterable<Element> takeWhile(bool test(Element value)) { |
- return IterableMixinWorkaround.takeWhile(this, test); |
+ return _childElements.takeWhile(test); |
} |
Iterable<Element> skip(int n) { |
- return IterableMixinWorkaround.skipList(this, n); |
+ return _childElements.skipList(n); |
} |
Iterable<Element> skipWhile(bool test(Element value)) { |
- return IterableMixinWorkaround.skipWhile(this, test); |
+ return _childElements.skipWhile(test); |
} |
Element firstWhere(bool test(Element value), {Element orElse()}) { |
- return IterableMixinWorkaround.firstWhere(this, test, orElse); |
+ return _childElements.firstWhere(test, orElse: orElse); |
} |
Element lastWhere(bool test(Element value), {Element orElse()}) { |
- return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
+ return _childElements.lastWhere(test, orElse: orElse); |
} |
Element singleWhere(bool test(Element value)) { |
- return IterableMixinWorkaround.singleWhere(this, test); |
+ return _childElements.singleWhere(test); |
} |
Element elementAt(int index) { |
@@ -150,7 +150,7 @@ class _ChildrenElementList implements List<Element> { |
} |
Iterable<Element> get reversed { |
- return IterableMixinWorkaround.reversedList(this); |
+ return _childElements.reversed; |
} |
void sort([int compare(Element a, Element b)]) { |
@@ -159,15 +159,16 @@ class _ChildrenElementList implements List<Element> { |
dynamic reduce(dynamic initialValue, |
dynamic combine(dynamic previousValue, Element element)) { |
- return IterableMixinWorkaround.reduce(this, initialValue, combine); |
+ return _childElements.reduce(initialValue, combine); |
} |
dynamic fold(dynamic initialValue, |
dynamic combine(dynamic previousValue, Element element)) { |
- return IterableMixinWorkaround.fold(this, initialValue, combine); |
+ return _childElements.fold(initialValue, combine); |
} |
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { |
+ void setRange(int start, int rangeLength, List from, |
+ [int startFrom = 0]) { |
throw new UnimplementedError(); |
} |
@@ -181,19 +182,19 @@ class _ChildrenElementList implements List<Element> { |
} |
void removeAll(Iterable elements) { |
- IterableMixinWorkaround.removeAll(this, elements); |
+ _childElements.removeAll(elements); |
} |
void retainAll(Iterable elements) { |
- IterableMixinWorkaround.retainAll(this, elements); |
+ _childElements.retainAll(elements); |
} |
void removeWhere(bool test(Element element)) { |
- IterableMixinWorkaround.removeWhere(this, test); |
+ _childElements.removeWhere(test); |
} |
void retainWhere(bool test(Element element)) { |
- IterableMixinWorkaround.retainWhere(this, test); |
+ _childElements.retainWhere(test); |
} |
void removeRange(int start, int rangeLength) { |
@@ -272,15 +273,15 @@ class _ChildrenElementList implements List<Element> { |
} |
Element min([int compare(Element a, Element b)]) { |
- return IterableMixinWorkaround.min(this, compare); |
+ return _childElements.min(compare); |
} |
Element max([int compare(Element a, Element b)]) { |
- return IterableMixinWorkaround.max(this, compare); |
+ return _childElements.max(compare); |
} |
Map<int, Element> asMap() { |
- return IterableMixinWorkaround.asMapList(this); |
+ return _childElements.asMapList(this); |
} |
String toString() { |
@@ -295,96 +296,11 @@ class _ChildrenElementList implements List<Element> { |
// a better option given that we cannot quite force NodeList to be an |
// ElementList as there are valid cases where a NodeList JavaScript object |
// contains Node objects that are not Elements. |
-class _FrozenElementList implements List { |
+class _FrozenElementList extends ListBase<Element> { |
final List<Node> _nodeList; |
_FrozenElementList._wrap(this._nodeList); |
- bool contains(Element element) { |
- for (Element el in this) { |
- if (el == element) return true; |
- } |
- return false; |
- } |
- |
- void forEach(void f(Element element)) { |
- for (Element el in this) { |
- f(el); |
- } |
- } |
- |
- String join([String separator]) { |
- return IterableMixinWorkaround.joinList(this, separator); |
- } |
- |
- Iterable map(f(Element element)) { |
- return IterableMixinWorkaround.mapList(this, f); |
- } |
- |
- Iterable<Element> where(bool f(Element element)) { |
- return IterableMixinWorkaround.where(this, f); |
- } |
- |
- Iterable expand(Iterable f(Element element)) { |
- return IterableMixinWorkaround.expand(this, f); |
- } |
- |
- bool every(bool f(Element element)) { |
- for(Element element in this) { |
- if (!f(element)) { |
- return false; |
- } |
- }; |
- return true; |
- } |
- |
- bool any(bool f(Element element)) { |
- for(Element element in this) { |
- if (f(element)) { |
- return true; |
- } |
- }; |
- return false; |
- } |
- |
- List<Element> toList({ bool growable: true }) => |
- new List<Element>.from(this, growable: growable); |
- Set<Element> toSet() => new Set<Element>.from(this); |
- |
- Iterable<Element> take(int n) { |
- return IterableMixinWorkaround.takeList(this, n); |
- } |
- |
- Iterable<Element> takeWhile(bool test(Element value)) { |
- return IterableMixinWorkaround.takeWhile(this, test); |
- } |
- |
- Iterable<Element> skip(int n) { |
- return IterableMixinWorkaround.skipList(this, n); |
- } |
- |
- Iterable<Element> skipWhile(bool test(Element value)) { |
- return IterableMixinWorkaround.skipWhile(this, test); |
- } |
- |
- Element firstWhere(bool test(Element value), {Element orElse()}) { |
- return IterableMixinWorkaround.firstWhere(this, test, orElse); |
- } |
- |
- Element lastWhere(bool test(Element value), {Element orElse()}) { |
- return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
- } |
- |
- Element singleWhere(bool test(Element value)) { |
- return IterableMixinWorkaround.singleWhere(this, test); |
- } |
- |
- Element elementAt(int index) { |
- return this[index]; |
- } |
- |
- bool get isEmpty => _nodeList.isEmpty; |
- |
int get length => _nodeList.length; |
Element operator [](int index) => _nodeList[index]; |
@@ -401,31 +317,16 @@ class _FrozenElementList implements List { |
throw new UnsupportedError(''); |
} |
- Iterator<Element> get iterator => new _FrozenElementListIterator(this); |
- |
void addAll(Iterable<Element> iterable) { |
throw new UnsupportedError(''); |
} |
- Iterable<Element> get reversed { |
- return IterableMixinWorkaround.reversedList(this); |
- } |
- |
void sort([int compare(Element a, Element b)]) { |
throw new UnsupportedError(''); |
} |
- dynamic reduce(dynamic initialValue, |
- dynamic combine(dynamic previousValue, Element element)) { |
- return IterableMixinWorkaround.reduce(this, initialValue, combine); |
- } |
- |
- dynamic fold(dynamic initialValue, |
- dynamic combine(dynamic previousValue, Element element)) { |
- return IterableMixinWorkaround.fold(this, initialValue, combine); |
- } |
- |
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { |
+ void setRange(int start, int rangeLength, List from, |
+ [int startFrom = 0]) { |
throw new UnsupportedError(''); |
} |
@@ -441,15 +342,6 @@ class _FrozenElementList implements List { |
return new _FrozenElementList._wrap(_nodeList.sublist(start, end)); |
} |
- List<Element> getRange(int start, int rangeLength) => |
- sublist(start, start + rangeLength); |
- |
- int indexOf(Element element, [int start = 0]) => |
- _nodeList.indexOf(element, start); |
- |
- int lastIndexOf(Element element, [int start = null]) => |
- _nodeList.lastIndexOf(element, start); |
- |
void clear() { |
throw new UnsupportedError(''); |
} |
@@ -488,18 +380,6 @@ class _FrozenElementList implements List { |
Element get single => _nodeList.single; |
- Element min([int compare(Element a, Element b)]) { |
- return IterableMixinWorkaround.min(this, compare); |
- } |
- |
- Element max([int compare(Element a, Element b)]) { |
- return IterableMixinWorkaround.max(this, compare); |
- } |
- |
- Map<int, Element> asMap() { |
- return IterableMixinWorkaround.asMapList(this); |
- } |
- |
String toString() { |
StringBuffer buffer = new StringBuffer('['); |
buffer.writeAll(this, ', '); |
@@ -508,38 +388,6 @@ class _FrozenElementList implements List { |
} |
} |
-class _FrozenElementListIterator implements Iterator<Element> { |
- final _FrozenElementList _list; |
- int _index = -1; |
- Element _current; |
- |
- _FrozenElementListIterator(this._list); |
- |
- /** |
- * Moves to the next element. Returns true if the iterator is positioned |
- * at an element. Returns false if it is positioned after the last element. |
- */ |
- bool moveNext() { |
- int nextIndex = _index + 1; |
- if (nextIndex < _list.length) { |
- _current = _list[nextIndex]; |
- _index = nextIndex; |
- return true; |
- } |
- _index = _list.length; |
- _current = null; |
- return false; |
- } |
- |
- /** |
- * Returns the element the [Iterator] is positioned at. |
- * |
- * Return [:null:] if the iterator is positioned before the first, or |
- * after the last element. |
- */ |
- Element get current => _current; |
-} |
- |
class _ElementCssClassSet extends CssClassSet { |
final Element _element; |