| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Base class that supports listening for and dispatching browser events. | 8 * Base class that supports listening for and dispatching browser events. |
| 9 * | 9 * |
| 10 * Normally events are accessed via the Stream getter: | 10 * Normally events are accessed via the Stream getter: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * some DOM events may have multiple platform-dependent event names under the | 39 * some DOM events may have multiple platform-dependent event names under the |
| 40 * covers. By using the standard Stream getters you will get the platform | 40 * covers. By using the standard Stream getters you will get the platform |
| 41 * specific event name automatically. | 41 * specific event name automatically. |
| 42 */ | 42 */ |
| 43 class Events { | 43 class Events { |
| 44 /* Raw event target. */ | 44 /* Raw event target. */ |
| 45 final EventTarget _ptr; | 45 final EventTarget _ptr; |
| 46 | 46 |
| 47 Events(this._ptr); | 47 Events(this._ptr); |
| 48 | 48 |
| 49 Stream operator [](String type) { | 49 Stream<Event> operator [](String type) { |
| 50 return new _EventStream(_ptr, type, false); | 50 return new _EventStream(_ptr, type, false); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 class ElementEvents extends Events { | 54 class ElementEvents extends Events { |
| 55 static final webkitEvents = { | 55 static final webkitEvents = { |
| 56 'animationend' : 'webkitAnimationEnd', | 56 'animationend' : 'webkitAnimationEnd', |
| 57 'animationiteration' : 'webkitAnimationIteration', | 57 'animationiteration' : 'webkitAnimationIteration', |
| 58 'animationstart' : 'webkitAnimationStart', | 58 'animationstart' : 'webkitAnimationStart', |
| 59 'fullscreenchange' : 'webkitfullscreenchange', | 59 'fullscreenchange' : 'webkitfullscreenchange', |
| 60 'fullscreenerror' : 'webkitfullscreenerror', | 60 'fullscreenerror' : 'webkitfullscreenerror', |
| 61 'keyadded' : 'webkitkeyadded', | 61 'keyadded' : 'webkitkeyadded', |
| 62 'keyerror' : 'webkitkeyerror', | 62 'keyerror' : 'webkitkeyerror', |
| 63 'keymessage' : 'webkitkeymessage', | 63 'keymessage' : 'webkitkeymessage', |
| 64 'needkey' : 'webkitneedkey', | 64 'needkey' : 'webkitneedkey', |
| 65 'pointerlockchange' : 'webkitpointerlockchange', | 65 'pointerlockchange' : 'webkitpointerlockchange', |
| 66 'pointerlockerror' : 'webkitpointerlockerror', | 66 'pointerlockerror' : 'webkitpointerlockerror', |
| 67 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull', | 67 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull', |
| 68 'transitionend': 'webkitTransitionEnd', | 68 'transitionend': 'webkitTransitionEnd', |
| 69 'speechchange' : 'webkitSpeechChange' | 69 'speechchange' : 'webkitSpeechChange' |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 ElementEvents(Element ptr) : super(ptr); | 72 ElementEvents(Element ptr) : super(ptr); |
| 73 | 73 |
| 74 Stream operator [](String type) { | 74 Stream<Event> operator [](String type) { |
| 75 if (webkitEvents.keys.contains(type.toLowerCase())) { | 75 if (webkitEvents.keys.contains(type.toLowerCase())) { |
| 76 if (Device.isWebKit) { | 76 if (Device.isWebKit) { |
| 77 return new _ElementEventStreamImpl( | 77 return new _ElementEventStreamImpl( |
| 78 _ptr, webkitEvents[type.toLowerCase()], false); | 78 _ptr, webkitEvents[type.toLowerCase()], false); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 return new _ElementEventStreamImpl(_ptr, type, false); | 81 return new _ElementEventStreamImpl(_ptr, type, false); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // TODO(leafp): This check is avoid a bug in our dispatch code when | 118 // TODO(leafp): This check is avoid a bug in our dispatch code when |
| 119 // listener is null. The browser treats this call as a no-op in this | 119 // listener is null. The browser treats this call as a no-op in this |
| 120 // case, so it's fine to short-circuit it, but we should not have to. | 120 // case, so it's fine to short-circuit it, but we should not have to. |
| 121 if (listener != null) { | 121 if (listener != null) { |
| 122 _removeEventListener(type, listener, useCapture); | 122 _removeEventListener(type, listener, useCapture); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 $!MEMBERS | 126 $!MEMBERS |
| 127 } | 127 } |
| OLD | NEW |