| OLD | NEW |
| 1 #library('html'); | 1 #library('html'); |
| 2 | 2 |
| 3 #import('dart:dom', prefix:'dom'); | 3 #import('dart:dom', prefix:'dom'); |
| 4 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 4 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 5 // for details. All rights reserved. Use of this source code is governed by a | 5 // for details. All rights reserved. Use of this source code is governed by a |
| 6 // BSD-style license that can be found in the LICENSE file. | 6 // BSD-style license that can be found in the LICENSE file. |
| 7 | 7 |
| 8 // DO NOT EDIT | 8 // DO NOT EDIT |
| 9 // Auto-generated Dart HTML library. | 9 // Auto-generated Dart HTML library. |
| 10 | 10 |
| 11 | 11 |
| 12 | 12 |
| 13 | 13 |
| 14 | 14 |
| 15 | 15 |
| 16 | |
| 17 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 16 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 18 // for details. All rights reserved. Use of this source code is governed by a | 17 // for details. All rights reserved. Use of this source code is governed by a |
| 19 // BSD-style license that can be found in the LICENSE file. | 18 // BSD-style license that can be found in the LICENSE file. |
| 20 | 19 |
| 21 // WARNING: Do not edit - generated code. | 20 // WARNING: Do not edit - generated code. |
| 22 | 21 |
| 23 interface AnchorElement extends Element { | 22 interface AnchorElement extends Element { |
| 24 | 23 |
| 25 String get accessKey(); | 24 String get accessKey(); |
| 26 | 25 |
| (...skipping 7340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7367 } | 7366 } |
| 7368 | 7367 |
| 7369 void sort(int compare(int a, int b)) { | 7368 void sort(int compare(int a, int b)) { |
| 7370 throw new UnsupportedOperationException("Cannot sort immutable List."); | 7369 throw new UnsupportedOperationException("Cannot sort immutable List."); |
| 7371 } | 7370 } |
| 7372 | 7371 |
| 7373 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 7372 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 7374 throw new UnsupportedOperationException("This object is immutable."); | 7373 throw new UnsupportedOperationException("This object is immutable."); |
| 7375 } | 7374 } |
| 7376 | 7375 |
| 7377 int indexOf(int element, int startIndex) { | 7376 int indexOf(int element, [int start = 0]) { |
| 7378 return _Lists.indexOf(this, element, startIndex, this.length); | 7377 return _Lists.indexOf(this, element, start, this.length); |
| 7379 } | 7378 } |
| 7380 | 7379 |
| 7381 int lastIndexOf(int element, int startIndex) { | 7380 int lastIndexOf(int element, [int start = null]) { |
| 7382 return _Lists.lastIndexOf(this, element, startIndex); | 7381 if (start == null) start = length - 1; |
| 7382 return _Lists.lastIndexOf(this, element, start); |
| 7383 } | 7383 } |
| 7384 | 7384 |
| 7385 int clear() { | 7385 int clear() { |
| 7386 throw new UnsupportedOperationException("Cannot clear immutable List."); | 7386 throw new UnsupportedOperationException("Cannot clear immutable List."); |
| 7387 } | 7387 } |
| 7388 | 7388 |
| 7389 int removeLast() { | 7389 int removeLast() { |
| 7390 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); | 7390 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); |
| 7391 } | 7391 } |
| 7392 | 7392 |
| (...skipping 4111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11504 } | 11504 } |
| 11505 | 11505 |
| 11506 void sort(int compare(String a, String b)) { | 11506 void sort(int compare(String a, String b)) { |
| 11507 throw new UnsupportedOperationException("Cannot sort immutable List."); | 11507 throw new UnsupportedOperationException("Cannot sort immutable List."); |
| 11508 } | 11508 } |
| 11509 | 11509 |
| 11510 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 11510 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 11511 throw new UnsupportedOperationException("This object is immutable."); | 11511 throw new UnsupportedOperationException("This object is immutable."); |
| 11512 } | 11512 } |
| 11513 | 11513 |
| 11514 int indexOf(String element, int startIndex) { | 11514 int indexOf(String element, [int start = 0]) { |
| 11515 return _Lists.indexOf(this, element, startIndex, this.length); | 11515 return _Lists.indexOf(this, element, start, this.length); |
| 11516 } | 11516 } |
| 11517 | 11517 |
| 11518 int lastIndexOf(String element, int startIndex) { | 11518 int lastIndexOf(String element, [int start = null]) { |
| 11519 return _Lists.lastIndexOf(this, element, startIndex); | 11519 if (start === null) start = length - 1; |
| 11520 return _Lists.lastIndexOf(this, element, start); |
| 11520 } | 11521 } |
| 11521 | 11522 |
| 11522 int clear() { | 11523 int clear() { |
| 11523 throw new UnsupportedOperationException("Cannot clear immutable List."); | 11524 throw new UnsupportedOperationException("Cannot clear immutable List."); |
| 11524 } | 11525 } |
| 11525 | 11526 |
| 11526 String removeLast() { | 11527 String removeLast() { |
| 11527 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); | 11528 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); |
| 11528 } | 11529 } |
| 11529 | 11530 |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13020 } | 13021 } |
| 13021 | 13022 |
| 13022 void sort(int compare(StyleSheet a, StyleSheet b)) { | 13023 void sort(int compare(StyleSheet a, StyleSheet b)) { |
| 13023 throw new UnsupportedOperationException("Cannot sort immutable List."); | 13024 throw new UnsupportedOperationException("Cannot sort immutable List."); |
| 13024 } | 13025 } |
| 13025 | 13026 |
| 13026 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 13027 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 13027 throw new UnsupportedOperationException("This object is immutable."); | 13028 throw new UnsupportedOperationException("This object is immutable."); |
| 13028 } | 13029 } |
| 13029 | 13030 |
| 13030 int indexOf(StyleSheet element, int startIndex) { | 13031 int indexOf(StyleSheet element, [int start = 0]) { |
| 13031 return _Lists.indexOf(this, element, startIndex, this.length); | 13032 return _Lists.indexOf(this, element, start, this.length); |
| 13032 } | 13033 } |
| 13033 | 13034 |
| 13034 int lastIndexOf(StyleSheet element, int startIndex) { | 13035 int lastIndexOf(StyleSheet element, [int start = null]) { |
| 13035 return _Lists.lastIndexOf(this, element, startIndex); | 13036 if (start == null) start = length - 1; |
| 13037 return _Lists.lastIndexOf(this, element, start); |
| 13036 } | 13038 } |
| 13037 | 13039 |
| 13038 int clear() { | 13040 int clear() { |
| 13039 throw new UnsupportedOperationException("Cannot clear immutable List."); | 13041 throw new UnsupportedOperationException("Cannot clear immutable List."); |
| 13040 } | 13042 } |
| 13041 | 13043 |
| 13042 StyleSheet removeLast() { | 13044 StyleSheet removeLast() { |
| 13043 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); | 13045 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); |
| 13044 } | 13046 } |
| 13045 | 13047 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13592 } | 13594 } |
| 13593 | 13595 |
| 13594 void sort(int compare(Touch a, Touch b)) { | 13596 void sort(int compare(Touch a, Touch b)) { |
| 13595 throw new UnsupportedOperationException("Cannot sort immutable List."); | 13597 throw new UnsupportedOperationException("Cannot sort immutable List."); |
| 13596 } | 13598 } |
| 13597 | 13599 |
| 13598 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 13600 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 13599 throw new UnsupportedOperationException("This object is immutable."); | 13601 throw new UnsupportedOperationException("This object is immutable."); |
| 13600 } | 13602 } |
| 13601 | 13603 |
| 13602 int indexOf(Touch element, int startIndex) { | 13604 int indexOf(Touch element, [int start = 0]) { |
| 13603 return _Lists.indexOf(this, element, startIndex, this.length); | 13605 return _Lists.indexOf(this, element, start, this.length); |
| 13604 } | 13606 } |
| 13605 | 13607 |
| 13606 int lastIndexOf(Touch element, int startIndex) { | 13608 int lastIndexOf(Touch element, [int start = null]) { |
| 13607 return _Lists.lastIndexOf(this, element, startIndex); | 13609 if (start === null) start = length - 1; |
| 13610 return _Lists.lastIndexOf(this, element, start); |
| 13608 } | 13611 } |
| 13609 | 13612 |
| 13610 int clear() { | 13613 int clear() { |
| 13611 throw new UnsupportedOperationException("Cannot clear immutable List."); | 13614 throw new UnsupportedOperationException("Cannot clear immutable List."); |
| 13612 } | 13615 } |
| 13613 | 13616 |
| 13614 Touch removeLast() { | 13617 Touch removeLast() { |
| 13615 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); | 13618 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); |
| 13616 } | 13619 } |
| 13617 | 13620 |
| (...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16753 static void initialize(var rawWindow) { | 16756 static void initialize(var rawWindow) { |
| 16754 secretWindow = wrapWindow(rawWindow); | 16757 secretWindow = wrapWindow(rawWindow); |
| 16755 secretDocument = wrapDocument(rawWindow.document); | 16758 secretDocument = wrapDocument(rawWindow.document); |
| 16756 } | 16759 } |
| 16757 | 16760 |
| 16758 } | 16761 } |
| 16759 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 16762 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16760 // for details. All rights reserved. Use of this source code is governed by a | 16763 // for details. All rights reserved. Use of this source code is governed by a |
| 16761 // BSD-style license that can be found in the LICENSE file. | 16764 // BSD-style license that can be found in the LICENSE file. |
| 16762 | 16765 |
| 16766 /** |
| 16767 * The [Collections] class implements static methods useful when |
| 16768 * writing a class that implements [Collection] and the [iterator] |
| 16769 * method. |
| 16770 */ |
| 16771 class _Collections { |
| 16772 static void forEach(Iterable<Object> iterable, void f(Object o)) { |
| 16773 for (final e in iterable) { |
| 16774 f(e); |
| 16775 } |
| 16776 } |
| 16777 |
| 16778 static bool some(Iterable<Object> iterable, bool f(Object o)) { |
| 16779 for (final e in iterable) { |
| 16780 if (f(e)) return true; |
| 16781 } |
| 16782 return false; |
| 16783 } |
| 16784 |
| 16785 static bool every(Iterable<Object> iterable, bool f(Object o)) { |
| 16786 for (final e in iterable) { |
| 16787 if (!f(e)) return false; |
| 16788 } |
| 16789 return true; |
| 16790 } |
| 16791 |
| 16792 static List filter(Iterable<Object> source, |
| 16793 List<Object> destination, |
| 16794 bool f(o)) { |
| 16795 for (final e in source) { |
| 16796 if (f(e)) destination.add(e); |
| 16797 } |
| 16798 return destination; |
| 16799 } |
| 16800 |
| 16801 static bool isEmpty(Iterable<Object> iterable) { |
| 16802 return !iterable.iterator().hasNext(); |
| 16803 } |
| 16804 } |
| 16805 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16806 // for details. All rights reserved. Use of this source code is governed by a |
| 16807 // BSD-style license that can be found in the LICENSE file. |
| 16808 |
| 16809 |
| 16810 // These factory methods could all live in one factory provider class but dartc |
| 16811 // has a bug (5399939) preventing that. |
| 16812 |
| 16813 class _FileReaderFactoryProvider { |
| 16814 |
| 16815 factory FileReader() { |
| 16816 return new dom.FileReader(); |
| 16817 } |
| 16818 } |
| 16819 |
| 16820 class _CSSMatrixFactoryProvider { |
| 16821 |
| 16822 factory CSSMatrix([String spec = '']) { |
| 16823 return new CSSMatrixWrappingImplementation._wrap( |
| 16824 new dom.WebKitCSSMatrix(spec)); |
| 16825 } |
| 16826 } |
| 16827 |
| 16828 class _PointFactoryProvider { |
| 16829 |
| 16830 factory Point(num x, num y) { |
| 16831 return new PointWrappingImplementation._wrap(new dom.WebKitPoint(x, y)); |
| 16832 } |
| 16833 } |
| 16834 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16835 // for details. All rights reserved. Use of this source code is governed by a |
| 16836 // BSD-style license that can be found in the LICENSE file. |
| 16837 |
| 16838 // Iterator for lists with fixed size. |
| 16839 class _FixedSizeListIterator<T> extends _VariableSizeListIterator<T> { |
| 16840 _FixedSizeListIterator(List<T> list) |
| 16841 : super(list), |
| 16842 _length = list.length; |
| 16843 |
| 16844 bool hasNext() => _length > _pos; |
| 16845 |
| 16846 final int _length; // Cache list length for faster access. |
| 16847 } |
| 16848 |
| 16849 // Iterator for lists with variable size. |
| 16850 class _VariableSizeListIterator<T> implements Iterator<T> { |
| 16851 _VariableSizeListIterator(List<T> list) |
| 16852 : _list = list, |
| 16853 _pos = 0; |
| 16854 |
| 16855 bool hasNext() => _list.length > _pos; |
| 16856 |
| 16857 T next() { |
| 16858 if (!hasNext()) { |
| 16859 throw const NoMoreElementsException(); |
| 16860 } |
| 16861 return _list[_pos++]; |
| 16862 } |
| 16863 |
| 16864 final List<T> _list; |
| 16865 int _pos; |
| 16866 } |
| 16867 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16868 // for details. All rights reserved. Use of this source code is governed by a |
| 16869 // BSD-style license that can be found in the LICENSE file. |
| 16870 |
| 16871 // TODO(jacobr): move into a core library or at least merge with the copy |
| 16872 // in client/dom/src |
| 16873 class _Lists { |
| 16874 |
| 16875 /** |
| 16876 * Returns the index in the array [a] of the given [element], starting |
| 16877 * the search at index [startIndex] to [endIndex] (exclusive). |
| 16878 * Returns -1 if [element] is not found. |
| 16879 */ |
| 16880 static int indexOf(List a, |
| 16881 Object element, |
| 16882 int startIndex, |
| 16883 int endIndex) { |
| 16884 if (startIndex >= a.length) { |
| 16885 return -1; |
| 16886 } |
| 16887 if (startIndex < 0) { |
| 16888 startIndex = 0; |
| 16889 } |
| 16890 for (int i = startIndex; i < endIndex; i++) { |
| 16891 if (a[i] == element) { |
| 16892 return i; |
| 16893 } |
| 16894 } |
| 16895 return -1; |
| 16896 } |
| 16897 |
| 16898 /** |
| 16899 * Returns the last index in the array [a] of the given [element], starting |
| 16900 * the search at index [startIndex] to 0. |
| 16901 * Returns -1 if [element] is not found. |
| 16902 */ |
| 16903 static int lastIndexOf(List a, Object element, int startIndex) { |
| 16904 if (startIndex < 0) { |
| 16905 return -1; |
| 16906 } |
| 16907 if (startIndex >= a.length) { |
| 16908 startIndex = a.length - 1; |
| 16909 } |
| 16910 for (int i = startIndex; i >= 0; i--) { |
| 16911 if (a[i] == element) { |
| 16912 return i; |
| 16913 } |
| 16914 } |
| 16915 return -1; |
| 16916 } |
| 16917 } |
| 16918 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16919 // for details. All rights reserved. Use of this source code is governed by a |
| 16920 // BSD-style license that can be found in the LICENSE file. |
| 16921 |
| 16763 interface AbstractWorkerEvents extends Events { | 16922 interface AbstractWorkerEvents extends Events { |
| 16764 EventListenerList get error(); | 16923 EventListenerList get error(); |
| 16765 } | 16924 } |
| 16766 | 16925 |
| 16767 interface AbstractWorker extends EventTarget { | 16926 interface AbstractWorker extends EventTarget { |
| 16768 AbstractWorkerEvents get on(); | 16927 AbstractWorkerEvents get on(); |
| 16769 } | 16928 } |
| 16770 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 16929 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16771 // for details. All rights reserved. Use of this source code is governed by a | 16930 // for details. All rights reserved. Use of this source code is governed by a |
| 16772 // BSD-style license that can be found in the LICENSE file. | 16931 // BSD-style license that can be found in the LICENSE file. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16856 e.initBeforeLoadEvent(type, canBubble, cancelable, url); | 17015 e.initBeforeLoadEvent(type, canBubble, cancelable, url); |
| 16857 return LevelDom.wrapBeforeLoadEvent(e); | 17016 return LevelDom.wrapBeforeLoadEvent(e); |
| 16858 } | 17017 } |
| 16859 | 17018 |
| 16860 String get url() => _ptr.url; | 17019 String get url() => _ptr.url; |
| 16861 } | 17020 } |
| 16862 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 17021 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16863 // for details. All rights reserved. Use of this source code is governed by a | 17022 // for details. All rights reserved. Use of this source code is governed by a |
| 16864 // BSD-style license that can be found in the LICENSE file. | 17023 // BSD-style license that can be found in the LICENSE file. |
| 16865 | 17024 |
| 17025 interface BodyElementEvents extends ElementEvents { |
| 17026 EventListenerList get beforeUnload(); |
| 17027 EventListenerList get hashChange(); |
| 17028 EventListenerList get message(); |
| 17029 EventListenerList get offline(); |
| 17030 EventListenerList get online(); |
| 17031 EventListenerList get orientationChange(); |
| 17032 EventListenerList get popState(); |
| 17033 EventListenerList get resize(); |
| 17034 EventListenerList get storage(); |
| 17035 EventListenerList get unLoad(); |
| 17036 } |
| 17037 |
| 17038 interface BodyElement extends Element { |
| 17039 BodyElementEvents get on(); |
| 17040 } |
| 17041 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 17042 // for details. All rights reserved. Use of this source code is governed by a |
| 17043 // BSD-style license that can be found in the LICENSE file. |
| 17044 |
| 17045 class BodyElementEventsImplementation |
| 17046 extends ElementEventsImplementation implements BodyElementEvents { |
| 17047 |
| 17048 BodyElementEventsImplementation._wrap(_ptr) : super._wrap(_ptr); |
| 17049 |
| 17050 EventListenerList get beforeUnload() => _get('beforeunload'); |
| 17051 EventListenerList get hashChange() => _get('hashchange'); |
| 17052 EventListenerList get message() => _get('message'); |
| 17053 EventListenerList get offline() => _get('offline'); |
| 17054 EventListenerList get online() => _get('online'); |
| 17055 EventListenerList get orientationChange() => _get('orientationchange'); |
| 17056 EventListenerList get popState() => _get('popstate'); |
| 17057 EventListenerList get resize() => _get('resize'); |
| 17058 EventListenerList get storage() => _get('storage'); |
| 17059 EventListenerList get unLoad() => _get('unload'); |
| 17060 } |
| 17061 |
| 17062 class BodyElementWrappingImplementation |
| 17063 extends ElementWrappingImplementation implements BodyElement { |
| 17064 |
| 17065 BodyElementWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} |
| 17066 |
| 17067 BodyElementEvents get on() { |
| 17068 if (_on === null) { |
| 17069 _on = new BodyElementEventsImplementation._wrap(_ptr); |
| 17070 } |
| 17071 return _on; |
| 17072 } |
| 17073 } |
| 17074 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 17075 // for details. All rights reserved. Use of this source code is governed by a |
| 17076 // BSD-style license that can be found in the LICENSE file. |
| 17077 |
| 16866 interface CloseEvent extends Event factory CloseEventWrappingImplementation { | 17078 interface CloseEvent extends Event factory CloseEventWrappingImplementation { |
| 16867 | 17079 |
| 16868 CloseEvent(String type, int code, String reason, | 17080 CloseEvent(String type, int code, String reason, |
| 16869 [bool canBubble, bool cancelable, bool wasClean]); | 17081 [bool canBubble, bool cancelable, bool wasClean]); |
| 16870 | 17082 |
| 16871 int get code(); | 17083 int get code(); |
| 16872 | 17084 |
| 16873 String get reason(); | 17085 String get reason(); |
| 16874 | 17086 |
| 16875 bool get wasClean(); | 17087 bool get wasClean(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16919 data); | 17131 data); |
| 16920 return LevelDom.wrapCompositionEvent(e); | 17132 return LevelDom.wrapCompositionEvent(e); |
| 16921 } | 17133 } |
| 16922 | 17134 |
| 16923 String get data() => _ptr.data; | 17135 String get data() => _ptr.data; |
| 16924 } | 17136 } |
| 16925 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 17137 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 16926 // for details. All rights reserved. Use of this source code is governed by a | 17138 // for details. All rights reserved. Use of this source code is governed by a |
| 16927 // BSD-style license that can be found in the LICENSE file. | 17139 // BSD-style license that can be found in the LICENSE file. |
| 16928 | 17140 |
| 17141 // TODO - figure out whether classList exists, and if so use that |
| 17142 // rather than the className property that is being used here. |
| 17143 |
| 17144 class _CssClassSet implements Set<String> { |
| 17145 |
| 17146 final _element; |
| 17147 |
| 17148 _CssClassSet(this._element); |
| 17149 |
| 17150 String toString() { |
| 17151 return _formatSet(_read()); |
| 17152 } |
| 17153 |
| 17154 // interface Iterable - BEGIN |
| 17155 Iterator<String> iterator() { |
| 17156 return _read().iterator(); |
| 17157 } |
| 17158 // interface Iterable - END |
| 17159 |
| 17160 // interface Collection - BEGIN |
| 17161 void forEach(void f(String element)) { |
| 17162 _read().forEach(f); |
| 17163 } |
| 17164 |
| 17165 Collection<String> filter(bool f(String element)) { |
| 17166 return _read().filter(f); |
| 17167 } |
| 17168 |
| 17169 bool every(bool f(String element)) { |
| 17170 return _read().every(f); |
| 17171 } |
| 17172 |
| 17173 bool some(bool f(String element)) { |
| 17174 return _read().some(f); |
| 17175 } |
| 17176 |
| 17177 bool isEmpty() { |
| 17178 return _read().isEmpty(); |
| 17179 } |
| 17180 |
| 17181 int get length() { |
| 17182 return _read().length; |
| 17183 } |
| 17184 // interface Collection - END |
| 17185 |
| 17186 // interface Set - BEGIN |
| 17187 bool contains(String value) { |
| 17188 return _read().contains(value); |
| 17189 } |
| 17190 |
| 17191 void add(String value) { |
| 17192 // TODO - figure out if we need to do any validation here |
| 17193 // or if the browser natively does enough |
| 17194 _modify((s) => s.add(value)); |
| 17195 } |
| 17196 |
| 17197 bool remove(String value) { |
| 17198 Set<String> s = _read(); |
| 17199 bool result = s.remove(value); |
| 17200 _write(s); |
| 17201 return result; |
| 17202 } |
| 17203 |
| 17204 void addAll(Collection<String> collection) { |
| 17205 // TODO - see comment above about validation |
| 17206 _modify((s) => s.addAll(collection)); |
| 17207 } |
| 17208 |
| 17209 void removeAll(Collection<String> collection) { |
| 17210 _modify((s) => s.removeAll(collection)); |
| 17211 } |
| 17212 |
| 17213 bool isSubsetOf(Collection<String> collection) { |
| 17214 return _read().isSubsetOf(collection); |
| 17215 } |
| 17216 |
| 17217 bool containsAll(Collection<String> collection) { |
| 17218 return _read().containsAll(collection); |
| 17219 } |
| 17220 |
| 17221 Set<String> intersection(Collection<String> other) { |
| 17222 return _read().intersection(other); |
| 17223 } |
| 17224 |
| 17225 void clear() { |
| 17226 _modify((s) => s.clear()); |
| 17227 } |
| 17228 // interface Set - END |
| 17229 |
| 17230 /** |
| 17231 * Helper method used to modify the set of css classes on this element. |
| 17232 * |
| 17233 * f - callback with: |
| 17234 * s - a Set of all the css class name currently on this element. |
| 17235 * |
| 17236 * After f returns, the modified set is written to the |
| 17237 * className property of this element. |
| 17238 */ |
| 17239 void _modify( f(Set<String> s)) { |
| 17240 Set<String> s = _read(); |
| 17241 f(s); |
| 17242 _write(s); |
| 17243 } |
| 17244 |
| 17245 /** |
| 17246 * Read the class names from the HTMLElement class property, |
| 17247 * and put them into a set (duplicates are discarded). |
| 17248 */ |
| 17249 Set<String> _read() { |
| 17250 // TODO(mattsh) simplify this once split can take regex. |
| 17251 Set<String> s = new Set<String>(); |
| 17252 for (String name in _element.className.split(' ')) { |
| 17253 String trimmed = name.trim(); |
| 17254 if (!trimmed.isEmpty()) { |
| 17255 s.add(trimmed); |
| 17256 } |
| 17257 } |
| 17258 return s; |
| 17259 } |
| 17260 |
| 17261 /** |
| 17262 * Join all the elements of a set into one string and write |
| 17263 * back to the element. |
| 17264 */ |
| 17265 void _write(Set s) { |
| 17266 _element.className = _formatSet(s); |
| 17267 } |
| 17268 |
| 17269 String _formatSet(Set<String> s) { |
| 17270 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 |
| 17271 List list = new List.from(s); |
| 17272 return Strings.join(list, ' '); |
| 17273 } |
| 17274 |
| 17275 } |
| 17276 |
| 17277 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 17278 // for details. All rights reserved. Use of this source code is governed by a |
| 17279 // BSD-style license that can be found in the LICENSE file. |
| 17280 |
| 16929 // WARNING: Do not edit. | 17281 // WARNING: Do not edit. |
| 16930 // This file was generated by html/scripts/css_code_generator.py | 17282 // This file was generated by html/scripts/css_code_generator.py |
| 16931 | 17283 |
| 16932 // Source of CSS properties: | 17284 // Source of CSS properties: |
| 16933 // Source/WebCore/css/CSSPropertyNames.in | 17285 // Source/WebCore/css/CSSPropertyNames.in |
| 16934 | 17286 |
| 16935 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. | 17287 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. |
| 16936 | 17288 |
| 16937 interface CSSStyleDeclaration factory CSSStyleDeclarationWrappingImplementation
{ | 17289 interface CSSStyleDeclaration factory CSSStyleDeclarationWrappingImplementation
{ |
| 16938 | 17290 |
| (...skipping 4736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21675 e.initCustomEvent(type, canBubble, cancelable, detail); | 22027 e.initCustomEvent(type, canBubble, cancelable, detail); |
| 21676 return LevelDom.wrapCustomEvent(e); | 22028 return LevelDom.wrapCustomEvent(e); |
| 21677 } | 22029 } |
| 21678 | 22030 |
| 21679 String get detail() => _ptr.detail; | 22031 String get detail() => _ptr.detail; |
| 21680 } | 22032 } |
| 21681 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22033 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 21682 // for details. All rights reserved. Use of this source code is governed by a | 22034 // for details. All rights reserved. Use of this source code is governed by a |
| 21683 // BSD-style license that can be found in the LICENSE file. | 22035 // BSD-style license that can be found in the LICENSE file. |
| 21684 | 22036 |
| 21685 interface DOMApplicationCacheEvents extends Events { | |
| 21686 EventListenerList get cached(); | |
| 21687 EventListenerList get checking(); | |
| 21688 EventListenerList get downloading(); | |
| 21689 EventListenerList get error(); | |
| 21690 EventListenerList get noUpdate(); | |
| 21691 EventListenerList get obsolete(); | |
| 21692 EventListenerList get progress(); | |
| 21693 EventListenerList get updateReady(); | |
| 21694 } | |
| 21695 | |
| 21696 interface DOMApplicationCache extends EventTarget { | |
| 21697 | |
| 21698 static final int CHECKING = 2; | |
| 21699 | |
| 21700 static final int DOWNLOADING = 3; | |
| 21701 | |
| 21702 static final int IDLE = 1; | |
| 21703 | |
| 21704 static final int OBSOLETE = 5; | |
| 21705 | |
| 21706 static final int UNCACHED = 0; | |
| 21707 | |
| 21708 static final int UPDATEREADY = 4; | |
| 21709 | |
| 21710 int get status(); | |
| 21711 | |
| 21712 void swapCache(); | |
| 21713 | |
| 21714 void update(); | |
| 21715 | |
| 21716 DOMApplicationCacheEvents get on(); | |
| 21717 } | |
| 21718 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 21719 // for details. All rights reserved. Use of this source code is governed by a | |
| 21720 // BSD-style license that can be found in the LICENSE file. | |
| 21721 | |
| 21722 class DOMApplicationCacheEventsImplementation extends EventsImplementation | |
| 21723 implements DOMApplicationCacheEvents { | |
| 21724 DOMApplicationCacheEventsImplementation._wrap(ptr) : super._wrap(ptr); | |
| 21725 | |
| 21726 EventListenerList get cached() => _get('cached'); | |
| 21727 EventListenerList get checking() => _get('checking'); | |
| 21728 EventListenerList get downloading() => _get('downloading'); | |
| 21729 EventListenerList get error() => _get('error'); | |
| 21730 EventListenerList get noUpdate() => _get('noupdate'); | |
| 21731 EventListenerList get obsolete() => _get('obsolete'); | |
| 21732 EventListenerList get progress() => _get('progress'); | |
| 21733 EventListenerList get updateReady() => _get('updateready'); | |
| 21734 } | |
| 21735 | |
| 21736 class DOMApplicationCacheWrappingImplementation extends EventTargetWrappingImple
mentation implements DOMApplicationCache { | |
| 21737 DOMApplicationCacheWrappingImplementation._wrap(ptr) : super._wrap(ptr); | |
| 21738 | |
| 21739 int get status() => _ptr.status; | |
| 21740 | |
| 21741 void swapCache() { | |
| 21742 _ptr.swapCache(); | |
| 21743 } | |
| 21744 | |
| 21745 void update() { | |
| 21746 _ptr.update(); | |
| 21747 } | |
| 21748 | |
| 21749 DOMApplicationCacheEvents get on() { | |
| 21750 if (_on === null) { | |
| 21751 _on = new DOMApplicationCacheEventsImplementation._wrap(_ptr); | |
| 21752 } | |
| 21753 return _on; | |
| 21754 } | |
| 21755 } | |
| 21756 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 21757 // for details. All rights reserved. Use of this source code is governed by a | |
| 21758 // BSD-style license that can be found in the LICENSE file. | |
| 21759 | |
| 21760 class DOMWrapperBase { | |
| 21761 final _ptr; | |
| 21762 | |
| 21763 DOMWrapperBase._wrap(this._ptr) { | |
| 21764 // We should never be creating duplicate wrappers. | |
| 21765 assert(_ptr.dartObjectLocalStorage === null); | |
| 21766 _ptr.dartObjectLocalStorage = this; | |
| 21767 } | |
| 21768 } | |
| 21769 | |
| 21770 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 21771 // for details. All rights reserved. Use of this source code is governed by a | |
| 21772 // BSD-style license that can be found in the LICENSE file. | |
| 21773 | |
| 21774 interface DocumentEvents extends ElementEvents { | |
| 21775 EventListenerList get readyStateChange(); | |
| 21776 EventListenerList get selectionChange(); | |
| 21777 EventListenerList get contentLoaded(); | |
| 21778 } | |
| 21779 | |
| 21780 // TODO(jacobr): add DocumentFragment ctor | |
| 21781 // add something smarted for document.domain | |
| 21782 interface Document extends Element /*, common.NodeSelector */ { | |
| 21783 | |
| 21784 // TODO(jacobr): remove. | |
| 21785 Event createEvent([String eventType]); | |
| 21786 | |
| 21787 Element get activeElement(); | |
| 21788 | |
| 21789 // TODO(jacobr): add | |
| 21790 // Map<String, Class> tags; | |
| 21791 | |
| 21792 Element get body(); | |
| 21793 | |
| 21794 void set body(Element value); | |
| 21795 | |
| 21796 String get charset(); | |
| 21797 | |
| 21798 void set charset(String value); | |
| 21799 | |
| 21800 // FIXME(slightlyoff): FIX COOKIES, MMM...COOKIES. ME WANT COOKIES!! | |
| 21801 // Map<String, CookieList> cookies | |
| 21802 // Map<String, Cookie> CookieList | |
| 21803 String get cookie(); | |
| 21804 | |
| 21805 void set cookie(String value); | |
| 21806 | |
| 21807 Window get window(); | |
| 21808 | |
| 21809 String get domain(); | |
| 21810 | |
| 21811 HeadElement get head(); | |
| 21812 | |
| 21813 String get lastModified(); | |
| 21814 | |
| 21815 // TODO(jacobr): remove once on.contentLoaded is changed to return a Promise. | |
| 21816 String get readyState(); | |
| 21817 | |
| 21818 String get referrer(); | |
| 21819 | |
| 21820 StyleSheetList get styleSheets(); | |
| 21821 | |
| 21822 // TODO(jacobr): should this be removed? Users could write document.query("tit
le").text instead. | |
| 21823 String get title(); | |
| 21824 | |
| 21825 void set title(String value); | |
| 21826 | |
| 21827 bool get webkitHidden(); | |
| 21828 | |
| 21829 String get webkitVisibilityState(); | |
| 21830 | |
| 21831 Promise<Range> caretRangeFromPoint([int x, int y]); | |
| 21832 | |
| 21833 // TODO(jacobr): remove. | |
| 21834 Element createElement([String tagName]); | |
| 21835 | |
| 21836 Promise<Element> elementFromPoint([int x, int y]); | |
| 21837 | |
| 21838 bool execCommand([String command, bool userInterface, String value]); | |
| 21839 | |
| 21840 // TODO(jacobr): remove once a new API is specified | |
| 21841 CanvasRenderingContext getCSSCanvasContext(String contextId, String name, | |
| 21842 int width, int height); | |
| 21843 | |
| 21844 bool queryCommandEnabled([String command]); | |
| 21845 | |
| 21846 bool queryCommandIndeterm([String command]); | |
| 21847 | |
| 21848 bool queryCommandState([String command]); | |
| 21849 | |
| 21850 bool queryCommandSupported([String command]); | |
| 21851 | |
| 21852 String queryCommandValue([String command]); | |
| 21853 | |
| 21854 String get manifest(); | |
| 21855 | |
| 21856 void set manifest(String value); | |
| 21857 | |
| 21858 DocumentEvents get on(); | |
| 21859 } | |
| 21860 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 21861 // for details. All rights reserved. Use of this source code is governed by a | |
| 21862 // BSD-style license that can be found in the LICENSE file. | |
| 21863 | |
| 21864 /** | 22037 /** |
| 21865 * Provides a Map abstraction on top of data-* attributes, similar to the | 22038 * Provides a Map abstraction on top of data-* attributes, similar to the |
| 21866 * dataSet in the old DOM. | 22039 * dataSet in the old DOM. |
| 21867 */ | 22040 */ |
| 21868 class _DataAttributeMap implements Map<String, String> { | 22041 class _DataAttributeMap implements Map<String, String> { |
| 21869 | 22042 |
| 21870 final Map<String, String> _attributes; | 22043 final Map<String, String> _attributes; |
| 21871 | 22044 |
| 21872 _DataAttributeMap(this._attributes); | 22045 _DataAttributeMap(this._attributes); |
| 21873 | 22046 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22021 num get alpha() => _ptr.alpha; | 22194 num get alpha() => _ptr.alpha; |
| 22022 | 22195 |
| 22023 num get beta() => _ptr.beta; | 22196 num get beta() => _ptr.beta; |
| 22024 | 22197 |
| 22025 num get gamma() => _ptr.gamma; | 22198 num get gamma() => _ptr.gamma; |
| 22026 } | 22199 } |
| 22027 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22200 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22028 // for details. All rights reserved. Use of this source code is governed by a | 22201 // for details. All rights reserved. Use of this source code is governed by a |
| 22029 // BSD-style license that can be found in the LICENSE file. | 22202 // BSD-style license that can be found in the LICENSE file. |
| 22030 | 22203 |
| 22031 interface BodyElementEvents extends ElementEvents { | 22204 interface DocumentEvents extends ElementEvents { |
| 22032 EventListenerList get beforeUnload(); | 22205 EventListenerList get readyStateChange(); |
| 22033 EventListenerList get hashChange(); | 22206 EventListenerList get selectionChange(); |
| 22034 EventListenerList get message(); | 22207 EventListenerList get contentLoaded(); |
| 22035 EventListenerList get offline(); | |
| 22036 EventListenerList get online(); | |
| 22037 EventListenerList get orientationChange(); | |
| 22038 EventListenerList get popState(); | |
| 22039 EventListenerList get resize(); | |
| 22040 EventListenerList get storage(); | |
| 22041 EventListenerList get unLoad(); | |
| 22042 } | 22208 } |
| 22043 | 22209 |
| 22044 interface BodyElement extends Element { | 22210 // TODO(jacobr): add DocumentFragment ctor |
| 22045 BodyElementEvents get on(); | 22211 // add something smarted for document.domain |
| 22212 interface Document extends Element /*, common.NodeSelector */ { |
| 22213 |
| 22214 // TODO(jacobr): remove. |
| 22215 Event createEvent([String eventType]); |
| 22216 |
| 22217 Element get activeElement(); |
| 22218 |
| 22219 // TODO(jacobr): add |
| 22220 // Map<String, Class> tags; |
| 22221 |
| 22222 Element get body(); |
| 22223 |
| 22224 void set body(Element value); |
| 22225 |
| 22226 String get charset(); |
| 22227 |
| 22228 void set charset(String value); |
| 22229 |
| 22230 // FIXME(slightlyoff): FIX COOKIES, MMM...COOKIES. ME WANT COOKIES!! |
| 22231 // Map<String, CookieList> cookies |
| 22232 // Map<String, Cookie> CookieList |
| 22233 String get cookie(); |
| 22234 |
| 22235 void set cookie(String value); |
| 22236 |
| 22237 Window get window(); |
| 22238 |
| 22239 String get domain(); |
| 22240 |
| 22241 HeadElement get head(); |
| 22242 |
| 22243 String get lastModified(); |
| 22244 |
| 22245 // TODO(jacobr): remove once on.contentLoaded is changed to return a Future. |
| 22246 String get readyState(); |
| 22247 |
| 22248 String get referrer(); |
| 22249 |
| 22250 StyleSheetList get styleSheets(); |
| 22251 |
| 22252 // TODO(jacobr): should this be removed? Users could write document.query("tit
le").text instead. |
| 22253 String get title(); |
| 22254 |
| 22255 void set title(String value); |
| 22256 |
| 22257 bool get webkitHidden(); |
| 22258 |
| 22259 String get webkitVisibilityState(); |
| 22260 |
| 22261 Future<Range> caretRangeFromPoint([int x, int y]); |
| 22262 |
| 22263 // TODO(jacobr): remove. |
| 22264 Element createElement([String tagName]); |
| 22265 |
| 22266 Future<Element> elementFromPoint([int x, int y]); |
| 22267 |
| 22268 bool execCommand([String command, bool userInterface, String value]); |
| 22269 |
| 22270 // TODO(jacobr): remove once a new API is specified |
| 22271 CanvasRenderingContext getCSSCanvasContext(String contextId, String name, |
| 22272 int width, int height); |
| 22273 |
| 22274 bool queryCommandEnabled([String command]); |
| 22275 |
| 22276 bool queryCommandIndeterm([String command]); |
| 22277 |
| 22278 bool queryCommandState([String command]); |
| 22279 |
| 22280 bool queryCommandSupported([String command]); |
| 22281 |
| 22282 String queryCommandValue([String command]); |
| 22283 |
| 22284 String get manifest(); |
| 22285 |
| 22286 void set manifest(String value); |
| 22287 |
| 22288 DocumentEvents get on(); |
| 22289 |
| 22290 Future<ElementRect> get rect(); |
| 22046 } | 22291 } |
| 22047 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22292 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22048 // for details. All rights reserved. Use of this source code is governed by a | 22293 // for details. All rights reserved. Use of this source code is governed by a |
| 22049 // BSD-style license that can be found in the LICENSE file. | 22294 // BSD-style license that can be found in the LICENSE file. |
| 22050 | |
| 22051 class BodyElementEventsImplementation | |
| 22052 extends ElementEventsImplementation implements BodyElementEvents { | |
| 22053 | |
| 22054 BodyElementEventsImplementation._wrap(_ptr) : super._wrap(_ptr); | |
| 22055 | |
| 22056 EventListenerList get beforeUnload() => _get('beforeunload'); | |
| 22057 EventListenerList get hashChange() => _get('hashchange'); | |
| 22058 EventListenerList get message() => _get('message'); | |
| 22059 EventListenerList get offline() => _get('offline'); | |
| 22060 EventListenerList get online() => _get('online'); | |
| 22061 EventListenerList get orientationChange() => _get('orientationchange'); | |
| 22062 EventListenerList get popState() => _get('popstate'); | |
| 22063 EventListenerList get resize() => _get('resize'); | |
| 22064 EventListenerList get storage() => _get('storage'); | |
| 22065 EventListenerList get unLoad() => _get('unload'); | |
| 22066 } | |
| 22067 | |
| 22068 class BodyElementWrappingImplementation | |
| 22069 extends ElementWrappingImplementation implements BodyElement { | |
| 22070 | |
| 22071 BodyElementWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} | |
| 22072 | |
| 22073 BodyElementEvents get on() { | |
| 22074 if (_on === null) { | |
| 22075 _on = new BodyElementEventsImplementation._wrap(_ptr); | |
| 22076 } | |
| 22077 return _on; | |
| 22078 } | |
| 22079 } | |
| 22080 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 22081 // for details. All rights reserved. Use of this source code is governed by a | |
| 22082 // BSD-style license that can be found in the LICENSE file. | |
| 22083 | |
| 22084 // TODO - figure out whether classList exists, and if so use that | |
| 22085 // rather than the className property that is being used here. | |
| 22086 | |
| 22087 class _CssClassSet implements Set<String> { | |
| 22088 | |
| 22089 final _element; | |
| 22090 | |
| 22091 _CssClassSet(this._element); | |
| 22092 | |
| 22093 String toString() { | |
| 22094 return _formatSet(_read()); | |
| 22095 } | |
| 22096 | |
| 22097 // interface Iterable - BEGIN | |
| 22098 Iterator<String> iterator() { | |
| 22099 return _read().iterator(); | |
| 22100 } | |
| 22101 // interface Iterable - END | |
| 22102 | |
| 22103 // interface Collection - BEGIN | |
| 22104 void forEach(void f(String element)) { | |
| 22105 _read().forEach(f); | |
| 22106 } | |
| 22107 | |
| 22108 Collection<String> filter(bool f(String element)) { | |
| 22109 return _read().filter(f); | |
| 22110 } | |
| 22111 | |
| 22112 bool every(bool f(String element)) { | |
| 22113 return _read().every(f); | |
| 22114 } | |
| 22115 | |
| 22116 bool some(bool f(String element)) { | |
| 22117 return _read().some(f); | |
| 22118 } | |
| 22119 | |
| 22120 bool isEmpty() { | |
| 22121 return _read().isEmpty(); | |
| 22122 } | |
| 22123 | |
| 22124 int get length() { | |
| 22125 return _read().length; | |
| 22126 } | |
| 22127 // interface Collection - END | |
| 22128 | |
| 22129 // interface Set - BEGIN | |
| 22130 bool contains(String value) { | |
| 22131 return _read().contains(value); | |
| 22132 } | |
| 22133 | |
| 22134 void add(String value) { | |
| 22135 // TODO - figure out if we need to do any validation here | |
| 22136 // or if the browser natively does enough | |
| 22137 _modify((s) => s.add(value)); | |
| 22138 } | |
| 22139 | |
| 22140 bool remove(String value) { | |
| 22141 Set<String> s = _read(); | |
| 22142 bool result = s.remove(value); | |
| 22143 _write(s); | |
| 22144 return result; | |
| 22145 } | |
| 22146 | |
| 22147 void addAll(Collection<String> collection) { | |
| 22148 // TODO - see comment above about validation | |
| 22149 _modify((s) => s.addAll(collection)); | |
| 22150 } | |
| 22151 | |
| 22152 void removeAll(Collection<String> collection) { | |
| 22153 _modify((s) => s.removeAll(collection)); | |
| 22154 } | |
| 22155 | |
| 22156 bool isSubsetOf(Collection<String> collection) { | |
| 22157 return _read().isSubsetOf(collection); | |
| 22158 } | |
| 22159 | |
| 22160 bool containsAll(Collection<String> collection) { | |
| 22161 return _read().containsAll(collection); | |
| 22162 } | |
| 22163 | |
| 22164 Set<String> intersection(Collection<String> other) { | |
| 22165 return _read().intersection(other); | |
| 22166 } | |
| 22167 | |
| 22168 void clear() { | |
| 22169 _modify((s) => s.clear()); | |
| 22170 } | |
| 22171 // interface Set - END | |
| 22172 | |
| 22173 /** | |
| 22174 * Helper method used to modify the set of css classes on this element. | |
| 22175 * | |
| 22176 * f - callback with: | |
| 22177 * s - a Set of all the css class name currently on this element. | |
| 22178 * | |
| 22179 * After f returns, the modified set is written to the | |
| 22180 * className property of this element. | |
| 22181 */ | |
| 22182 void _modify( f(Set<String> s)) { | |
| 22183 Set<String> s = _read(); | |
| 22184 f(s); | |
| 22185 _write(s); | |
| 22186 } | |
| 22187 | |
| 22188 /** | |
| 22189 * Read the class names from the HTMLElement class property, | |
| 22190 * and put them into a set (duplicates are discarded). | |
| 22191 */ | |
| 22192 Set<String> _read() { | |
| 22193 // TODO(mattsh) simplify this once split can take regex. | |
| 22194 Set<String> s = new Set<String>(); | |
| 22195 for (String name in _element.className.split(' ')) { | |
| 22196 String trimmed = name.trim(); | |
| 22197 if (!trimmed.isEmpty()) { | |
| 22198 s.add(trimmed); | |
| 22199 } | |
| 22200 } | |
| 22201 return s; | |
| 22202 } | |
| 22203 | |
| 22204 /** | |
| 22205 * Join all the elements of a set into one string and write | |
| 22206 * back to the element. | |
| 22207 */ | |
| 22208 void _write(Set s) { | |
| 22209 _element.className = _formatSet(s); | |
| 22210 } | |
| 22211 | |
| 22212 String _formatSet(Set<String> s) { | |
| 22213 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 | |
| 22214 List list = new List.from(s); | |
| 22215 return Strings.join(list, ' '); | |
| 22216 } | |
| 22217 | |
| 22218 } | |
| 22219 | |
| 22220 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 22221 // for details. All rights reserved. Use of this source code is governed by a | |
| 22222 // BSD-style license that can be found in the LICENSE file. | |
| 22223 | 22295 |
| 22224 interface DocumentFragment extends Element factory DocumentFragmentWrappingImple
mentation { | 22296 interface DocumentFragment extends Element factory DocumentFragmentWrappingImple
mentation { |
| 22225 | 22297 |
| 22226 DocumentFragment(); | 22298 DocumentFragment(); |
| 22227 | 22299 |
| 22228 DocumentFragment.html(String html); | 22300 DocumentFragment.html(String html); |
| 22229 } | 22301 } |
| 22230 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22302 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22231 // for details. All rights reserved. Use of this source code is governed by a | 22303 // for details. All rights reserved. Use of this source code is governed by a |
| 22232 // BSD-style license that can be found in the LICENSE file. | 22304 // BSD-style license that can be found in the LICENSE file. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22321 | 22393 |
| 22322 Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); | 22394 Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); |
| 22323 bool every(bool f(Element element)) => _filtered.every(f); | 22395 bool every(bool f(Element element)) => _filtered.every(f); |
| 22324 bool some(bool f(Element element)) => _filtered.some(f); | 22396 bool some(bool f(Element element)) => _filtered.some(f); |
| 22325 bool isEmpty() => _filtered.isEmpty(); | 22397 bool isEmpty() => _filtered.isEmpty(); |
| 22326 int get length() => _filtered.length; | 22398 int get length() => _filtered.length; |
| 22327 Element operator [](int index) => _filtered[index]; | 22399 Element operator [](int index) => _filtered[index]; |
| 22328 Iterator<Element> iterator() => _filtered.iterator(); | 22400 Iterator<Element> iterator() => _filtered.iterator(); |
| 22329 List<Element> getRange(int start, int length) => | 22401 List<Element> getRange(int start, int length) => |
| 22330 _filtered.getRange(start, length); | 22402 _filtered.getRange(start, length); |
| 22331 int indexOf(Element element, int startIndex) => | 22403 int indexOf(Element element, [int start = 0]) => |
| 22332 _filtered.indexOf(element, startIndex); | 22404 _filtered.indexOf(element, start); |
| 22333 int lastIndexOf(Element element, int startIndex) => | 22405 |
| 22334 _filtered.lastIndexOf(element, startIndex); | 22406 int lastIndexOf(Element element, [int start = null]) { |
| 22407 if (start === null) start = length - 1; |
| 22408 return _filtered.lastIndexOf(element, start); |
| 22409 } |
| 22410 |
| 22335 Element last() => _filtered.last(); | 22411 Element last() => _filtered.last(); |
| 22336 } | 22412 } |
| 22337 | 22413 |
| 22338 class EmptyStyleDeclaration extends CSSStyleDeclarationWrappingImplementation { | 22414 class EmptyStyleDeclaration extends CSSStyleDeclarationWrappingImplementation { |
| 22339 // This can't call super(), since that's a factory constructor | 22415 // This can't call super(), since that's a factory constructor |
| 22340 EmptyStyleDeclaration() | 22416 EmptyStyleDeclaration() |
| 22341 : super._wrap(dom.document.createElement('div').style); | 22417 : super._wrap(dom.document.createElement('div').style); |
| 22342 | 22418 |
| 22343 void set cssText(String value) { | 22419 void set cssText(String value) { |
| 22344 throw new UnsupportedOperationException( | 22420 throw new UnsupportedOperationException( |
| 22345 "Can't modify a frozen style declaration."); | 22421 "Can't modify a frozen style declaration."); |
| 22346 } | 22422 } |
| 22347 | 22423 |
| 22348 String removeProperty(String propertyName) { | 22424 String removeProperty(String propertyName) { |
| 22349 throw new UnsupportedOperationException( | 22425 throw new UnsupportedOperationException( |
| 22350 "Can't modify a frozen style declaration."); | 22426 "Can't modify a frozen style declaration."); |
| 22351 } | 22427 } |
| 22352 | 22428 |
| 22353 void setProperty(String propertyName, String value, [String priority]) { | 22429 void setProperty(String propertyName, String value, [String priority]) { |
| 22354 throw new UnsupportedOperationException( | 22430 throw new UnsupportedOperationException( |
| 22355 "Can't modify a frozen style declaration."); | 22431 "Can't modify a frozen style declaration."); |
| 22356 } | 22432 } |
| 22357 } | 22433 } |
| 22358 | 22434 |
| 22359 class EmptyClientRect implements ClientRect { | 22435 Future<CSSStyleDeclaration> _emptyStyleFuture() { |
| 22360 num get bottom() => 0; | 22436 return _createMeasurementFuture(() => new EmptyStyleDeclaration(), |
| 22361 num get top() => 0; | 22437 new Completer<CSSStyleDeclaration>()); |
| 22362 num get left() => 0; | 22438 } |
| 22363 num get right() => 0; | 22439 |
| 22364 num get height() => 0; | 22440 class EmptyElementRect implements ElementRect { |
| 22365 num get width() => 0; | 22441 final ClientRect client = const SimpleClientRect(0, 0, 0, 0); |
| 22442 final ClientRect offset = const SimpleClientRect(0, 0, 0, 0); |
| 22443 final ClientRect scroll = const SimpleClientRect(0, 0, 0, 0); |
| 22444 final ClientRect bounding = const SimpleClientRect(0, 0, 0, 0); |
| 22445 final List<ClientRect> clientRects = const <ClientRect>[]; |
| 22446 |
| 22447 const EmptyElementRect(); |
| 22366 } | 22448 } |
| 22367 | 22449 |
| 22368 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation
implements DocumentFragment { | 22450 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation
implements DocumentFragment { |
| 22369 ElementList _elements; | 22451 ElementList _elements; |
| 22370 | 22452 |
| 22371 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} | 22453 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} |
| 22372 | 22454 |
| 22373 factory DocumentFragmentWrappingImplementation() { | 22455 factory DocumentFragmentWrappingImplementation() { |
| 22374 return new DocumentFragmentWrappingImplementation._wrap( | 22456 return new DocumentFragmentWrappingImplementation._wrap( |
| 22375 dom.document.createDocumentFragment()); | 22457 dom.document.createDocumentFragment()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22444 position_OR_where, new DocumentFragment.html(text)); | 22526 position_OR_where, new DocumentFragment.html(text)); |
| 22445 } | 22527 } |
| 22446 | 22528 |
| 22447 ElementEvents get on() { | 22529 ElementEvents get on() { |
| 22448 if (_on === null) { | 22530 if (_on === null) { |
| 22449 _on = new ElementEventsImplementation._wrap(_ptr); | 22531 _on = new ElementEventsImplementation._wrap(_ptr); |
| 22450 } | 22532 } |
| 22451 return _on; | 22533 return _on; |
| 22452 } | 22534 } |
| 22453 | 22535 |
| 22536 Future<ElementRect> get rect() { |
| 22537 return _createMeasurementFuture(() => const EmptyElementRect(), |
| 22538 new Completer<ElementRect>()); |
| 22539 } |
| 22540 |
| 22454 Element query(String selectors) => | 22541 Element query(String selectors) => |
| 22455 LevelDom.wrapElement(_ptr.querySelector(selectors)); | 22542 LevelDom.wrapElement(_ptr.querySelector(selectors)); |
| 22456 | 22543 |
| 22457 ElementList queryAll(String selectors) => | 22544 ElementList queryAll(String selectors) => |
| 22458 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors)); | 22545 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors)); |
| 22459 | 22546 |
| 22460 // If we can come up with a semi-reasonable default value for an Element | 22547 // If we can come up with a semi-reasonable default value for an Element |
| 22461 // getter, we'll use it. In general, these return the same values as an | 22548 // getter, we'll use it. In general, these return the same values as an |
| 22462 // element that has no parent. | 22549 // element that has no parent. |
| 22463 int get clientHeight() => 0; | |
| 22464 int get clientWidth() => 0; | |
| 22465 int get offsetHeight() => 0; | |
| 22466 int get offsetWidth() => 0; | |
| 22467 int get scrollHeight() => 0; | |
| 22468 int get scrollWidth() => 0; | |
| 22469 int get clientLeft() => 0; | |
| 22470 int get clientTop() => 0; | |
| 22471 int get offsetLeft() => 0; | |
| 22472 int get offsetTop() => 0; | |
| 22473 int get scrollLeft() => 0; | |
| 22474 int get scrollTop() => 0; | |
| 22475 String get contentEditable() => "false"; | 22550 String get contentEditable() => "false"; |
| 22476 bool get isContentEditable() => false; | 22551 bool get isContentEditable() => false; |
| 22477 bool get draggable() => false; | 22552 bool get draggable() => false; |
| 22478 bool get hidden() => false; | 22553 bool get hidden() => false; |
| 22479 bool get spellcheck() => false; | 22554 bool get spellcheck() => false; |
| 22480 int get tabIndex() => -1; | 22555 int get tabIndex() => -1; |
| 22481 String get id() => ""; | 22556 String get id() => ""; |
| 22482 String get title() => ""; | 22557 String get title() => ""; |
| 22483 String get tagName() => ""; | 22558 String get tagName() => ""; |
| 22484 String get webkitdropzone() => ""; | 22559 String get webkitdropzone() => ""; |
| 22485 Element get firstElementChild() => elements.first(); | 22560 Element get firstElementChild() => elements.first(); |
| 22486 Element get lastElementChild() => elements.last(); | 22561 Element get lastElementChild() => elements.last(); |
| 22487 Element get nextElementSibling() => null; | 22562 Element get nextElementSibling() => null; |
| 22488 Element get previousElementSibling() => null; | 22563 Element get previousElementSibling() => null; |
| 22489 Element get offsetParent() => null; | 22564 Element get offsetParent() => null; |
| 22490 Element get parent() => null; | 22565 Element get parent() => null; |
| 22491 Map<String, String> get attributes() => const {}; | 22566 Map<String, String> get attributes() => const {}; |
| 22492 // Issue 174: this should be a const set. | 22567 // Issue 174: this should be a const set. |
| 22493 Set<String> get classes() => new Set<String>(); | 22568 Set<String> get classes() => new Set<String>(); |
| 22494 Map<String, String> get dataAttributes() => const {}; | 22569 Map<String, String> get dataAttributes() => const {}; |
| 22495 CSSStyleDeclaration get style() => new EmptyStyleDeclaration(); | 22570 CSSStyleDeclaration get style() => new EmptyStyleDeclaration(); |
| 22496 ClientRect getBoundingClientRect() => new EmptyClientRect(); | 22571 Future<CSSStyleDeclaration> get computedStyle() => |
| 22497 List<ClientRect> getClientRects() => const []; | 22572 _emptyStyleFuture(); |
| 22573 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) => |
| 22574 _emptyStyleFuture(); |
| 22498 bool matchesSelector([String selectors]) => false; | 22575 bool matchesSelector([String selectors]) => false; |
| 22499 | 22576 |
| 22500 // Imperative Element methods are made into no-ops, as they are on parentless | 22577 // Imperative Element methods are made into no-ops, as they are on parentless |
| 22501 // elements. | 22578 // elements. |
| 22502 void blur() {} | 22579 void blur() {} |
| 22503 void focus() {} | 22580 void focus() {} |
| 22504 void scrollByLines([int lines]) {} | 22581 void scrollByLines([int lines]) {} |
| 22505 void scrollByPages([int pages]) {} | 22582 void scrollByPages([int pages]) {} |
| 22506 void scrollIntoView([bool centerIfNeeded]) {} | 22583 void scrollIntoView([bool centerIfNeeded]) {} |
| 22507 | 22584 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22584 | 22661 |
| 22585 void set title(String value) { | 22662 void set title(String value) { |
| 22586 throw new UnsupportedOperationException( | 22663 throw new UnsupportedOperationException( |
| 22587 "Title can't be set for document fragments."); | 22664 "Title can't be set for document fragments."); |
| 22588 } | 22665 } |
| 22589 | 22666 |
| 22590 void set webkitdropzone(String value) { | 22667 void set webkitdropzone(String value) { |
| 22591 throw new UnsupportedOperationException( | 22668 throw new UnsupportedOperationException( |
| 22592 "WebKit drop zone can't be set for document fragments."); | 22669 "WebKit drop zone can't be set for document fragments."); |
| 22593 } | 22670 } |
| 22594 }// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22671 } |
| 22672 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22595 // for details. All rights reserved. Use of this source code is governed by a | 22673 // for details. All rights reserved. Use of this source code is governed by a |
| 22596 // BSD-style license that can be found in the LICENSE file. | 22674 // BSD-style license that can be found in the LICENSE file. |
| 22597 | 22675 |
| 22598 class DocumentEventsImplementation extends ElementEventsImplementation | 22676 class DocumentEventsImplementation extends ElementEventsImplementation |
| 22599 implements DocumentEvents { | 22677 implements DocumentEvents { |
| 22600 | 22678 |
| 22601 DocumentEventsImplementation._wrap(_ptr) : super._wrap(_ptr); | 22679 DocumentEventsImplementation._wrap(_ptr) : super._wrap(_ptr); |
| 22602 | 22680 |
| 22603 EventListenerList get readyStateChange() => _get('readystatechange'); | 22681 EventListenerList get readyStateChange() => _get('readystatechange'); |
| 22604 | 22682 |
| 22605 EventListenerList get selectionChange() => _get('selectionchange'); | 22683 EventListenerList get selectionChange() => _get('selectionchange'); |
| 22606 | 22684 |
| 22607 EventListenerList get contentLoaded() => _get('DOMContentLoaded'); | 22685 EventListenerList get contentLoaded() => _get('DOMContentLoaded'); |
| 22608 } | 22686 } |
| 22609 | 22687 |
| 22610 class DocumentWrappingImplementation extends ElementWrappingImplementation imple
ments Document { | 22688 class DocumentWrappingImplementation extends ElementWrappingImplementation imple
ments Document { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22650 StyleSheetList get styleSheets() => LevelDom.wrapStyleSheetList(_documentPtr.s
tyleSheets); | 22728 StyleSheetList get styleSheets() => LevelDom.wrapStyleSheetList(_documentPtr.s
tyleSheets); |
| 22651 | 22729 |
| 22652 String get title() => _documentPtr.title; | 22730 String get title() => _documentPtr.title; |
| 22653 | 22731 |
| 22654 void set title(String value) { _documentPtr.title = value; } | 22732 void set title(String value) { _documentPtr.title = value; } |
| 22655 | 22733 |
| 22656 bool get webkitHidden() => _documentPtr.webkitHidden; | 22734 bool get webkitHidden() => _documentPtr.webkitHidden; |
| 22657 | 22735 |
| 22658 String get webkitVisibilityState() => _documentPtr.webkitVisibilityState; | 22736 String get webkitVisibilityState() => _documentPtr.webkitVisibilityState; |
| 22659 | 22737 |
| 22660 Promise<Range> caretRangeFromPoint([int x = null, int y = null]) { | 22738 Future<Range> caretRangeFromPoint([int x = null, int y = null]) { |
| 22661 throw 'TODO(jacobr): impl promise.'; | 22739 return _createMeasurementFuture( |
| 22662 // return LevelDom.wrapRange(_documentPtr.caretRangeFromPoint(x, y)); | 22740 () => LevelDom.wrapRange(_documentPtr.caretRangeFromPoint(x, y)), |
| 22741 new Completer<Range>()); |
| 22663 } | 22742 } |
| 22664 | 22743 |
| 22665 Element createElement([String tagName = null]) { | 22744 Element createElement([String tagName = null]) { |
| 22666 return LevelDom.wrapElement(_documentPtr.createElement(tagName)); | 22745 return LevelDom.wrapElement(_documentPtr.createElement(tagName)); |
| 22667 } | 22746 } |
| 22668 | 22747 |
| 22669 Event createEvent([String eventType = null]) { | 22748 Event createEvent([String eventType = null]) { |
| 22670 return LevelDom.wrapEvent(_documentPtr.createEvent(eventType)); | 22749 return LevelDom.wrapEvent(_documentPtr.createEvent(eventType)); |
| 22671 } | 22750 } |
| 22672 | 22751 |
| 22673 Promise<Element> elementFromPoint([int x = null, int y = null]) { | 22752 Future<Element> elementFromPoint([int x = null, int y = null]) { |
| 22674 throw 'TODO(jacobr): impl using promise'; | 22753 return _createMeasurementFuture( |
| 22675 // return LevelDom.wrapElement(_documentPtr.elementFromPoint(x, y)); | 22754 () => LevelDom.wrapElement(_documentPtr.elementFromPoint(x, y)), |
| 22755 new Completer<Element>()); |
| 22676 } | 22756 } |
| 22677 | 22757 |
| 22678 bool execCommand([String command = null, bool userInterface = null, String val
ue = null]) { | 22758 bool execCommand([String command = null, bool userInterface = null, String val
ue = null]) { |
| 22679 return _documentPtr.execCommand(command, userInterface, value); | 22759 return _documentPtr.execCommand(command, userInterface, value); |
| 22680 } | 22760 } |
| 22681 | 22761 |
| 22682 CanvasRenderingContext getCSSCanvasContext(String contextId, String name, | 22762 CanvasRenderingContext getCSSCanvasContext(String contextId, String name, |
| 22683 int width, int height) { | 22763 int width, int height) { |
| 22684 return LevelDom.wrapCanvasRenderingContext(_documentPtr.getCSSCanvasContext(
contextId, name, width, height)); | 22764 return LevelDom.wrapCanvasRenderingContext(_documentPtr.getCSSCanvasContext(
contextId, name, width, height)); |
| 22685 } | 22765 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 22712 if (_on === null) { | 22792 if (_on === null) { |
| 22713 _on = new DocumentEventsImplementation._wrap(_ptr); | 22793 _on = new DocumentEventsImplementation._wrap(_ptr); |
| 22714 } | 22794 } |
| 22715 return _on; | 22795 return _on; |
| 22716 } | 22796 } |
| 22717 } | 22797 } |
| 22718 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22798 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22719 // for details. All rights reserved. Use of this source code is governed by a | 22799 // for details. All rights reserved. Use of this source code is governed by a |
| 22720 // BSD-style license that can be found in the LICENSE file. | 22800 // BSD-style license that can be found in the LICENSE file. |
| 22721 | 22801 |
| 22802 interface DOMApplicationCacheEvents extends Events { |
| 22803 EventListenerList get cached(); |
| 22804 EventListenerList get checking(); |
| 22805 EventListenerList get downloading(); |
| 22806 EventListenerList get error(); |
| 22807 EventListenerList get noUpdate(); |
| 22808 EventListenerList get obsolete(); |
| 22809 EventListenerList get progress(); |
| 22810 EventListenerList get updateReady(); |
| 22811 } |
| 22812 |
| 22813 interface DOMApplicationCache extends EventTarget { |
| 22814 |
| 22815 static final int CHECKING = 2; |
| 22816 |
| 22817 static final int DOWNLOADING = 3; |
| 22818 |
| 22819 static final int IDLE = 1; |
| 22820 |
| 22821 static final int OBSOLETE = 5; |
| 22822 |
| 22823 static final int UNCACHED = 0; |
| 22824 |
| 22825 static final int UPDATEREADY = 4; |
| 22826 |
| 22827 int get status(); |
| 22828 |
| 22829 void swapCache(); |
| 22830 |
| 22831 void update(); |
| 22832 |
| 22833 DOMApplicationCacheEvents get on(); |
| 22834 } |
| 22835 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22836 // for details. All rights reserved. Use of this source code is governed by a |
| 22837 // BSD-style license that can be found in the LICENSE file. |
| 22838 |
| 22839 class DOMApplicationCacheEventsImplementation extends EventsImplementation |
| 22840 implements DOMApplicationCacheEvents { |
| 22841 DOMApplicationCacheEventsImplementation._wrap(ptr) : super._wrap(ptr); |
| 22842 |
| 22843 EventListenerList get cached() => _get('cached'); |
| 22844 EventListenerList get checking() => _get('checking'); |
| 22845 EventListenerList get downloading() => _get('downloading'); |
| 22846 EventListenerList get error() => _get('error'); |
| 22847 EventListenerList get noUpdate() => _get('noupdate'); |
| 22848 EventListenerList get obsolete() => _get('obsolete'); |
| 22849 EventListenerList get progress() => _get('progress'); |
| 22850 EventListenerList get updateReady() => _get('updateready'); |
| 22851 } |
| 22852 |
| 22853 class DOMApplicationCacheWrappingImplementation extends EventTargetWrappingImple
mentation implements DOMApplicationCache { |
| 22854 DOMApplicationCacheWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 22855 |
| 22856 int get status() => _ptr.status; |
| 22857 |
| 22858 void swapCache() { |
| 22859 _ptr.swapCache(); |
| 22860 } |
| 22861 |
| 22862 void update() { |
| 22863 _ptr.update(); |
| 22864 } |
| 22865 |
| 22866 DOMApplicationCacheEvents get on() { |
| 22867 if (_on === null) { |
| 22868 _on = new DOMApplicationCacheEventsImplementation._wrap(_ptr); |
| 22869 } |
| 22870 return _on; |
| 22871 } |
| 22872 } |
| 22873 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22874 // for details. All rights reserved. Use of this source code is governed by a |
| 22875 // BSD-style license that can be found in the LICENSE file. |
| 22876 |
| 22877 class DOMWrapperBase { |
| 22878 final _ptr; |
| 22879 |
| 22880 DOMWrapperBase._wrap(this._ptr) { |
| 22881 // We should never be creating duplicate wrappers. |
| 22882 assert(_ptr.dartObjectLocalStorage === null); |
| 22883 _ptr.dartObjectLocalStorage = this; |
| 22884 } |
| 22885 } |
| 22886 |
| 22887 /** This function is provided for unittest purposes only. */ |
| 22888 unwrapDomObject(DOMWrapperBase wrapper) { |
| 22889 return wrapper._ptr; |
| 22890 }// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22891 // for details. All rights reserved. Use of this source code is governed by a |
| 22892 // BSD-style license that can be found in the LICENSE file. |
| 22893 |
| 22722 interface ElementList extends List<Element> { | 22894 interface ElementList extends List<Element> { |
| 22723 // TODO(jacobr): add element batch manipulation methods. | 22895 // TODO(jacobr): add element batch manipulation methods. |
| 22724 Element get first(); | 22896 Element get first(); |
| 22725 // TODO(jacobr): add insertAt | 22897 // TODO(jacobr): add insertAt |
| 22726 } | 22898 } |
| 22727 | 22899 |
| 22728 class DeferredElementRect { | 22900 class DeferredElementRect { |
| 22729 // TODO(jacobr) | 22901 // TODO(jacobr) |
| 22730 } | 22902 } |
| 22731 | 22903 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22779 EventListenerList get submit(); | 22951 EventListenerList get submit(); |
| 22780 EventListenerList get touchCancel(); | 22952 EventListenerList get touchCancel(); |
| 22781 EventListenerList get touchEnd(); | 22953 EventListenerList get touchEnd(); |
| 22782 EventListenerList get touchLeave(); | 22954 EventListenerList get touchLeave(); |
| 22783 EventListenerList get touchMove(); | 22955 EventListenerList get touchMove(); |
| 22784 EventListenerList get touchStart(); | 22956 EventListenerList get touchStart(); |
| 22785 EventListenerList get transitionEnd(); | 22957 EventListenerList get transitionEnd(); |
| 22786 EventListenerList get fullscreenChange(); | 22958 EventListenerList get fullscreenChange(); |
| 22787 } | 22959 } |
| 22788 | 22960 |
| 22961 /** |
| 22962 * All your element measurement needs in one place |
| 22963 */ |
| 22964 interface ElementRect { |
| 22965 ClientRect get client(); |
| 22966 ClientRect get offset(); |
| 22967 ClientRect get scroll(); |
| 22968 ClientRect get bounding(); |
| 22969 List<ClientRect> get clientRects(); |
| 22970 } |
| 22971 |
| 22972 |
| 22789 interface Element extends Node /*, common.NodeSelector, common.ElementTraversal
*/ | 22973 interface Element extends Node /*, common.NodeSelector, common.ElementTraversal
*/ |
| 22790 factory ElementWrappingImplementation { | 22974 factory ElementWrappingImplementation { |
| 22791 | 22975 |
| 22792 Element.html(String html); | 22976 Element.html(String html); |
| 22793 Element.tag(String tag); | 22977 Element.tag(String tag); |
| 22794 | 22978 |
| 22795 Map<String, String> get attributes(); | 22979 Map<String, String> get attributes(); |
| 22796 void set attributes(Map<String, String> value); | 22980 void set attributes(Map<String, String> value); |
| 22797 | 22981 |
| 22798 ElementList get elements(); | 22982 ElementList get elements(); |
| 22799 | 22983 |
| 22800 // TODO: The type of value should be Collection<Element>. See http://b/5392897 | 22984 // TODO: The type of value should be Collection<Element>. See http://b/5392897 |
| 22801 void set elements(value); | 22985 void set elements(value); |
| 22802 | 22986 |
| 22803 Set<String> get classes(); | 22987 Set<String> get classes(); |
| 22804 | 22988 |
| 22805 // TODO: The type of value should be Collection<String>. See http://b/5392897 | 22989 // TODO: The type of value should be Collection<String>. See http://b/5392897 |
| 22806 void set classes(value); | 22990 void set classes(value); |
| 22807 | 22991 |
| 22808 Map<String, String> get dataAttributes(); | 22992 Map<String, String> get dataAttributes(); |
| 22809 void set dataAttributes(Map<String, String> value); | 22993 void set dataAttributes(Map<String, String> value); |
| 22810 | 22994 |
| 22811 int get clientHeight(); | |
| 22812 | |
| 22813 int get clientLeft(); | |
| 22814 | |
| 22815 int get clientTop(); | |
| 22816 | |
| 22817 int get clientWidth(); | |
| 22818 | |
| 22819 String get contentEditable(); | 22995 String get contentEditable(); |
| 22820 | 22996 |
| 22821 void set contentEditable(String value); | 22997 void set contentEditable(String value); |
| 22822 | 22998 |
| 22823 String get dir(); | 22999 String get dir(); |
| 22824 | 23000 |
| 22825 void set dir(String value); | 23001 void set dir(String value); |
| 22826 | 23002 |
| 22827 bool get draggable(); | 23003 bool get draggable(); |
| 22828 | 23004 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 22845 bool get isContentEditable(); | 23021 bool get isContentEditable(); |
| 22846 | 23022 |
| 22847 String get lang(); | 23023 String get lang(); |
| 22848 | 23024 |
| 22849 void set lang(String value); | 23025 void set lang(String value); |
| 22850 | 23026 |
| 22851 Element get lastElementChild(); | 23027 Element get lastElementChild(); |
| 22852 | 23028 |
| 22853 Element get nextElementSibling(); | 23029 Element get nextElementSibling(); |
| 22854 | 23030 |
| 22855 int get offsetHeight(); | |
| 22856 | |
| 22857 int get offsetLeft(); | |
| 22858 | |
| 22859 Element get offsetParent(); | 23031 Element get offsetParent(); |
| 22860 | 23032 |
| 22861 int get offsetTop(); | |
| 22862 | |
| 22863 int get offsetWidth(); | |
| 22864 | |
| 22865 String get outerHTML(); | 23033 String get outerHTML(); |
| 22866 | 23034 |
| 22867 Element get previousElementSibling(); | 23035 Element get previousElementSibling(); |
| 22868 | 23036 |
| 22869 int get scrollHeight(); | |
| 22870 | |
| 22871 int get scrollLeft(); | |
| 22872 | |
| 22873 void set scrollLeft(int value); | 23037 void set scrollLeft(int value); |
| 22874 | 23038 |
| 22875 int get scrollTop(); | |
| 22876 | |
| 22877 void set scrollTop(int value); | 23039 void set scrollTop(int value); |
| 22878 | 23040 |
| 22879 int get scrollWidth(); | |
| 22880 | |
| 22881 bool get spellcheck(); | 23041 bool get spellcheck(); |
| 22882 | 23042 |
| 22883 void set spellcheck(bool value); | 23043 void set spellcheck(bool value); |
| 22884 | 23044 |
| 22885 CSSStyleDeclaration get style(); | 23045 CSSStyleDeclaration get style(); |
| 22886 | 23046 |
| 22887 int get tabIndex(); | 23047 int get tabIndex(); |
| 22888 | 23048 |
| 22889 void set tabIndex(int value); | 23049 void set tabIndex(int value); |
| 22890 | 23050 |
| 22891 String get tagName(); | 23051 String get tagName(); |
| 22892 | 23052 |
| 22893 String get title(); | 23053 String get title(); |
| 22894 | 23054 |
| 22895 void set title(String value); | 23055 void set title(String value); |
| 22896 | 23056 |
| 22897 String get webkitdropzone(); | 23057 String get webkitdropzone(); |
| 22898 | 23058 |
| 22899 void set webkitdropzone(String value); | 23059 void set webkitdropzone(String value); |
| 22900 | 23060 |
| 22901 void blur(); | 23061 void blur(); |
| 22902 | 23062 |
| 22903 void focus(); | 23063 void focus(); |
| 22904 | 23064 |
| 22905 ClientRect getBoundingClientRect(); | |
| 22906 | |
| 22907 List<ClientRect> getClientRects(); | |
| 22908 | |
| 22909 Element insertAdjacentElement([String where, Element element]); | 23065 Element insertAdjacentElement([String where, Element element]); |
| 22910 | 23066 |
| 22911 void insertAdjacentHTML([String position_OR_where, String text]); | 23067 void insertAdjacentHTML([String position_OR_where, String text]); |
| 22912 | 23068 |
| 22913 void insertAdjacentText([String where, String text]); | 23069 void insertAdjacentText([String where, String text]); |
| 22914 | 23070 |
| 22915 Element query(String selectors); | 23071 Element query(String selectors); |
| 22916 | 23072 |
| 22917 ElementList queryAll(String selectors); | 23073 ElementList queryAll(String selectors); |
| 22918 | 23074 |
| 22919 Element get parent(); | 23075 Element get parent(); |
| 22920 | 23076 |
| 22921 void scrollByLines([int lines]); | 23077 void scrollByLines([int lines]); |
| 22922 | 23078 |
| 22923 void scrollByPages([int pages]); | 23079 void scrollByPages([int pages]); |
| 22924 | 23080 |
| 22925 void scrollIntoView([bool centerIfNeeded]); | 23081 void scrollIntoView([bool centerIfNeeded]); |
| 22926 | 23082 |
| 22927 bool matchesSelector([String selectors]); | 23083 bool matchesSelector([String selectors]); |
| 22928 | 23084 |
| 23085 Future<ElementRect> get rect(); |
| 23086 |
| 23087 Future<CSSStyleDeclaration> get computedStyle(); |
| 23088 |
| 23089 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement); |
| 23090 |
| 22929 ElementEvents get on(); | 23091 ElementEvents get on(); |
| 22930 } | 23092 } |
| 22931 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 23093 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 22932 // for details. All rights reserved. Use of this source code is governed by a | 23094 // for details. All rights reserved. Use of this source code is governed by a |
| 22933 // BSD-style license that can be found in the LICENSE file. | 23095 // BSD-style license that can be found in the LICENSE file. |
| 22934 | 23096 |
| 22935 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. | 23097 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. |
| 22936 class _ChildrenElementList implements ElementList { | 23098 class _ChildrenElementList implements ElementList { |
| 22937 // Raw Element. | 23099 // Raw Element. |
| 22938 final _element; | 23100 final _element; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23041 } | 23203 } |
| 23042 | 23204 |
| 23043 void insertRange(int start, int length, [initialValue = null]) { | 23205 void insertRange(int start, int length, [initialValue = null]) { |
| 23044 throw const NotImplementedException(); | 23206 throw const NotImplementedException(); |
| 23045 } | 23207 } |
| 23046 | 23208 |
| 23047 List getRange(int start, int length) { | 23209 List getRange(int start, int length) { |
| 23048 throw const NotImplementedException(); | 23210 throw const NotImplementedException(); |
| 23049 } | 23211 } |
| 23050 | 23212 |
| 23051 int indexOf(Element element, int startIndex) { | 23213 int indexOf(Element element, [int start = 0]) { |
| 23052 return _Lists.indexOf(this, element, startIndex, this.length); | 23214 return _Lists.indexOf(this, element, start, this.length); |
| 23053 } | 23215 } |
| 23054 | 23216 |
| 23055 int lastIndexOf(Element element, int startIndex) { | 23217 int lastIndexOf(Element element, [int start = null]) { |
| 23056 return _Lists.lastIndexOf(this, element, startIndex); | 23218 if (start === null) start = length - 1; |
| 23219 return _Lists.lastIndexOf(this, element, start); |
| 23057 } | 23220 } |
| 23058 | 23221 |
| 23059 void clear() { | 23222 void clear() { |
| 23060 // It is unclear if we want to keep non element nodes? | 23223 // It is unclear if we want to keep non element nodes? |
| 23061 _element.textContent = ''; | 23224 _element.textContent = ''; |
| 23062 } | 23225 } |
| 23063 | 23226 |
| 23064 Element removeLast() { | 23227 Element removeLast() { |
| 23065 final last = this.last(); | 23228 final last = this.last(); |
| 23066 if (last != null) { | 23229 if (last != null) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23153 } | 23316 } |
| 23154 | 23317 |
| 23155 void insertRange(int start, int length, [initialValue = null]) { | 23318 void insertRange(int start, int length, [initialValue = null]) { |
| 23156 throw const NotImplementedException(); | 23319 throw const NotImplementedException(); |
| 23157 } | 23320 } |
| 23158 | 23321 |
| 23159 List getRange(int start, int length) { | 23322 List getRange(int start, int length) { |
| 23160 throw const NotImplementedException(); | 23323 throw const NotImplementedException(); |
| 23161 } | 23324 } |
| 23162 | 23325 |
| 23163 int indexOf(Element element, int startIndex) { | 23326 int indexOf(Element element, [int start = 0]) { |
| 23164 throw 'Not impl yet. todo(jacobr)'; | 23327 throw 'Not impl yet. todo(jacobr)'; |
| 23165 } | 23328 } |
| 23166 | 23329 |
| 23167 int lastIndexOf(Element element, int startIndex) { | 23330 int lastIndexOf(Element element, [int start = null]) { |
| 23168 throw 'Not impl yet. todo(jacobr)'; | 23331 throw 'Not impl yet. todo(jacobr)'; |
| 23169 } | 23332 } |
| 23170 | 23333 |
| 23171 void clear() { | 23334 void clear() { |
| 23172 throw 'Not impl yet. todo(jacobr)'; | 23335 throw 'Not impl yet. todo(jacobr)'; |
| 23173 } | 23336 } |
| 23174 | 23337 |
| 23175 Element removeLast() { | 23338 Element removeLast() { |
| 23176 throw 'Not impl yet. todo(jacobr)'; | 23339 throw 'Not impl yet. todo(jacobr)'; |
| 23177 } | 23340 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23334 EventListenerList get search() => _get("search"); | 23497 EventListenerList get search() => _get("search"); |
| 23335 EventListenerList get select() => _get("select"); | 23498 EventListenerList get select() => _get("select"); |
| 23336 EventListenerList get selectStart() => _get("selectstart"); | 23499 EventListenerList get selectStart() => _get("selectstart"); |
| 23337 EventListenerList get submit() => _get("submit"); | 23500 EventListenerList get submit() => _get("submit"); |
| 23338 EventListenerList get touchCancel() => _get("touchcancel"); | 23501 EventListenerList get touchCancel() => _get("touchcancel"); |
| 23339 EventListenerList get touchEnd() => _get("touchend"); | 23502 EventListenerList get touchEnd() => _get("touchend"); |
| 23340 EventListenerList get touchLeave() => _get("touchleave"); | 23503 EventListenerList get touchLeave() => _get("touchleave"); |
| 23341 EventListenerList get touchMove() => _get("touchmove"); | 23504 EventListenerList get touchMove() => _get("touchmove"); |
| 23342 EventListenerList get touchStart() => _get("touchstart"); | 23505 EventListenerList get touchStart() => _get("touchstart"); |
| 23343 EventListenerList get transitionEnd() => _get("webkitTransitionEnd"); | 23506 EventListenerList get transitionEnd() => _get("webkitTransitionEnd"); |
| 23344 EventListenerList get fullscreenChange() => _get("fullscreenchange"); | 23507 EventListenerList get fullscreenChange() => _get("webkitfullscreenchange"); |
| 23508 } |
| 23509 |
| 23510 class SimpleClientRect implements ClientRect { |
| 23511 final num left; |
| 23512 final num top; |
| 23513 final num width; |
| 23514 final num height; |
| 23515 num get right() => left + width; |
| 23516 num get bottom() => top + height; |
| 23517 |
| 23518 const SimpleClientRect(this.left, this.top, this.width, this.height); |
| 23519 |
| 23520 bool operator ==(ClientRect other) { |
| 23521 return other !== null && left == other.left && top == other.top |
| 23522 && width == other.width && height == other.height; |
| 23523 } |
| 23524 |
| 23525 String toString() => "($left, $top, $width, $height)"; |
| 23526 } |
| 23527 |
| 23528 // TODO(jacobr): we cannot currently be lazy about calculating the client |
| 23529 // rects as we must perform all measurement queries at a safe point to avoid |
| 23530 // triggering unneeded layouts. |
| 23531 /** |
| 23532 * All your element measurement needs in one place |
| 23533 */ |
| 23534 class ElementRectWrappingImplementation implements ElementRect { |
| 23535 final ClientRect client; |
| 23536 final ClientRect offset; |
| 23537 final ClientRect scroll; |
| 23538 |
| 23539 // TODO(jacobr): should we move these outside of ElementRect to avoid the |
| 23540 // overhead of computing them every time even though they are rarely used. |
| 23541 // This should be type dom.ClientRect but that fails on dartium. b/5522629 |
| 23542 final _boundingClientRect; |
| 23543 // an exception due to a dartium bug. |
| 23544 final dom.ClientRectList _clientRects; |
| 23545 |
| 23546 ElementRectWrappingImplementation(dom.HTMLElement element) : |
| 23547 client = new SimpleClientRect(element.clientLeft, |
| 23548 element.clientTop, |
| 23549 element.clientWidth, |
| 23550 element.clientHeight), |
| 23551 offset = new SimpleClientRect(element.offsetLeft, |
| 23552 element.offsetTop, |
| 23553 element.offsetWidth, |
| 23554 element.offsetHeight), |
| 23555 scroll = new SimpleClientRect(element.scrollLeft, |
| 23556 element.scrollTop, |
| 23557 element.scrollWidth, |
| 23558 element.scrollHeight), |
| 23559 _boundingClientRect = element.getBoundingClientRect(), |
| 23560 _clientRects = element.getClientRects(); |
| 23561 |
| 23562 ClientRect get bounding() => |
| 23563 LevelDom.wrapClientRect(_boundingClientRect); |
| 23564 |
| 23565 List<ClientRect> get clientRects() { |
| 23566 final out = new List(_clientRects.length); |
| 23567 for (num i = 0; i < _clientRects.length; i++) { |
| 23568 out[i] = LevelDom.wrapClientRect(_clientRects.item(i)); |
| 23569 } |
| 23570 return out; |
| 23571 } |
| 23345 } | 23572 } |
| 23346 | 23573 |
| 23347 class ElementWrappingImplementation extends NodeWrappingImplementation implement
s Element { | 23574 class ElementWrappingImplementation extends NodeWrappingImplementation implement
s Element { |
| 23575 |
| 23576 static final _START_TAG_REGEXP = const RegExp('<(\\w+)'); |
| 23577 static final _CUSTOM_PARENT_TAG_MAP = const { |
| 23578 'body' : 'html', |
| 23579 'head' : 'html', |
| 23580 'caption' : 'table', |
| 23581 'td': 'tr', |
| 23582 'tbody': 'table', |
| 23583 'colgroup': 'table', |
| 23584 'col' : 'colgroup', |
| 23585 'tr' : 'tbody', |
| 23586 'tbody' : 'table', |
| 23587 'tfoot' : 'table', |
| 23588 'thead' : 'table', |
| 23589 'track' : 'audio', |
| 23590 }; |
| 23348 | 23591 |
| 23349 factory ElementWrappingImplementation.html(String html) { | 23592 factory ElementWrappingImplementation.html(String html) { |
| 23350 final temp = dom.document.createElement('div'); | 23593 // TODO(jacobr): this method can be made more robust and performant. |
| 23594 // 1) Cache the dummy parent elements required to use innerHTML rather than |
| 23595 // creating them every call. |
| 23596 // 2) Verify that the html does not contain leading or trailing text nodes. |
| 23597 // 3) Verify that the html does not contain both <head> and <body> tags. |
| 23598 // 4) Detatch the created element from its dummy parent. |
| 23599 String parentTag = 'div'; |
| 23600 String tag; |
| 23601 final match = _START_TAG_REGEXP.firstMatch(html); |
| 23602 if (match !== null) { |
| 23603 tag = match.group(1).toLowerCase(); |
| 23604 if (_CUSTOM_PARENT_TAG_MAP.containsKey(tag)) { |
| 23605 parentTag = _CUSTOM_PARENT_TAG_MAP[tag]; |
| 23606 } |
| 23607 } |
| 23608 final temp = dom.document.createElement(parentTag); |
| 23351 temp.innerHTML = html; | 23609 temp.innerHTML = html; |
| 23352 | 23610 |
| 23353 if (temp.childElementCount != 1) { | 23611 if (temp.childElementCount == 1) { |
| 23612 return LevelDom.wrapElement(temp.firstElementChild); |
| 23613 } else if (parentTag == 'html' && temp.childElementCount == 2) { |
| 23614 // Work around for edge case in WebKit and possibly other browsers where |
| 23615 // both body and head elements are created even though the inner html |
| 23616 // only contains a head or body element. |
| 23617 return LevelDom.wrapElement(temp.children.item(tag == 'head' ? 0 : 1)); |
| 23618 } else { |
| 23354 throw 'HTML had ${temp.childElementCount} top level elements but 1 expecte
d'; | 23619 throw 'HTML had ${temp.childElementCount} top level elements but 1 expecte
d'; |
| 23355 } | 23620 } |
| 23356 | |
| 23357 return LevelDom.wrapElement(temp.firstElementChild); | |
| 23358 } | 23621 } |
| 23359 | 23622 |
| 23360 factory ElementWrappingImplementation.tag(String tag) { | 23623 factory ElementWrappingImplementation.tag(String tag) { |
| 23361 return LevelDom.wrapElement(dom.document.createElement(tag)); | 23624 return LevelDom.wrapElement(dom.document.createElement(tag)); |
| 23362 } | 23625 } |
| 23363 | 23626 |
| 23364 ElementWrappingImplementation._wrap(ptr) : super._wrap(ptr); | 23627 ElementWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 23365 | 23628 |
| 23366 ElementAttributeMap _elementAttributeMap; | 23629 ElementAttributeMap _elementAttributeMap; |
| 23367 ElementList _elements; | 23630 ElementList _elements; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23419 } | 23682 } |
| 23420 | 23683 |
| 23421 void set dataAttributes(Map<String, String> value) { | 23684 void set dataAttributes(Map<String, String> value) { |
| 23422 Map<String, String> dataAttributes = this.dataAttributes; | 23685 Map<String, String> dataAttributes = this.dataAttributes; |
| 23423 dataAttributes.clear(); | 23686 dataAttributes.clear(); |
| 23424 for (String key in value.getKeys()) { | 23687 for (String key in value.getKeys()) { |
| 23425 dataAttributes[key] = value[key]; | 23688 dataAttributes[key] = value[key]; |
| 23426 } | 23689 } |
| 23427 } | 23690 } |
| 23428 | 23691 |
| 23429 int get clientHeight() => _ptr.clientHeight; | |
| 23430 | |
| 23431 int get clientLeft() => _ptr.clientLeft; | |
| 23432 | |
| 23433 int get clientTop() => _ptr.clientTop; | |
| 23434 | |
| 23435 int get clientWidth() => _ptr.clientWidth; | |
| 23436 | |
| 23437 String get contentEditable() => _ptr.contentEditable; | 23692 String get contentEditable() => _ptr.contentEditable; |
| 23438 | 23693 |
| 23439 void set contentEditable(String value) { _ptr.contentEditable = value; } | 23694 void set contentEditable(String value) { _ptr.contentEditable = value; } |
| 23440 | 23695 |
| 23441 String get dir() => _ptr.dir; | 23696 String get dir() => _ptr.dir; |
| 23442 | 23697 |
| 23443 void set dir(String value) { _ptr.dir = value; } | 23698 void set dir(String value) { _ptr.dir = value; } |
| 23444 | 23699 |
| 23445 bool get draggable() => _ptr.draggable; | 23700 bool get draggable() => _ptr.draggable; |
| 23446 | 23701 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 23463 bool get isContentEditable() => _ptr.isContentEditable; | 23718 bool get isContentEditable() => _ptr.isContentEditable; |
| 23464 | 23719 |
| 23465 String get lang() => _ptr.lang; | 23720 String get lang() => _ptr.lang; |
| 23466 | 23721 |
| 23467 void set lang(String value) { _ptr.lang = value; } | 23722 void set lang(String value) { _ptr.lang = value; } |
| 23468 | 23723 |
| 23469 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); | 23724 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); |
| 23470 | 23725 |
| 23471 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); | 23726 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); |
| 23472 | 23727 |
| 23473 int get offsetHeight() => _ptr.offsetHeight; | |
| 23474 | |
| 23475 int get offsetLeft() => _ptr.offsetLeft; | |
| 23476 | |
| 23477 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); | 23728 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); |
| 23478 | 23729 |
| 23479 int get offsetTop() => _ptr.offsetTop; | |
| 23480 | |
| 23481 int get offsetWidth() => _ptr.offsetWidth; | |
| 23482 | |
| 23483 String get outerHTML() => _ptr.outerHTML; | 23730 String get outerHTML() => _ptr.outerHTML; |
| 23484 | 23731 |
| 23485 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); | 23732 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); |
| 23486 | 23733 |
| 23487 int get scrollHeight() => _ptr.scrollHeight; | |
| 23488 | |
| 23489 int get scrollLeft() => _ptr.scrollLeft; | |
| 23490 | |
| 23491 void set scrollLeft(int value) { _ptr.scrollLeft = value; } | |
| 23492 | |
| 23493 int get scrollTop() => _ptr.scrollTop; | |
| 23494 | |
| 23495 void set scrollTop(int value) { _ptr.scrollTop = value; } | |
| 23496 | |
| 23497 int get scrollWidth() => _ptr.scrollWidth; | |
| 23498 | |
| 23499 bool get spellcheck() => _ptr.spellcheck; | 23734 bool get spellcheck() => _ptr.spellcheck; |
| 23500 | 23735 |
| 23501 void set spellcheck(bool value) { _ptr.spellcheck = value; } | 23736 void set spellcheck(bool value) { _ptr.spellcheck = value; } |
| 23502 | 23737 |
| 23503 CSSStyleDeclaration get style() => LevelDom.wrapCSSStyleDeclaration(_ptr.style
); | 23738 CSSStyleDeclaration get style() => LevelDom.wrapCSSStyleDeclaration(_ptr.style
); |
| 23504 | 23739 |
| 23505 int get tabIndex() => _ptr.tabIndex; | 23740 int get tabIndex() => _ptr.tabIndex; |
| 23506 | 23741 |
| 23507 void set tabIndex(int value) { _ptr.tabIndex = value; } | 23742 void set tabIndex(int value) { _ptr.tabIndex = value; } |
| 23508 | 23743 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23521 } | 23756 } |
| 23522 | 23757 |
| 23523 bool contains(Node element) { | 23758 bool contains(Node element) { |
| 23524 return _ptr.contains(LevelDom.unwrap(element)); | 23759 return _ptr.contains(LevelDom.unwrap(element)); |
| 23525 } | 23760 } |
| 23526 | 23761 |
| 23527 void focus() { | 23762 void focus() { |
| 23528 _ptr.focus(); | 23763 _ptr.focus(); |
| 23529 } | 23764 } |
| 23530 | 23765 |
| 23531 ClientRect getBoundingClientRect() { | |
| 23532 return LevelDom.wrapClientRect(_ptr.getBoundingClientRect()); | |
| 23533 } | |
| 23534 | |
| 23535 List<ClientRect> getClientRects() { | |
| 23536 var rects = _ptr.getClientRects(); | |
| 23537 var out = new List(rects.length); | |
| 23538 for (var i = 0; i < rects.length; i++) { | |
| 23539 out.add(LevelDom.wrapClientRect(rects.item(i))); | |
| 23540 } | |
| 23541 return out; | |
| 23542 } | |
| 23543 | |
| 23544 Element insertAdjacentElement([String where = null, Element element = null]) { | 23766 Element insertAdjacentElement([String where = null, Element element = null]) { |
| 23545 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); | 23767 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); |
| 23546 } | 23768 } |
| 23547 | 23769 |
| 23548 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ | 23770 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ |
| 23549 _ptr.insertAdjacentHTML(position_OR_where, text); | 23771 _ptr.insertAdjacentHTML(position_OR_where, text); |
| 23550 } | 23772 } |
| 23551 | 23773 |
| 23552 void insertAdjacentText([String where = null, String text = null]) { | 23774 void insertAdjacentText([String where = null, String text = null]) { |
| 23553 _ptr.insertAdjacentText(where, text); | 23775 _ptr.insertAdjacentText(where, text); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 23572 } | 23794 } |
| 23573 | 23795 |
| 23574 void scrollIntoView([bool centerIfNeeded = null]) { | 23796 void scrollIntoView([bool centerIfNeeded = null]) { |
| 23575 _ptr.scrollIntoViewIfNeeded(centerIfNeeded); | 23797 _ptr.scrollIntoViewIfNeeded(centerIfNeeded); |
| 23576 } | 23798 } |
| 23577 | 23799 |
| 23578 bool matchesSelector([String selectors = null]) { | 23800 bool matchesSelector([String selectors = null]) { |
| 23579 return _ptr.webkitMatchesSelector(selectors); | 23801 return _ptr.webkitMatchesSelector(selectors); |
| 23580 } | 23802 } |
| 23581 | 23803 |
| 23804 void set scrollLeft(int value) { _ptr.scrollLeft = value; } |
| 23805 |
| 23806 void set scrollTop(int value) { _ptr.scrollTop = value; } |
| 23807 |
| 23808 Future<ElementRect> get rect() { |
| 23809 return _createMeasurementFuture( |
| 23810 () => new ElementRectWrappingImplementation(_ptr), |
| 23811 new Completer<ElementRect>()); |
| 23812 } |
| 23813 |
| 23814 Future<CSSStyleDeclaration> get computedStyle() { |
| 23815 // TODO(jacobr): last param should be null, see b/5045788 |
| 23816 return getComputedStyle(''); |
| 23817 } |
| 23818 |
| 23819 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { |
| 23820 return _createMeasurementFuture(() => |
| 23821 LevelDom.wrapCSSStyleDeclaration( |
| 23822 dom.window.getComputedStyle(_ptr, pseudoElement)), |
| 23823 new Completer<CSSStyleDeclaration>()); |
| 23824 } |
| 23825 |
| 23582 ElementEvents get on() { | 23826 ElementEvents get on() { |
| 23583 if (_on === null) { | 23827 if (_on === null) { |
| 23584 _on = new ElementEventsImplementation._wrap(_ptr); | 23828 _on = new ElementEventsImplementation._wrap(_ptr); |
| 23585 } | 23829 } |
| 23586 return _on; | 23830 return _on; |
| 23587 } | 23831 } |
| 23588 } | 23832 } |
| 23589 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 23833 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 23590 // for details. All rights reserved. Use of this source code is governed by a | 23834 // for details. All rights reserved. Use of this source code is governed by a |
| 23591 // BSD-style license that can be found in the LICENSE file. | 23835 // BSD-style license that can be found in the LICENSE file. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23703 void preventDefault(); | 23947 void preventDefault(); |
| 23704 | 23948 |
| 23705 void stopImmediatePropagation(); | 23949 void stopImmediatePropagation(); |
| 23706 | 23950 |
| 23707 void stopPropagation(); | 23951 void stopPropagation(); |
| 23708 } | 23952 } |
| 23709 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 23953 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 23710 // for details. All rights reserved. Use of this source code is governed by a | 23954 // for details. All rights reserved. Use of this source code is governed by a |
| 23711 // BSD-style license that can be found in the LICENSE file. | 23955 // BSD-style license that can be found in the LICENSE file. |
| 23712 | 23956 |
| 23713 class EventWrappingImplementation extends DOMWrapperBase implements Event { | |
| 23714 EventWrappingImplementation._wrap(ptr) : super._wrap(ptr); | |
| 23715 | |
| 23716 factory EventWrappingImplementation(String type, [bool canBubble = true, | |
| 23717 bool cancelable = true]) { | |
| 23718 final e = dom.document.createEvent("Event"); | |
| 23719 e.initEvent(type, canBubble, cancelable); | |
| 23720 return LevelDom.wrapEvent(e); | |
| 23721 } | |
| 23722 | |
| 23723 bool get bubbles() => _ptr.bubbles; | |
| 23724 | |
| 23725 bool get cancelBubble() => _ptr.cancelBubble; | |
| 23726 | |
| 23727 void set cancelBubble(bool value) { _ptr.cancelBubble = value; } | |
| 23728 | |
| 23729 bool get cancelable() => _ptr.cancelable; | |
| 23730 | |
| 23731 EventTarget get currentTarget() => LevelDom.wrapEventTarget(_ptr.currentTarget
); | |
| 23732 | |
| 23733 bool get defaultPrevented() => _ptr.defaultPrevented; | |
| 23734 | |
| 23735 int get eventPhase() => _ptr.eventPhase; | |
| 23736 | |
| 23737 bool get returnValue() => _ptr.returnValue; | |
| 23738 | |
| 23739 void set returnValue(bool value) { _ptr.returnValue = value; } | |
| 23740 | |
| 23741 EventTarget get srcElement() => LevelDom.wrapEventTarget(_ptr.srcElement); | |
| 23742 | |
| 23743 EventTarget get target() => LevelDom.wrapEventTarget(_ptr.target); | |
| 23744 | |
| 23745 int get timeStamp() => _ptr.timeStamp; | |
| 23746 | |
| 23747 String get type() => _ptr.type; | |
| 23748 | |
| 23749 void preventDefault() { | |
| 23750 _ptr.preventDefault(); | |
| 23751 return; | |
| 23752 } | |
| 23753 | |
| 23754 void stopImmediatePropagation() { | |
| 23755 _ptr.stopImmediatePropagation(); | |
| 23756 return; | |
| 23757 } | |
| 23758 | |
| 23759 void stopPropagation() { | |
| 23760 _ptr.stopPropagation(); | |
| 23761 return; | |
| 23762 } | |
| 23763 } | |
| 23764 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 23765 // for details. All rights reserved. Use of this source code is governed by a | |
| 23766 // BSD-style license that can be found in the LICENSE file. | |
| 23767 | |
| 23768 typedef void EventListener(Event event); | 23957 typedef void EventListener(Event event); |
| 23769 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 23958 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 23770 // for details. All rights reserved. Use of this source code is governed by a | 23959 // for details. All rights reserved. Use of this source code is governed by a |
| 23771 // BSD-style license that can be found in the LICENSE file. | 23960 // BSD-style license that can be found in the LICENSE file. |
| 23772 | 23961 |
| 23773 interface EventSourceEvents extends Events { | 23962 interface EventSourceEvents extends Events { |
| 23774 EventListenerList get error(); | 23963 EventListenerList get error(); |
| 23775 EventListenerList get message(); | 23964 EventListenerList get message(); |
| 23776 EventListenerList get open(); | 23965 EventListenerList get open(); |
| 23777 } | 23966 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23839 } | 24028 } |
| 23840 | 24029 |
| 23841 interface EventTarget { | 24030 interface EventTarget { |
| 23842 Events get on(); | 24031 Events get on(); |
| 23843 } | 24032 } |
| 23844 | 24033 |
| 23845 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 24034 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 23846 // for details. All rights reserved. Use of this source code is governed by a | 24035 // for details. All rights reserved. Use of this source code is governed by a |
| 23847 // BSD-style license that can be found in the LICENSE file. | 24036 // BSD-style license that can be found in the LICENSE file. |
| 23848 | 24037 |
| 23849 class _ListenerWrapper { | |
| 23850 final EventListener raw; | |
| 23851 final Function wrapped; | |
| 23852 final String type; | |
| 23853 final bool useCapture; | |
| 23854 | |
| 23855 _ListenerWrapper(this.raw, this.wrapped, this.type, this.useCapture); | |
| 23856 } | |
| 23857 | |
| 23858 class EventsImplementation implements Events { | 24038 class EventsImplementation implements Events { |
| 23859 /* raw event target. */ | 24039 /* Raw event target. */ |
| 23860 var _ptr; | 24040 var _ptr; |
| 23861 | 24041 |
| 23862 Map<String, EventListenerList> _listenerMap; | 24042 Map<String, EventListenerList> _listenerMap; |
| 23863 | 24043 |
| 23864 EventsImplementation._wrap(this._ptr) { | 24044 EventsImplementation._wrap(this._ptr) { |
| 23865 _listenerMap = <String, EventListenerList>{}; | 24045 _listenerMap = <String, EventListenerList>{}; |
| 23866 } | 24046 } |
| 23867 | 24047 |
| 23868 EventListenerList operator [](String type) { | 24048 EventListenerList operator [](String type) { |
| 23869 return _get(type.toLowerCase()); | 24049 return _get(type.toLowerCase()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 23895 _add(listener, useCapture); | 24075 _add(listener, useCapture); |
| 23896 return this; | 24076 return this; |
| 23897 } | 24077 } |
| 23898 | 24078 |
| 23899 EventListenerList remove(EventListener listener, [bool useCapture = false]) { | 24079 EventListenerList remove(EventListener listener, [bool useCapture = false]) { |
| 23900 _remove(listener, useCapture); | 24080 _remove(listener, useCapture); |
| 23901 return this; | 24081 return this; |
| 23902 } | 24082 } |
| 23903 | 24083 |
| 23904 bool dispatch(Event evt) { | 24084 bool dispatch(Event evt) { |
| 23905 // TODO(jacobr): what is the correct behavior here? | 24085 // TODO(jacobr): what is the correct behavior here. We could alternately |
| 24086 // force the event to have the expected type. |
| 23906 assert(evt.type == _type); | 24087 assert(evt.type == _type); |
| 23907 return _ptr.dispatchEvent(LevelDom.unwrap(evt)); | 24088 return _ptr.dispatchEvent(LevelDom.unwrap(evt)); |
| 23908 } | 24089 } |
| 23909 | 24090 |
| 23910 void _add(EventListener listener, bool useCapture) { | 24091 void _add(EventListener listener, bool useCapture) { |
| 23911 _ptr.addEventListener(_type, | 24092 _ptr.addEventListener(_type, |
| 23912 _findOrAddWrapper(listener, useCapture), | 24093 _findOrAddWrapper(listener, useCapture), |
| 23913 useCapture); | 24094 useCapture); |
| 23914 } | 24095 } |
| 23915 | 24096 |
| 23916 void _remove(EventListener listener, bool useCapture) { | 24097 void _remove(EventListener listener, bool useCapture) { |
| 23917 Function wrapper = _removeWrapper(listener, useCapture); | 24098 Function wrapper = _removeWrapper(listener, useCapture); |
| 23918 if (wrapper !== null) { | 24099 if (wrapper !== null) { |
| 23919 _ptr.removeEventListener(_type, wrapper, useCapture); | 24100 _ptr.removeEventListener(_type, wrapper, useCapture); |
| 23920 } | 24101 } |
| 23921 } | 24102 } |
| 23922 | 24103 |
| 23923 Function _removeWrapper(EventListener listener, bool useCapture) { | 24104 Function _removeWrapper(EventListener listener, bool useCapture) { |
| 23924 if (_wrappers === null) { | 24105 if (_wrappers === null) { |
| 23925 return null; | 24106 return null; |
| 23926 } | 24107 } |
| 23927 for (int i = 0; i < _wrappers.length; i++) { | 24108 for (int i = 0; i < _wrappers.length; i++) { |
| 23928 _EventListenerWrapper wrapper = _wrappers[i]; | 24109 _EventListenerWrapper wrapper = _wrappers[i]; |
| 23929 if (wrapper.raw === listener | 24110 if (wrapper.raw === listener && wrapper.useCapture == useCapture) { |
| 23930 && wrapper.useCapture == useCapture) { | |
| 23931 // Order doesn't matter so we swap with the last element instead of | 24111 // Order doesn't matter so we swap with the last element instead of |
| 23932 // performing a more expensive remove from the middle of the list. | 24112 // performing a more expensive remove from the middle of the list. |
| 23933 if (i + 1 != _wrappers.length) { | 24113 if (i + 1 != _wrappers.length) { |
| 23934 _wrappers[i] = _wrappers.removeLast(); | 24114 _wrappers[i] = _wrappers.removeLast(); |
| 23935 } else { | 24115 } else { |
| 23936 _wrappers.removeLast(); | 24116 _wrappers.removeLast(); |
| 23937 } | 24117 } |
| 23938 return wrapper.wrapped; | 24118 return wrapper.wrapped; |
| 23939 } | 24119 } |
| 23940 } | 24120 } |
| 23941 return null; | 24121 return null; |
| 23942 } | 24122 } |
| 23943 | 24123 |
| 23944 Function _findOrAddWrapper(EventListener listener, bool useCapture) { | 24124 Function _findOrAddWrapper(EventListener listener, bool useCapture) { |
| 23945 if (_wrappers === null) { | 24125 if (_wrappers === null) { |
| 23946 _wrappers = <_EventListenerWrapper>[]; | 24126 _wrappers = <_EventListenerWrapper>[]; |
| 23947 } else { | 24127 } else { |
| 23948 for (_EventListenerWrapper wrapper in _wrappers) { | 24128 for (_EventListenerWrapper wrapper in _wrappers) { |
| 23949 if (wrapper.raw === listener && wrapper.useCapture == useCapture) { | 24129 if (wrapper.raw === listener && wrapper.useCapture == useCapture) { |
| 23950 return wrapper.wrapped; | 24130 return wrapper.wrapped; |
| 23951 } | 24131 } |
| 23952 } | 24132 } |
| 23953 } | 24133 } |
| 23954 final wrapped = (e) => listener(LevelDom.wrapEvent(e)); | 24134 final wrapped = (e) { listener(LevelDom.wrapEvent(e)); }; |
| 23955 _wrappers.add(new _EventListenerWrapper(listener, wrapped, useCapture)); | 24135 _wrappers.add(new _EventListenerWrapper(listener, wrapped, useCapture)); |
| 23956 return wrapped; | 24136 return wrapped; |
| 23957 } | 24137 } |
| 23958 } | 24138 } |
| 23959 | 24139 |
| 23960 class EventTargetWrappingImplementation extends DOMWrapperBase implements EventT
arget { | 24140 class EventTargetWrappingImplementation extends DOMWrapperBase implements EventT
arget { |
| 23961 Events _on; | 24141 Events _on; |
| 23962 | 24142 |
| 23963 EventTargetWrappingImplementation._wrap(ptr) : super._wrap(ptr); | 24143 EventTargetWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 23964 | 24144 |
| 23965 Events get on() { | 24145 Events get on() { |
| 23966 if (_on === null) { | 24146 if (_on === null) { |
| 23967 _on = new EventsImplementation._wrap(_ptr); | 24147 _on = new EventsImplementation._wrap(_ptr); |
| 23968 } | 24148 } |
| 23969 return _on; | 24149 return _on; |
| 23970 } | 24150 } |
| 23971 } | 24151 } |
| 23972 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 24152 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 23973 // for details. All rights reserved. Use of this source code is governed by a | 24153 // for details. All rights reserved. Use of this source code is governed by a |
| 23974 // BSD-style license that can be found in the LICENSE file. | 24154 // BSD-style license that can be found in the LICENSE file. |
| 23975 | 24155 |
| 24156 class EventWrappingImplementation extends DOMWrapperBase implements Event { |
| 24157 EventWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 24158 |
| 24159 factory EventWrappingImplementation(String type, [bool canBubble = true, |
| 24160 bool cancelable = true]) { |
| 24161 final e = dom.document.createEvent("Event"); |
| 24162 e.initEvent(type, canBubble, cancelable); |
| 24163 return LevelDom.wrapEvent(e); |
| 24164 } |
| 24165 |
| 24166 bool get bubbles() => _ptr.bubbles; |
| 24167 |
| 24168 bool get cancelBubble() => _ptr.cancelBubble; |
| 24169 |
| 24170 void set cancelBubble(bool value) { _ptr.cancelBubble = value; } |
| 24171 |
| 24172 bool get cancelable() => _ptr.cancelable; |
| 24173 |
| 24174 EventTarget get currentTarget() => LevelDom.wrapEventTarget(_ptr.currentTarget
); |
| 24175 |
| 24176 bool get defaultPrevented() => _ptr.defaultPrevented; |
| 24177 |
| 24178 int get eventPhase() => _ptr.eventPhase; |
| 24179 |
| 24180 bool get returnValue() => _ptr.returnValue; |
| 24181 |
| 24182 void set returnValue(bool value) { _ptr.returnValue = value; } |
| 24183 |
| 24184 EventTarget get srcElement() => LevelDom.wrapEventTarget(_ptr.srcElement); |
| 24185 |
| 24186 EventTarget get target() => LevelDom.wrapEventTarget(_ptr.target); |
| 24187 |
| 24188 int get timeStamp() => _ptr.timeStamp; |
| 24189 |
| 24190 String get type() => _ptr.type; |
| 24191 |
| 24192 void preventDefault() { |
| 24193 _ptr.preventDefault(); |
| 24194 return; |
| 24195 } |
| 24196 |
| 24197 void stopImmediatePropagation() { |
| 24198 _ptr.stopImmediatePropagation(); |
| 24199 return; |
| 24200 } |
| 24201 |
| 24202 void stopPropagation() { |
| 24203 _ptr.stopPropagation(); |
| 24204 return; |
| 24205 } |
| 24206 } |
| 24207 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 24208 // for details. All rights reserved. Use of this source code is governed by a |
| 24209 // BSD-style license that can be found in the LICENSE file. |
| 24210 |
| 23976 var secretWindow; | 24211 var secretWindow; |
| 23977 var secretDocument; | 24212 var secretDocument; |
| 23978 | 24213 |
| 23979 Window get window() { | 24214 Window get window() { |
| 23980 if (secretWindow === null) { | 24215 if (secretWindow === null) { |
| 23981 LevelDom.initialize(dom.window); | 24216 LevelDom.initialize(dom.window); |
| 23982 } | 24217 } |
| 23983 return secretWindow; | 24218 return secretWindow; |
| 23984 } | 24219 } |
| 23985 | 24220 |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24620 | 24855 |
| 24621 bool get metaKey() => _ptr.metaKey; | 24856 bool get metaKey() => _ptr.metaKey; |
| 24622 | 24857 |
| 24623 bool get shiftKey() => _ptr.shiftKey; | 24858 bool get shiftKey() => _ptr.shiftKey; |
| 24624 | 24859 |
| 24625 bool getModifierState(String keyIdentifierArg) { | 24860 bool getModifierState(String keyIdentifierArg) { |
| 24626 return _ptr.getModifierState(keyIdentifierArg); | 24861 return _ptr.getModifierState(keyIdentifierArg); |
| 24627 } | 24862 } |
| 24628 } | 24863 } |
| 24629 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 24864 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 24865 // for details. All rights reserved. Use of this source code is governed by a |
| 24866 // BSD-style license that can be found in the LICENSE file. |
| 24867 |
| 24868 typedef Object ComputeValue(); |
| 24869 |
| 24870 class _MeasurementRequest<T> { |
| 24871 final ComputeValue computeValue; |
| 24872 final Completer<T> completer; |
| 24873 Object value; |
| 24874 bool exception = false; |
| 24875 _MeasurementRequest(this.computeValue, this.completer); |
| 24876 } |
| 24877 |
| 24878 final _MEASUREMENT_MESSAGE = "DART-MEASURE"; |
| 24879 List<_MeasurementRequest> _pendingRequests; |
| 24880 List<TimeoutHandler> _pendingMeasurementFrameCallbacks; |
| 24881 bool _nextMeasurementFrameScheduled = false; |
| 24882 bool _firstMeasurementRequest = true; |
| 24883 |
| 24884 void _maybeScheduleMeasurementFrame() { |
| 24885 if (_nextMeasurementFrameScheduled) return; |
| 24886 |
| 24887 _nextMeasurementFrameScheduled = true; |
| 24888 // postMessage gives us a way to receive a callback after the current |
| 24889 // event listener has unwound but before the browser has repainted. |
| 24890 if (_firstMeasurementRequest) { |
| 24891 // Messages from other windows do not cause a security risk as |
| 24892 // all we care about is that _onCompleteMeasurementRequests is called |
| 24893 // after the current event loop is unwound and calling the function is |
| 24894 // a noop when zero requests are pending. |
| 24895 window.on.message.add((e) => _completeMeasurementFutures()); |
| 24896 _firstMeasurementRequest = false; |
| 24897 } |
| 24898 |
| 24899 // TODO(jacobr): other mechanisms such as setImmediate and |
| 24900 // requestAnimationFrame may work better of platforms that support them. |
| 24901 // The key is we need a way to execute code immediately after the current |
| 24902 // event listener queue unwinds. |
| 24903 window.postMessage(_MEASUREMENT_MESSAGE, "*"); |
| 24904 } |
| 24905 |
| 24906 /** |
| 24907 * Registers a [callback] which is called after the next batch of measurements |
| 24908 * completes. Even if no measurements completed, the callback is triggered |
| 24909 * when they would have completed to avoid confusing bugs if it happened that |
| 24910 * no measurements were actually requested. |
| 24911 */ |
| 24912 void _addMeasurementFrameCallback(TimeoutHandler callback) { |
| 24913 if (_pendingMeasurementFrameCallbacks === null) { |
| 24914 _pendingMeasurementFrameCallbacks = <TimeoutHandler>[]; |
| 24915 _maybeScheduleMeasurementFrame(); |
| 24916 } |
| 24917 _pendingMeasurementFrameCallbacks.add(callback); |
| 24918 } |
| 24919 |
| 24920 /** |
| 24921 * Returns a [Future] whose value will be the result of evaluating |
| 24922 * [computeValue] during the next safe measurement interval. |
| 24923 * The next safe measurement interval is after the current event loop has |
| 24924 * unwound but before the browser has rendered the page. |
| 24925 * It is important that the [computeValue] function only queries the html |
| 24926 * layout and html in any way. |
| 24927 */ |
| 24928 Future _createMeasurementFuture(ComputeValue computeValue, |
| 24929 Completer completer) { |
| 24930 if (_pendingRequests === null) { |
| 24931 _pendingRequests = <_MeasurementRequest>[]; |
| 24932 _maybeScheduleMeasurementFrame(); |
| 24933 } |
| 24934 _pendingRequests.add(new _MeasurementRequest(computeValue, completer)); |
| 24935 return completer.future; |
| 24936 } |
| 24937 |
| 24938 /** |
| 24939 * Complete all pending measurement futures evaluating them in a single batch |
| 24940 * so that the the browser is guaranteed to avoid multiple layouts. |
| 24941 */ |
| 24942 void _completeMeasurementFutures() { |
| 24943 if (_nextMeasurementFrameScheduled == false) { |
| 24944 // Ignore spurious call to this function. |
| 24945 return; |
| 24946 } |
| 24947 |
| 24948 _nextMeasurementFrameScheduled = false; |
| 24949 // We must compute all new values before fulfilling the futures as |
| 24950 // the onComplete callbacks for the futures could modify the DOM making |
| 24951 // subsequent measurement calculations expensive to compute. |
| 24952 for (_MeasurementRequest request in _pendingRequests) { |
| 24953 try { |
| 24954 request.value = request.computeValue(); |
| 24955 } catch(var e) { |
| 24956 request.value = e; |
| 24957 request.exception = true; |
| 24958 } |
| 24959 } |
| 24960 |
| 24961 final completedRequests = _pendingRequests; |
| 24962 final readyMeasurementFrameCallbacks = _pendingMeasurementFrameCallbacks; |
| 24963 _pendingRequests = null; |
| 24964 _pendingMeasurementFrameCallbacks = null; |
| 24965 for (_MeasurementRequest request in completedRequests) { |
| 24966 if (request.exception) { |
| 24967 request.completer.completeException(request.value); |
| 24968 } else { |
| 24969 request.completer.complete(request.value); |
| 24970 } |
| 24971 } |
| 24972 |
| 24973 if (readyMeasurementFrameCallbacks !== null) { |
| 24974 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { |
| 24975 // TODO(jacobr): wrap each call to a handler in a try-catch block. |
| 24976 handler(); |
| 24977 } |
| 24978 } |
| 24979 } |
| 24980 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 24630 // for details. All rights reserved. Use of this source code is governed by a | 24981 // for details. All rights reserved. Use of this source code is governed by a |
| 24631 // BSD-style license that can be found in the LICENSE file. | 24982 // BSD-style license that can be found in the LICENSE file. |
| 24632 | 24983 |
| 24633 interface MessageEvent extends Event factory MessageEventWrappingImplementation
{ | 24984 interface MessageEvent extends Event factory MessageEventWrappingImplementation
{ |
| 24634 | 24985 |
| 24635 MessageEvent(String type, String data, String origin, String lastEventId, | 24986 MessageEvent(String type, String data, String origin, String lastEventId, |
| 24636 Window source, [bool canBubble, bool cancelable, MessagePort port]); | 24987 Window source, [bool canBubble, bool cancelable, MessagePort port]); |
| 24637 | 24988 |
| 24638 String get data(); | 24989 String get data(); |
| 24639 | 24990 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24996 } | 25347 } |
| 24997 | 25348 |
| 24998 void insertRange(int start, int length, [initialValue = null]) { | 25349 void insertRange(int start, int length, [initialValue = null]) { |
| 24999 throw const NotImplementedException(); | 25350 throw const NotImplementedException(); |
| 25000 } | 25351 } |
| 25001 | 25352 |
| 25002 List getRange(int start, int length) { | 25353 List getRange(int start, int length) { |
| 25003 throw const NotImplementedException(); | 25354 throw const NotImplementedException(); |
| 25004 } | 25355 } |
| 25005 | 25356 |
| 25006 int indexOf(Node element, int startIndex) { | 25357 int indexOf(Node element, [int start = 0]) { |
| 25007 return _Lists.indexOf(this, element, startIndex, this.length); | 25358 return _Lists.indexOf(this, element, start, this.length); |
| 25008 } | 25359 } |
| 25009 | 25360 |
| 25010 int lastIndexOf(Node element, int startIndex) { | 25361 int lastIndexOf(Node element, [int start = null]) { |
| 25011 return _Lists.lastIndexOf(this, element, startIndex); | 25362 if (start === null) start = length - 1; |
| 25363 return _Lists.lastIndexOf(this, element, start); |
| 25012 } | 25364 } |
| 25013 | 25365 |
| 25014 void clear() { | 25366 void clear() { |
| 25015 _node.textContent = ''; | 25367 _node.textContent = ''; |
| 25016 } | 25368 } |
| 25017 | 25369 |
| 25018 Node removeLast() { | 25370 Node removeLast() { |
| 25019 final last = this.last(); | 25371 final last = this.last(); |
| 25020 if (last != null) { | 25372 if (last != null) { |
| 25021 _node.removeChild(LevelDom.unwrap(last)); | 25373 _node.removeChild(LevelDom.unwrap(last)); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 25385 String get wholeText(); | 25737 String get wholeText(); |
| 25386 | 25738 |
| 25387 Text replaceWholeText([String content]); | 25739 Text replaceWholeText([String content]); |
| 25388 | 25740 |
| 25389 Text splitText([int offset]); | 25741 Text splitText([int offset]); |
| 25390 } | 25742 } |
| 25391 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 25743 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 25392 // for details. All rights reserved. Use of this source code is governed by a | 25744 // for details. All rights reserved. Use of this source code is governed by a |
| 25393 // BSD-style license that can be found in the LICENSE file. | 25745 // BSD-style license that can be found in the LICENSE file. |
| 25394 | 25746 |
| 25747 interface TextEvent extends UIEvent factory TextEventWrappingImplementation { |
| 25748 |
| 25749 TextEvent(String type, Window view, String data, [bool canBubble, |
| 25750 bool cancelable]); |
| 25751 |
| 25752 String get data(); |
| 25753 } |
| 25754 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 25755 // for details. All rights reserved. Use of this source code is governed by a |
| 25756 // BSD-style license that can be found in the LICENSE file. |
| 25757 |
| 25758 class TextEventWrappingImplementation extends UIEventWrappingImplementation impl
ements TextEvent { |
| 25759 TextEventWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 25760 |
| 25761 factory TextEventWrappingImplementation(String type, Window view, String data, |
| 25762 [bool canBubble = true, bool cancelable = true]) { |
| 25763 final e = dom.document.createEvent("TextEvent"); |
| 25764 e.initTextEvent(type, canBubble, cancelable, LevelDom.unwrap(view), data); |
| 25765 return LevelDom.wrapTextEvent(e); |
| 25766 } |
| 25767 |
| 25768 String get data() => _ptr.data; |
| 25769 } |
| 25770 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 25771 // for details. All rights reserved. Use of this source code is governed by a |
| 25772 // BSD-style license that can be found in the LICENSE file. |
| 25773 |
| 25395 class TextWrappingImplementation extends CharacterDataWrappingImplementation imp
lements Text { | 25774 class TextWrappingImplementation extends CharacterDataWrappingImplementation imp
lements Text { |
| 25396 factory TextWrappingImplementation(String content) { | 25775 factory TextWrappingImplementation(String content) { |
| 25397 return new TextWrappingImplementation._wrap( | 25776 return new TextWrappingImplementation._wrap( |
| 25398 dom.document.createTextNode(content)); | 25777 dom.document.createTextNode(content)); |
| 25399 } | 25778 } |
| 25400 | 25779 |
| 25401 TextWrappingImplementation._wrap(ptr) : super._wrap(ptr); | 25780 TextWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 25402 | 25781 |
| 25403 String get wholeText() => _ptr.wholeText; | 25782 String get wholeText() => _ptr.wholeText; |
| 25404 | 25783 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 25415 return LevelDom.wrapText(_ptr.splitText()); | 25794 return LevelDom.wrapText(_ptr.splitText()); |
| 25416 } else { | 25795 } else { |
| 25417 return LevelDom.wrapText(_ptr.splitText(offset)); | 25796 return LevelDom.wrapText(_ptr.splitText(offset)); |
| 25418 } | 25797 } |
| 25419 } | 25798 } |
| 25420 } | 25799 } |
| 25421 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 25800 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 25422 // for details. All rights reserved. Use of this source code is governed by a | 25801 // for details. All rights reserved. Use of this source code is governed by a |
| 25423 // BSD-style license that can be found in the LICENSE file. | 25802 // BSD-style license that can be found in the LICENSE file. |
| 25424 | 25803 |
| 25425 interface TextEvent extends UIEvent factory TextEventWrappingImplementation { | |
| 25426 | |
| 25427 TextEvent(String type, Window view, String data, [bool canBubble, | |
| 25428 bool cancelable]); | |
| 25429 | |
| 25430 String get data(); | |
| 25431 } | |
| 25432 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 25433 // for details. All rights reserved. Use of this source code is governed by a | |
| 25434 // BSD-style license that can be found in the LICENSE file. | |
| 25435 | |
| 25436 class TextEventWrappingImplementation extends UIEventWrappingImplementation impl
ements TextEvent { | |
| 25437 TextEventWrappingImplementation._wrap(ptr) : super._wrap(ptr); | |
| 25438 | |
| 25439 factory TextEventWrappingImplementation(String type, Window view, String data, | |
| 25440 [bool canBubble = true, bool cancelable = true]) { | |
| 25441 final e = dom.document.createEvent("TextEvent"); | |
| 25442 e.initTextEvent(type, canBubble, cancelable, LevelDom.unwrap(view), data); | |
| 25443 return LevelDom.wrapTextEvent(e); | |
| 25444 } | |
| 25445 | |
| 25446 String get data() => _ptr.data; | |
| 25447 } | |
| 25448 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 25449 // for details. All rights reserved. Use of this source code is governed by a | |
| 25450 // BSD-style license that can be found in the LICENSE file. | |
| 25451 | |
| 25452 typedef void TimeoutHandler(); | 25804 typedef void TimeoutHandler(); |
| 25453 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 25805 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 25454 // for details. All rights reserved. Use of this source code is governed by a | 25806 // for details. All rights reserved. Use of this source code is governed by a |
| 25455 // BSD-style license that can be found in the LICENSE file. | 25807 // BSD-style license that can be found in the LICENSE file. |
| 25456 | 25808 |
| 25457 interface TouchEvent extends UIEvent factory TouchEventWrappingImplementation { | 25809 interface TouchEvent extends UIEvent factory TouchEventWrappingImplementation { |
| 25458 | 25810 |
| 25459 TouchEvent(TouchList touches, TouchList targetTouches, | 25811 TouchEvent(TouchList touches, TouchList targetTouches, |
| 25460 TouchList changedTouches, String type, Window view, int screenX, | 25812 TouchList changedTouches, String type, Window view, int screenX, |
| 25461 int screenY, int clientX, int clientY, [bool ctrlKey, bool altKey, | 25813 int screenY, int clientX, int clientY, [bool ctrlKey, bool altKey, |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 26050 void close(); | 26402 void close(); |
| 26051 | 26403 |
| 26052 bool confirm([String message]); | 26404 bool confirm([String message]); |
| 26053 | 26405 |
| 26054 FileReader createFileReader(); | 26406 FileReader createFileReader(); |
| 26055 | 26407 |
| 26056 bool find([String string, bool caseSensitive, bool backwards, bool wrap, bool
wholeWord, bool searchInFrames, bool showDialog]); | 26408 bool find([String string, bool caseSensitive, bool backwards, bool wrap, bool
wholeWord, bool searchInFrames, bool showDialog]); |
| 26057 | 26409 |
| 26058 void focus(); | 26410 void focus(); |
| 26059 | 26411 |
| 26060 CSSStyleDeclaration getComputedStyle([Element element, String pseudoElement]); | |
| 26061 | |
| 26062 DOMSelection getSelection(); | 26412 DOMSelection getSelection(); |
| 26063 | 26413 |
| 26064 MediaQueryList matchMedia(String query); | 26414 MediaQueryList matchMedia(String query); |
| 26065 | 26415 |
| 26066 void moveBy(num x, num y); | 26416 void moveBy(num x, num y); |
| 26067 | 26417 |
| 26068 void moveTo(num x, num y); | 26418 void moveTo(num x, num y); |
| 26069 | 26419 |
| 26070 Window open(String url, String target, [String features]); | 26420 Window open(String url, String target, [String features]); |
| 26071 | 26421 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26082 void resizeTo(num width, num height); | 26432 void resizeTo(num width, num height); |
| 26083 | 26433 |
| 26084 void scroll(int x, int y); | 26434 void scroll(int x, int y); |
| 26085 | 26435 |
| 26086 void scrollBy(int x, int y); | 26436 void scrollBy(int x, int y); |
| 26087 | 26437 |
| 26088 void scrollTo(int x, int y); | 26438 void scrollTo(int x, int y); |
| 26089 | 26439 |
| 26090 int setInterval(TimeoutHandler handler, int timeout); | 26440 int setInterval(TimeoutHandler handler, int timeout); |
| 26091 | 26441 |
| 26092 int setTimeout([TimeoutHandler handler, int timeout]); | 26442 int setTimeout(TimeoutHandler handler, int timeout); |
| 26093 | 26443 |
| 26094 Object showModalDialog(String url, [Object dialogArgs, String featureArgs]); | 26444 Object showModalDialog(String url, [Object dialogArgs, String featureArgs]); |
| 26095 | 26445 |
| 26096 void stop(); | 26446 void stop(); |
| 26097 | 26447 |
| 26098 void webkitCancelRequestAnimationFrame(int id); | 26448 void webkitCancelRequestAnimationFrame(int id); |
| 26099 | 26449 |
| 26450 // TODO(jacobr): make these return Future<Point>. |
| 26100 Point webkitConvertPointFromNodeToPage([Node node, Point p]); | 26451 Point webkitConvertPointFromNodeToPage([Node node, Point p]); |
| 26101 | 26452 |
| 26102 Point webkitConvertPointFromPageToNode([Node node, Point p]); | 26453 Point webkitConvertPointFromPageToNode([Node node, Point p]); |
| 26103 | 26454 |
| 26104 int webkitRequestAnimationFrame(RequestAnimationFrameCallback callback, [Eleme
nt element]); | 26455 int webkitRequestAnimationFrame(RequestAnimationFrameCallback callback, [Eleme
nt element]); |
| 26105 | 26456 |
| 26457 /** |
| 26458 * Executes a [callback] after the next batch of browser layout measurements |
| 26459 * has completed or would have completed if any browser layout measurements |
| 26460 * had been scheduled. |
| 26461 */ |
| 26462 void requestLayoutFrame(TimeoutHandler callback); |
| 26463 |
| 26106 // Window open(String url, String target, WindowSpec features); | 26464 // Window open(String url, String target, WindowSpec features); |
| 26107 | 26465 |
| 26108 WindowEvents get on(); | 26466 WindowEvents get on(); |
| 26109 } | 26467 } |
| 26110 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 26468 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 26111 // for details. All rights reserved. Use of this source code is governed by a | 26469 // for details. All rights reserved. Use of this source code is governed by a |
| 26112 // BSD-style license that can be found in the LICENSE file. | 26470 // BSD-style license that can be found in the LICENSE file. |
| 26113 | 26471 |
| 26114 // TODO(jacobr): define a base class containing the overlap between | 26472 // TODO(jacobr): define a base class containing the overlap between |
| 26115 // this class and ElementEvents. | 26473 // this class and ElementEvents. |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 26699 } | 27057 } |
| 26700 | 27058 |
| 26701 bool confirm([String message = null]) { | 27059 bool confirm([String message = null]) { |
| 26702 if (message === null) { | 27060 if (message === null) { |
| 26703 return _ptr.confirm(); | 27061 return _ptr.confirm(); |
| 26704 } else { | 27062 } else { |
| 26705 return _ptr.confirm(message); | 27063 return _ptr.confirm(message); |
| 26706 } | 27064 } |
| 26707 } | 27065 } |
| 26708 | 27066 |
| 26709 FileReader createFileReader() { | 27067 FileReader createFileReader() => |
| 26710 return LevelDom.wrapFileReader(_ptr.createFileReader()); | 27068 LevelDom.wrapFileReader(_ptr.createFileReader()); |
| 26711 } | |
| 26712 | 27069 |
| 26713 CSSMatrix createCSSMatrix([String cssValue = null]) { | 27070 CSSMatrix createCSSMatrix([String cssValue = null]) { |
| 26714 if (cssValue === null) { | 27071 if (cssValue === null) { |
| 26715 return LevelDom.wrapCSSMatrix(_ptr.createWebKitCSSMatrix()); | 27072 return LevelDom.wrapCSSMatrix(_ptr.createWebKitCSSMatrix()); |
| 26716 } else { | 27073 } else { |
| 26717 return LevelDom.wrapCSSMatrix(_ptr.createWebKitCSSMatrix(cssValue)); | 27074 return LevelDom.wrapCSSMatrix(_ptr.createWebKitCSSMatrix(cssValue)); |
| 26718 } | 27075 } |
| 26719 } | 27076 } |
| 26720 | 27077 |
| 26721 bool find([String string = null, bool caseSensitive = null, bool backwards = n
ull, bool wrap = null, bool wholeWord = null, bool searchInFrames = null, bool s
howDialog = null]) { | 27078 bool find([String string = null, bool caseSensitive = null, bool backwards = n
ull, bool wrap = null, bool wholeWord = null, bool searchInFrames = null, bool s
howDialog = null]) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 26790 } | 27147 } |
| 26791 } | 27148 } |
| 26792 } | 27149 } |
| 26793 throw "Incorrect number or type of arguments"; | 27150 throw "Incorrect number or type of arguments"; |
| 26794 } | 27151 } |
| 26795 | 27152 |
| 26796 void focus() { | 27153 void focus() { |
| 26797 _ptr.focus(); | 27154 _ptr.focus(); |
| 26798 } | 27155 } |
| 26799 | 27156 |
| 26800 CSSStyleDeclaration getComputedStyle([Element element = null, String pseudoEle
ment = null]) { | 27157 DOMSelection getSelection() => |
| 26801 if (element === null) { | 27158 LevelDom.wrapDOMSelection(_ptr.getSelection()); |
| 26802 if (pseudoElement === null) { | |
| 26803 return LevelDom.wrapCSSStyleDeclaration(_ptr.getComputedStyle()); | |
| 26804 } | |
| 26805 } else { | |
| 26806 if (pseudoElement === null) { | |
| 26807 return LevelDom.wrapCSSStyleDeclaration(_ptr.getComputedStyle(LevelDom.u
nwrap(element))); | |
| 26808 } else { | |
| 26809 return LevelDom.wrapCSSStyleDeclaration(_ptr.getComputedStyle(LevelDom.u
nwrap(element), pseudoElement)); | |
| 26810 } | |
| 26811 } | |
| 26812 throw "Incorrect number or type of arguments"; | |
| 26813 } | |
| 26814 | |
| 26815 DOMSelection getSelection() { | |
| 26816 return LevelDom.wrapDOMSelection(_ptr.getSelection()); | |
| 26817 } | |
| 26818 | 27159 |
| 26819 MediaQueryList matchMedia(String query) { | 27160 MediaQueryList matchMedia(String query) { |
| 26820 return LevelDom.wrapMediaQueryList(_ptr.matchMedia(query)); | 27161 return LevelDom.wrapMediaQueryList(_ptr.matchMedia(query)); |
| 26821 } | 27162 } |
| 26822 | 27163 |
| 26823 void moveBy(num x, num y) { | 27164 void moveBy(num x, num y) { |
| 26824 _ptr.moveBy(x, y); | 27165 _ptr.moveBy(x, y); |
| 26825 } | 27166 } |
| 26826 | 27167 |
| 26827 void moveTo(num x, num y) { | 27168 void moveTo(num x, num y) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 26890 } | 27231 } |
| 26891 | 27232 |
| 26892 void scrollBy(int x, int y) { | 27233 void scrollBy(int x, int y) { |
| 26893 _ptr.scrollBy(x, y); | 27234 _ptr.scrollBy(x, y); |
| 26894 } | 27235 } |
| 26895 | 27236 |
| 26896 void scrollTo(int x, int y) { | 27237 void scrollTo(int x, int y) { |
| 26897 _ptr.scrollTo(x, y); | 27238 _ptr.scrollTo(x, y); |
| 26898 } | 27239 } |
| 26899 | 27240 |
| 26900 int setInterval(TimeoutHandler handler, int timeout) { | 27241 int setInterval(TimeoutHandler handler, int timeout) => |
| 26901 return _ptr.setInterval(handler, timeout); | 27242 _ptr.setInterval(handler, timeout); |
| 26902 } | |
| 26903 | 27243 |
| 26904 int setTimeout([TimeoutHandler handler = null, int timeout = null]) { | 27244 int setTimeout(TimeoutHandler handler, int timeout) => |
| 26905 if (handler === null) { | 27245 _ptr.setTimeout(handler, timeout); |
| 26906 if (timeout === null) { | |
| 26907 return _ptr.setTimeout(); | |
| 26908 } | |
| 26909 } else { | |
| 26910 if (timeout === null) { | |
| 26911 return _ptr.setTimeout(handler); | |
| 26912 } else { | |
| 26913 return _ptr.setTimeout(handler, timeout); | |
| 26914 } | |
| 26915 } | |
| 26916 throw "Incorrect number or type of arguments"; | |
| 26917 } | |
| 26918 | 27246 |
| 26919 Object showModalDialog(String url, [Object dialogArgs = null, String featureAr
gs = null]) { | 27247 Object showModalDialog(String url, [Object dialogArgs = null, String featureAr
gs = null]) { |
| 26920 if (dialogArgs === null) { | 27248 if (dialogArgs === null) { |
| 26921 if (featureArgs === null) { | 27249 if (featureArgs === null) { |
| 26922 return _ptr.showModalDialog(url); | 27250 return _ptr.showModalDialog(url); |
| 26923 } | 27251 } |
| 26924 } else { | 27252 } else { |
| 26925 if (featureArgs === null) { | 27253 if (featureArgs === null) { |
| 26926 return _ptr.showModalDialog(url, LevelDom.unwrap(dialogArgs)); | 27254 return _ptr.showModalDialog(url, LevelDom.unwrap(dialogArgs)); |
| 26927 } else { | 27255 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 26967 return LevelDom.wrapPoint(_ptr.webkitConvertPointFromPageToNode(LevelDom
.unwrap(node), LevelDom.unwrap(p))); | 27295 return LevelDom.wrapPoint(_ptr.webkitConvertPointFromPageToNode(LevelDom
.unwrap(node), LevelDom.unwrap(p))); |
| 26968 } | 27296 } |
| 26969 } | 27297 } |
| 26970 throw "Incorrect number or type of arguments"; | 27298 throw "Incorrect number or type of arguments"; |
| 26971 } | 27299 } |
| 26972 | 27300 |
| 26973 int webkitRequestAnimationFrame(RequestAnimationFrameCallback callback, [Eleme
nt element = null]) { | 27301 int webkitRequestAnimationFrame(RequestAnimationFrameCallback callback, [Eleme
nt element = null]) { |
| 26974 if (element === null) { | 27302 if (element === null) { |
| 26975 return _ptr.webkitRequestAnimationFrame(callback); | 27303 return _ptr.webkitRequestAnimationFrame(callback); |
| 26976 } else { | 27304 } else { |
| 26977 return _ptr.webkitRequestAnimationFrame(callback, LevelDom.unwrap(element)
); | 27305 return _ptr.webkitRequestAnimationFrame( |
| 27306 callback, LevelDom.unwrap(element)); |
| 26978 } | 27307 } |
| 26979 } | 27308 } |
| 26980 | 27309 |
| 27310 void requestLayoutFrame(TimeoutHandler callback) { |
| 27311 _addMeasurementFrameCallback(callback); |
| 27312 } |
| 27313 |
| 26981 WindowEvents get on() { | 27314 WindowEvents get on() { |
| 26982 if (_on === null) { | 27315 if (_on === null) { |
| 26983 _on = new WindowEventsImplementation._wrap(_ptr); | 27316 _on = new WindowEventsImplementation._wrap(_ptr); |
| 26984 } | 27317 } |
| 26985 return _on; | 27318 return _on; |
| 26986 } | 27319 } |
| 26987 } | 27320 } |
| 26988 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 27321 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 26989 // for details. All rights reserved. Use of this source code is governed by a | 27322 // for details. All rights reserved. Use of this source code is governed by a |
| 26990 // BSD-style license that can be found in the LICENSE file. | 27323 // BSD-style license that can be found in the LICENSE file. |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 27300 _ptr.setRequestHeader(header, value); | 27633 _ptr.setRequestHeader(header, value); |
| 27301 } | 27634 } |
| 27302 | 27635 |
| 27303 XMLHttpRequestEvents get on() { | 27636 XMLHttpRequestEvents get on() { |
| 27304 if (_on === null) { | 27637 if (_on === null) { |
| 27305 _on = new XMLHttpRequestEventsImplementation._wrap(_ptr); | 27638 _on = new XMLHttpRequestEventsImplementation._wrap(_ptr); |
| 27306 } | 27639 } |
| 27307 return _on; | 27640 return _on; |
| 27308 } | 27641 } |
| 27309 } | 27642 } |
| 27310 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 27311 // for details. All rights reserved. Use of this source code is governed by a | |
| 27312 // BSD-style license that can be found in the LICENSE file. | |
| 27313 | |
| 27314 /** | |
| 27315 * The [Collections] class implements static methods useful when | |
| 27316 * writing a class that implements [Collection] and the [iterator] | |
| 27317 * method. | |
| 27318 */ | |
| 27319 class _Collections { | |
| 27320 static void forEach(Iterable<Object> iterable, void f(Object o)) { | |
| 27321 for (final e in iterable) { | |
| 27322 f(e); | |
| 27323 } | |
| 27324 } | |
| 27325 | |
| 27326 static bool some(Iterable<Object> iterable, bool f(Object o)) { | |
| 27327 for (final e in iterable) { | |
| 27328 if (f(e)) return true; | |
| 27329 } | |
| 27330 return false; | |
| 27331 } | |
| 27332 | |
| 27333 static bool every(Iterable<Object> iterable, bool f(Object o)) { | |
| 27334 for (final e in iterable) { | |
| 27335 if (!f(e)) return false; | |
| 27336 } | |
| 27337 return true; | |
| 27338 } | |
| 27339 | |
| 27340 static List filter(Iterable<Object> source, | |
| 27341 List<Object> destination, | |
| 27342 bool f(o)) { | |
| 27343 for (final e in source) { | |
| 27344 if (f(e)) destination.add(e); | |
| 27345 } | |
| 27346 return destination; | |
| 27347 } | |
| 27348 | |
| 27349 static bool isEmpty(Iterable<Object> iterable) { | |
| 27350 return !iterable.iterator().hasNext(); | |
| 27351 } | |
| 27352 } | |
| 27353 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 27354 // for details. All rights reserved. Use of this source code is governed by a | |
| 27355 // BSD-style license that can be found in the LICENSE file. | |
| 27356 | |
| 27357 | |
| 27358 // These factory methods could all live in one factory provider class but dartc | |
| 27359 // has a bug (5399939) preventing that. | |
| 27360 | |
| 27361 class _FileReaderFactoryProvider { | |
| 27362 | |
| 27363 factory FileReader() { | |
| 27364 return new dom.FileReader(); | |
| 27365 } | |
| 27366 } | |
| 27367 | |
| 27368 class _CSSMatrixFactoryProvider { | |
| 27369 | |
| 27370 factory CSSMatrix([String spec = '']) { | |
| 27371 return new CSSMatrixWrappingImplementation._wrap( | |
| 27372 new dom.WebKitCSSMatrix(spec)); | |
| 27373 } | |
| 27374 } | |
| 27375 | |
| 27376 class _PointFactoryProvider { | |
| 27377 | |
| 27378 factory Point(num x, num y) { | |
| 27379 return new PointWrappingImplementation._wrap(new dom.WebKitPoint(x, y)); | |
| 27380 } | |
| 27381 } | |
| 27382 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 27383 // for details. All rights reserved. Use of this source code is governed by a | |
| 27384 // BSD-style license that can be found in the LICENSE file. | |
| 27385 | |
| 27386 // Iterator for lists with fixed size. | |
| 27387 class _FixedSizeListIterator<T> extends _VariableSizeListIterator<T> { | |
| 27388 _FixedSizeListIterator(List<T> list) | |
| 27389 : super(list), | |
| 27390 _length = list.length; | |
| 27391 | |
| 27392 bool hasNext() => _length > _pos; | |
| 27393 | |
| 27394 final int _length; // Cache list length for faster access. | |
| 27395 } | |
| 27396 | |
| 27397 // Iterator for lists with variable size. | |
| 27398 class _VariableSizeListIterator<T> implements Iterator<T> { | |
| 27399 _VariableSizeListIterator(List<T> list) | |
| 27400 : _list = list, | |
| 27401 _pos = 0; | |
| 27402 | |
| 27403 bool hasNext() => _list.length > _pos; | |
| 27404 | |
| 27405 T next() { | |
| 27406 if (!hasNext()) { | |
| 27407 throw const NoMoreElementsException(); | |
| 27408 } | |
| 27409 return _list[_pos++]; | |
| 27410 } | |
| 27411 | |
| 27412 final List<T> _list; | |
| 27413 int _pos; | |
| 27414 } | |
| 27415 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 27416 // for details. All rights reserved. Use of this source code is governed by a | |
| 27417 // BSD-style license that can be found in the LICENSE file. | |
| 27418 | |
| 27419 // TODO(jacobr): move into a core library or at least merge with the copy | |
| 27420 // in client/dom/src | |
| 27421 class _Lists { | |
| 27422 | |
| 27423 /** | |
| 27424 * Returns the index in the array [a] of the given [element], starting | |
| 27425 * the search at index [startIndex] to [endIndex] (exclusive). | |
| 27426 * Returns -1 if [element] is not found. | |
| 27427 */ | |
| 27428 static int indexOf(List a, | |
| 27429 Object element, | |
| 27430 int startIndex, | |
| 27431 int endIndex) { | |
| 27432 if (startIndex >= a.length) { | |
| 27433 return -1; | |
| 27434 } | |
| 27435 if (startIndex < 0) { | |
| 27436 startIndex = 0; | |
| 27437 } | |
| 27438 for (int i = startIndex; i < endIndex; i++) { | |
| 27439 if (a[i] == element) { | |
| 27440 return i; | |
| 27441 } | |
| 27442 } | |
| 27443 return -1; | |
| 27444 } | |
| 27445 | |
| 27446 /** | |
| 27447 * Returns the last index in the array [a] of the given [element], starting | |
| 27448 * the search at index [startIndex] to 0. | |
| 27449 * Returns -1 if [element] is not found. | |
| 27450 */ | |
| 27451 static int lastIndexOf(List a, Object element, int startIndex) { | |
| 27452 if (startIndex < 0) { | |
| 27453 return -1; | |
| 27454 } | |
| 27455 if (startIndex >= a.length) { | |
| 27456 startIndex = a.length - 1; | |
| 27457 } | |
| 27458 for (int i = startIndex; i >= 0; i--) { | |
| 27459 if (a[i] == element) { | |
| 27460 return i; | |
| 27461 } | |
| 27462 } | |
| 27463 return -1; | |
| 27464 } | |
| 27465 } | |
| OLD | NEW |