| 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 class _EventsImpl implements Events { | 5 class _EventsImpl implements Events { |
| 6 | 6 |
| 7 final _EventTargetImpl _ptr; | 7 final _EventTargetImpl _ptr; |
| 8 | 8 |
| 9 final Map<String, EventListenerList> _listenerMap; | 9 final Map<String, EventListenerList> _listenerMap; |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 EventListenerList remove(EventListener listener, [bool useCapture = false]) { | 44 EventListenerList remove(EventListener listener, [bool useCapture = false]) { |
| 45 _remove(listener, useCapture); | 45 _remove(listener, useCapture); |
| 46 return this; | 46 return this; |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool dispatch(Event evt) { | 49 bool dispatch(Event evt) { |
| 50 // TODO(jacobr): what is the correct behavior here. We could alternately | 50 // TODO(jacobr): what is the correct behavior here. We could alternately |
| 51 // force the event to have the expected type. | 51 // force the event to have the expected type. |
| 52 assert(evt.type == _type); | 52 assert(evt.type == _type); |
| 53 return _ptr._dispatchEvent(evt); | 53 return _ptr.$dom_dispatchEvent(evt); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void _add(EventListener listener, bool useCapture) { | 56 void _add(EventListener listener, bool useCapture) { |
| 57 _ptr._addEventListener(_type, | 57 _ptr.$dom_addEventListener(_type, |
| 58 _findOrAddWrapper(listener, useCapture), | 58 _findOrAddWrapper(listener, useCapture), |
| 59 useCapture); | 59 useCapture); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void _remove(EventListener listener, bool useCapture) { | 62 void _remove(EventListener listener, bool useCapture) { |
| 63 Function wrapper = _removeWrapper(listener, useCapture); | 63 Function wrapper = _removeWrapper(listener, useCapture); |
| 64 if (wrapper !== null) { | 64 if (wrapper !== null) { |
| 65 _ptr._removeEventListener(_type, wrapper, useCapture); | 65 _ptr.$dom_removeEventListener(_type, wrapper, useCapture); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 Function _removeWrapper(EventListener listener, bool useCapture) { | 69 Function _removeWrapper(EventListener listener, bool useCapture) { |
| 70 if (_wrappers === null) { | 70 if (_wrappers === null) { |
| 71 return null; | 71 return null; |
| 72 } | 72 } |
| 73 for (int i = 0; i < _wrappers.length; i++) { | 73 for (int i = 0; i < _wrappers.length; i++) { |
| 74 _EventListenerWrapper wrapper = _wrappers[i]; | 74 _EventListenerWrapper wrapper = _wrappers[i]; |
| 75 if (wrapper.raw === listener && wrapper.useCapture == useCapture) { | 75 if (wrapper.raw === listener && wrapper.useCapture == useCapture) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 Events _on; | 107 Events _on; |
| 108 | 108 |
| 109 Events get on() { | 109 Events get on() { |
| 110 if (_on == null) _on = new _EventsImpl(this); | 110 if (_on == null) _on = new _EventsImpl(this); |
| 111 return _on; | 111 return _on; |
| 112 } | 112 } |
| 113 | 113 |
| 114 $!MEMBERS | 114 $!MEMBERS |
| 115 } | 115 } |
| OLD | NEW |