diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index eef65aba..466f7b4f 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -20,7 +20,7 @@ var Bookmarks = Module("bookmarks", { valueOf: function () arg } }, arg)); - statusline.updateUrl(); + statusline.updateStatus(); }, window); }, diff --git a/common/content/browser.js b/common/content/browser.js index 731165f6..534ba143 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -76,7 +76,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), // hacky way to get rid of "Transferring data from ..." on sites with frames // when you click on a link inside a frameset, because asyncUpdateUI // is not triggered there (Gecko bug?) - this.timeout(function () { statusline.updateUrl(); }, 10); + this.timeout(function () { statusline.updateStatus(); }, 10); } else { // code which should happen for all (also background) newly loaded tabs goes here: @@ -160,7 +160,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), // called at the very end of a page load asyncUpdateUI: util.wrapCallback(function asyncUpdateUI() { asyncUpdateUI.superapply(this, arguments); - util.timeout(function () { statusline.updateUrl(); }, 100); + util.timeout(function () { statusline.updateStatus(); }, 100); }), setOverLink: util.wrapCallback(function setOverLink(link, b) { setOverLink.superapply(this, arguments); @@ -189,7 +189,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), function () { window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils) .redraw(); - statusline.updateUrl(); + statusline.updateStatus(); commandline.clear(); }, { argCount: "0" }); diff --git a/common/content/events.js b/common/content/events.js index c3a66d8e..c16b6e64 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -65,7 +65,7 @@ var ProcessorStack = Class("ProcessorStack", { this.processors.length = 0; if (this.ownsBuffer) - statusline.updateInputBuffer(this.processors.length ? this.buffer : ""); + statusline.inputBuffer = this.processors.length ? this.buffer : ""; if (!this.processors.some(function (p) !p.extended) && this.actions.length) { if (this._actions.length == 0) { diff --git a/common/content/hints.js b/common/content/hints.js index 12eb36da..443f0f8e 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -668,8 +668,8 @@ var HintSession = Class("HintSession", CommandMode, { * Display the current status to the user. */ updateStatusline: function _updateStatusline() { - statusline.updateInputBuffer((this.escapeNumbers ? options["mapleader"] : "") + - (this.hintNumber ? this.getHintString(this.hintNumber) : "")); + statusline.inputBuffer = (this.escapeNumbers ? options["mapleader"] : "") + + (this.hintNumber ? this.getHintString(this.hintNumber) : ""); }, }); diff --git a/common/content/modes.js b/common/content/modes.js index b750526f..8edce45a 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -184,7 +184,7 @@ var Modes = Module("modes", { if (prefs.get("accessibility.browsewithcaret")) prefs.set("accessibility.browsewithcaret", false); - statusline.updateUrl(); + statusline.updateStatus(); if (!stack.fromFocus && prev.main.ownsFocus) dactyl.focusContent(true); if (prev.main == modes.NORMAL) { diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index 532343a5..1ef116f1 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -15,7 +15,7 @@ var QuickMarks = Module("quickmarks", { init: function () { this._qmarks = storage.newMap("quickmarks", { store: true }); storage.addObserver("quickmarks", function () { - statusline.updateUrl(); + statusline.updateStatus(); }, window); }, diff --git a/common/content/statusline.js b/common/content/statusline.js index 17f4d0c5..79607270 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -95,7 +95,7 @@ var StatusLine = Module("statusline", { signals: { "browser.locationChange": function (webProgress, request, uri) { let win = webProgress.DOMWindow; - this.updateUrl(); + this.status = buffer.uri; this.progress = uri && win && win.dactylProgress || ""; // if this is not delayed we get the position of the old buffer @@ -107,7 +107,7 @@ var StatusLine = Module("statusline", { "browser.overLink": function (link) { switch (options["showstatuslinks"]) { case "status": - this.updateUrl(link ? _("status.link", link) : null); + this.status = link ? _("status.link", link) : buffer.uri; break; case "command": if (link) @@ -141,11 +141,11 @@ var StatusLine = Module("statusline", { this.progress = 0; if (flags & Ci.nsIWebProgressListener.STATE_STOP) { this.progress = ""; - this.updateUrl(); + this.status = buffer.uri; } }, "browser.statusChange": function onStatusChange(webProgress, request, status, message) { - this.updateUrl(message); + this.status = message || buffer.uri; }, }, @@ -174,14 +174,43 @@ var StatusLine = Module("statusline", { // update all fields of the statusline update: function update() { - this.updateUrl(); - this.updateInputBuffer(); - this.updateProgress(); + this.status = buffer.uri; + this.inputBuffer = ""; + this.progress = ""; this.updateTabCount(); this.updateBufferPosition(); this.updateZoomLevel(); }, + // ripped from Firefox; modified + unsafeURI: util.regexp(String.replace(, /U/g, "\\u"), + "gx"), + losslessDecodeURI: function losslessDecodeURI(url) { + return url.split("%25").map(function (url) { + // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors. + try { + return decodeURI(url).replace(this.unsafeURI, encodeURIComponent); + } + catch (e) { + return url; + } + }, this).join("%25"); + }, + /** * Update the URL displayed in the status line. Also displays status * icons, [+-♥], when there are next and previous pages in the @@ -189,64 +218,32 @@ var StatusLine = Module("statusline", { * respectively. * * @param {string} url The URL to display. - * @default buffer.uri */ - updateUrl: function updateUrl(url) { - // ripped from Firefox; modified - function losslessDecodeURI(url) { - // 1. decodeURI decodes %25 to %, which creates unintended - // encoding sequences. - url = url.split("%25").map(function (url) { - // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors. - try { - return decodeURI(url); - } - catch (e) { - return url; - } - }).join("%25"); - // 2. Re-encode whitespace so that it doesn't get eaten away - // by the location bar (bug 410726). - url = url.replace(/[\r\n\t]/g, encodeURIComponent); - - // Encode invisible characters (soft hyphen, zero-width space, BOM, - // line and paragraph separator, word joiner, invisible times, - // invisible separator, object replacement character) (bug 452979) - url = url.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u00ad\u200b\ufeff\u2028\u2029\u2060\u2062\u2063\ufffc]/g, - encodeURIComponent); - - // Encode bidirectional formatting characters. - // (RFC 3987 sections 3.2 and 4.1 paragraph 6) - url = url.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g, - encodeURIComponent); - return url; - }; - - // TODO: this probably needs a more general solution. - if (url == null) - url = buffer.uri.spec; - - // when session information is available, add [+] when we can go - // backwards, [-] when we can go forwards + get status() this._uri, + set status(uri) { let modified = ""; - if (url === buffer.uri.spec) { - if (window.getWebNavigation) { + let url = uri; + if (isinstance(uri, Ci.nsIURI)) { + // when session information is available, add [+] when we can go + // backwards, [-] when we can go forwards + if (uri.equals(buffer.uri) && window.getWebNavigation) { let sh = window.getWebNavigation().sessionHistory; if (sh && sh.index > 0) modified += "+"; if (sh && sh.index < sh.count - 1) modified += "-"; } - if (modules.bookmarkcache) { - if (bookmarkcache.isBookmarked(url)) - modified += UTF8("❤"); - //modified += UTF8("♥"); - } - if (modules.quickmarks) - modified += quickmarks.find(url.replace(/#.*/, "")).join(""); - } - url = losslessDecodeURI(url); + if (modules.bookmarkcache) { + if (bookmarkcache.isBookmarked(uri)) + modified += UTF8("❤"); + } + + if (modules.quickmarks) + modified += quickmarks.find(uri.spec.replace(/#.*/, "")).join(""); + + url = this.losslessDecodeURI(uri.spec); + } if (url == "about:blank") { if (!buffer.title) @@ -261,8 +258,14 @@ var StatusLine = Module("statusline", { url += " [" + modified + "]"; this.widgets.url.value = url; + this._status = uri; + }, + updateStatus: function updateStatus() { this.status = buffer.uri; }, + + updateUrl: deprecated("statusline.status", function updateUrl(url) { this.status = url || buffer.uri }), + /** * Set the contents of the status line's input buffer to the given * string. Used primarily when a key press requires further input @@ -272,12 +275,9 @@ var StatusLine = Module("statusline", { * @param {string} buffer * @optional */ - updateInputBuffer: function updateInputBuffer(buffer) { - if (buffer == null) - buffer = ""; - - this.widgets.inputbuffer.value = buffer; - }, + get inputBuffer() this.widgets.inputbuffer.value, + set inputBuffer(val) this.widgets.inputbuffer.value = val == null ? "" : val, + updateInputBuffer: deprecated("statusline.inputBuffer", function updateInputBuffer(val) { this.inputBuffer = val; }), /** * Update the page load progress bar. @@ -310,9 +310,9 @@ var StatusLine = Module("statusline", { } } }), - updateProgress: function updateProgress(progress) { + updateProgress: deprecated("statusline.progress", function updateProgress(progress) { this.progress = progress; - }, + }), /** * Display the correct tabcount (e.g., [1/5]) on the status bar. diff --git a/common/modules/base.jsm b/common/modules/base.jsm index f260f662..e00211ad 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -875,15 +875,20 @@ Class.prototype = { }; Class.makeClosure = function makeClosure() { const self = this; - function closure(fn) function _closure() { - try { - return fn.apply(self, arguments); - } - catch (e if !(e instanceof FailedAssertion)) { - util.reportError(e); - throw e.stack ? e : Error(e); + function closure(fn) { + function _closure() { + try { + return fn.apply(self, arguments); + } + catch (e if !(e instanceof FailedAssertion)) { + util.reportError(e); + throw e.stack ? e : Error(e); + } } + _closure.wrapped = fn; + return _closure; } + iter(properties(this), properties(this, true)).forEach(function (k) { if (!__lookupGetter__.call(this, k) && callable(this[k])) closure[k] = closure(this[k]); @@ -895,6 +900,7 @@ Class.makeClosure = function makeClosure() { set: function set_proxy(val) self[k] = val, }); }, this); + return closure; }; memoize(Class.prototype, "closure", Class.makeClosure); @@ -981,11 +987,13 @@ Module.INIT = { modules.jsmodules[this.constructor.className] = module; locals.reverse().forEach(function (fn, i) update(objs[i], fn.apply(module, args))) + + memoize(module, "closure", Class.makeClosure); module.instance = module; module.init(); if (module.signals) - modules.dactyl.registerObservers + modules.dactyl.registerObservers(module); } } } diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index f830e4fb..6de76cdf 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -311,7 +311,6 @@ var Overlay = Module("Overlay", { modules.events.listen(window, "unload", function onUnload() { window.removeEventListener("unload", onUnload.wrapped, false); - util.dump("unload", modules.moduleList); for each (let mod in modules.moduleList.reverse()) { mod.stale = true;