| OLD | NEW |
| 1 library html; | 1 library html; |
| 2 | 2 |
| 3 import 'dart:collection'; | 3 import 'dart:collection'; |
| 4 import 'dart:html_common'; | 4 import 'dart:html_common'; |
| 5 import 'dart:indexed_db'; | 5 import 'dart:indexed_db'; |
| 6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
| 7 import 'dart:json'; | 7 import 'dart:json'; |
| 8 import 'dart:nativewrappers'; | 8 import 'dart:nativewrappers'; |
| 9 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
| 10 import 'dart:web_audio' as web_audio; | 10 import 'dart:web_audio' as web_audio; |
| (...skipping 27350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 27361 * This is intended to be overridden by specific implementations. | 27361 * This is intended to be overridden by specific implementations. |
| 27362 */ | 27362 */ |
| 27363 void writeClasses(Set<String> s); | 27363 void writeClasses(Set<String> s); |
| 27364 } | 27364 } |
| 27365 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 27365 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 27366 // for details. All rights reserved. Use of this source code is governed by a | 27366 // for details. All rights reserved. Use of this source code is governed by a |
| 27367 // BSD-style license that can be found in the LICENSE file. | 27367 // BSD-style license that can be found in the LICENSE file. |
| 27368 | 27368 |
| 27369 | 27369 |
| 27370 typedef void EventListener(Event event); | 27370 typedef void EventListener(Event event); |
| 27371 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 27372 // for details. All rights reserved. Use of this source code is governed by a | |
| 27373 // BSD-style license that can be found in the LICENSE file. | |
| 27374 | |
| 27375 | |
| 27376 class FilteredElementList implements List { | |
| 27377 final Node _node; | |
| 27378 final List<Node> _childNodes; | |
| 27379 | |
| 27380 FilteredElementList(Node node): _childNodes = node.nodes, _node = node; | |
| 27381 | |
| 27382 // We can't memoize this, since it's possible that children will be messed | |
| 27383 // with externally to this class. | |
| 27384 // | |
| 27385 // TODO(nweiz): Do we really need to copy the list to make the types work out? | |
| 27386 List<Element> get _filtered => | |
| 27387 new List.from(_childNodes.filter((n) => n is Element)); | |
| 27388 | |
| 27389 void forEach(void f(Element element)) { | |
| 27390 _filtered.forEach(f); | |
| 27391 } | |
| 27392 | |
| 27393 void operator []=(int index, Element value) { | |
| 27394 this[index].replaceWith(value); | |
| 27395 } | |
| 27396 | |
| 27397 void set length(int newLength) { | |
| 27398 final len = this.length; | |
| 27399 if (newLength >= len) { | |
| 27400 return; | |
| 27401 } else if (newLength < 0) { | |
| 27402 throw new ArgumentError("Invalid list length"); | |
| 27403 } | |
| 27404 | |
| 27405 removeRange(newLength - 1, len - newLength); | |
| 27406 } | |
| 27407 | |
| 27408 void add(Element value) { | |
| 27409 _childNodes.add(value); | |
| 27410 } | |
| 27411 | |
| 27412 void addAll(Collection<Element> collection) { | |
| 27413 collection.forEach(add); | |
| 27414 } | |
| 27415 | |
| 27416 void addLast(Element value) { | |
| 27417 add(value); | |
| 27418 } | |
| 27419 | |
| 27420 bool contains(Element element) { | |
| 27421 return element is Element && _childNodes.contains(element); | |
| 27422 } | |
| 27423 | |
| 27424 void sort([int compare(Element a, Element b)]) { | |
| 27425 throw new UnsupportedError('TODO(jacobr): should we impl?'); | |
| 27426 } | |
| 27427 | |
| 27428 void setRange(int start, int rangeLength, List from, [int startFrom = 0]) { | |
| 27429 throw new UnimplementedError(); | |
| 27430 } | |
| 27431 | |
| 27432 void removeRange(int start, int rangeLength) { | |
| 27433 _filtered.getRange(start, rangeLength).forEach((el) => el.remove()); | |
| 27434 } | |
| 27435 | |
| 27436 void insertRange(int start, int rangeLength, [initialValue = null]) { | |
| 27437 throw new UnimplementedError(); | |
| 27438 } | |
| 27439 | |
| 27440 void clear() { | |
| 27441 // Currently, ElementList#clear clears even non-element nodes, so we follow | |
| 27442 // that behavior. | |
| 27443 _childNodes.clear(); | |
| 27444 } | |
| 27445 | |
| 27446 Element removeLast() { | |
| 27447 final result = this.last; | |
| 27448 if (result != null) { | |
| 27449 result.remove(); | |
| 27450 } | |
| 27451 return result; | |
| 27452 } | |
| 27453 | |
| 27454 Element removeAt(int index) { | |
| 27455 final result = this[index]; | |
| 27456 result.remove(); | |
| 27457 return result; | |
| 27458 } | |
| 27459 | |
| 27460 dynamic reduce(dynamic initialValue, | |
| 27461 dynamic combine(dynamic previousValue, Element element)) { | |
| 27462 return Collections.reduce(this, initialValue, combine); | |
| 27463 } | |
| 27464 Collection map(f(Element element)) => _filtered.map(f); | |
| 27465 Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); | |
| 27466 bool every(bool f(Element element)) => _filtered.every(f); | |
| 27467 bool some(bool f(Element element)) => _filtered.some(f); | |
| 27468 bool get isEmpty => _filtered.isEmpty; | |
| 27469 int get length => _filtered.length; | |
| 27470 Element operator [](int index) => _filtered[index]; | |
| 27471 Iterator<Element> iterator() => _filtered.iterator(); | |
| 27472 List<Element> getRange(int start, int rangeLength) => | |
| 27473 _filtered.getRange(start, rangeLength); | |
| 27474 int indexOf(Element element, [int start = 0]) => | |
| 27475 _filtered.indexOf(element, start); | |
| 27476 | |
| 27477 int lastIndexOf(Element element, [int start = null]) { | |
| 27478 if (start == null) start = length - 1; | |
| 27479 return _filtered.lastIndexOf(element, start); | |
| 27480 } | |
| 27481 | |
| 27482 Element get first => _filtered.first; | |
| 27483 | |
| 27484 Element get last => _filtered.last; | |
| 27485 } | |
| 27486 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 27371 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 27487 // for details. All rights reserved. Use of this source code is governed by a | 27372 // for details. All rights reserved. Use of this source code is governed by a |
| 27488 // BSD-style license that can be found in the LICENSE file. | 27373 // BSD-style license that can be found in the LICENSE file. |
| 27489 | 27374 |
| 27490 | 27375 |
| 27491 /** | 27376 /** |
| 27492 * Works with KeyboardEvent and KeyEvent to determine how to expose information | 27377 * Works with KeyboardEvent and KeyEvent to determine how to expose information |
| 27493 * about Key(board)Events. This class functions like an EventListenerList, and | 27378 * about Key(board)Events. This class functions like an EventListenerList, and |
| 27494 * provides a consistent interface for the Dart | 27379 * provides a consistent interface for the Dart |
| 27495 * user, despite the fact that a multitude of browsers that have varying | 27380 * user, despite the fact that a multitude of browsers that have varying |
| (...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29832 bool get isEmpty => Maps.isEmpty(this); | 29717 bool get isEmpty => Maps.isEmpty(this); |
| 29833 } | 29718 } |
| 29834 | 29719 |
| 29835 get _printClosure => (s) { | 29720 get _printClosure => (s) { |
| 29836 try { | 29721 try { |
| 29837 window.console.log(s); | 29722 window.console.log(s); |
| 29838 } catch (_) { | 29723 } catch (_) { |
| 29839 _Utils.print(s); | 29724 _Utils.print(s); |
| 29840 } | 29725 } |
| 29841 }; | 29726 }; |
| OLD | NEW |