| OLD | NEW |
| 1 library html; | 1 library html; |
| 2 | 2 |
| 3 import 'dart:isolate'; | 3 import 'dart:isolate'; |
| 4 import 'dart:json'; | 4 import 'dart:json'; |
| 5 import 'dart:nativewrappers'; | 5 import 'dart:nativewrappers'; |
| 6 import 'dart:svg' as svg; | 6 import 'dart:svg' as svg; |
| 7 import 'dart:web_audio' as web_audio; | 7 import 'dart:web_audio' as web_audio; |
| 8 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 8 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 9 // for details. All rights reserved. Use of this source code is governed by a | 9 // for details. All rights reserved. Use of this source code is governed by a |
| 10 // BSD-style license that can be found in the LICENSE file. | 10 // BSD-style license that can be found in the LICENSE file. |
| (...skipping 7638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7649 factory DivElement() => document.$dom_createElement("div"); | 7649 factory DivElement() => document.$dom_createElement("div"); |
| 7650 DivElement.internal(): super.internal(); | 7650 DivElement.internal(): super.internal(); |
| 7651 | 7651 |
| 7652 } | 7652 } |
| 7653 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 7653 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 7654 // for details. All rights reserved. Use of this source code is governed by a | 7654 // for details. All rights reserved. Use of this source code is governed by a |
| 7655 // BSD-style license that can be found in the LICENSE file. | 7655 // BSD-style license that can be found in the LICENSE file. |
| 7656 | 7656 |
| 7657 | 7657 |
| 7658 /// @domName Document | 7658 /// @domName Document |
| 7659 /** |
| 7660 * The base class for all documents. |
| 7661 * |
| 7662 * Each web page loaded in the browser has its own [Document] object, which is |
| 7663 * typically an [HtmlDocument]. |
| 7664 * |
| 7665 * If you aren't comfortable with DOM concepts, see the Dart tutorial |
| 7666 * [Target 2: Connect Dart & HTML](http://www.dartlang.org/docs/tutorials/connec
t-dart-html/). |
| 7667 */ |
| 7659 class Document extends Node | 7668 class Document extends Node |
| 7660 { | 7669 { |
| 7661 | 7670 |
| 7662 Document.internal(): super.internal(); | 7671 Document.internal(): super.internal(); |
| 7663 | 7672 |
| 7664 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev
entTarget.dispatchEvent; @docsEditable true | 7673 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev
entTarget.dispatchEvent; @docsEditable true |
| 7665 DocumentEvents get on => | 7674 DocumentEvents get on => |
| 7666 new DocumentEvents(this); | 7675 new DocumentEvents(this); |
| 7667 | 7676 |
| 7668 | 7677 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7870 void $dom_webkitCancelFullScreen() native "Document_webkitCancelFullScreen_Cal
lback"; | 7879 void $dom_webkitCancelFullScreen() native "Document_webkitCancelFullScreen_Cal
lback"; |
| 7871 | 7880 |
| 7872 | 7881 |
| 7873 /** @domName Document.webkitExitFullscreen */ | 7882 /** @domName Document.webkitExitFullscreen */ |
| 7874 void $dom_webkitExitFullscreen() native "Document_webkitExitFullscreen_Callbac
k"; | 7883 void $dom_webkitExitFullscreen() native "Document_webkitExitFullscreen_Callbac
k"; |
| 7875 | 7884 |
| 7876 | 7885 |
| 7877 /** @domName Document.webkitExitPointerLock */ | 7886 /** @domName Document.webkitExitPointerLock */ |
| 7878 void $dom_webkitExitPointerLock() native "Document_webkitExitPointerLock_Callb
ack"; | 7887 void $dom_webkitExitPointerLock() native "Document_webkitExitPointerLock_Callb
ack"; |
| 7879 | 7888 |
| 7880 // TODO(jacobr): implement all Element methods not on Document. | |
| 7881 | 7889 |
| 7890 /** |
| 7891 * Finds the first descendant element of this document that matches the |
| 7892 * specified group of selectors. |
| 7893 * |
| 7894 * Unless your webpage contains multiple documents, the top-level query |
| 7895 * method behaves the same as this method, so you should use it instead to |
| 7896 * save typing a few characters. |
| 7897 * |
| 7898 * [selectors] should be a string using CSS selector syntax. |
| 7899 * var element1 = document.query('.className'); |
| 7900 * var element2 = document.query('#id'); |
| 7901 * |
| 7902 * For details about CSS selector syntax, see the |
| 7903 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
| 7904 */ |
| 7882 Element query(String selectors) { | 7905 Element query(String selectors) { |
| 7883 // It is fine for our RegExp to detect element id query selectors to have | 7906 // It is fine for our RegExp to detect element id query selectors to have |
| 7884 // false negatives but not false positives. | 7907 // false negatives but not false positives. |
| 7885 if (new RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) { | 7908 if (new RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) { |
| 7886 return $dom_getElementById(selectors.substring(1)); | 7909 return $dom_getElementById(selectors.substring(1)); |
| 7887 } | 7910 } |
| 7888 return $dom_querySelector(selectors); | 7911 return $dom_querySelector(selectors); |
| 7889 } | 7912 } |
| 7890 | 7913 |
| 7914 /** |
| 7915 * Finds all descendant elements of this document that match the specified |
| 7916 * group of selectors. |
| 7917 * |
| 7918 * Unless your webpage contains multiple documents, the top-level queryAll |
| 7919 * method behaves the same as this method, so you should use it instead to |
| 7920 * save typing a few characters. |
| 7921 * |
| 7922 * [selectors] should be a string using CSS selector syntax. |
| 7923 * var items = document.queryAll('.itemClassName'); |
| 7924 * |
| 7925 * For details about CSS selector syntax, see the |
| 7926 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
| 7927 */ |
| 7891 List<Element> queryAll(String selectors) { | 7928 List<Element> queryAll(String selectors) { |
| 7892 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { | 7929 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { |
| 7893 final mutableMatches = $dom_getElementsByName( | 7930 final mutableMatches = $dom_getElementsByName( |
| 7894 selectors.substring(7,selectors.length - 2)); | 7931 selectors.substring(7,selectors.length - 2)); |
| 7895 int len = mutableMatches.length; | 7932 int len = mutableMatches.length; |
| 7896 final copyOfMatches = new List<Element>(len); | 7933 final copyOfMatches = new List<Element>(len); |
| 7897 for (int i = 0; i < len; ++i) { | 7934 for (int i = 0; i < len; ++i) { |
| 7898 copyOfMatches[i] = mutableMatches[i]; | 7935 copyOfMatches[i] = mutableMatches[i]; |
| 7899 } | 7936 } |
| 7900 return new _FrozenElementList._wrap(copyOfMatches); | 7937 return new _FrozenElementList._wrap(copyOfMatches); |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9702 | 9739 |
| 9703 EventListenerList get message => this['message']; | 9740 EventListenerList get message => this['message']; |
| 9704 | 9741 |
| 9705 EventListenerList get open => this['open']; | 9742 EventListenerList get open => this['open']; |
| 9706 } | 9743 } |
| 9707 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 9744 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 9708 // for details. All rights reserved. Use of this source code is governed by a | 9745 // for details. All rights reserved. Use of this source code is governed by a |
| 9709 // BSD-style license that can be found in the LICENSE file. | 9746 // BSD-style license that can be found in the LICENSE file. |
| 9710 | 9747 |
| 9711 | 9748 |
| 9749 /** |
| 9750 * Base class that supports listening for and dispatching browser events. |
| 9751 * |
| 9752 * Events can either be accessed by string name (using the indexed getter) or by |
| 9753 * getters exposed by subclasses. Use the getters exposed by subclasses when |
| 9754 * possible for better compile-time type checks. |
| 9755 * |
| 9756 * Using an indexed getter: |
| 9757 * events['mouseover'].add((e) => print("Mouse over!")); |
| 9758 * |
| 9759 * Using a getter provided by a subclass: |
| 9760 * elementEvents.mouseOver.add((e) => print("Mouse over!")); |
| 9761 */ |
| 9712 class Events { | 9762 class Events { |
| 9713 /* Raw event target. */ | 9763 /* Raw event target. */ |
| 9714 final EventTarget _ptr; | 9764 final EventTarget _ptr; |
| 9715 | 9765 |
| 9716 Events(this._ptr); | 9766 Events(this._ptr); |
| 9717 | 9767 |
| 9718 EventListenerList operator [](String type) { | 9768 EventListenerList operator [](String type) { |
| 9719 return new EventListenerList(_ptr, type); | 9769 return new EventListenerList(_ptr, type); |
| 9720 } | 9770 } |
| 9721 } | 9771 } |
| 9722 | 9772 |
| 9773 /** |
| 9774 * Supports adding, removing, and dispatching events for a specific event type. |
| 9775 */ |
| 9723 class EventListenerList { | 9776 class EventListenerList { |
| 9724 | 9777 |
| 9725 final EventTarget _ptr; | 9778 final EventTarget _ptr; |
| 9726 final String _type; | 9779 final String _type; |
| 9727 | 9780 |
| 9728 EventListenerList(this._ptr, this._type); | 9781 EventListenerList(this._ptr, this._type); |
| 9729 | 9782 |
| 9730 // TODO(jacobr): implement equals. | 9783 // TODO(jacobr): implement equals. |
| 9731 | 9784 |
| 9732 EventListenerList add(EventListener listener, | 9785 EventListenerList add(EventListener listener, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9748 void _add(EventListener listener, bool useCapture) { | 9801 void _add(EventListener listener, bool useCapture) { |
| 9749 _ptr.$dom_addEventListener(_type, listener, useCapture); | 9802 _ptr.$dom_addEventListener(_type, listener, useCapture); |
| 9750 } | 9803 } |
| 9751 | 9804 |
| 9752 void _remove(EventListener listener, bool useCapture) { | 9805 void _remove(EventListener listener, bool useCapture) { |
| 9753 _ptr.$dom_removeEventListener(_type, listener, useCapture); | 9806 _ptr.$dom_removeEventListener(_type, listener, useCapture); |
| 9754 } | 9807 } |
| 9755 } | 9808 } |
| 9756 | 9809 |
| 9757 /// @domName EventTarget | 9810 /// @domName EventTarget |
| 9811 /** |
| 9812 * Base class for all browser objects that support events. |
| 9813 * |
| 9814 * Use the [on] property to add, remove, and dispatch events (rather than |
| 9815 * [$dom_addEventListener], [$dom_dispatchEvent], and |
| 9816 * [$dom_removeEventListener]) for compile-time type checks and a more concise |
| 9817 * API. |
| 9818 */ |
| 9758 class EventTarget extends NativeFieldWrapperClass1 { | 9819 class EventTarget extends NativeFieldWrapperClass1 { |
| 9759 | 9820 |
| 9760 /** @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev
entTarget.dispatchEvent */ | 9821 /** @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev
entTarget.dispatchEvent */ |
| 9761 Events get on => new Events(this); | 9822 Events get on => new Events(this); |
| 9762 EventTarget.internal(); | 9823 EventTarget.internal(); |
| 9763 | 9824 |
| 9764 | 9825 |
| 9765 /** @domName EventTarget.addEventListener */ | 9826 /** @domName EventTarget.addEventListener */ |
| 9766 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu
re]) native "EventTarget_addEventListener_Callback"; | 9827 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu
re]) native "EventTarget_addEventListener_Callback"; |
| 9767 | 9828 |
| (...skipping 20040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29808 bool get isEmpty => Maps.isEmpty(this); | 29869 bool get isEmpty => Maps.isEmpty(this); |
| 29809 } | 29870 } |
| 29810 | 29871 |
| 29811 get _printClosure => (s) { | 29872 get _printClosure => (s) { |
| 29812 try { | 29873 try { |
| 29813 window.console.log(s); | 29874 window.console.log(s); |
| 29814 } catch (_) { | 29875 } catch (_) { |
| 29815 _Utils.print(s); | 29876 _Utils.print(s); |
| 29816 } | 29877 } |
| 29817 }; | 29878 }; |
| OLD | NEW |