Chromium Code Reviews| 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]) { | |
|
Siggi Cherem (dart-lang)
2013/01/16 18:52:00
generally indentation here looks strange. Consider
blois
2013/01/16 20:04:02
Updated. In general I find the collapsed form fair
| |
| 21817 | |
| 21818 var eventType = 'WheelEvent'; | |
| 21819 if (_Device.isFirefox) { | |
| 21820 eventType = 'MouseScrollEvents'; | |
| 21821 } | |
| 21822 final event = document.$dom_createEvent(eventType); | |
| 21823 | |
| 21824 if (_Device.isWebKit) { | |
| 21825 event.$dom_initMouseEvent( | |
| 21826 type, | |
| 21827 canBubble, | |
| 21828 cancelable, | |
| 21829 view, | |
| 21830 detail, | |
| 21831 screenX, | |
| 21832 screenY, | |
| 21833 clientX, | |
| 21834 clientY, | |
| 21835 ctrlKey, | |
| 21836 altKey, | |
| 21837 shiftKey, | |
| 21838 metaKey, | |
| 21839 button, | |
| 21840 relatedTarget); | |
| 21841 event.$dom_initWebKitWheelEvent( | |
| 21842 wheelDeltaX, | |
| 21843 (wheelDeltaY / 120).toInt(), // Chrome does an auto-convert to pixels. | |
| 21844 view, | |
| 21845 screenX, | |
| 21846 screenY, | |
| 21847 clientX, | |
| 21848 clientY, | |
| 21849 ctrlKey, | |
| 21850 altKey, | |
| 21851 shiftKey, | |
| 21852 metaKey); | |
| 21853 } | |
| 21854 else if (_Device.isIE) { | |
|
Siggi Cherem (dart-lang)
2013/01/16 18:52:00
move else to previous line?
blois
2013/01/16 20:04:02
Was a by-product of template expansion, updated wi
| |
| 21855 var modifiers = []; | |
| 21856 if (ctrlKey) { | |
| 21857 modifiers.push('Control'); | |
| 21858 } | |
| 21859 if (altKey) { | |
| 21860 modifiers.push('Alt'); | |
| 21861 } | |
| 21862 if (shiftKey) { | |
| 21863 modifiers.push('Shift'); | |
| 21864 } | |
| 21865 if (metaKey) { | |
| 21866 modifiers.push('Meta'); | |
| 21867 } | |
| 21868 var modifiersList = modifiers.join(' '); | |
| 21869 event._initIEWheelEvent( | |
| 21870 type, | |
| 21871 canBubble, | |
| 21872 cancelable, | |
| 21873 view, | |
| 21874 detail, | |
| 21875 screenX, | |
| 21876 screenY, | |
| 21877 clientX, | |
| 21878 clientY, | |
| 21879 button, | |
| 21880 relatedTarget, | |
| 21881 modifiersList, | |
|
Siggi Cherem (dart-lang)
2013/01/16 18:52:00
nit: maybe simply inline modifiers.join(' ') here?
blois
2013/01/16 20:04:02
Done.
| |
| 21882 wheelDeltaX, | |
| 21883 wheelDeltaY, | |
| 21884 0, | |
| 21885 0); | |
| 21886 } else if (_Device.isFirefox) { | |
| 21887 var axis = 0; | |
| 21888 var detail = 0; | |
| 21889 if (wheelDeltaX != 0 && wheelDeltaY != 0) { | |
| 21890 throw UnsupportedError( | |
| 21891 'Cannot modify wheelDeltaX and wheelDeltaY simultaneously'); | |
| 21892 } | |
| 21893 if (wheelDeltaY != 0) { | |
| 21894 detail = wheelDeltaY; | |
| 21895 axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS'); | |
| 21896 } else if (wheelDeltaX != 0) { | |
| 21897 detail = wheelDeltaX; | |
| 21898 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); | |
| 21899 } | |
| 21900 event._initFireFoxMouseScrollEvent( | |
| 21901 type, | |
| 21902 canBubble, | |
| 21903 cancelable, | |
| 21904 view, | |
| 21905 detail, | |
| 21906 screenX, | |
| 21907 screenY, | |
| 21908 clientX, | |
| 21909 clientY, | |
| 21910 ctrlKey, | |
| 21911 altKey, | |
| 21912 shiftKey, | |
| 21913 metaKey, | |
| 21914 button, | |
| 21915 relatedTarget, | |
| 21916 axis); | |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21849 return this._deltaMode; | 21992 return this._deltaMode; |
| 21850 } | 21993 } |
| 21851 | 21994 |
| 21852 num get _deltaY => JS('num', '#.deltaY', this); | 21995 num get _deltaY => JS('num', '#.deltaY', this); |
| 21853 num get _deltaX => JS('num', '#.deltaX', this); | 21996 num get _deltaX => JS('num', '#.deltaX', this); |
| 21854 num get _wheelDelta => JS('num', '#.wheelDelta', this); | 21997 num get _wheelDelta => JS('num', '#.wheelDelta', this); |
| 21855 num get _wheelDeltaX => JS('num', '#.wheelDeltaX', this); | 21998 num get _wheelDeltaX => JS('num', '#.wheelDeltaX', this); |
| 21856 num get _detail => JS('num', '#.detail', this); | 21999 num get _detail => JS('num', '#.detail', this); |
| 21857 int get _deltaMode => JS('int', '#.deltaMode', this); | 22000 int get _deltaMode => JS('int', '#.deltaMode', this); |
| 21858 | 22001 |
| 22002 @JSName('initMouseScrollEvent') | |
| 22003 void _initFireFoxMouseScrollEvent( | |
| 22004 String type, | |
| 22005 bool canBubble, | |
| 22006 bool cancelable, | |
| 22007 Window view, | |
| 22008 int detail, | |
| 22009 int screenX, | |
| 22010 int screenY, | |
| 22011 int clientX, | |
| 22012 int clientY, | |
| 22013 bool ctrlKey, | |
| 22014 bool altKey, | |
| 22015 bool shiftKey, | |
| 22016 bool metaKey, | |
| 22017 int button, | |
| 22018 EventTarget relatedTarget, | |
| 22019 int axis) native; | |
| 22020 | |
| 22021 @JSName('initWheelEvent') | |
| 22022 void _initIEWheelEvent( | |
| 22023 String eventType, | |
| 22024 bool canBubble, | |
| 22025 bool cancelable, | |
| 22026 Window view, | |
| 22027 int detail, | |
| 22028 int screenX, | |
| 22029 int screenY, | |
| 22030 int clientX, | |
| 22031 int clientY, | |
| 22032 int button, | |
| 22033 EventTarget relatedTarget, | |
| 22034 String modifiersList, | |
| 22035 int deltaX, | |
| 22036 int deltaY, | |
| 22037 int deltaZ, | |
| 22038 int deltaMode) native; | |
| 22039 | |
| 21859 } | 22040 } |
| 21860 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 22041 // 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 | 22042 // 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. | 22043 // BSD-style license that can be found in the LICENSE file. |
| 21863 | 22044 |
| 21864 | 22045 |
| 21865 /// @domName Window | 22046 /// @domName Window |
| 21866 class Window extends EventTarget implements WindowBase native "@*DOMWindow" { | 22047 class Window extends EventTarget implements WindowBase native "@*DOMWindow" { |
| 21867 | 22048 |
| 21868 Document get document => JS('Document', '#.document', this); | 22049 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(...); | 25707 * MediaElement.pauseEvent.forTarget(document.body).listen(...); |
| 25527 * | 25708 * |
| 25528 * See also: | 25709 * See also: |
| 25529 * | 25710 * |
| 25530 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener) | 25711 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener) |
| 25531 */ | 25712 */ |
| 25532 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { | 25713 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { |
| 25533 return new _EventStream(e, _eventType, useCapture); | 25714 return new _EventStream(e, _eventType, useCapture); |
| 25534 } | 25715 } |
| 25535 } | 25716 } |
| 25717 | |
| 25718 typedef String _EventTypeGetter(EventTarget target); | |
|
Siggi Cherem (dart-lang)
2013/01/16 18:52:00
did you mean to use this type somewhere? (e.g. fie
blois
2013/01/16 20:04:02
Yes, but dart2js checked mode issue blocked it. re
| |
| 25719 | |
| 25720 /** | |
| 25721 * A factory to expose DOM events as streams, where the DOM event name has to | |
| 25722 * be determined on the fly (for example, mouse wheel events). | |
| 25723 */ | |
| 25724 class _CustomEventStreamProvider<T extends Event> | |
| 25725 implements EventStreamProvider<T> { | |
| 25726 | |
| 25727 final _eventTypeGetter; | |
| 25728 const _CustomEventStreamProvider(this._eventTypeGetter); | |
| 25729 | |
| 25730 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { | |
| 25731 return new _EventStream(e, _eventTypeGetter(e), useCapture); | |
| 25732 } | |
| 25733 } | |
| 25536 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 25734 // 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 | 25735 // 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. | 25736 // BSD-style license that can be found in the LICENSE file. |
| 25539 | 25737 |
| 25540 | 25738 |
| 25541 /** | 25739 /** |
| 25542 * Works with KeyboardEvent and KeyEvent to determine how to expose information | 25740 * Works with KeyboardEvent and KeyEvent to determine how to expose information |
| 25543 * about Key(board)Events. This class functions like an EventListenerList, and | 25741 * about Key(board)Events. This class functions like an EventListenerList, and |
| 25544 * provides a consistent interface for the Dart | 25742 * provides a consistent interface for the Dart |
| 25545 * user, despite the fact that a multitude of browsers that have varying | 25743 * 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; | 28276 _position = nextPosition; |
| 28079 return true; | 28277 return true; |
| 28080 } | 28278 } |
| 28081 _current = null; | 28279 _current = null; |
| 28082 _position = _array.length; | 28280 _position = _array.length; |
| 28083 return false; | 28281 return false; |
| 28084 } | 28282 } |
| 28085 | 28283 |
| 28086 T get current => _current; | 28284 T get current => _current; |
| 28087 } | 28285 } |
| OLD | NEW |