| OLD | NEW |
| 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 // TODO(jacobr): use _Lists.dart to remove some of the duplicated | 5 // TODO(jacobr): use _Lists.dart to remove some of the duplicated |
| 6 // functionality. | 6 // functionality. |
| 7 class _ChildrenElementList implements ElementList { | 7 class _ChildrenElementList implements ElementList { |
| 8 // Raw Element. | 8 // Raw Element. |
| 9 final _ElementImpl _element; | 9 final _ElementImpl _element; |
| 10 final _HTMLCollectionImpl _childElements; | 10 final _HTMLCollectionImpl _childElements; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 void sort(int compare(Element a, Element b)) { | 106 void sort(int compare(Element a, Element b)) { |
| 107 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 107 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 110 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 111 throw 'Not impl yet. todo(jacobr)'; | 111 throw 'Not impl yet. todo(jacobr)'; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void setRange(int start, int length, List from, [int startFrom = 0]) { | 114 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { |
| 115 throw const NotImplementedException(); | 115 throw const NotImplementedException(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void removeRange(int start, int length) { | 118 void removeRange(int start, int rangeLength) { |
| 119 throw const NotImplementedException(); | 119 throw const NotImplementedException(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void insertRange(int start, int length, [initialValue = null]) { | 122 void insertRange(int start, int rangeLength, [initialValue = null]) { |
| 123 throw const NotImplementedException(); | 123 throw const NotImplementedException(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 List getRange(int start, int length) => | 126 List getRange(int start, int rangeLength) => |
| 127 new _FrozenElementList._wrap(_Lists.getRange(this, start, length, | 127 new _FrozenElementList._wrap(_Lists.getRange(this, start, rangeLength, |
| 128 <Element>[])); | 128 <Element>[])); |
| 129 | 129 |
| 130 int indexOf(Element element, [int start = 0]) { | 130 int indexOf(Element element, [int start = 0]) { |
| 131 return _Lists.indexOf(this, element, start, this.length); | 131 return _Lists.indexOf(this, element, start, this.length); |
| 132 } | 132 } |
| 133 | 133 |
| 134 int lastIndexOf(Element element, [int start = null]) { | 134 int lastIndexOf(Element element, [int start = null]) { |
| 135 if (start === null) start = length - 1; | 135 if (start === null) start = length - 1; |
| 136 return _Lists.lastIndexOf(this, element, start); | 136 return _Lists.lastIndexOf(this, element, start); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void clear() { | 139 void clear() { |
| 140 // It is unclear if we want to keep non element nodes? | 140 // It is unclear if we want to keep non element nodes? |
| 141 _element.text = ''; | 141 _element.text = ''; |
| 142 } | 142 } |
| 143 | 143 |
| 144 Element removeLast() { | 144 Element removeLast() { |
| 145 final last = this.last(); | 145 final result = this.last(); |
| 146 if (last != null) { | 146 if (result != null) { |
| 147 _element.$dom_removeChild(last); | 147 _element.$dom_removeChild(result); |
| 148 } | 148 } |
| 149 return last; | 149 return result; |
| 150 } | 150 } |
| 151 | 151 |
| 152 Element last() { | 152 Element last() { |
| 153 return _element.$dom_lastElementChild; | 153 return _element.$dom_lastElementChild; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 // TODO(jacobr): this is an inefficient implementation but it is hard to see | 157 // TODO(jacobr): this is an inefficient implementation but it is hard to see |
| 158 // a better option given that we cannot quite force NodeList to be an | 158 // a better option given that we cannot quite force NodeList to be an |
| 159 // ElementList as there are valid cases where a NodeList JavaScript object | 159 // ElementList as there are valid cases where a NodeList JavaScript object |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 Iterator<Element> iterator() => new _FrozenElementListIterator(this); | 232 Iterator<Element> iterator() => new _FrozenElementListIterator(this); |
| 233 | 233 |
| 234 void addAll(Collection<Element> collection) { | 234 void addAll(Collection<Element> collection) { |
| 235 throw const UnsupportedOperationException(''); | 235 throw const UnsupportedOperationException(''); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void sort(int compare(Element a, Element b)) { | 238 void sort(int compare(Element a, Element b)) { |
| 239 throw const UnsupportedOperationException(''); | 239 throw const UnsupportedOperationException(''); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void setRange(int start, int length, List from, [int startFrom = 0]) { | 242 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { |
| 243 throw const UnsupportedOperationException(''); | 243 throw const UnsupportedOperationException(''); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void removeRange(int start, int length) { | 246 void removeRange(int start, int rangeLength) { |
| 247 throw const UnsupportedOperationException(''); | 247 throw const UnsupportedOperationException(''); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void insertRange(int start, int length, [initialValue = null]) { | 250 void insertRange(int start, int rangeLength, [initialValue = null]) { |
| 251 throw const UnsupportedOperationException(''); | 251 throw const UnsupportedOperationException(''); |
| 252 } | 252 } |
| 253 | 253 |
| 254 ElementList getRange(int start, int length) => | 254 ElementList getRange(int start, int rangeLength) => |
| 255 new _FrozenElementList._wrap(_nodeList.getRange(start, length)); | 255 new _FrozenElementList._wrap(_nodeList.getRange(start, rangeLength)); |
| 256 | 256 |
| 257 int indexOf(Element element, [int start = 0]) => | 257 int indexOf(Element element, [int start = 0]) => |
| 258 _nodeList.indexOf(element, start); | 258 _nodeList.indexOf(element, start); |
| 259 | 259 |
| 260 int lastIndexOf(Element element, [int start = null]) => | 260 int lastIndexOf(Element element, [int start = null]) => |
| 261 _nodeList.lastIndexOf(element, start); | 261 _nodeList.lastIndexOf(element, start); |
| 262 | 262 |
| 263 void clear() { | 263 void clear() { |
| 264 throw const UnsupportedOperationException(''); | 264 throw const UnsupportedOperationException(''); |
| 265 } | 265 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 294 */ | 294 */ |
| 295 bool hasNext() => _index < _list.length; | 295 bool hasNext() => _index < _list.length; |
| 296 } | 296 } |
| 297 | 297 |
| 298 class _ElementList extends _ListWrapper<Element> implements ElementList { | 298 class _ElementList extends _ListWrapper<Element> implements ElementList { |
| 299 _ElementList(List<Element> list) : super(list); | 299 _ElementList(List<Element> list) : super(list); |
| 300 | 300 |
| 301 ElementList filter(bool f(Element element)) => | 301 ElementList filter(bool f(Element element)) => |
| 302 new _ElementList(super.filter(f)); | 302 new _ElementList(super.filter(f)); |
| 303 | 303 |
| 304 ElementList getRange(int start, int length) => | 304 ElementList getRange(int start, int rangeLength) => |
| 305 new _ElementList(super.getRange(start, length)); | 305 new _ElementList(super.getRange(start, rangeLength)); |
| 306 } | 306 } |
| 307 | 307 |
| 308 class _ElementAttributeMap implements AttributeMap { | 308 class _ElementAttributeMap implements AttributeMap { |
| 309 | 309 |
| 310 final _ElementImpl _element; | 310 final _ElementImpl _element; |
| 311 | 311 |
| 312 _ElementAttributeMap(this._element); | 312 _ElementAttributeMap(this._element); |
| 313 | 313 |
| 314 bool containsValue(String value) { | 314 bool containsValue(String value) { |
| 315 final attributes = _element.$dom_attributes; | 315 final attributes = _element.$dom_attributes; |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 772 |
| 773 /** @domName Document.createElement */ | 773 /** @domName Document.createElement */ |
| 774 $if FROG | 774 $if FROG |
| 775 // Optimization to improve performance until the frog compiler inlines this | 775 // Optimization to improve performance until the frog compiler inlines this |
| 776 // method. | 776 // method. |
| 777 factory Element.tag(String tag) native "return document.createElement(tag)"; | 777 factory Element.tag(String tag) native "return document.createElement(tag)"; |
| 778 $else | 778 $else |
| 779 factory Element.tag(String tag) => _document.$dom_createElement(tag); | 779 factory Element.tag(String tag) => _document.$dom_createElement(tag); |
| 780 $endif | 780 $endif |
| 781 } | 781 } |
| OLD | NEW |