OLD | NEW |
1 library html; | 1 library html; |
2 | 2 |
3 import 'dart:async'; | 3 import 'dart:async'; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'dart:html_common'; | 5 import 'dart:html_common'; |
6 import 'dart:indexed_db'; | 6 import 'dart:indexed_db'; |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 import 'dart:json' as json; | 8 import 'dart:json' as json; |
9 import 'dart:math'; | 9 import 'dart:math'; |
10 import 'dart:svg' as svg; | 10 import 'dart:svg' as svg; |
(...skipping 7945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7956 * [x-tags][] project. Please note: in the future it may be possible to | 7956 * [x-tags][] project. Please note: in the future it may be possible to |
7957 * `extend Element` from your class, in which case this field will be | 7957 * `extend Element` from your class, in which case this field will be |
7958 * deprecated and will simply return this [Element] object. | 7958 * deprecated and will simply return this [Element] object. |
7959 * | 7959 * |
7960 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html | 7960 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html |
7961 * [x-tags]: http://x-tags.org/ | 7961 * [x-tags]: http://x-tags.org/ |
7962 */ | 7962 */ |
7963 @Creates('Null') // Set from Dart code; does not instantiate a native type. | 7963 @Creates('Null') // Set from Dart code; does not instantiate a native type. |
7964 var xtag; | 7964 var xtag; |
7965 | 7965 |
| 7966 static const EventStreamProvider<WheelEvent> mouseWheelEvent = |
| 7967 const _CustomEventStreamProvider<WheelEvent>( |
| 7968 Element._determineMouseWheelEventType); |
| 7969 |
| 7970 static String _determineMouseWheelEventType(EventTarget e) { |
| 7971 if (JS('bool', '#.onwheel !== undefined', e)) { |
| 7972 // W3C spec, and should be IE9+, but IE has a bug exposing onwheel. |
| 7973 return 'wheel'; |
| 7974 } else if (JS('bool', '#.onmousewheel !== undefined', e)) { |
| 7975 // Chrome & IE |
| 7976 return 'mousewheel'; |
| 7977 } else { |
| 7978 // Firefox |
| 7979 return 'DOMMouseScroll'; |
| 7980 } |
| 7981 } |
| 7982 |
7966 /** | 7983 /** |
7967 * Creates a text node and inserts it into the DOM at the specified location. | 7984 * Creates a text node and inserts it into the DOM at the specified location. |
7968 * | 7985 * |
7969 * To see the possible values for [where], read the doc for | 7986 * To see the possible values for [where], read the doc for |
7970 * [insertAdjacentHtml]. | 7987 * [insertAdjacentHtml]. |
7971 * | 7988 * |
7972 * See also: | 7989 * See also: |
7973 * | 7990 * |
7974 * * [insertAdjacentHtml] | 7991 * * [insertAdjacentHtml] |
7975 */ | 7992 */ |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8446 Stream<MouseEvent> get onMouseDown => mouseDownEvent.forTarget(this); | 8463 Stream<MouseEvent> get onMouseDown => mouseDownEvent.forTarget(this); |
8447 | 8464 |
8448 Stream<MouseEvent> get onMouseMove => mouseMoveEvent.forTarget(this); | 8465 Stream<MouseEvent> get onMouseMove => mouseMoveEvent.forTarget(this); |
8449 | 8466 |
8450 Stream<MouseEvent> get onMouseOut => mouseOutEvent.forTarget(this); | 8467 Stream<MouseEvent> get onMouseOut => mouseOutEvent.forTarget(this); |
8451 | 8468 |
8452 Stream<MouseEvent> get onMouseOver => mouseOverEvent.forTarget(this); | 8469 Stream<MouseEvent> get onMouseOver => mouseOverEvent.forTarget(this); |
8453 | 8470 |
8454 Stream<MouseEvent> get onMouseUp => mouseUpEvent.forTarget(this); | 8471 Stream<MouseEvent> get onMouseUp => mouseUpEvent.forTarget(this); |
8455 | 8472 |
| 8473 Stream<WheelEvent> get onMouseWheel => mouseWheelEvent.forTarget(this); |
| 8474 |
8456 Stream<Event> get onPaste => pasteEvent.forTarget(this); | 8475 Stream<Event> get onPaste => pasteEvent.forTarget(this); |
8457 | 8476 |
8458 Stream<Event> get onReset => resetEvent.forTarget(this); | 8477 Stream<Event> get onReset => resetEvent.forTarget(this); |
8459 | 8478 |
8460 Stream<Event> get onScroll => scrollEvent.forTarget(this); | 8479 Stream<Event> get onScroll => scrollEvent.forTarget(this); |
8461 | 8480 |
8462 Stream<Event> get onSearch => searchEvent.forTarget(this); | 8481 Stream<Event> get onSearch => searchEvent.forTarget(this); |
8463 | 8482 |
8464 Stream<Event> get onSelect => selectEvent.forTarget(this); | 8483 Stream<Event> get onSelect => selectEvent.forTarget(this); |
8465 | 8484 |
(...skipping 13304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21770 EventListenerList get open => this['open']; | 21789 EventListenerList get open => this['open']; |
21771 } | 21790 } |
21772 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 21791 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
21773 // for details. All rights reserved. Use of this source code is governed by a | 21792 // for details. All rights reserved. Use of this source code is governed by a |
21774 // BSD-style license that can be found in the LICENSE file. | 21793 // BSD-style license that can be found in the LICENSE file. |
21775 | 21794 |
21776 | 21795 |
21777 /// @domName WheelEvent | 21796 /// @domName WheelEvent |
21778 class WheelEvent extends MouseEvent native "*WheelEvent" { | 21797 class WheelEvent extends MouseEvent native "*WheelEvent" { |
21779 | 21798 |
| 21799 factory WheelEvent( |
| 21800 String type, |
| 21801 Window view, |
| 21802 int wheelDeltaX, |
| 21803 int wheelDeltaY, |
| 21804 int detail, |
| 21805 int screenX, |
| 21806 int screenY, |
| 21807 int clientX, |
| 21808 int clientY, |
| 21809 int button, |
| 21810 [bool canBubble = true, |
| 21811 bool cancelable = true, |
| 21812 bool ctrlKey = false, |
| 21813 bool altKey = false, |
| 21814 bool shiftKey = false, |
| 21815 bool metaKey = false, |
| 21816 EventTarget relatedTarget = null]) { |
| 21817 |
| 21818 var eventType = 'WheelEvent'; |
| 21819 if (_Device.isFirefox) { |
| 21820 eventType = 'MouseScrollEvents'; |
| 21821 } |
| 21822 final event = document.$dom_createEvent(eventType); |
| 21823 if (event._hasInitWheelEvent) { |
| 21824 var modifiers = []; |
| 21825 if (ctrlKey) { |
| 21826 modifiers.push('Control'); |
| 21827 } |
| 21828 if (altKey) { |
| 21829 modifiers.push('Alt'); |
| 21830 } |
| 21831 if (shiftKey) { |
| 21832 modifiers.push('Shift'); |
| 21833 } |
| 21834 if (metaKey) { |
| 21835 modifiers.push('Meta'); |
| 21836 } |
| 21837 var modifiersList = modifiers.join(' '); |
| 21838 event._initWheelEvent( |
| 21839 type, |
| 21840 canBubble, |
| 21841 cancelable, |
| 21842 view, |
| 21843 detail, |
| 21844 screenX, |
| 21845 screenY, |
| 21846 clientX, |
| 21847 clientY, |
| 21848 button, |
| 21849 relatedTarget, |
| 21850 modifiersList, |
| 21851 wheelDeltaX, |
| 21852 wheelDeltaY, |
| 21853 0, |
| 21854 0); |
| 21855 } else if (event._hasInitMouseScrollEvent) { |
| 21856 var axis = 0; |
| 21857 var detail = 0; |
| 21858 if (wheelDeltaX != 0 && wheelDeltaY != 0) { |
| 21859 throw UnsupportedError( |
| 21860 'Cannot modify wheelDeltaX and wheelDeltaY simultaneously'); |
| 21861 } |
| 21862 if (wheelDeltaY != 0) { |
| 21863 detail = wheelDeltaY; |
| 21864 axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS'); |
| 21865 } else if (wheelDeltaX != 0) { |
| 21866 detail = wheelDeltaX; |
| 21867 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); |
| 21868 } |
| 21869 event._initMouseScrollEvent( |
| 21870 type, |
| 21871 canBubble, |
| 21872 cancelable, |
| 21873 view, |
| 21874 detail, |
| 21875 screenX, |
| 21876 screenY, |
| 21877 clientX, |
| 21878 clientY, |
| 21879 ctrlKey, |
| 21880 altKey, |
| 21881 shiftKey, |
| 21882 metaKey, |
| 21883 button, |
| 21884 relatedTarget, |
| 21885 axis); |
| 21886 } else { |
| 21887 // Fallthrough for Dartium. |
| 21888 event.$dom_initMouseEvent( |
| 21889 type, |
| 21890 canBubble, |
| 21891 cancelable, |
| 21892 view, |
| 21893 detail, |
| 21894 screenX, |
| 21895 screenY, |
| 21896 clientX, |
| 21897 clientY, |
| 21898 ctrlKey, |
| 21899 altKey, |
| 21900 shiftKey, |
| 21901 metaKey, |
| 21902 button, |
| 21903 relatedTarget); |
| 21904 event.$dom_initWebKitWheelEvent( |
| 21905 wheelDeltaX, |
| 21906 (wheelDeltaY / 120).toInt(), // Chrome does an auto-convert to pixels. |
| 21907 view, |
| 21908 screenX, |
| 21909 screenY, |
| 21910 clientX, |
| 21911 clientY, |
| 21912 ctrlKey, |
| 21913 altKey, |
| 21914 shiftKey, |
| 21915 metaKey); |
| 21916 } |
| 21917 |
| 21918 return event; |
| 21919 } |
| 21920 |
| 21921 |
21780 /// @domName WheelEvent.webkitDirectionInvertedFromDevice; @docsEditable true | 21922 /// @domName WheelEvent.webkitDirectionInvertedFromDevice; @docsEditable true |
21781 final bool webkitDirectionInvertedFromDevice; | 21923 final bool webkitDirectionInvertedFromDevice; |
21782 | 21924 |
21783 /// @domName WheelEvent.initWebKitWheelEvent; @docsEditable true | 21925 /// @domName WheelEvent.initWebKitWheelEvent; @docsEditable true |
21784 void initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int s
creenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool s
hiftKey, bool metaKey) native; | 21926 @JSName('initWebKitWheelEvent') |
| 21927 void $dom_initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view,
int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, b
ool shiftKey, bool metaKey) native; |
21785 | 21928 |
21786 | 21929 |
21787 /** @domName WheelEvent.deltaY */ | 21930 /** @domName WheelEvent.deltaY */ |
21788 num get deltaY { | 21931 num get deltaY { |
21789 if (JS('bool', '#.deltaY !== undefined', this)) { | 21932 if (JS('bool', '#.deltaY !== undefined', this)) { |
21790 // W3C WheelEvent | 21933 // W3C WheelEvent |
21791 return this._deltaY; | 21934 return this._deltaY; |
21792 } else if (JS('bool', '#.wheelDelta !== undefined', this)) { | 21935 } else if (JS('bool', '#.wheelDelta !== undefined', this)) { |
21793 // Chrome and IE | 21936 // Chrome and IE |
21794 return this._wheelDelta; | 21937 return this._wheelDelta; |
(...skipping 24 matching lines...) Expand all Loading... |
21819 return this._deltaX; | 21962 return this._deltaX; |
21820 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) { | 21963 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) { |
21821 // Chrome | 21964 // Chrome |
21822 return this._wheelDeltaX; | 21965 return this._wheelDeltaX; |
21823 } else if (JS('bool', '#.detail !== undefined', this)) { | 21966 } else if (JS('bool', '#.detail !== undefined', this)) { |
21824 // Firefox and IE. | 21967 // Firefox and IE. |
21825 // IE will have detail set but will not set axis. | 21968 // IE will have detail set but will not set axis. |
21826 | 21969 |
21827 // Handle DOMMouseScroll case where it uses detail and the axis to | 21970 // Handle DOMMouseScroll case where it uses detail and the axis to |
21828 // differentiate. | 21971 // differentiate. |
21829 if (JS('bool', '#.axis !== undefined && #.axis == MouseScrollEvent.HORIZON
TAL_AXIS', this, this)) { | 21972 if (JS('bool', '#.axis !== undefined && ' |
| 21973 '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) { |
21830 var detail = this._detail; | 21974 var detail = this._detail; |
21831 // Firefox is normally the number of lines to scale (normally 3) | 21975 // Firefox is normally the number of lines to scale (normally 3) |
21832 // so multiply it by 40 to get pixels to move, matching IE & WebKit. | 21976 // so multiply it by 40 to get pixels to move, matching IE & WebKit. |
21833 if (detail < 100) { | 21977 if (detail < 100) { |
21834 return detail * 40; | 21978 return detail * 40; |
21835 } | 21979 } |
21836 return detail; | 21980 return detail; |
21837 } | 21981 } |
21838 return 0; | 21982 return 0; |
21839 } | 21983 } |
21840 throw new UnsupportedError( | 21984 throw new UnsupportedError( |
21841 'deltaX is not supported'); | 21985 'deltaX is not supported'); |
21842 } | 21986 } |
21843 | 21987 |
21844 int get deltaMode { | 21988 int get deltaMode { |
21845 if (JS('bool', '!!#.deltaMode', this)) { | 21989 if (JS('bool', '!!#.deltaMode', this)) { |
21846 // If not available then we're poly-filling and doing pixel scroll. | 21990 // If not available then we're poly-filling and doing pixel scroll. |
21847 return 0; | 21991 return 0; |
21848 } | 21992 } |
21849 return this._deltaMode; | 21993 return this._deltaMode; |
21850 } | 21994 } |
21851 | 21995 |
21852 num get _deltaY => JS('num', '#.deltaY', this); | 21996 num get _deltaY => JS('num', '#.deltaY', this); |
21853 num get _deltaX => JS('num', '#.deltaX', this); | 21997 num get _deltaX => JS('num', '#.deltaX', this); |
21854 num get _wheelDelta => JS('num', '#.wheelDelta', this); | 21998 num get _wheelDelta => JS('num', '#.wheelDelta', this); |
21855 num get _wheelDeltaX => JS('num', '#.wheelDeltaX', this); | 21999 num get _wheelDeltaX => JS('num', '#.wheelDeltaX', this); |
21856 num get _detail => JS('num', '#.detail', this); | 22000 num get _detail => JS('num', '#.detail', this); |
21857 int get _deltaMode => JS('int', '#.deltaMode', this); | 22001 int get _deltaMode => JS('int', '#.deltaMode', this); |
21858 | 22002 |
| 22003 bool get _hasInitMouseScrollEvent => |
| 22004 JS('bool', '!!(#.initMouseScrollEvent)', this); |
| 22005 |
| 22006 @JSName('initMouseScrollEvent') |
| 22007 void _initMouseScrollEvent( |
| 22008 String type, |
| 22009 bool canBubble, |
| 22010 bool cancelable, |
| 22011 Window view, |
| 22012 int detail, |
| 22013 int screenX, |
| 22014 int screenY, |
| 22015 int clientX, |
| 22016 int clientY, |
| 22017 bool ctrlKey, |
| 22018 bool altKey, |
| 22019 bool shiftKey, |
| 22020 bool metaKey, |
| 22021 int button, |
| 22022 EventTarget relatedTarget, |
| 22023 int axis) native; |
| 22024 |
| 22025 bool get _hasInitWheelEvent => |
| 22026 JS('bool', '!!(#.initWheelEvent)', this); |
| 22027 @JSName('initWheelEvent') |
| 22028 void _initWheelEvent( |
| 22029 String eventType, |
| 22030 bool canBubble, |
| 22031 bool cancelable, |
| 22032 Window view, |
| 22033 int detail, |
| 22034 int screenX, |
| 22035 int screenY, |
| 22036 int clientX, |
| 22037 int clientY, |
| 22038 int button, |
| 22039 EventTarget relatedTarget, |
| 22040 String modifiersList, |
| 22041 int deltaX, |
| 22042 int deltaY, |
| 22043 int deltaZ, |
| 22044 int deltaMode) native; |
| 22045 |
21859 } | 22046 } |
21860 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 22047 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
21861 // for details. All rights reserved. Use of this source code is governed by a | 22048 // 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. | 22049 // BSD-style license that can be found in the LICENSE file. |
21863 | 22050 |
21864 | 22051 |
21865 /// @domName Window | 22052 /// @domName Window |
21866 class Window extends EventTarget implements WindowBase native "@*DOMWindow" { | 22053 class Window extends EventTarget implements WindowBase native "@*DOMWindow" { |
21867 | 22054 |
21868 Document get document => JS('Document', '#.document', this); | 22055 Document get document => JS('Document', '#.document', this); |
(...skipping 3657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25526 * MediaElement.pauseEvent.forTarget(document.body).listen(...); | 25713 * MediaElement.pauseEvent.forTarget(document.body).listen(...); |
25527 * | 25714 * |
25528 * See also: | 25715 * See also: |
25529 * | 25716 * |
25530 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) | 25717 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) |
25531 */ | 25718 */ |
25532 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { | 25719 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { |
25533 return new _EventStream(e, _eventType, useCapture); | 25720 return new _EventStream(e, _eventType, useCapture); |
25534 } | 25721 } |
25535 } | 25722 } |
| 25723 |
| 25724 typedef String _EventTypeGetter(EventTarget target); |
| 25725 |
| 25726 /** |
| 25727 * A factory to expose DOM events as streams, where the DOM event name has to |
| 25728 * be determined on the fly (for example, mouse wheel events). |
| 25729 */ |
| 25730 class _CustomEventStreamProvider<T extends Event> |
| 25731 implements EventStreamProvider<T> { |
| 25732 |
| 25733 final _eventTypeGetter; |
| 25734 const _CustomEventStreamProvider(this._eventTypeGetter); |
| 25735 |
| 25736 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { |
| 25737 return new _EventStream(e, _eventTypeGetter(e), useCapture); |
| 25738 } |
| 25739 } |
25536 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 25740 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
25537 // for details. All rights reserved. Use of this source code is governed by a | 25741 // for details. All rights reserved. Use of this source code is governed by a |
25538 // BSD-style license that can be found in the LICENSE file. | 25742 // BSD-style license that can be found in the LICENSE file. |
25539 | 25743 |
25540 | 25744 |
25541 /** | 25745 /** |
25542 * Works with KeyboardEvent and KeyEvent to determine how to expose information | 25746 * Works with KeyboardEvent and KeyEvent to determine how to expose information |
25543 * about Key(board)Events. This class functions like an EventListenerList, and | 25747 * about Key(board)Events. This class functions like an EventListenerList, and |
25544 * provides a consistent interface for the Dart | 25748 * provides a consistent interface for the Dart |
25545 * user, despite the fact that a multitude of browsers that have varying | 25749 * user, despite the fact that a multitude of browsers that have varying |
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
28078 _position = nextPosition; | 28282 _position = nextPosition; |
28079 return true; | 28283 return true; |
28080 } | 28284 } |
28081 _current = null; | 28285 _current = null; |
28082 _position = _array.length; | 28286 _position = _array.length; |
28083 return false; | 28287 return false; |
28084 } | 28288 } |
28085 | 28289 |
28086 T get current => _current; | 28290 T get current => _current; |
28087 } | 28291 } |
OLD | NEW |