diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 21:47:55 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 21:47:55 +0000 |
commit | 25898d64396ac91275a9bc72a77817347ab474dd (patch) | |
tree | f9699f8ec7a7e87e30a73a8f49d776d4083a09e9 /ui/webui | |
parent | 8d990950957e4d4a66952764d41011a51dae9c3a (diff) | |
download | chromium_src-25898d64396ac91275a9bc72a77817347ab474dd.zip chromium_src-25898d64396ac91275a9bc72a77817347ab474dd.tar.gz chromium_src-25898d64396ac91275a9bc72a77817347ab474dd.tar.bz2 |
Remove cr.Event in favor of Event
DOM has improved a lot since we first started. We can now use the native
Event constructor.
BUG=None
Review URL: https://codereview.chromium.org/26891004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/webui')
-rw-r--r-- | ui/webui/resources/js/cr.js | 35 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/array_data_model.js | 1 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/autocomplete_list.js | 2 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/command.js | 5 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/context_menu_handler.js | 1 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/list.js | 2 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/list_selection_model.js | 1 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/list_single_selection_model.js | 1 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/table/table_column.js | 1 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/table/table_column_model.js | 1 |
10 files changed, 10 insertions, 40 deletions
diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js index 3ea3b91..a3d1263 100644 --- a/ui/webui/resources/js/cr.js +++ b/ui/webui/resources/js/cr.js @@ -49,7 +49,7 @@ this.cr = (function() { * @param {*} oldValue The old value for the property. */ function dispatchPropertyChange(target, propertyName, newValue, oldValue) { - var e = new cr.Event(propertyName + 'Change'); + var e = new Event(propertyName + 'Change'); e.propertyName = propertyName; e.newValue = newValue; e.oldValue = oldValue; @@ -226,12 +226,15 @@ this.cr = (function() { * @param {string} type The type of the event. * @param {boolean=} opt_bubbles Whether the event bubbles or not. * @param {boolean=} opt_cancelable Whether the default action of the event - * can be prevented. + * can be prevented. Default is true. * @return {boolean} If any of the listeners called {@code preventDefault} * during the dispatch this will return false. */ function dispatchSimpleEvent(target, type, opt_bubbles, opt_cancelable) { - var e = new cr.Event(type, opt_bubbles, opt_cancelable); + var e = new Event(type, { + bubbles: opt_bubbles, + cancelable: opt_cancelable === undefined || opt_cancelable + }); return target.dispatchEvent(e); } @@ -280,29 +283,6 @@ this.cr = (function() { }; } - var OriginalEvent = global.Event; - - /** - * Creates a new event to be used with cr.EventTarget or DOM EventTarget - * objects. - * @param {string} type The name of the event. - * @param {boolean=} opt_bubbles Whether the event bubbles. - * Default is false. - * @param {boolean=} opt_cancelable Whether the default action of the event - * can be prevented. Unlike the DOM event constructor, this defaults to - * true. - * @constructor - * @extends {Event} - */ - function Event(type, opt_bubbles, opt_cancelable) { - var e = new OriginalEvent(type, { - bubbles: opt_bubbles, - cancelable: opt_cancelable === undefined ? true : opt_cancelable - }); - e.__proto__ = OriginalEvent.prototype; - return e; - }; - /** * Initialization which must be deferred until run-time. */ @@ -324,8 +304,6 @@ this.cr = (function() { return; } - Event.prototype = {__proto__: OriginalEvent.prototype}; - cr.doc = document; /** @@ -368,7 +346,6 @@ this.cr = (function() { defineProperty: defineProperty, dispatchPropertyChange: dispatchPropertyChange, dispatchSimpleEvent: dispatchSimpleEvent, - Event: Event, getUid: getUid, initialize: initialize, PropertyKind: PropertyKind diff --git a/ui/webui/resources/js/cr/ui/array_data_model.js b/ui/webui/resources/js/cr/ui/array_data_model.js index 0c4a99b..fdbdca9 100644 --- a/ui/webui/resources/js/cr/ui/array_data_model.js +++ b/ui/webui/resources/js/cr/ui/array_data_model.js @@ -8,7 +8,6 @@ cr.define('cr.ui', function() { /** @const */ var EventTarget = cr.EventTarget; - /** @const */ var Event = cr.Event; /** * A data model that wraps a simple array and supports sorting by storing diff --git a/ui/webui/resources/js/cr/ui/autocomplete_list.js b/ui/webui/resources/js/cr/ui/autocomplete_list.js index 1134425..6dd04f3 100644 --- a/ui/webui/resources/js/cr/ui/autocomplete_list.js +++ b/ui/webui/resources/js/cr/ui/autocomplete_list.js @@ -233,7 +233,7 @@ cr.define('cr.ui', function() { break; case 'Up': case 'Down': - var newEvent = new cr.Event(event.type); + var newEvent = new Event(event.type); newEvent.keyIdentifier = event.keyIdentifier; this.dispatchEvent(newEvent); handled = true; diff --git a/ui/webui/resources/js/cr/ui/command.js b/ui/webui/resources/js/cr/ui/command.js index 280503b..540db04 100644 --- a/ui/webui/resources/js/cr/ui/command.js +++ b/ui/webui/resources/js/cr/ui/command.js @@ -95,7 +95,7 @@ cr.define('cr.ui', function() { return; var doc = this.ownerDocument; if (doc.activeElement) { - var e = new cr.Event('command', true, false); + var e = new Event('command', {bubbles: true}); e.command = this; (opt_element || doc.activeElement).dispatchEvent(e); @@ -283,8 +283,7 @@ cr.define('cr.ui', function() { * @class */ function CanExecuteEvent(command) { - var e = command.ownerDocument.createEvent('Event'); - e.initEvent('canExecute', true, false); + var e = new Event('canExecute', {bubbles: true}); e.__proto__ = CanExecuteEvent.prototype; e.command = command; return e; diff --git a/ui/webui/resources/js/cr/ui/context_menu_handler.js b/ui/webui/resources/js/cr/ui/context_menu_handler.js index 05264d6..c54bdd6 100644 --- a/ui/webui/resources/js/cr/ui/context_menu_handler.js +++ b/ui/webui/resources/js/cr/ui/context_menu_handler.js @@ -6,7 +6,6 @@ cr.define('cr.ui', function() { /** @const */ var EventTarget = cr.EventTarget; - /** @const */ var Event = cr.Event; /** @const */ var Menu = cr.ui.Menu; /** diff --git a/ui/webui/resources/js/cr/ui/list.js b/ui/webui/resources/js/cr/ui/list.js index f8ab231..4c49bd8 100644 --- a/ui/webui/resources/js/cr/ui/list.js +++ b/ui/webui/resources/js/cr/ui/list.js @@ -591,7 +591,7 @@ cr.define('cr.ui', function() { /** * Callback from the selection model. We dispatch {@code change} events * when the selection changes. - * @param {!cr.Event} e Event with change info. + * @param {!Event} e Event with change info. * @private */ handleOnChange_: function(ce) { diff --git a/ui/webui/resources/js/cr/ui/list_selection_model.js b/ui/webui/resources/js/cr/ui/list_selection_model.js index 73ffd5e..4fb2ccf 100644 --- a/ui/webui/resources/js/cr/ui/list_selection_model.js +++ b/ui/webui/resources/js/cr/ui/list_selection_model.js @@ -3,7 +3,6 @@ // found in the LICENSE file. cr.define('cr.ui', function() { - /** @const */ var Event = cr.Event; /** @const */ var EventTarget = cr.EventTarget; /** diff --git a/ui/webui/resources/js/cr/ui/list_single_selection_model.js b/ui/webui/resources/js/cr/ui/list_single_selection_model.js index 8789f20..bf951b7 100644 --- a/ui/webui/resources/js/cr/ui/list_single_selection_model.js +++ b/ui/webui/resources/js/cr/ui/list_single_selection_model.js @@ -3,7 +3,6 @@ // found in the LICENSE file. cr.define('cr.ui', function() { - /** @const */ var Event = cr.Event; /** @const */ var EventTarget = cr.EventTarget; /** diff --git a/ui/webui/resources/js/cr/ui/table/table_column.js b/ui/webui/resources/js/cr/ui/table/table_column.js index bcc5702..d8533a0 100644 --- a/ui/webui/resources/js/cr/ui/table/table_column.js +++ b/ui/webui/resources/js/cr/ui/table/table_column.js @@ -8,7 +8,6 @@ cr.define('cr.ui.table', function() { /** @const */ var EventTarget = cr.EventTarget; - /** @const */ var Event = cr.Event; /** * A table column that wraps column ids and settings. diff --git a/ui/webui/resources/js/cr/ui/table/table_column_model.js b/ui/webui/resources/js/cr/ui/table/table_column_model.js index 10c3907..1d9f600 100644 --- a/ui/webui/resources/js/cr/ui/table/table_column_model.js +++ b/ui/webui/resources/js/cr/ui/table/table_column_model.js @@ -7,7 +7,6 @@ */ cr.define('cr.ui.table', function() { /** @const */ var EventTarget = cr.EventTarget; - /** @const */ var Event = cr.Event; /** * A table column model that wraps table columns array |