| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview This contains an implementation of the EventTarget interface | 6 * @fileoverview This contains an implementation of the EventTarget interface |
| 7 * as defined by DOM Level 2 Events. | 7 * as defined by DOM Level 2 Events. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('cr', function() { | 10 cr.define('cr', function() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 delete this.listeners_[type]; | 55 delete this.listeners_[type]; |
| 56 else | 56 else |
| 57 handlers.splice(index, 1); | 57 handlers.splice(index, 1); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Dispatches an event and calls all the listeners that are listening to | 63 * Dispatches an event and calls all the listeners that are listening to |
| 64 * the type of the event. | 64 * the type of the event. |
| 65 * @param {!cr.event.Event} event The event to dispatch. | 65 * @param {!Event} event The event to dispatch. |
| 66 * @return {boolean} Whether the default action was prevented. If someone | 66 * @return {boolean} Whether the default action was prevented. If someone |
| 67 * calls preventDefault on the event object then this returns false. | 67 * calls preventDefault on the event object then this returns false. |
| 68 */ | 68 */ |
| 69 dispatchEvent: function(event) { | 69 dispatchEvent: function(event) { |
| 70 if (!this.listeners_) | 70 if (!this.listeners_) |
| 71 return true; | 71 return true; |
| 72 | 72 |
| 73 // Since we are using DOM Event objects we need to override some of the | 73 // Since we are using DOM Event objects we need to override some of the |
| 74 // properties and methods so that we can emulate this correctly. | 74 // properties and methods so that we can emulate this correctly. |
| 75 var self = this; | 75 var self = this; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 | 92 |
| 93 return !prevented && !event.defaultPrevented; | 93 return !prevented && !event.defaultPrevented; |
| 94 } | 94 } |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // Export | 97 // Export |
| 98 return { | 98 return { |
| 99 EventTarget: EventTarget | 99 EventTarget: EventTarget |
| 100 }; | 100 }; |
| 101 }); | 101 }); |
| OLD | NEW |