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