| 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 7370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7381 | 7381 |
| 7382 return _list[_index++]; | 7382 return _list[_index++]; |
| 7383 } | 7383 } |
| 7384 | 7384 |
| 7385 /** | 7385 /** |
| 7386 * Returns whether the [Iterator] has elements left. | 7386 * Returns whether the [Iterator] has elements left. |
| 7387 */ | 7387 */ |
| 7388 bool get hasNext => _index < _list.length; | 7388 bool get hasNext => _index < _list.length; |
| 7389 } | 7389 } |
| 7390 | 7390 |
| 7391 class _ElementAttributeMap implements Map<String, String> { | |
| 7392 | |
| 7393 final Element _element; | |
| 7394 | |
| 7395 _ElementAttributeMap(this._element); | |
| 7396 | |
| 7397 bool containsValue(String value) { | |
| 7398 final attributes = _element.$dom_attributes; | |
| 7399 for (int i = 0, len = attributes.length; i < len; i++) { | |
| 7400 if(value == attributes[i].value) { | |
| 7401 return true; | |
| 7402 } | |
| 7403 } | |
| 7404 return false; | |
| 7405 } | |
| 7406 | |
| 7407 bool containsKey(String key) { | |
| 7408 return _element.$dom_hasAttribute(key); | |
| 7409 } | |
| 7410 | |
| 7411 String operator [](String key) { | |
| 7412 return _element.$dom_getAttribute(key); | |
| 7413 } | |
| 7414 | |
| 7415 void operator []=(String key, value) { | |
| 7416 _element.$dom_setAttribute(key, '$value'); | |
| 7417 } | |
| 7418 | |
| 7419 String putIfAbsent(String key, String ifAbsent()) { | |
| 7420 if (!containsKey(key)) { | |
| 7421 this[key] = ifAbsent(); | |
| 7422 } | |
| 7423 return this[key]; | |
| 7424 } | |
| 7425 | |
| 7426 String remove(String key) { | |
| 7427 String value = _element.$dom_getAttribute(key); | |
| 7428 _element.$dom_removeAttribute(key); | |
| 7429 return value; | |
| 7430 } | |
| 7431 | |
| 7432 void clear() { | |
| 7433 final attributes = _element.$dom_attributes; | |
| 7434 for (int i = attributes.length - 1; i >= 0; i--) { | |
| 7435 remove(attributes[i].name); | |
| 7436 } | |
| 7437 } | |
| 7438 | |
| 7439 void forEach(void f(String key, String value)) { | |
| 7440 final attributes = _element.$dom_attributes; | |
| 7441 for (int i = 0, len = attributes.length; i < len; i++) { | |
| 7442 final item = attributes[i]; | |
| 7443 f(item.name, item.value); | |
| 7444 } | |
| 7445 } | |
| 7446 | |
| 7447 Collection<String> get keys { | |
| 7448 // TODO(jacobr): generate a lazy collection instead. | |
| 7449 final attributes = _element.$dom_attributes; | |
| 7450 final keys = new List<String>(attributes.length); | |
| 7451 for (int i = 0, len = attributes.length; i < len; i++) { | |
| 7452 keys[i] = attributes[i].name; | |
| 7453 } | |
| 7454 return keys; | |
| 7455 } | |
| 7456 | |
| 7457 Collection<String> get values { | |
| 7458 // TODO(jacobr): generate a lazy collection instead. | |
| 7459 final attributes = _element.$dom_attributes; | |
| 7460 final values = new List<String>(attributes.length); | |
| 7461 for (int i = 0, len = attributes.length; i < len; i++) { | |
| 7462 values[i] = attributes[i].value; | |
| 7463 } | |
| 7464 return values; | |
| 7465 } | |
| 7466 | |
| 7467 /** | |
| 7468 * The number of {key, value} pairs in the map. | |
| 7469 */ | |
| 7470 int get length { | |
| 7471 return _element.$dom_attributes.length; | |
| 7472 } | |
| 7473 | |
| 7474 /** | |
| 7475 * Returns true if there is no {key, value} pair in the map. | |
| 7476 */ | |
| 7477 bool get isEmpty { | |
| 7478 return length == 0; | |
| 7479 } | |
| 7480 } | |
| 7481 | |
| 7482 /** | |
| 7483 * Provides a Map abstraction on top of data-* attributes, similar to the | |
| 7484 * dataSet in the old DOM. | |
| 7485 */ | |
| 7486 class _DataAttributeMap implements Map<String, String> { | |
| 7487 | |
| 7488 final Map<String, String> $dom_attributes; | |
| 7489 | |
| 7490 _DataAttributeMap(this.$dom_attributes); | |
| 7491 | |
| 7492 // interface Map | |
| 7493 | |
| 7494 // TODO: Use lazy iterator when it is available on Map. | |
| 7495 bool containsValue(String value) => values.some((v) => v == value); | |
| 7496 | |
| 7497 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key)); | |
| 7498 | |
| 7499 String operator [](String key) => $dom_attributes[_attr(key)]; | |
| 7500 | |
| 7501 void operator []=(String key, value) { | |
| 7502 $dom_attributes[_attr(key)] = '$value'; | |
| 7503 } | |
| 7504 | |
| 7505 String putIfAbsent(String key, String ifAbsent()) => | |
| 7506 $dom_attributes.putIfAbsent(_attr(key), ifAbsent); | |
| 7507 | |
| 7508 String remove(String key) => $dom_attributes.remove(_attr(key)); | |
| 7509 | |
| 7510 void clear() { | |
| 7511 // Needs to operate on a snapshot since we are mutating the collection. | |
| 7512 for (String key in keys) { | |
| 7513 remove(key); | |
| 7514 } | |
| 7515 } | |
| 7516 | |
| 7517 void forEach(void f(String key, String value)) { | |
| 7518 $dom_attributes.forEach((String key, String value) { | |
| 7519 if (_matches(key)) { | |
| 7520 f(_strip(key), value); | |
| 7521 } | |
| 7522 }); | |
| 7523 } | |
| 7524 | |
| 7525 Collection<String> get keys { | |
| 7526 final keys = new List<String>(); | |
| 7527 $dom_attributes.forEach((String key, String value) { | |
| 7528 if (_matches(key)) { | |
| 7529 keys.add(_strip(key)); | |
| 7530 } | |
| 7531 }); | |
| 7532 return keys; | |
| 7533 } | |
| 7534 | |
| 7535 Collection<String> get values { | |
| 7536 final values = new List<String>(); | |
| 7537 $dom_attributes.forEach((String key, String value) { | |
| 7538 if (_matches(key)) { | |
| 7539 values.add(value); | |
| 7540 } | |
| 7541 }); | |
| 7542 return values; | |
| 7543 } | |
| 7544 | |
| 7545 int get length => keys.length; | |
| 7546 | |
| 7547 // TODO: Use lazy iterator when it is available on Map. | |
| 7548 bool get isEmpty => length == 0; | |
| 7549 | |
| 7550 // Helpers. | |
| 7551 String _attr(String key) => 'data-$key'; | |
| 7552 bool _matches(String key) => key.startsWith('data-'); | |
| 7553 String _strip(String key) => key.substring(5); | |
| 7554 } | |
| 7555 | |
| 7556 class _ElementCssClassSet extends CssClassSet { | 7391 class _ElementCssClassSet extends CssClassSet { |
| 7557 | 7392 |
| 7558 final Element _element; | 7393 final Element _element; |
| 7559 | 7394 |
| 7560 _ElementCssClassSet(this._element); | 7395 _ElementCssClassSet(this._element); |
| 7561 | 7396 |
| 7562 Set<String> readClasses() { | 7397 Set<String> readClasses() { |
| 7563 var s = new Set<String>(); | 7398 var s = new Set<String>(); |
| 7564 var classname = _element.$dom_className; | 7399 var classname = _element.$dom_className; |
| 7565 | 7400 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7647 new _DataAttributeMap(attributes); | 7482 new _DataAttributeMap(attributes); |
| 7648 | 7483 |
| 7649 void set dataAttributes(Map<String, String> value) { | 7484 void set dataAttributes(Map<String, String> value) { |
| 7650 final dataAttributes = this.dataAttributes; | 7485 final dataAttributes = this.dataAttributes; |
| 7651 dataAttributes.clear(); | 7486 dataAttributes.clear(); |
| 7652 for (String key in value.keys) { | 7487 for (String key in value.keys) { |
| 7653 dataAttributes[key] = value[key]; | 7488 dataAttributes[key] = value[key]; |
| 7654 } | 7489 } |
| 7655 } | 7490 } |
| 7656 | 7491 |
| 7492 /** |
| 7493 * Gets a map for manipulating the attributes of a particular namespace. |
| 7494 * This is primarily useful for SVG attributes such as xref:link. |
| 7495 */ |
| 7496 Map<String, String> getNamespacedAttributes(String namespace) { |
| 7497 return new _NamespacedAttributeMap(this, namespace); |
| 7498 } |
| 7499 |
| 7657 /** @domName Window.getComputedStyle */ | 7500 /** @domName Window.getComputedStyle */ |
| 7658 Future<CSSStyleDeclaration> get computedStyle { | 7501 Future<CSSStyleDeclaration> get computedStyle { |
| 7659 // TODO(jacobr): last param should be null, see b/5045788 | 7502 // TODO(jacobr): last param should be null, see b/5045788 |
| 7660 return getComputedStyle(''); | 7503 return getComputedStyle(''); |
| 7661 } | 7504 } |
| 7662 | 7505 |
| 7663 /** @domName Window.getComputedStyle */ | 7506 /** @domName Window.getComputedStyle */ |
| 7664 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { | 7507 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { |
| 7665 return _createMeasurementFuture( | 7508 return _createMeasurementFuture( |
| 7666 () => window.$dom_getComputedStyle(this, pseudoElement), | 7509 () => window.$dom_getComputedStyle(this, pseudoElement), |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7884 | 7727 |
| 7885 /** @domName Element.blur */ | 7728 /** @domName Element.blur */ |
| 7886 void blur() native; | 7729 void blur() native; |
| 7887 | 7730 |
| 7888 /** @domName Element.focus */ | 7731 /** @domName Element.focus */ |
| 7889 void focus() native; | 7732 void focus() native; |
| 7890 | 7733 |
| 7891 /** @domName Element.getAttribute */ | 7734 /** @domName Element.getAttribute */ |
| 7892 String $dom_getAttribute(String name) native "getAttribute"; | 7735 String $dom_getAttribute(String name) native "getAttribute"; |
| 7893 | 7736 |
| 7737 /** @domName Element.getAttributeNS */ |
| 7738 String $dom_getAttributeNS(String namespaceURI, String localName) native "getA
ttributeNS"; |
| 7739 |
| 7894 /** @domName Element.getBoundingClientRect */ | 7740 /** @domName Element.getBoundingClientRect */ |
| 7895 ClientRect getBoundingClientRect() native; | 7741 ClientRect getBoundingClientRect() native; |
| 7896 | 7742 |
| 7897 /** @domName Element.getClientRects */ | 7743 /** @domName Element.getClientRects */ |
| 7898 List<ClientRect> getClientRects() native; | 7744 List<ClientRect> getClientRects() native; |
| 7899 | 7745 |
| 7900 /** @domName Element.getElementsByClassName */ | 7746 /** @domName Element.getElementsByClassName */ |
| 7901 List<Node> $dom_getElementsByClassName(String name) native "getElementsByClass
Name"; | 7747 List<Node> $dom_getElementsByClassName(String name) native "getElementsByClass
Name"; |
| 7902 | 7748 |
| 7903 /** @domName Element.getElementsByTagName */ | 7749 /** @domName Element.getElementsByTagName */ |
| 7904 List<Node> $dom_getElementsByTagName(String name) native "getElementsByTagName
"; | 7750 List<Node> $dom_getElementsByTagName(String name) native "getElementsByTagName
"; |
| 7905 | 7751 |
| 7906 /** @domName Element.hasAttribute */ | 7752 /** @domName Element.hasAttribute */ |
| 7907 bool $dom_hasAttribute(String name) native "hasAttribute"; | 7753 bool $dom_hasAttribute(String name) native "hasAttribute"; |
| 7908 | 7754 |
| 7755 /** @domName Element.hasAttributeNS */ |
| 7756 bool $dom_hasAttributeNS(String namespaceURI, String localName) native "hasAtt
ributeNS"; |
| 7757 |
| 7909 /** @domName Element.querySelector */ | 7758 /** @domName Element.querySelector */ |
| 7910 Element $dom_querySelector(String selectors) native "querySelector"; | 7759 Element $dom_querySelector(String selectors) native "querySelector"; |
| 7911 | 7760 |
| 7912 /** @domName Element.querySelectorAll */ | 7761 /** @domName Element.querySelectorAll */ |
| 7913 List<Node> $dom_querySelectorAll(String selectors) native "querySelectorAll"; | 7762 List<Node> $dom_querySelectorAll(String selectors) native "querySelectorAll"; |
| 7914 | 7763 |
| 7915 /** @domName Element.removeAttribute */ | 7764 /** @domName Element.removeAttribute */ |
| 7916 void $dom_removeAttribute(String name) native "removeAttribute"; | 7765 void $dom_removeAttribute(String name) native "removeAttribute"; |
| 7917 | 7766 |
| 7767 /** @domName Element.removeAttributeNS */ |
| 7768 void $dom_removeAttributeNS(String namespaceURI, String localName) native "rem
oveAttributeNS"; |
| 7769 |
| 7918 /** @domName Element.scrollByLines */ | 7770 /** @domName Element.scrollByLines */ |
| 7919 void scrollByLines(int lines) native; | 7771 void scrollByLines(int lines) native; |
| 7920 | 7772 |
| 7921 /** @domName Element.scrollByPages */ | 7773 /** @domName Element.scrollByPages */ |
| 7922 void scrollByPages(int pages) native; | 7774 void scrollByPages(int pages) native; |
| 7923 | 7775 |
| 7924 /** @domName Element.scrollIntoViewIfNeeded */ | 7776 /** @domName Element.scrollIntoViewIfNeeded */ |
| 7925 void scrollIntoView([bool centerIfNeeded]) native "scrollIntoViewIfNeeded"; | 7777 void scrollIntoView([bool centerIfNeeded]) native "scrollIntoViewIfNeeded"; |
| 7926 | 7778 |
| 7927 /** @domName Element.setAttribute */ | 7779 /** @domName Element.setAttribute */ |
| 7928 void $dom_setAttribute(String name, String value) native "setAttribute"; | 7780 void $dom_setAttribute(String name, String value) native "setAttribute"; |
| 7929 | 7781 |
| 7782 /** @domName Element.setAttributeNS */ |
| 7783 void $dom_setAttributeNS(String namespaceURI, String qualifiedName, String val
ue) native "setAttributeNS"; |
| 7784 |
| 7930 /** @domName Element.webkitMatchesSelector */ | 7785 /** @domName Element.webkitMatchesSelector */ |
| 7931 bool matchesSelector(String selectors) native "webkitMatchesSelector"; | 7786 bool matchesSelector(String selectors) native "webkitMatchesSelector"; |
| 7932 | 7787 |
| 7933 /** @domName Element.webkitRequestFullScreen */ | 7788 /** @domName Element.webkitRequestFullScreen */ |
| 7934 void webkitRequestFullScreen(int flags) native; | 7789 void webkitRequestFullScreen(int flags) native; |
| 7935 | 7790 |
| 7936 /** @domName Element.webkitRequestFullscreen */ | 7791 /** @domName Element.webkitRequestFullscreen */ |
| 7937 void webkitRequestFullscreen() native; | 7792 void webkitRequestFullscreen() native; |
| 7938 | 7793 |
| 7939 /** @domName Element.webkitRequestPointerLock */ | 7794 /** @domName Element.webkitRequestPointerLock */ |
| (...skipping 6011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13951 | 13806 |
| 13952 /** @domName Node.childNodes */ | 13807 /** @domName Node.childNodes */ |
| 13953 List<Node> get $dom_childNodes => JS("List<Node>", "#.childNodes", this); | 13808 List<Node> get $dom_childNodes => JS("List<Node>", "#.childNodes", this); |
| 13954 | 13809 |
| 13955 /** @domName Node.firstChild */ | 13810 /** @domName Node.firstChild */ |
| 13956 Node get $dom_firstChild => JS("Node", "#.firstChild", this); | 13811 Node get $dom_firstChild => JS("Node", "#.firstChild", this); |
| 13957 | 13812 |
| 13958 /** @domName Node.lastChild */ | 13813 /** @domName Node.lastChild */ |
| 13959 Node get $dom_lastChild => JS("Node", "#.lastChild", this); | 13814 Node get $dom_lastChild => JS("Node", "#.lastChild", this); |
| 13960 | 13815 |
| 13816 /** @domName Node.localName */ |
| 13817 String get $dom_localName => JS("String", "#.localName", this); |
| 13818 |
| 13819 /** @domName Node.namespaceURI */ |
| 13820 String get $dom_namespaceURI => JS("String", "#.namespaceURI", this); |
| 13821 |
| 13961 /** @domName Node.nextSibling */ | 13822 /** @domName Node.nextSibling */ |
| 13962 Node get nextNode => JS("Node", "#.nextSibling", this); | 13823 Node get nextNode => JS("Node", "#.nextSibling", this); |
| 13963 | 13824 |
| 13964 /** @domName Node.nodeType */ | 13825 /** @domName Node.nodeType */ |
| 13965 final int nodeType; | 13826 final int nodeType; |
| 13966 | 13827 |
| 13967 /** @domName Node.ownerDocument */ | 13828 /** @domName Node.ownerDocument */ |
| 13968 Document get document => JS("Document", "#.ownerDocument", this); | 13829 Document get document => JS("Document", "#.ownerDocument", this); |
| 13969 | 13830 |
| 13970 /** @domName Node.parentNode */ | 13831 /** @domName Node.parentNode */ |
| (...skipping 8491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22462 | 22323 |
| 22463 class _XSLTProcessorFactoryProvider { | 22324 class _XSLTProcessorFactoryProvider { |
| 22464 static XSLTProcessor createXSLTProcessor() => | 22325 static XSLTProcessor createXSLTProcessor() => |
| 22465 JS('XSLTProcessor', 'new XSLTProcessor()' ); | 22326 JS('XSLTProcessor', 'new XSLTProcessor()' ); |
| 22466 } | 22327 } |
| 22467 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 22328 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 22468 // for details. All rights reserved. Use of this source code is governed by a | 22329 // for details. All rights reserved. Use of this source code is governed by a |
| 22469 // BSD-style license that can be found in the LICENSE file. | 22330 // BSD-style license that can be found in the LICENSE file. |
| 22470 | 22331 |
| 22471 | 22332 |
| 22333 abstract class _AttributeMap implements Map<String, String> { |
| 22334 |
| 22335 bool containsValue(String value) { |
| 22336 for (var v in this.values) { |
| 22337 if (value == v) { |
| 22338 return true; |
| 22339 } |
| 22340 } |
| 22341 return false; |
| 22342 } |
| 22343 |
| 22344 String putIfAbsent(String key, String ifAbsent()) { |
| 22345 if (!containsKey(key)) { |
| 22346 this[key] = ifAbsent(); |
| 22347 } |
| 22348 return this[key]; |
| 22349 } |
| 22350 |
| 22351 void clear() { |
| 22352 for (var key in keys) { |
| 22353 remove(key); |
| 22354 } |
| 22355 } |
| 22356 |
| 22357 void forEach(void f(String key, String value)) { |
| 22358 for (var key in keys) { |
| 22359 var value = this[key]; |
| 22360 f(key, value); |
| 22361 } |
| 22362 } |
| 22363 |
| 22364 Collection<String> get keys { |
| 22365 // TODO: generate a lazy collection instead. |
| 22366 var attributes = _element.$dom_attributes; |
| 22367 var keys = new List<String>(); |
| 22368 for (int i = 0, len = attributes.length; i < len; i++) { |
| 22369 if (_matches(attributes[i])) { |
| 22370 keys.add(attributes[i].$dom_localName); |
| 22371 } |
| 22372 } |
| 22373 return keys; |
| 22374 } |
| 22375 |
| 22376 Collection<String> get values { |
| 22377 // TODO: generate a lazy collection instead. |
| 22378 var attributes = _element.$dom_attributes; |
| 22379 var values = new List<String>(); |
| 22380 for (int i = 0, len = attributes.length; i < len; i++) { |
| 22381 if (_matches(attributes[i])) { |
| 22382 values.add(attributes[i].value); |
| 22383 } |
| 22384 } |
| 22385 return values; |
| 22386 } |
| 22387 |
| 22388 /** |
| 22389 * Returns true if there is no {key, value} pair in the map. |
| 22390 */ |
| 22391 bool get isEmpty { |
| 22392 return length == 0; |
| 22393 } |
| 22394 |
| 22395 /** |
| 22396 * Checks to see if the node should be included in this map. |
| 22397 */ |
| 22398 bool _matches(Node node); |
| 22399 } |
| 22400 |
| 22401 /** |
| 22402 * Wrapper to expose Element.attributes as a typed map. |
| 22403 */ |
| 22404 class _ElementAttributeMap extends _AttributeMap { |
| 22405 |
| 22406 final Element _element; |
| 22407 |
| 22408 _ElementAttributeMap(this._element); |
| 22409 |
| 22410 bool containsKey(String key) { |
| 22411 return _element.$dom_hasAttribute(key); |
| 22412 } |
| 22413 |
| 22414 String operator [](String key) { |
| 22415 return _element.$dom_getAttribute(key); |
| 22416 } |
| 22417 |
| 22418 void operator []=(String key, value) { |
| 22419 _element.$dom_setAttribute(key, '$value'); |
| 22420 } |
| 22421 |
| 22422 String remove(String key) { |
| 22423 String value = _element.$dom_getAttribute(key); |
| 22424 _element.$dom_removeAttribute(key); |
| 22425 return value; |
| 22426 } |
| 22427 |
| 22428 /** |
| 22429 * The number of {key, value} pairs in the map. |
| 22430 */ |
| 22431 int get length { |
| 22432 return keys.length; |
| 22433 } |
| 22434 |
| 22435 bool _matches(Node node) => node.$dom_namespaceURI == null; |
| 22436 } |
| 22437 |
| 22438 /** |
| 22439 * Wrapper to expose namespaced attributes as a typed map. |
| 22440 */ |
| 22441 class _NamespacedAttributeMap extends _AttributeMap { |
| 22442 |
| 22443 final Element _element; |
| 22444 final String _namespace; |
| 22445 |
| 22446 _NamespacedAttributeMap(this._element, this._namespace); |
| 22447 |
| 22448 bool containsKey(String key) { |
| 22449 return _element.$dom_hasAttributeNS(_namespace, key); |
| 22450 } |
| 22451 |
| 22452 String operator [](String key) { |
| 22453 return _element.$dom_getAttributeNS(_namespace, key); |
| 22454 } |
| 22455 |
| 22456 void operator []=(String key, value) { |
| 22457 _element.$dom_setAttributeNS(_namespace, key, '$value'); |
| 22458 } |
| 22459 |
| 22460 String remove(String key) { |
| 22461 String value = this[key]; |
| 22462 _element.$dom_removeAttributeNS(_namespace, key); |
| 22463 return value; |
| 22464 } |
| 22465 |
| 22466 /** |
| 22467 * The number of {key, value} pairs in the map. |
| 22468 */ |
| 22469 int get length { |
| 22470 return keys.length; |
| 22471 } |
| 22472 |
| 22473 bool _matches(Node node) => node.$dom_namespaceURI == _namespace; |
| 22474 } |
| 22475 |
| 22476 |
| 22477 /** |
| 22478 * Provides a Map abstraction on top of data-* attributes, similar to the |
| 22479 * dataSet in the old DOM. |
| 22480 */ |
| 22481 class _DataAttributeMap implements Map<String, String> { |
| 22482 |
| 22483 final Map<String, String> $dom_attributes; |
| 22484 |
| 22485 _DataAttributeMap(this.$dom_attributes); |
| 22486 |
| 22487 // interface Map |
| 22488 |
| 22489 // TODO: Use lazy iterator when it is available on Map. |
| 22490 bool containsValue(String value) => values.some((v) => v == value); |
| 22491 |
| 22492 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key)); |
| 22493 |
| 22494 String operator [](String key) => $dom_attributes[_attr(key)]; |
| 22495 |
| 22496 void operator []=(String key, value) { |
| 22497 $dom_attributes[_attr(key)] = '$value'; |
| 22498 } |
| 22499 |
| 22500 String putIfAbsent(String key, String ifAbsent()) => |
| 22501 $dom_attributes.putIfAbsent(_attr(key), ifAbsent); |
| 22502 |
| 22503 String remove(String key) => $dom_attributes.remove(_attr(key)); |
| 22504 |
| 22505 void clear() { |
| 22506 // Needs to operate on a snapshot since we are mutating the collection. |
| 22507 for (String key in keys) { |
| 22508 remove(key); |
| 22509 } |
| 22510 } |
| 22511 |
| 22512 void forEach(void f(String key, String value)) { |
| 22513 $dom_attributes.forEach((String key, String value) { |
| 22514 if (_matches(key)) { |
| 22515 f(_strip(key), value); |
| 22516 } |
| 22517 }); |
| 22518 } |
| 22519 |
| 22520 Collection<String> get keys { |
| 22521 final keys = new List<String>(); |
| 22522 $dom_attributes.forEach((String key, String value) { |
| 22523 if (_matches(key)) { |
| 22524 keys.add(_strip(key)); |
| 22525 } |
| 22526 }); |
| 22527 return keys; |
| 22528 } |
| 22529 |
| 22530 Collection<String> get values { |
| 22531 final values = new List<String>(); |
| 22532 $dom_attributes.forEach((String key, String value) { |
| 22533 if (_matches(key)) { |
| 22534 values.add(value); |
| 22535 } |
| 22536 }); |
| 22537 return values; |
| 22538 } |
| 22539 |
| 22540 int get length => keys.length; |
| 22541 |
| 22542 // TODO: Use lazy iterator when it is available on Map. |
| 22543 bool get isEmpty => length == 0; |
| 22544 |
| 22545 // Helpers. |
| 22546 String _attr(String key) => 'data-$key'; |
| 22547 bool _matches(String key) => key.startsWith('data-'); |
| 22548 String _strip(String key) => key.substring(5); |
| 22549 } |
| 22550 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 22551 // for details. All rights reserved. Use of this source code is governed by a |
| 22552 // BSD-style license that can be found in the LICENSE file. |
| 22553 |
| 22554 |
| 22472 /** | 22555 /** |
| 22473 * An object representing the top-level context object for web scripting. | 22556 * An object representing the top-level context object for web scripting. |
| 22474 * | 22557 * |
| 22475 * In a web browser, a [Window] object represents the actual browser window. | 22558 * In a web browser, a [Window] object represents the actual browser window. |
| 22476 * In a multi-tabbed browser, each tab has its own [Window] object. A [Window] | 22559 * In a multi-tabbed browser, each tab has its own [Window] object. A [Window] |
| 22477 * is the container that displays a [Document]'s content. All web scripting | 22560 * is the container that displays a [Document]'s content. All web scripting |
| 22478 * happens within the context of a [Window] object. | 22561 * happens within the context of a [Window] object. |
| 22479 * | 22562 * |
| 22480 * **Note:** This class represents any window, whereas [LocalWindow] is | 22563 * **Note:** This class represents any window, whereas [LocalWindow] is |
| 22481 * used to access the properties and content of the current window. | 22564 * used to access the properties and content of the current window. |
| (...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 25332 if (length < 0) throw new ArgumentError('length'); | 25415 if (length < 0) throw new ArgumentError('length'); |
| 25333 if (start < 0) throw new RangeError.value(start); | 25416 if (start < 0) throw new RangeError.value(start); |
| 25334 int end = start + length; | 25417 int end = start + length; |
| 25335 if (end > a.length) throw new RangeError.value(end); | 25418 if (end > a.length) throw new RangeError.value(end); |
| 25336 for (int i = start; i < end; i++) { | 25419 for (int i = start; i < end; i++) { |
| 25337 accumulator.add(a[i]); | 25420 accumulator.add(a[i]); |
| 25338 } | 25421 } |
| 25339 return accumulator; | 25422 return accumulator; |
| 25340 } | 25423 } |
| 25341 } | 25424 } |
| OLD | NEW |