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 if (!containsKey(key)) { |
| 5691 return this[key] = ifAbsent(); |
| 5692 } |
| 5693 return this[key]; |
| 5694 } |
| 5695 |
| 5696 String remove(String key) => $dom_attributes.remove(_attr(key)); |
| 5697 |
| 5698 void clear() { |
| 5699 // Needs to operate on a snapshot since we are mutatiting the collection. |
| 5700 for (String key in getKeys()) { |
| 5701 remove(key); |
| 5702 } |
| 5703 } |
| 5704 |
| 5705 void forEach(void f(String key, String value)) { |
| 5706 $dom_attributes.forEach((String key, String value) { |
| 5707 if (_matches(key)) { |
| 5708 f(_strip(key), value); |
| 5709 } |
| 5710 }); |
| 5711 } |
| 5712 |
| 5713 Collection<String> getKeys() { |
| 5714 final keys = new List<String>(); |
| 5715 $dom_attributes.forEach((String key, String value) { |
| 5716 if (_matches(key)) { |
| 5717 keys.add(_strip(key)); |
| 5718 } |
| 5719 }); |
| 5720 return keys; |
| 5721 } |
| 5722 |
| 5723 Collection<String> getValues() { |
| 5724 final values = new List<String>(); |
| 5725 $dom_attributes.forEach((String key, String value) { |
| 5726 if (_matches(key)) { |
| 5727 values.add(value); |
| 5728 } |
| 5729 }); |
| 5730 return values; |
| 5731 } |
| 5732 |
| 5733 int get length() => getKeys().length; |
| 5734 |
| 5735 // TODO: Use lazy iterator when it is available on Map. |
| 5736 bool isEmpty() => length == 0; |
| 5737 |
| 5738 // Helpers. |
| 5739 String _attr(String key) => 'data-$key'; |
| 5740 bool _matches(String key) => key.startsWith('data-'); |
| 5741 String _strip(String key) => key.substring(5); |
| 5742 } |
| 5743 |
| 5744 class _CssClassSet implements Set<String> { |
| 5745 |
| 5746 final _ElementImpl _element; |
| 5747 |
| 5748 _CssClassSet(this._element); |
| 5749 |
| 5750 String toString() { |
| 5751 return _formatSet(_read()); |
| 5752 } |
| 5753 |
| 5754 // interface Iterable - BEGIN |
| 5755 Iterator<String> iterator() { |
| 5756 return _read().iterator(); |
| 5757 } |
| 5758 // interface Iterable - END |
| 5759 |
| 5760 // interface Collection - BEGIN |
| 5761 void forEach(void f(String element)) { |
| 5762 _read().forEach(f); |
| 5763 } |
| 5764 |
| 5765 Collection map(f(String element)) { |
| 5766 return _read().map(f); |
| 5767 } |
| 5768 |
| 5769 Collection<String> filter(bool f(String element)) { |
| 5770 return _read().filter(f); |
| 5771 } |
| 5772 |
| 5773 bool every(bool f(String element)) { |
| 5774 return _read().every(f); |
| 5775 } |
| 5776 |
| 5777 bool some(bool f(String element)) { |
| 5778 return _read().some(f); |
| 5779 } |
| 5780 |
| 5781 bool isEmpty() { |
| 5782 return _read().isEmpty(); |
| 5783 } |
| 5784 |
| 5785 int get length() { |
| 5786 return _read().length; |
| 5787 } |
| 5788 // interface Collection - END |
| 5789 |
| 5790 // interface Set - BEGIN |
| 5791 bool contains(String value) { |
| 5792 return _read().contains(value); |
| 5793 } |
| 5794 |
| 5795 void add(String value) { |
| 5796 // TODO - figure out if we need to do any validation here |
| 5797 // or if the browser natively does enough |
| 5798 _modify((s) => s.add(value)); |
| 5799 } |
| 5800 |
| 5801 bool remove(String value) { |
| 5802 Set<String> s = _read(); |
| 5803 bool result = s.remove(value); |
| 5804 _write(s); |
| 5805 return result; |
| 5806 } |
| 5807 |
| 5808 void addAll(Collection<String> collection) { |
| 5809 // TODO - see comment above about validation |
| 5810 _modify((s) => s.addAll(collection)); |
| 5811 } |
| 5812 |
| 5813 void removeAll(Collection<String> collection) { |
| 5814 _modify((s) => s.removeAll(collection)); |
| 5815 } |
| 5816 |
| 5817 bool isSubsetOf(Collection<String> collection) { |
| 5818 return _read().isSubsetOf(collection); |
| 5819 } |
| 5820 |
| 5821 bool containsAll(Collection<String> collection) { |
| 5822 return _read().containsAll(collection); |
| 5823 } |
| 5824 |
| 5825 Set<String> intersection(Collection<String> other) { |
| 5826 return _read().intersection(other); |
| 5827 } |
| 5828 |
| 5829 void clear() { |
| 5830 _modify((s) => s.clear()); |
| 5831 } |
| 5832 // interface Set - END |
| 5833 |
| 5834 /** |
| 5835 * Helper method used to modify the set of css classes on this element. |
| 5836 * |
| 5837 * f - callback with: |
| 5838 * s - a Set of all the css class name currently on this element. |
| 5839 * |
| 5840 * After f returns, the modified set is written to the |
| 5841 * className property of this element. |
| 5842 */ |
| 5843 void _modify( f(Set<String> s)) { |
| 5844 Set<String> s = _read(); |
| 5845 f(s); |
| 5846 _write(s); |
| 5847 } |
| 5848 |
| 5849 /** |
| 5850 * Read the class names from the Element class property, |
| 5851 * and put them into a set (duplicates are discarded). |
| 5852 */ |
| 5853 Set<String> _read() { |
| 5854 // TODO(mattsh) simplify this once split can take regex. |
| 5855 Set<String> s = new Set<String>(); |
| 5856 for (String name in $dom_className().split(' ')) { |
| 5857 String trimmed = name.trim(); |
| 5858 if (!trimmed.isEmpty()) { |
| 5859 s.add(trimmed); |
| 5860 } |
| 5861 } |
| 5862 return s; |
| 5863 } |
| 5864 |
| 5865 /** |
| 5866 * Read the class names as a space-separated string. This is meant to be |
| 5867 * overridden by subclasses. |
| 5868 */ |
| 5869 String $dom_className() => _element.$dom_className; |
| 5870 |
| 5871 /** |
| 5872 * Join all the elements of a set into one string and write |
| 5873 * back to the element. |
| 5874 */ |
| 5875 void _write(Set s) { |
| 5876 _element.$dom_className = _formatSet(s); |
| 5877 } |
| 5878 |
| 5879 String _formatSet(Set<String> s) { |
| 5880 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 |
| 5881 List list = new List.from(s); |
| 5882 return Strings.join(list, ' '); |
| 5883 } |
| 5884 } |
| 5885 |
5666 class _SimpleClientRect implements ClientRect { | 5886 class _SimpleClientRect implements ClientRect { |
5667 final num left; | 5887 final num left; |
5668 final num top; | 5888 final num top; |
5669 final num width; | 5889 final num width; |
5670 final num height; | 5890 final num height; |
5671 num get right() => left + width; | 5891 num get right() => left + width; |
5672 num get bottom() => top + height; | 5892 num get bottom() => top + height; |
5673 | 5893 |
5674 const _SimpleClientRect(this.left, this.top, this.width, this.height); | 5894 const _SimpleClientRect(this.left, this.top, this.width, this.height); |
5675 | 5895 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5721 final out = new List(_clientRects.length); | 5941 final out = new List(_clientRects.length); |
5722 for (num i = 0; i < _clientRects.length; i++) { | 5942 for (num i = 0; i < _clientRects.length; i++) { |
5723 out[i] = _clientRects.item(i); | 5943 out[i] = _clientRects.item(i); |
5724 } | 5944 } |
5725 return out; | 5945 return out; |
5726 } | 5946 } |
5727 } | 5947 } |
5728 | 5948 |
5729 class _ElementImpl extends _NodeImpl implements Element native "*Element" { | 5949 class _ElementImpl extends _NodeImpl implements Element native "*Element" { |
5730 | 5950 |
5731 // TODO(jacobr): caching these may hurt performance. | |
5732 ElementAttributeMap _elementAttributeMap; | |
5733 _CssClassSet _cssClassSet; | |
5734 _DataAttributeMap _dataAttributes; | |
5735 | |
5736 /** | 5951 /** |
5737 * @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute, | 5952 * @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute, |
5738 * Element.removeAttribute | 5953 * Element.removeAttribute |
5739 */ | 5954 */ |
5740 Map<String, String> get attributes() { | 5955 _ElementAttributeMap get attributes() => new _ElementAttributeMap(this); |
5741 if (_elementAttributeMap === null) { | |
5742 _elementAttributeMap = new ElementAttributeMap._wrap(this); | |
5743 } | |
5744 return _elementAttributeMap; | |
5745 } | |
5746 | 5956 |
5747 void set attributes(Map<String, String> value) { | 5957 void set attributes(Map<String, String> value) { |
5748 Map<String, String> attributes = this.attributes; | 5958 Map<String, String> attributes = this.attributes; |
5749 attributes.clear(); | 5959 attributes.clear(); |
5750 for (String key in value.getKeys()) { | 5960 for (String key in value.getKeys()) { |
5751 attributes[key] = value[key]; | 5961 attributes[key] = value[key]; |
5752 } | 5962 } |
5753 } | 5963 } |
5754 | 5964 |
5755 void set elements(Collection<Element> value) { | 5965 void set elements(Collection<Element> value) { |
5756 final elements = this.elements; | 5966 final elements = this.elements; |
5757 elements.clear(); | 5967 elements.clear(); |
5758 elements.addAll(value); | 5968 elements.addAll(value); |
5759 } | 5969 } |
5760 | 5970 |
5761 ElementList get elements() => new _ChildrenElementList._wrap(this); | 5971 ElementList get elements() => new _ChildrenElementList._wrap(this); |
5762 | 5972 |
5763 ElementList queryAll(String selectors) => | 5973 ElementList queryAll(String selectors) => |
5764 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 5974 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
5765 | 5975 |
5766 Set<String> get classes() { | 5976 _CssClassSet get classes() => new _CssClassSet(this); |
5767 if (_cssClassSet === null) { | |
5768 _cssClassSet = new _CssClassSet(this); | |
5769 } | |
5770 return _cssClassSet; | |
5771 } | |
5772 | 5977 |
5773 void set classes(Collection<String> value) { | 5978 void set classes(Collection<String> value) { |
5774 _CssClassSet classSet = classes; | 5979 _CssClassSet classSet = classes; |
5775 classSet.clear(); | 5980 classSet.clear(); |
5776 classSet.addAll(value); | 5981 classSet.addAll(value); |
5777 } | 5982 } |
5778 | 5983 |
5779 Map<String, String> get dataAttributes() { | 5984 Map<String, String> get dataAttributes() { |
5780 if (_dataAttributes === null) { | 5985 return new _DataAttributeMap(attributes); |
5781 _dataAttributes = new _DataAttributeMap(attributes); | |
5782 } | |
5783 return _dataAttributes; | |
5784 } | 5986 } |
5785 | 5987 |
5786 void set dataAttributes(Map<String, String> value) { | 5988 void set dataAttributes(Map<String, String> value) { |
5787 Map<String, String> dataAttributes = this.dataAttributes; | 5989 final dataAttributes = this.dataAttributes; |
5788 dataAttributes.clear(); | 5990 dataAttributes.clear(); |
5789 for (String key in value.getKeys()) { | 5991 for (String key in value.getKeys()) { |
5790 dataAttributes[key] = value[key]; | 5992 dataAttributes[key] = value[key]; |
5791 } | 5993 } |
5792 } | 5994 } |
5793 | 5995 |
5794 Future<ElementRect> get rect() { | 5996 Future<ElementRect> get rect() { |
5795 return _createMeasurementFuture( | 5997 return _createMeasurementFuture( |
5796 () => new _ElementRectImpl(this), | 5998 () => new _ElementRectImpl(this), |
5797 new Completer<ElementRect>()); | 5999 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; | 21154 static final int MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; |
20953 | 21155 |
20954 static final int TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; | 21156 static final int TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; |
20955 } | 21157 } |
20956 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 21158 // 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 | 21159 // 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. | 21160 // BSD-style license that can be found in the LICENSE file. |
20959 | 21161 |
20960 // WARNING: Do not edit - generated code. | 21162 // WARNING: Do not edit - generated code. |
20961 | 21163 |
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> { | 21164 interface ElementList extends List<Element> { |
21183 // TODO(jacobr): add element batch manipulation methods. | 21165 // TODO(jacobr): add element batch manipulation methods. |
21184 ElementList filter(bool f(Element element)); | 21166 ElementList filter(bool f(Element element)); |
21185 | 21167 |
21186 ElementList getRange(int start, int length); | 21168 ElementList getRange(int start, int length); |
21187 | 21169 |
21188 Element get first(); | 21170 Element get first(); |
21189 // TODO(jacobr): add insertAt | 21171 // TODO(jacobr): add insertAt |
21190 } | 21172 } |
21191 | 21173 |
21192 /** | 21174 /** |
| 21175 * All your attribute manipulation needs in one place. |
| 21176 * Extends the regular Map interface by automatically coercing non-string |
| 21177 * values to strings. |
| 21178 */ |
| 21179 interface AttributeMap extends Map<String, String> { |
| 21180 void operator []=(String key, value); |
| 21181 } |
| 21182 |
| 21183 /** |
21193 * All your element measurement needs in one place | 21184 * All your element measurement needs in one place |
21194 */ | 21185 */ |
21195 interface ElementRect { | 21186 interface ElementRect { |
21196 // Relative to offsetParent | 21187 // Relative to offsetParent |
21197 ClientRect get client(); | 21188 ClientRect get client(); |
21198 ClientRect get offset(); | 21189 ClientRect get offset(); |
21199 ClientRect get scroll(); | 21190 ClientRect get scroll(); |
21200 // In global coords | 21191 // In global coords |
21201 ClientRect get bounding(); | 21192 ClientRect get bounding(); |
21202 // In global coords | 21193 // In global coords |
21203 List<ClientRect> get clientRects(); | 21194 List<ClientRect> get clientRects(); |
21204 } | 21195 } |
21205 | 21196 |
21206 interface Element extends Node, NodeSelector default _ElementFactoryProvider { | 21197 interface Element extends Node, NodeSelector default _ElementFactoryProvider { |
21207 // TODO(jacobr): switch back to: | 21198 // TODO(jacobr): switch back to: |
21208 // interface Element extends Node, NodeSelector, ElementTraversal default _Eleme
ntImpl { | 21199 // interface Element extends Node, NodeSelector, ElementTraversal default _Eleme
ntImpl { |
21209 Element.html(String html); | 21200 Element.html(String html); |
21210 Element.tag(String tag); | 21201 Element.tag(String tag); |
21211 | 21202 |
21212 Map<String, String> get attributes(); | 21203 AttributeMap get attributes(); |
21213 void set attributes(Map<String, String> value); | 21204 void set attributes(Map<String, String> value); |
21214 | 21205 |
21215 /** | 21206 /** |
21216 * @domName querySelectorAll, getElementsByClassName, getElementsByTagName, | 21207 * @domName querySelectorAll, getElementsByClassName, getElementsByTagName, |
21217 * getElementsByTagNameNS | 21208 * getElementsByTagNameNS |
21218 */ | 21209 */ |
21219 ElementList queryAll(String selectors); | 21210 ElementList queryAll(String selectors); |
21220 | 21211 |
21221 /** | 21212 /** |
21222 * @domName childElementCount, firstElementChild, lastElementChild, | 21213 * @domName childElementCount, firstElementChild, lastElementChild, |
21223 * children, Node.nodes.add | 21214 * children, Node.nodes.add |
21224 */ | 21215 */ |
21225 ElementList get elements(); | 21216 ElementList get elements(); |
21226 | 21217 |
21227 void set elements(Collection<Element> value); | 21218 void set elements(Collection<Element> value); |
21228 | 21219 |
21229 /** @domName className, classList */ | 21220 /** @domName className, classList */ |
21230 Set<String> get classes(); | 21221 Set<String> get classes(); |
21231 | 21222 |
21232 void set classes(Collection<String> value); | 21223 void set classes(Collection<String> value); |
21233 | 21224 |
21234 Map<String, String> get dataAttributes(); | 21225 AttributeMap get dataAttributes(); |
21235 void set dataAttributes(Map<String, String> value); | 21226 void set dataAttributes(Map<String, String> value); |
21236 | 21227 |
21237 /** | 21228 /** |
21238 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, | 21229 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, |
21239 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, | 21230 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, |
21240 * scrollHeight, scrollWidth, scrollTop, scrollLeft | 21231 * scrollHeight, scrollWidth, scrollTop, scrollLeft |
21241 */ | 21232 */ |
21242 Future<ElementRect> get rect(); | 21233 Future<ElementRect> get rect(); |
21243 | 21234 |
21244 /** @domName Window.getComputedStyle */ | 21235 /** @domName Window.getComputedStyle */ |
(...skipping 10885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
32130 if (length < 0) throw new IllegalArgumentException('length'); | 32121 if (length < 0) throw new IllegalArgumentException('length'); |
32131 if (start < 0) throw new IndexOutOfRangeException(start); | 32122 if (start < 0) throw new IndexOutOfRangeException(start); |
32132 int end = start + length; | 32123 int end = start + length; |
32133 if (end > a.length) throw new IndexOutOfRangeException(end); | 32124 if (end > a.length) throw new IndexOutOfRangeException(end); |
32134 for (int i = start; i < end; i++) { | 32125 for (int i = start; i < end; i++) { |
32135 accumulator.add(a[i]); | 32126 accumulator.add(a[i]); |
32136 } | 32127 } |
32137 return accumulator; | 32128 return accumulator; |
32138 } | 32129 } |
32139 } | 32130 } |
OLD | NEW |