OLD | NEW |
1 #library('html'); | 1 #library('html'); |
2 | 2 |
3 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
6 | 6 |
7 // DO NOT EDIT | 7 // DO NOT EDIT |
8 // Auto-generated dart:html library. | 8 // Auto-generated dart:html library. |
9 | 9 |
10 | 10 |
(...skipping 5557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5568 class _ElementList extends _ListWrapper<Element> implements ElementList { | 5568 class _ElementList extends _ListWrapper<Element> implements ElementList { |
5569 _ElementList(List<Element> list) : super(list); | 5569 _ElementList(List<Element> list) : super(list); |
5570 | 5570 |
5571 ElementList filter(bool f(Element element)) => | 5571 ElementList filter(bool f(Element element)) => |
5572 new _ElementList(super.filter(f)); | 5572 new _ElementList(super.filter(f)); |
5573 | 5573 |
5574 ElementList getRange(int start, int length) => | 5574 ElementList getRange(int start, int length) => |
5575 new _ElementList(super.getRange(start, length)); | 5575 new _ElementList(super.getRange(start, length)); |
5576 } | 5576 } |
5577 | 5577 |
5578 class ElementAttributeMap implements Map<String, String> { | 5578 class _ElementAttributeMap implements AttributeMap { |
5579 | 5579 |
5580 final _ElementImpl _element; | 5580 final _ElementImpl _element; |
5581 | 5581 |
5582 ElementAttributeMap._wrap(this._element); | 5582 _ElementAttributeMap(this._element); |
5583 | 5583 |
5584 bool containsValue(String value) { | 5584 bool containsValue(String value) { |
5585 final attributes = _element.$dom_attributes; | 5585 final attributes = _element.$dom_attributes; |
5586 for (int i = 0, len = attributes.length; i < len; i++) { | 5586 for (int i = 0, len = attributes.length; i < len; i++) { |
5587 if(value == attributes[i].value) { | 5587 if(value == attributes[i].value) { |
5588 return true; | 5588 return true; |
5589 } | 5589 } |
5590 } | 5590 } |
5591 return false; | 5591 return false; |
5592 } | 5592 } |
5593 | 5593 |
5594 bool containsKey(String key) { | 5594 bool containsKey(String key) { |
5595 return _element.$dom_hasAttribute(key); | 5595 return _element.$dom_hasAttribute(key); |
5596 } | 5596 } |
5597 | 5597 |
5598 String operator [](String key) { | 5598 String operator [](String key) { |
5599 return _element.$dom_getAttribute(key); | 5599 return _element.$dom_getAttribute(key); |
5600 } | 5600 } |
5601 | 5601 |
5602 void operator []=(String key, String value) { | 5602 void operator []=(String key, value) { |
5603 _element.$dom_setAttribute(key, value); | 5603 _element.$dom_setAttribute(key, '$value'); |
5604 } | 5604 } |
5605 | 5605 |
5606 String putIfAbsent(String key, String ifAbsent()) { | 5606 String putIfAbsent(String key, String ifAbsent()) { |
5607 if (!containsKey(key)) { | 5607 if (!containsKey(key)) { |
5608 this[key] = ifAbsent(); | 5608 this[key] = ifAbsent(); |
5609 } | 5609 } |
5610 } | 5610 } |
5611 | 5611 |
5612 String remove(String key) { | 5612 String remove(String key) { |
5613 _element.$dom_removeAttribute(key); | 5613 _element.$dom_removeAttribute(key); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5656 } | 5656 } |
5657 | 5657 |
5658 /** | 5658 /** |
5659 * Returns true if there is no {key, value} pair in the map. | 5659 * Returns true if there is no {key, value} pair in the map. |
5660 */ | 5660 */ |
5661 bool isEmpty() { | 5661 bool isEmpty() { |
5662 return length == 0; | 5662 return length == 0; |
5663 } | 5663 } |
5664 } | 5664 } |
5665 | 5665 |
| 5666 /** |
| 5667 * Provides a Map abstraction on top of data-* attributes, similar to the |
| 5668 * dataSet in the old DOM. |
| 5669 */ |
| 5670 class _DataAttributeMap implements AttributeMap { |
| 5671 |
| 5672 final Map<String, String> $dom_attributes; |
| 5673 |
| 5674 _DataAttributeMap(this.$dom_attributes); |
| 5675 |
| 5676 // interface Map |
| 5677 |
| 5678 // TODO: Use lazy iterator when it is available on Map. |
| 5679 bool containsValue(String value) => getValues().some((v) => v == value); |
| 5680 |
| 5681 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key)); |
| 5682 |
| 5683 String operator [](String key) => $dom_attributes[_attr(key)]; |
| 5684 |
| 5685 void operator []=(String key, value) { |
| 5686 $dom_attributes[_attr(key)] = '$value'; |
| 5687 } |
| 5688 |
| 5689 String putIfAbsent(String key, String ifAbsent()) { |
| 5690 $dom_attributes.putIfAbsent(_attr(key), ifAbsent); |
| 5691 } |
| 5692 |
| 5693 String remove(String key) => $dom_attributes.remove(_attr(key)); |
| 5694 |
| 5695 void clear() { |
| 5696 // Needs to operate on a snapshot since we are mutating the collection. |
| 5697 for (String key in getKeys()) { |
| 5698 remove(key); |
| 5699 } |
| 5700 } |
| 5701 |
| 5702 void forEach(void f(String key, String value)) { |
| 5703 $dom_attributes.forEach((String key, String value) { |
| 5704 if (_matches(key)) { |
| 5705 f(_strip(key), value); |
| 5706 } |
| 5707 }); |
| 5708 } |
| 5709 |
| 5710 Collection<String> getKeys() { |
| 5711 final keys = new List<String>(); |
| 5712 $dom_attributes.forEach((String key, String value) { |
| 5713 if (_matches(key)) { |
| 5714 keys.add(_strip(key)); |
| 5715 } |
| 5716 }); |
| 5717 return keys; |
| 5718 } |
| 5719 |
| 5720 Collection<String> getValues() { |
| 5721 final values = new List<String>(); |
| 5722 $dom_attributes.forEach((String key, String value) { |
| 5723 if (_matches(key)) { |
| 5724 values.add(value); |
| 5725 } |
| 5726 }); |
| 5727 return values; |
| 5728 } |
| 5729 |
| 5730 int get length() => getKeys().length; |
| 5731 |
| 5732 // TODO: Use lazy iterator when it is available on Map. |
| 5733 bool isEmpty() => length == 0; |
| 5734 |
| 5735 // Helpers. |
| 5736 String _attr(String key) => 'data-$key'; |
| 5737 bool _matches(String key) => key.startsWith('data-'); |
| 5738 String _strip(String key) => key.substring(5); |
| 5739 } |
| 5740 |
| 5741 class _CssClassSet implements Set<String> { |
| 5742 |
| 5743 final _ElementImpl _element; |
| 5744 |
| 5745 _CssClassSet(this._element); |
| 5746 |
| 5747 String toString() => _formatSet(_read()); |
| 5748 |
| 5749 // interface Iterable - BEGIN |
| 5750 Iterator<String> iterator() => _read().iterator(); |
| 5751 // interface Iterable - END |
| 5752 |
| 5753 // interface Collection - BEGIN |
| 5754 void forEach(void f(String element)) { |
| 5755 _read().forEach(f); |
| 5756 } |
| 5757 |
| 5758 Collection map(f(String element)) => _read().map(f); |
| 5759 |
| 5760 Collection<String> filter(bool f(String element)) => _read().filter(f); |
| 5761 |
| 5762 bool every(bool f(String element)) => _read().every(f); |
| 5763 |
| 5764 bool some(bool f(String element)) => _read().some(f); |
| 5765 |
| 5766 bool isEmpty() => _read().isEmpty(); |
| 5767 |
| 5768 int get length() =>_read().length; |
| 5769 |
| 5770 // interface Collection - END |
| 5771 |
| 5772 // interface Set - BEGIN |
| 5773 bool contains(String value) => _read().contains(value); |
| 5774 |
| 5775 void add(String value) { |
| 5776 // TODO - figure out if we need to do any validation here |
| 5777 // or if the browser natively does enough |
| 5778 _modify((s) => s.add(value)); |
| 5779 } |
| 5780 |
| 5781 bool remove(String value) { |
| 5782 Set<String> s = _read(); |
| 5783 bool result = s.remove(value); |
| 5784 _write(s); |
| 5785 return result; |
| 5786 } |
| 5787 |
| 5788 void addAll(Collection<String> collection) { |
| 5789 // TODO - see comment above about validation |
| 5790 _modify((s) => s.addAll(collection)); |
| 5791 } |
| 5792 |
| 5793 void removeAll(Collection<String> collection) { |
| 5794 _modify((s) => s.removeAll(collection)); |
| 5795 } |
| 5796 |
| 5797 bool isSubsetOf(Collection<String> collection) => |
| 5798 _read().isSubsetOf(collection); |
| 5799 |
| 5800 bool containsAll(Collection<String> collection) => |
| 5801 _read().containsAll(collection); |
| 5802 |
| 5803 Set<String> intersection(Collection<String> other) => |
| 5804 _read().intersection(other); |
| 5805 |
| 5806 void clear() { |
| 5807 _modify((s) => s.clear()); |
| 5808 } |
| 5809 // interface Set - END |
| 5810 |
| 5811 /** |
| 5812 * Helper method used to modify the set of css classes on this element. |
| 5813 * |
| 5814 * f - callback with: |
| 5815 * s - a Set of all the css class name currently on this element. |
| 5816 * |
| 5817 * After f returns, the modified set is written to the |
| 5818 * className property of this element. |
| 5819 */ |
| 5820 void _modify( f(Set<String> s)) { |
| 5821 Set<String> s = _read(); |
| 5822 f(s); |
| 5823 _write(s); |
| 5824 } |
| 5825 |
| 5826 /** |
| 5827 * Read the class names from the Element class property, |
| 5828 * and put them into a set (duplicates are discarded). |
| 5829 */ |
| 5830 Set<String> _read() { |
| 5831 // TODO(mattsh) simplify this once split can take regex. |
| 5832 Set<String> s = new Set<String>(); |
| 5833 for (String name in _classname().split(' ')) { |
| 5834 String trimmed = name.trim(); |
| 5835 if (!trimmed.isEmpty()) { |
| 5836 s.add(trimmed); |
| 5837 } |
| 5838 } |
| 5839 return s; |
| 5840 } |
| 5841 |
| 5842 /** |
| 5843 * Read the class names as a space-separated string. This is meant to be |
| 5844 * overridden by subclasses. |
| 5845 */ |
| 5846 String _classname() => _element.$dom_className; |
| 5847 |
| 5848 /** |
| 5849 * Join all the elements of a set into one string and write |
| 5850 * back to the element. |
| 5851 */ |
| 5852 void _write(Set s) { |
| 5853 _element.$dom_className = _formatSet(s); |
| 5854 } |
| 5855 |
| 5856 String _formatSet(Set<String> s) { |
| 5857 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 |
| 5858 List list = new List.from(s); |
| 5859 return Strings.join(list, ' '); |
| 5860 } |
| 5861 } |
| 5862 |
5666 class _SimpleClientRect implements ClientRect { | 5863 class _SimpleClientRect implements ClientRect { |
5667 final num left; | 5864 final num left; |
5668 final num top; | 5865 final num top; |
5669 final num width; | 5866 final num width; |
5670 final num height; | 5867 final num height; |
5671 num get right() => left + width; | 5868 num get right() => left + width; |
5672 num get bottom() => top + height; | 5869 num get bottom() => top + height; |
5673 | 5870 |
5674 const _SimpleClientRect(this.left, this.top, this.width, this.height); | 5871 const _SimpleClientRect(this.left, this.top, this.width, this.height); |
5675 | 5872 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5721 final out = new List(_clientRects.length); | 5918 final out = new List(_clientRects.length); |
5722 for (num i = 0; i < _clientRects.length; i++) { | 5919 for (num i = 0; i < _clientRects.length; i++) { |
5723 out[i] = _clientRects.item(i); | 5920 out[i] = _clientRects.item(i); |
5724 } | 5921 } |
5725 return out; | 5922 return out; |
5726 } | 5923 } |
5727 } | 5924 } |
5728 | 5925 |
5729 class _ElementImpl extends _NodeImpl implements Element native "*Element" { | 5926 class _ElementImpl extends _NodeImpl implements Element native "*Element" { |
5730 | 5927 |
5731 // TODO(jacobr): caching these may hurt performance. | |
5732 ElementAttributeMap _elementAttributeMap; | |
5733 _CssClassSet _cssClassSet; | |
5734 _DataAttributeMap _dataAttributes; | |
5735 | |
5736 /** | 5928 /** |
5737 * @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute, | 5929 * @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute, |
5738 * Element.removeAttribute | 5930 * Element.removeAttribute |
5739 */ | 5931 */ |
5740 Map<String, String> get attributes() { | 5932 _ElementAttributeMap get attributes() => new _ElementAttributeMap(this); |
5741 if (_elementAttributeMap === null) { | |
5742 _elementAttributeMap = new ElementAttributeMap._wrap(this); | |
5743 } | |
5744 return _elementAttributeMap; | |
5745 } | |
5746 | 5933 |
5747 void set attributes(Map<String, String> value) { | 5934 void set attributes(Map<String, String> value) { |
5748 Map<String, String> attributes = this.attributes; | 5935 Map<String, String> attributes = this.attributes; |
5749 attributes.clear(); | 5936 attributes.clear(); |
5750 for (String key in value.getKeys()) { | 5937 for (String key in value.getKeys()) { |
5751 attributes[key] = value[key]; | 5938 attributes[key] = value[key]; |
5752 } | 5939 } |
5753 } | 5940 } |
5754 | 5941 |
5755 void set elements(Collection<Element> value) { | 5942 void set elements(Collection<Element> value) { |
5756 final elements = this.elements; | 5943 final elements = this.elements; |
5757 elements.clear(); | 5944 elements.clear(); |
5758 elements.addAll(value); | 5945 elements.addAll(value); |
5759 } | 5946 } |
5760 | 5947 |
5761 ElementList get elements() => new _ChildrenElementList._wrap(this); | 5948 ElementList get elements() => new _ChildrenElementList._wrap(this); |
5762 | 5949 |
5763 ElementList queryAll(String selectors) => | 5950 ElementList queryAll(String selectors) => |
5764 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 5951 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
5765 | 5952 |
5766 Set<String> get classes() { | 5953 _CssClassSet get classes() => new _CssClassSet(this); |
5767 if (_cssClassSet === null) { | |
5768 _cssClassSet = new _CssClassSet(this); | |
5769 } | |
5770 return _cssClassSet; | |
5771 } | |
5772 | 5954 |
5773 void set classes(Collection<String> value) { | 5955 void set classes(Collection<String> value) { |
5774 _CssClassSet classSet = classes; | 5956 _CssClassSet classSet = classes; |
5775 classSet.clear(); | 5957 classSet.clear(); |
5776 classSet.addAll(value); | 5958 classSet.addAll(value); |
5777 } | 5959 } |
5778 | 5960 |
5779 Map<String, String> get dataAttributes() { | 5961 Map<String, String> get dataAttributes() => |
5780 if (_dataAttributes === null) { | 5962 new _DataAttributeMap(attributes); |
5781 _dataAttributes = new _DataAttributeMap(attributes); | |
5782 } | |
5783 return _dataAttributes; | |
5784 } | |
5785 | 5963 |
5786 void set dataAttributes(Map<String, String> value) { | 5964 void set dataAttributes(Map<String, String> value) { |
5787 Map<String, String> dataAttributes = this.dataAttributes; | 5965 final dataAttributes = this.dataAttributes; |
5788 dataAttributes.clear(); | 5966 dataAttributes.clear(); |
5789 for (String key in value.getKeys()) { | 5967 for (String key in value.getKeys()) { |
5790 dataAttributes[key] = value[key]; | 5968 dataAttributes[key] = value[key]; |
5791 } | 5969 } |
5792 } | 5970 } |
5793 | 5971 |
5794 Future<ElementRect> get rect() { | 5972 Future<ElementRect> get rect() { |
5795 return _createMeasurementFuture( | 5973 return _createMeasurementFuture( |
5796 () => new _ElementRectImpl(this), | 5974 () => new _ElementRectImpl(this), |
5797 new Completer<ElementRect>()); | 5975 new Completer<ElementRect>()); |
(...skipping 15154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20952 static final int MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; | 21130 static final int MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; |
20953 | 21131 |
20954 static final int TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; | 21132 static final int TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; |
20955 } | 21133 } |
20956 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 21134 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
20957 // for details. All rights reserved. Use of this source code is governed by a | 21135 // for details. All rights reserved. Use of this source code is governed by a |
20958 // BSD-style license that can be found in the LICENSE file. | 21136 // BSD-style license that can be found in the LICENSE file. |
20959 | 21137 |
20960 // WARNING: Do not edit - generated code. | 21138 // WARNING: Do not edit - generated code. |
20961 | 21139 |
20962 /** | |
20963 * Provides a Map abstraction on top of data-* attributes, similar to the | |
20964 * dataSet in the old DOM. | |
20965 */ | |
20966 class _DataAttributeMap implements Map<String, String> { | |
20967 | |
20968 final Map<String, String> $dom_attributes; | |
20969 | |
20970 _DataAttributeMap(this.$dom_attributes); | |
20971 | |
20972 // interface Map | |
20973 | |
20974 // TODO: Use lazy iterator when it is available on Map. | |
20975 bool containsValue(String value) => getValues().some((v) => v == value); | |
20976 | |
20977 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key)); | |
20978 | |
20979 String operator [](String key) => $dom_attributes[_attr(key)]; | |
20980 | |
20981 void operator []=(String key, String value) { | |
20982 $dom_attributes[_attr(key)] = value; | |
20983 } | |
20984 | |
20985 String putIfAbsent(String key, String ifAbsent()) { | |
20986 if (!containsKey(key)) { | |
20987 return this[key] = ifAbsent(); | |
20988 } | |
20989 return this[key]; | |
20990 } | |
20991 | |
20992 String remove(String key) => $dom_attributes.remove(_attr(key)); | |
20993 | |
20994 void clear() { | |
20995 // Needs to operate on a snapshot since we are mutatiting the collection. | |
20996 for (String key in getKeys()) { | |
20997 remove(key); | |
20998 } | |
20999 } | |
21000 | |
21001 void forEach(void f(String key, String value)) { | |
21002 $dom_attributes.forEach((String key, String value) { | |
21003 if (_matches(key)) { | |
21004 f(_strip(key), value); | |
21005 } | |
21006 }); | |
21007 } | |
21008 | |
21009 Collection<String> getKeys() { | |
21010 final keys = new List<String>(); | |
21011 $dom_attributes.forEach((String key, String value) { | |
21012 if (_matches(key)) { | |
21013 keys.add(_strip(key)); | |
21014 } | |
21015 }); | |
21016 return keys; | |
21017 } | |
21018 | |
21019 Collection<String> getValues() { | |
21020 final values = new List<String>(); | |
21021 $dom_attributes.forEach((String key, String value) { | |
21022 if (_matches(key)) { | |
21023 values.add(value); | |
21024 } | |
21025 }); | |
21026 return values; | |
21027 } | |
21028 | |
21029 int get length() => getKeys().length; | |
21030 | |
21031 // TODO: Use lazy iterator when it is available on Map. | |
21032 bool isEmpty() => length == 0; | |
21033 | |
21034 // Helpers. | |
21035 String _attr(String key) => 'data-$key'; | |
21036 bool _matches(String key) => key.startsWith('data-'); | |
21037 String _strip(String key) => key.substring(5); | |
21038 } | |
21039 | |
21040 class _CssClassSet implements Set<String> { | |
21041 | |
21042 final _ElementImpl _element; | |
21043 | |
21044 _CssClassSet(this._element); | |
21045 | |
21046 String toString() { | |
21047 return _formatSet(_read()); | |
21048 } | |
21049 | |
21050 // interface Iterable - BEGIN | |
21051 Iterator<String> iterator() { | |
21052 return _read().iterator(); | |
21053 } | |
21054 // interface Iterable - END | |
21055 | |
21056 // interface Collection - BEGIN | |
21057 void forEach(void f(String element)) { | |
21058 _read().forEach(f); | |
21059 } | |
21060 | |
21061 Collection map(f(String element)) { | |
21062 return _read().map(f); | |
21063 } | |
21064 | |
21065 Collection<String> filter(bool f(String element)) { | |
21066 return _read().filter(f); | |
21067 } | |
21068 | |
21069 bool every(bool f(String element)) { | |
21070 return _read().every(f); | |
21071 } | |
21072 | |
21073 bool some(bool f(String element)) { | |
21074 return _read().some(f); | |
21075 } | |
21076 | |
21077 bool isEmpty() { | |
21078 return _read().isEmpty(); | |
21079 } | |
21080 | |
21081 int get length() { | |
21082 return _read().length; | |
21083 } | |
21084 // interface Collection - END | |
21085 | |
21086 // interface Set - BEGIN | |
21087 bool contains(String value) { | |
21088 return _read().contains(value); | |
21089 } | |
21090 | |
21091 void add(String value) { | |
21092 // TODO - figure out if we need to do any validation here | |
21093 // or if the browser natively does enough | |
21094 _modify((s) => s.add(value)); | |
21095 } | |
21096 | |
21097 bool remove(String value) { | |
21098 Set<String> s = _read(); | |
21099 bool result = s.remove(value); | |
21100 _write(s); | |
21101 return result; | |
21102 } | |
21103 | |
21104 void addAll(Collection<String> collection) { | |
21105 // TODO - see comment above about validation | |
21106 _modify((s) => s.addAll(collection)); | |
21107 } | |
21108 | |
21109 void removeAll(Collection<String> collection) { | |
21110 _modify((s) => s.removeAll(collection)); | |
21111 } | |
21112 | |
21113 bool isSubsetOf(Collection<String> collection) { | |
21114 return _read().isSubsetOf(collection); | |
21115 } | |
21116 | |
21117 bool containsAll(Collection<String> collection) { | |
21118 return _read().containsAll(collection); | |
21119 } | |
21120 | |
21121 Set<String> intersection(Collection<String> other) { | |
21122 return _read().intersection(other); | |
21123 } | |
21124 | |
21125 void clear() { | |
21126 _modify((s) => s.clear()); | |
21127 } | |
21128 // interface Set - END | |
21129 | |
21130 /** | |
21131 * Helper method used to modify the set of css classes on this element. | |
21132 * | |
21133 * f - callback with: | |
21134 * s - a Set of all the css class name currently on this element. | |
21135 * | |
21136 * After f returns, the modified set is written to the | |
21137 * className property of this element. | |
21138 */ | |
21139 void _modify( f(Set<String> s)) { | |
21140 Set<String> s = _read(); | |
21141 f(s); | |
21142 _write(s); | |
21143 } | |
21144 | |
21145 /** | |
21146 * Read the class names from the Element class property, | |
21147 * and put them into a set (duplicates are discarded). | |
21148 */ | |
21149 Set<String> _read() { | |
21150 // TODO(mattsh) simplify this once split can take regex. | |
21151 Set<String> s = new Set<String>(); | |
21152 for (String name in $dom_className().split(' ')) { | |
21153 String trimmed = name.trim(); | |
21154 if (!trimmed.isEmpty()) { | |
21155 s.add(trimmed); | |
21156 } | |
21157 } | |
21158 return s; | |
21159 } | |
21160 | |
21161 /** | |
21162 * Read the class names as a space-separated string. This is meant to be | |
21163 * overridden by subclasses. | |
21164 */ | |
21165 String $dom_className() => _element.$dom_className; | |
21166 | |
21167 /** | |
21168 * Join all the elements of a set into one string and write | |
21169 * back to the element. | |
21170 */ | |
21171 void _write(Set s) { | |
21172 _element.$dom_className = _formatSet(s); | |
21173 } | |
21174 | |
21175 String _formatSet(Set<String> s) { | |
21176 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 | |
21177 List list = new List.from(s); | |
21178 return Strings.join(list, ' '); | |
21179 } | |
21180 } | |
21181 | |
21182 interface ElementList extends List<Element> { | 21140 interface ElementList extends List<Element> { |
21183 // TODO(jacobr): add element batch manipulation methods. | 21141 // TODO(jacobr): add element batch manipulation methods. |
21184 ElementList filter(bool f(Element element)); | 21142 ElementList filter(bool f(Element element)); |
21185 | 21143 |
21186 ElementList getRange(int start, int length); | 21144 ElementList getRange(int start, int length); |
21187 | 21145 |
21188 Element get first(); | 21146 Element get first(); |
21189 // TODO(jacobr): add insertAt | 21147 // TODO(jacobr): add insertAt |
21190 } | 21148 } |
21191 | 21149 |
21192 /** | 21150 /** |
| 21151 * All your attribute manipulation needs in one place. |
| 21152 * Extends the regular Map interface by automatically coercing non-string |
| 21153 * values to strings. |
| 21154 */ |
| 21155 interface AttributeMap extends Map<String, String> { |
| 21156 void operator []=(String key, value); |
| 21157 } |
| 21158 |
| 21159 /** |
21193 * All your element measurement needs in one place | 21160 * All your element measurement needs in one place |
21194 */ | 21161 */ |
21195 interface ElementRect { | 21162 interface ElementRect { |
21196 // Relative to offsetParent | 21163 // Relative to offsetParent |
21197 ClientRect get client(); | 21164 ClientRect get client(); |
21198 ClientRect get offset(); | 21165 ClientRect get offset(); |
21199 ClientRect get scroll(); | 21166 ClientRect get scroll(); |
21200 // In global coords | 21167 // In global coords |
21201 ClientRect get bounding(); | 21168 ClientRect get bounding(); |
21202 // In global coords | 21169 // In global coords |
21203 List<ClientRect> get clientRects(); | 21170 List<ClientRect> get clientRects(); |
21204 } | 21171 } |
21205 | 21172 |
21206 interface Element extends Node, NodeSelector default _ElementFactoryProvider { | 21173 interface Element extends Node, NodeSelector default _ElementFactoryProvider { |
21207 // TODO(jacobr): switch back to: | 21174 // TODO(jacobr): switch back to: |
21208 // interface Element extends Node, NodeSelector, ElementTraversal default _Eleme
ntImpl { | 21175 // interface Element extends Node, NodeSelector, ElementTraversal default _Eleme
ntImpl { |
21209 Element.html(String html); | 21176 Element.html(String html); |
21210 Element.tag(String tag); | 21177 Element.tag(String tag); |
21211 | 21178 |
21212 Map<String, String> get attributes(); | 21179 AttributeMap get attributes(); |
21213 void set attributes(Map<String, String> value); | 21180 void set attributes(Map<String, String> value); |
21214 | 21181 |
21215 /** | 21182 /** |
21216 * @domName querySelectorAll, getElementsByClassName, getElementsByTagName, | 21183 * @domName querySelectorAll, getElementsByClassName, getElementsByTagName, |
21217 * getElementsByTagNameNS | 21184 * getElementsByTagNameNS |
21218 */ | 21185 */ |
21219 ElementList queryAll(String selectors); | 21186 ElementList queryAll(String selectors); |
21220 | 21187 |
21221 /** | 21188 /** |
21222 * @domName childElementCount, firstElementChild, lastElementChild, | 21189 * @domName childElementCount, firstElementChild, lastElementChild, |
21223 * children, Node.nodes.add | 21190 * children, Node.nodes.add |
21224 */ | 21191 */ |
21225 ElementList get elements(); | 21192 ElementList get elements(); |
21226 | 21193 |
21227 void set elements(Collection<Element> value); | 21194 void set elements(Collection<Element> value); |
21228 | 21195 |
21229 /** @domName className, classList */ | 21196 /** @domName className, classList */ |
21230 Set<String> get classes(); | 21197 Set<String> get classes(); |
21231 | 21198 |
21232 void set classes(Collection<String> value); | 21199 void set classes(Collection<String> value); |
21233 | 21200 |
21234 Map<String, String> get dataAttributes(); | 21201 AttributeMap get dataAttributes(); |
21235 void set dataAttributes(Map<String, String> value); | 21202 void set dataAttributes(Map<String, String> value); |
21236 | 21203 |
21237 /** | 21204 /** |
21238 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, | 21205 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, |
21239 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, | 21206 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, |
21240 * scrollHeight, scrollWidth, scrollTop, scrollLeft | 21207 * scrollHeight, scrollWidth, scrollTop, scrollLeft |
21241 */ | 21208 */ |
21242 Future<ElementRect> get rect(); | 21209 Future<ElementRect> get rect(); |
21243 | 21210 |
21244 /** @domName Window.getComputedStyle */ | 21211 /** @domName Window.getComputedStyle */ |
(...skipping 10885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
32130 if (length < 0) throw new IllegalArgumentException('length'); | 32097 if (length < 0) throw new IllegalArgumentException('length'); |
32131 if (start < 0) throw new IndexOutOfRangeException(start); | 32098 if (start < 0) throw new IndexOutOfRangeException(start); |
32132 int end = start + length; | 32099 int end = start + length; |
32133 if (end > a.length) throw new IndexOutOfRangeException(end); | 32100 if (end > a.length) throw new IndexOutOfRangeException(end); |
32134 for (int i = start; i < end; i++) { | 32101 for (int i = start; i < end; i++) { |
32135 accumulator.add(a[i]); | 32102 accumulator.add(a[i]); |
32136 } | 32103 } |
32137 return accumulator; | 32104 return accumulator; |
32138 } | 32105 } |
32139 } | 32106 } |
OLD | NEW |