diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 02:51:42 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 02:51:42 +0000 |
commit | d02982248bb68073e940deeec7e36f5c3aab9ee6 (patch) | |
tree | ed8f78c90e0a5c8a4af9d43d39ef0e84797939de /chrome/renderer/resources/event_bindings.js | |
parent | 3332977cf064c71b0d25f83bc6e35d8856059d56 (diff) | |
download | chromium_src-d02982248bb68073e940deeec7e36f5c3aab9ee6.zip chromium_src-d02982248bb68073e940deeec7e36f5c3aab9ee6.tar.gz chromium_src-d02982248bb68073e940deeec7e36f5c3aab9ee6.tar.bz2 |
Revert 18765 to try to repair perf regression
TBR=mpcomplete
Review URL: http://codereview.chromium.org/131093
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/resources/event_bindings.js')
-rw-r--r-- | chrome/renderer/resources/event_bindings.js | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/chrome/renderer/resources/event_bindings.js b/chrome/renderer/resources/event_bindings.js index 54dd108..f11ec78 100644 --- a/chrome/renderer/resources/event_bindings.js +++ b/chrome/renderer/resources/event_bindings.js @@ -1,5 +1,5 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // ----------------------------------------------------------------------------- @@ -29,9 +29,6 @@ var chrome = chrome || {}; // A map of event names to the event object that is registered to that name. chrome.Event.attached_ = {}; - // An array of all attached event objects, used for detaching on unload. - chrome.Event.allAttached_ = []; - // Dispatches a named event with the given JSON array, which is deserialized // before dispatch. The JSON array is the list of arguments that will be // sent with the event callback. @@ -108,7 +105,8 @@ var chrome = chrome || {}; // name. chrome.Event.prototype.attach_ = function() { AttachEvent(this.eventName_); - chrome.Event.allAttached_[chrome.Event.allAttached_.length] = this; + this.unloadHandler_ = this.detach_.bind(this); + window.addEventListener('unload', this.unloadHandler_, false); if (!this.eventName_) return; @@ -122,9 +120,7 @@ var chrome = chrome || {}; // Detaches this event object from its name. chrome.Event.prototype.detach_ = function() { - var i = chrome.Event.allAttached_.indexOf(this); - if (i >= 0) - delete chrome.Event.allAttached_[i]; + window.removeEventListener('unload', this.unloadHandler_, false); DetachEvent(this.eventName_); if (!this.eventName_) return; @@ -136,21 +132,4 @@ var chrome = chrome || {}; delete chrome.Event.attached_[this.eventName_]; }; - - // Load events. Note that onUnload_ might not always fire, since Chrome will - // terminate renderers on shutdown. - chrome.onLoad_ = new chrome.Event(); - chrome.onUnload_ = new chrome.Event(); - - // This is called by native code when the DOM is ready. - chrome.dispatchOnLoad_ = function() { - chrome.onLoad_.dispatch(); - delete chrome.dispatchOnLoad_; - } - - chrome.dispatchOnUnload_ = function() { - chrome.onUnload_.dispatch(); - for (var i in chrome.Event.allAttached_) - chrome.Event.allAttached_[i].detach_(); - } })(); |