diff options
author | Kris Maglione <maglione.k@gmail.com> | 2010-12-24 18:32:22 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2010-12-24 18:32:22 -0500 |
commit | d3d60548f13ea9061f87ec203a7dfb3e8332b8cd (patch) | |
tree | ad424026e7789a7fe78d8ca66ac21e964539840d /common/content/buffer.js | |
parent | 2f081bd80518a4c0dc38948c657ab7360ce0383a (diff) | |
download | pentadactyl-d3d60548f13ea9061f87ec203a7dfb3e8332b8cd.tar.gz |
Fix some cleanup issues.
--HG--
branch : bootstrapped
Diffstat (limited to 'common/content/buffer.js')
-rw-r--r-- | common/content/buffer.js | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js index 456062e8..04dc93ed 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -147,6 +147,40 @@ const Buffer = Module("buffer", { let elem = event.originalTarget; buffer.viewSource([elem.getAttribute("href"), Number(elem.getAttribute("line"))]) }; + + this.replaceProgressListener(this.progressListener); + }, + + cleanup: function () { + for (let prop in properties(this.progressListener)) + if (!this.progressListener.__lookupGetter__(prop) && + !callable(this.progressListener[prop])) + this.origProgressListener[prop] = this.progressListener[prop] + + this.replaceProgressListener(this.origProgressListener); + }, + + replaceProgressListener: function (newListener) { + // I hate this whole hack. --Kris + let obj = window.XULBrowserWindow, getter; + for (let prop in properties(obj)) + if ((getter = obj.__lookupGetter__(prop)) && !obj.__lookupSetter__(prop)) { + newListener.__defineGetter__(prop, getter); + delete obj[prop]; + } + + this.origProgressListener = window.XULBrowserWindow; + try { + config.browser.removeProgressListener(window.XULBrowserWindow); + } + catch (e) {} // Why? --djk + + config.browser.addProgressListener(newListener, Ci.nsIWebProgress.NOTIFY_ALL); + window.XULBrowserWindow = newListener; + window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner + .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow) + .XULBrowserWindow = newListener; }, destroy: function () { @@ -1502,26 +1536,6 @@ const Buffer = Module("buffer", { }; }, events: function () { - try { - config.browser.removeProgressListener(window.XULBrowserWindow); - } - catch (e) {} // Why? --djk - - // I hate this whole hack. --Kris - let obj = window.XULBrowserWindow, getter; - for (let p in properties(obj)) - if ((getter = obj.__lookupGetter__(p)) && !obj.__lookupSetter__(p)) { - this.progressListener.__defineGetter__(p, getter); - delete obj[p]; - } - - config.browser.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_ALL); - window.XULBrowserWindow = this.progressListener; - window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow) - .XULBrowserWindow = this.progressListener; - events.addSessionListener(config.browser, "DOMContentLoaded", this.closure.onDOMContentLoaded, true); events.addSessionListener(config.browser, "load", this.closure.onPageLoad, true); events.addSessionListener(config.browser, "scroll", this.closure._updateBufferPosition, false); |