Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 library html; | 1 library html; |
| 2 | 2 |
| 3 import 'dart:isolate'; | 3 import 'dart:isolate'; |
| 4 import 'dart:json'; | 4 import 'dart:json'; |
| 5 import 'dart:svg' as svg; | 5 import 'dart:svg' as svg; |
| 6 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 6 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 7 // for details. All rights reserved. Use of this source code is governed by a | 7 // for details. All rights reserved. Use of this source code is governed by a |
| 8 // BSD-style license that can be found in the LICENSE file. | 8 // BSD-style license that can be found in the LICENSE file. |
| 9 | 9 |
| 10 // DO NOT EDIT | 10 // DO NOT EDIT |
| (...skipping 13815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13826 | 13826 |
| 13827 // TODO(jacobr): We can implement these methods much more efficiently by | 13827 // TODO(jacobr): We can implement these methods much more efficiently by |
| 13828 // looking up the nodeList only once instead of once per iteration. | 13828 // looking up the nodeList only once instead of once per iteration. |
| 13829 bool contains(Node element) => _Collections.contains(this, element); | 13829 bool contains(Node element) => _Collections.contains(this, element); |
| 13830 | 13830 |
| 13831 void forEach(void f(Node element)) => _Collections.forEach(this, f); | 13831 void forEach(void f(Node element)) => _Collections.forEach(this, f); |
| 13832 | 13832 |
| 13833 Collection map(f(Node element)) => _Collections.map(this, [], f); | 13833 Collection map(f(Node element)) => _Collections.map(this, [], f); |
| 13834 | 13834 |
| 13835 Collection<Node> filter(bool f(Node element)) => | 13835 Collection<Node> filter(bool f(Node element)) => |
| 13836 new _NodeListWrapper(_Collections.filter(this, <Node>[], f)); | 13836 _Collections.filter(this, <Node>[], f); |
| 13837 | 13837 |
| 13838 bool every(bool f(Node element)) => _Collections.every(this, f); | 13838 bool every(bool f(Node element)) => _Collections.every(this, f); |
| 13839 | 13839 |
| 13840 bool some(bool f(Node element)) => _Collections.some(this, f); | 13840 bool some(bool f(Node element)) => _Collections.some(this, f); |
| 13841 | 13841 |
| 13842 bool get isEmpty => this.length == 0; | 13842 bool get isEmpty => this.length == 0; |
| 13843 | 13843 |
| 13844 // From List<Node>: | 13844 // From List<Node>: |
| 13845 | 13845 |
| 13846 // TODO(jacobr): this could be implemented for child node lists. | 13846 // TODO(jacobr): this could be implemented for child node lists. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 13862 } | 13862 } |
| 13863 void removeRange(int start, int rangeLength) { | 13863 void removeRange(int start, int rangeLength) { |
| 13864 throw new UnsupportedError( | 13864 throw new UnsupportedError( |
| 13865 "Cannot removeRange on immutable List."); | 13865 "Cannot removeRange on immutable List."); |
| 13866 } | 13866 } |
| 13867 void insertRange(int start, int rangeLength, [Node initialValue]) { | 13867 void insertRange(int start, int rangeLength, [Node initialValue]) { |
| 13868 throw new UnsupportedError( | 13868 throw new UnsupportedError( |
| 13869 "Cannot insertRange on immutable List."); | 13869 "Cannot insertRange on immutable List."); |
| 13870 } | 13870 } |
| 13871 List<Node> getRange(int start, int rangeLength) => | 13871 List<Node> getRange(int start, int rangeLength) => |
| 13872 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); | 13872 _Lists.getRange(this, start, rangeLength, <Node>[]); |
| 13873 | 13873 |
| 13874 // -- end List<Node> mixins. | 13874 // -- end List<Node> mixins. |
| 13875 | 13875 |
| 13876 // TODO(jacobr): benchmark whether this is more efficient or whether caching | 13876 // TODO(jacobr): benchmark whether this is more efficient or whether caching |
| 13877 // a local copy of $dom_childNodes is more efficient. | 13877 // a local copy of $dom_childNodes is more efficient. |
| 13878 int get length => _this.$dom_childNodes.length; | 13878 int get length => _this.$dom_childNodes.length; |
| 13879 | 13879 |
| 13880 Node operator[](int index) => _this.$dom_childNodes[index]; | 13880 Node operator[](int index) => _this.$dom_childNodes[index]; |
| 13881 } | 13881 } |
| 13882 | 13882 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14101 Node nextNode() native; | 14101 Node nextNode() native; |
| 14102 | 14102 |
| 14103 /** @domName NodeIterator.previousNode */ | 14103 /** @domName NodeIterator.previousNode */ |
| 14104 Node previousNode() native; | 14104 Node previousNode() native; |
| 14105 } | 14105 } |
| 14106 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 14106 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 14107 // for details. All rights reserved. Use of this source code is governed by a | 14107 // for details. All rights reserved. Use of this source code is governed by a |
| 14108 // BSD-style license that can be found in the LICENSE file. | 14108 // BSD-style license that can be found in the LICENSE file. |
| 14109 | 14109 |
| 14110 | 14110 |
| 14111 // TODO(nweiz): when all implementations we target have the same name for the | |
| 14112 // implementation of List<E>, extend that rather than wrapping. | |
| 14113 class _ListWrapper<E> implements List<E> { | |
| 14114 List _list; | |
| 14115 | |
| 14116 _ListWrapper(List this._list); | |
| 14117 | |
| 14118 Iterator<E> iterator() => _list.iterator(); | |
| 14119 | |
| 14120 bool contains(E element) => _list.contains(element); | |
| 14121 | |
| 14122 void forEach(void f(E element)) => _list.forEach(f); | |
| 14123 | |
| 14124 Collection map(f(E element)) => _list.map(f); | |
| 14125 | |
| 14126 List<E> filter(bool f(E element)) => _list.filter(f); | |
| 14127 | |
| 14128 bool every(bool f(E element)) => _list.every(f); | |
| 14129 | |
| 14130 bool some(bool f(E element)) => _list.some(f); | |
| 14131 | |
| 14132 bool get isEmpty => _list.isEmpty; | |
| 14133 | |
| 14134 int get length => _list.length; | |
| 14135 | |
| 14136 E operator [](int index) => _list[index]; | |
| 14137 | |
| 14138 void operator []=(int index, E value) { _list[index] = value; } | |
| 14139 | |
| 14140 void set length(int newLength) { _list.length = newLength; } | |
| 14141 | |
| 14142 void add(E value) => _list.add(value); | |
| 14143 | |
| 14144 void addLast(E value) => _list.addLast(value); | |
| 14145 | |
| 14146 void addAll(Collection<E> collection) => _list.addAll(collection); | |
| 14147 | |
| 14148 void sort([Comparator<E> compare = Comparable.compare]) => _list.sort(compare) ; | |
| 14149 | |
| 14150 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); | |
| 14151 | |
| 14152 int lastIndexOf(E element, [int start = 0]) => | |
| 14153 _list.lastIndexOf(element, start); | |
| 14154 | |
| 14155 void clear() => _list.clear(); | |
| 14156 | |
| 14157 E removeLast() => _list.removeLast(); | |
| 14158 | |
| 14159 E get first => _list.first; | |
| 14160 | |
| 14161 E get last => _list.last; | |
| 14162 | |
| 14163 List<E> getRange(int start, int rangeLength) => | |
| 14164 _list.getRange(start, rangeLength); | |
| 14165 | |
| 14166 void setRange(int start, int rangeLength, List<E> from, [int startFrom = 0]) | |
| 14167 => _list.setRange(start, rangeLength, from, startFrom); | |
| 14168 | |
| 14169 void removeRange(int start, int rangeLength) => | |
| 14170 _list.removeRange(start, rangeLength); | |
| 14171 | |
| 14172 void insertRange(int start, int rangeLength, [E initialValue = null]) => | |
| 14173 _list.insertRange(start, rangeLength, initialValue); | |
| 14174 } | |
| 14175 | |
| 14176 /** | |
| 14177 * This class is used to insure the results of list operations are NodeLists | |
| 14178 * instead of lists. | |
| 14179 */ | |
| 14180 class _NodeListWrapper extends _ListWrapper<Node> implements List { | |
| 14181 _NodeListWrapper(List list) : super(list); | |
| 14182 | |
| 14183 List<Node> filter(bool f(Node element)) => | |
| 14184 new _NodeListWrapper(_list.filter(f)); | |
| 14185 | |
| 14186 List<Node> getRange(int start, int rangeLength) => | |
| 14187 new _NodeListWrapper(_list.getRange(start, rangeLength)); | |
| 14188 } | |
| 14189 | |
| 14190 class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi st" { | |
| 14191 Node _parent; | |
| 14192 | |
| 14193 // -- start List<Node> mixins. | |
| 14194 // Node is the element type. | |
| 14195 | |
| 14196 // From Iterable<Node>: | |
| 14197 | |
| 14198 Iterator<Node> iterator() { | |
| 14199 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
| 14200 // be cached in both iterator _and_ forEach method. For now caching it | |
| 14201 // for consistency. | |
| 14202 return new FixedSizeListIterator<Node>(this); | |
| 14203 } | |
| 14204 | |
| 14205 // From Collection<Node>: | |
| 14206 | |
| 14207 void add(Node value) { | |
| 14208 _parent.$dom_appendChild(value); | |
| 14209 } | |
| 14210 | |
| 14211 void addLast(Node value) { | |
| 14212 _parent.$dom_appendChild(value); | |
| 14213 } | |
| 14214 | |
| 14215 void addAll(Collection<Node> collection) { | |
| 14216 for (Node node in collection) { | |
| 14217 _parent.$dom_appendChild(node); | |
| 14218 } | |
| 14219 } | |
| 14220 | |
| 14221 Node removeLast() { | |
| 14222 final result = this.last; | |
| 14223 if (result != null) { | |
| 14224 _parent.$dom_removeChild(result); | |
| 14225 } | |
| 14226 return result; | |
| 14227 } | |
| 14228 | |
| 14229 void clear() { | |
| 14230 _parent.text = ''; | |
| 14231 } | |
| 14232 | |
| 14233 void operator []=(int index, Node value) { | |
| 14234 _parent.$dom_replaceChild(value, this[index]); | |
| 14235 } | |
| 14236 | |
| 14237 bool contains(Node element) => _Collections.contains(this, element); | |
| 14238 | |
| 14239 void forEach(void f(Node element)) => _Collections.forEach(this, f); | |
| 14240 | |
| 14241 Collection map(f(Node element)) => _Collections.map(this, [], f); | |
| 14242 | |
| 14243 Collection<Node> filter(bool f(Node element)) => | |
| 14244 new _NodeListWrapper(_Collections.filter(this, <Node>[], f)); | |
| 14245 | |
| 14246 bool every(bool f(Node element)) => _Collections.every(this, f); | |
| 14247 | |
| 14248 bool some(bool f(Node element)) => _Collections.some(this, f); | |
| 14249 | |
| 14250 bool get isEmpty => this.length == 0; | |
| 14251 | |
| 14252 // From List<Node>: | |
| 14253 | |
| 14254 void sort([Comparator<Node> compare = Comparable.compare]) { | |
| 14255 throw new UnsupportedError("Cannot sort immutable List."); | |
| 14256 } | |
| 14257 | |
| 14258 int indexOf(Node element, [int start = 0]) => | |
| 14259 _Lists.indexOf(this, element, start, this.length); | |
| 14260 | |
| 14261 int lastIndexOf(Node element, [int start = 0]) => | |
| 14262 _Lists.lastIndexOf(this, element, start); | |
| 14263 | |
| 14264 Node get last => this[length - 1]; | |
| 14265 Node get first => this[0]; | |
| 14266 | |
| 14267 // FIXME: implement thesee. | |
| 14268 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { | |
| 14269 throw new UnsupportedError("Cannot setRange on immutable List."); | |
| 14270 } | |
| 14271 void removeRange(int start, int rangeLength) { | |
| 14272 throw new UnsupportedError("Cannot removeRange on immutable List."); | |
| 14273 } | |
| 14274 void insertRange(int start, int rangeLength, [Node initialValue]) { | |
| 14275 throw new UnsupportedError("Cannot insertRange on immutable List."); | |
| 14276 } | |
| 14277 List<Node> getRange(int start, int rangeLength) => | |
| 14278 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); | |
| 14279 | |
| 14280 // -- end List<Node> mixins. | |
| 14281 | |
| 14282 | |
| 14283 /** @domName NodeList.length */ | |
| 14284 final int length; | |
| 14285 | |
| 14286 Node operator[](int index) => JS("Node", "#[#]", this, index); | |
| 14287 | |
| 14288 /** @domName NodeList.item */ | |
| 14289 Node _item(int index) native "item"; | |
| 14290 | |
| 14291 } | |
| 14292 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 14293 // for details. All rights reserved. Use of this source code is governed by a | |
| 14294 // BSD-style license that can be found in the LICENSE file. | |
| 14295 | |
| 14296 | |
| 14297 /// @domName Notation | 14111 /// @domName Notation |
| 14298 class Notation extends Node native "*Notation" { | 14112 class Notation extends Node native "*Notation" { |
| 14299 | 14113 |
| 14300 /** @domName Notation.publicId */ | 14114 /** @domName Notation.publicId */ |
| 14301 final String publicId; | 14115 final String publicId; |
| 14302 | 14116 |
| 14303 /** @domName Notation.systemId */ | 14117 /** @domName Notation.systemId */ |
| 14304 final String systemId; | 14118 final String systemId; |
| 14305 } | 14119 } |
| 14306 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 14120 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15607 | 15421 |
| 15608 /** @domName RTCStatsResponse.result */ | 15422 /** @domName RTCStatsResponse.result */ |
| 15609 List<RTCStatsReport> result() native; | 15423 List<RTCStatsReport> result() native; |
| 15610 } | 15424 } |
| 15611 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 15425 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 15612 // for details. All rights reserved. Use of this source code is governed by a | 15426 // for details. All rights reserved. Use of this source code is governed by a |
| 15613 // BSD-style license that can be found in the LICENSE file. | 15427 // BSD-style license that can be found in the LICENSE file. |
| 15614 | 15428 |
| 15615 | 15429 |
| 15616 /// @domName RadioNodeList | 15430 /// @domName RadioNodeList |
| 15617 class RadioNodeList extends NodeList native "*RadioNodeList" { | 15431 class RadioNodeList extends _NodeList native "*RadioNodeList" { |
|
Emily Fortuna
2012/11/17 02:44:30
is it an issue at all that it's extending a hidden
| |
| 15618 | 15432 |
| 15619 /** @domName RadioNodeList.value */ | 15433 /** @domName RadioNodeList.value */ |
| 15620 String value; | 15434 String value; |
| 15621 } | 15435 } |
| 15622 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 15436 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 15623 // for details. All rights reserved. Use of this source code is governed by a | 15437 // for details. All rights reserved. Use of this source code is governed by a |
| 15624 // BSD-style license that can be found in the LICENSE file. | 15438 // BSD-style license that can be found in the LICENSE file. |
| 15625 | 15439 |
| 15626 | 15440 |
| 15627 /// @domName Range | 15441 /// @domName Range |
| (...skipping 6003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21631 // possible to rewrite the above code to, e.g. (simplified): | 21445 // possible to rewrite the above code to, e.g. (simplified): |
| 21632 // | 21446 // |
| 21633 // static createMutationObserver(MutationCallback callback) => | 21447 // static createMutationObserver(MutationCallback callback) => |
| 21634 // JS('var', 'new (window.MutationObserver)(#)', callback); | 21448 // JS('var', 'new (window.MutationObserver)(#)', callback); |
| 21635 } | 21449 } |
| 21636 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 21450 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 21637 // for details. All rights reserved. Use of this source code is governed by a | 21451 // for details. All rights reserved. Use of this source code is governed by a |
| 21638 // BSD-style license that can be found in the LICENSE file. | 21452 // BSD-style license that can be found in the LICENSE file. |
| 21639 | 21453 |
| 21640 | 21454 |
| 21455 /// @domName NodeList | |
| 21456 class _NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeL ist" { | |
| 21457 | |
| 21458 /** @domName NodeList.length */ | |
| 21459 final int length; | |
| 21460 | |
| 21461 Node operator[](int index) => JS("Node", "#[#]", this, index); | |
| 21462 | |
| 21463 void operator[]=(int index, Node value) { | |
| 21464 throw new UnsupportedError("Cannot assign element of immutable List."); | |
| 21465 } | |
| 21466 // -- start List<Node> mixins. | |
| 21467 // Node is the element type. | |
| 21468 | |
| 21469 // From Iterable<Node>: | |
| 21470 | |
| 21471 Iterator<Node> iterator() { | |
| 21472 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
| 21473 // be cached in both iterator _and_ forEach method. For now caching it | |
| 21474 // for consistency. | |
| 21475 return new FixedSizeListIterator<Node>(this); | |
| 21476 } | |
| 21477 | |
| 21478 // From Collection<Node>: | |
| 21479 | |
| 21480 void add(Node value) { | |
| 21481 throw new UnsupportedError("Cannot add to immutable List."); | |
| 21482 } | |
| 21483 | |
| 21484 void addLast(Node value) { | |
| 21485 throw new UnsupportedError("Cannot add to immutable List."); | |
| 21486 } | |
| 21487 | |
| 21488 void addAll(Collection<Node> collection) { | |
| 21489 throw new UnsupportedError("Cannot add to immutable List."); | |
| 21490 } | |
| 21491 | |
| 21492 bool contains(Node element) => _Collections.contains(this, element); | |
| 21493 | |
| 21494 void forEach(void f(Node element)) => _Collections.forEach(this, f); | |
| 21495 | |
| 21496 Collection map(f(Node element)) => _Collections.map(this, [], f); | |
| 21497 | |
| 21498 Collection<Node> filter(bool f(Node element)) => | |
| 21499 _Collections.filter(this, <Node>[], f); | |
| 21500 | |
| 21501 bool every(bool f(Node element)) => _Collections.every(this, f); | |
| 21502 | |
| 21503 bool some(bool f(Node element)) => _Collections.some(this, f); | |
| 21504 | |
| 21505 bool get isEmpty => this.length == 0; | |
| 21506 | |
| 21507 // From List<Node>: | |
| 21508 | |
| 21509 void sort([Comparator<Node> compare = Comparable.compare]) { | |
| 21510 throw new UnsupportedError("Cannot sort immutable List."); | |
| 21511 } | |
| 21512 | |
| 21513 int indexOf(Node element, [int start = 0]) => | |
| 21514 _Lists.indexOf(this, element, start, this.length); | |
| 21515 | |
| 21516 int lastIndexOf(Node element, [int start]) { | |
| 21517 if (start == null) start = length - 1; | |
| 21518 return _Lists.lastIndexOf(this, element, start); | |
| 21519 } | |
| 21520 | |
| 21521 Node get first => this[0]; | |
| 21522 | |
| 21523 Node get last => this[length - 1]; | |
| 21524 | |
| 21525 Node removeLast() { | |
| 21526 throw new UnsupportedError("Cannot removeLast on immutable List."); | |
| 21527 } | |
| 21528 | |
| 21529 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { | |
| 21530 throw new UnsupportedError("Cannot setRange on immutable List."); | |
| 21531 } | |
| 21532 | |
| 21533 void removeRange(int start, int rangeLength) { | |
| 21534 throw new UnsupportedError("Cannot removeRange on immutable List."); | |
| 21535 } | |
| 21536 | |
| 21537 void insertRange(int start, int rangeLength, [Node initialValue]) { | |
| 21538 throw new UnsupportedError("Cannot insertRange on immutable List."); | |
| 21539 } | |
| 21540 | |
| 21541 List<Node> getRange(int start, int rangeLength) => | |
| 21542 _Lists.getRange(this, start, rangeLength, <Node>[]); | |
| 21543 | |
| 21544 // -- end List<Node> mixins. | |
| 21545 | |
| 21546 /** @domName NodeList.item */ | |
| 21547 Node _item(int index) native "item"; | |
| 21548 } | |
| 21549 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 21550 // for details. All rights reserved. Use of this source code is governed by a | |
| 21551 // BSD-style license that can be found in the LICENSE file. | |
| 21552 | |
| 21553 | |
| 21641 class _NotificationFactoryProvider { | 21554 class _NotificationFactoryProvider { |
| 21642 static Notification createNotification(String title, [Map options]) => | 21555 static Notification createNotification(String title, [Map options]) => |
| 21643 JS('Notification', 'new Notification(#,#)', title, options); | 21556 JS('Notification', 'new Notification(#,#)', title, options); |
| 21644 } | 21557 } |
| 21645 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 21558 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 21646 // for details. All rights reserved. Use of this source code is governed by a | 21559 // for details. All rights reserved. Use of this source code is governed by a |
| 21647 // BSD-style license that can be found in the LICENSE file. | 21560 // BSD-style license that can be found in the LICENSE file. |
| 21648 | 21561 |
| 21649 | 21562 |
| 21650 class _OptionElementFactoryProvider { | 21563 class _OptionElementFactoryProvider { |
| (...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 25086 if (length < 0) throw new ArgumentError('length'); | 24999 if (length < 0) throw new ArgumentError('length'); |
| 25087 if (start < 0) throw new RangeError.value(start); | 25000 if (start < 0) throw new RangeError.value(start); |
| 25088 int end = start + length; | 25001 int end = start + length; |
| 25089 if (end > a.length) throw new RangeError.value(end); | 25002 if (end > a.length) throw new RangeError.value(end); |
| 25090 for (int i = start; i < end; i++) { | 25003 for (int i = start; i < end; i++) { |
| 25091 accumulator.add(a[i]); | 25004 accumulator.add(a[i]); |
| 25092 } | 25005 } |
| 25093 return accumulator; | 25006 return accumulator; |
| 25094 } | 25007 } |
| 25095 } | 25008 } |
| OLD | NEW |