From 7d019560be3782ddb3e31e0602bd014e7bc0e88d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 31 May 2011 17:34:47 -0400 Subject: Fix Firefox freakout. Closes issue #463. --- common/content/events.js | 6 +++++- common/content/modes.js | 12 ++++++------ common/modules/addons.jsm | 39 ++++++++++++++++++++++----------------- common/modules/contexts.jsm | 4 ++++ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 1f13aefa..22a1f3ae 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1451,11 +1451,15 @@ var Events = Module("events", { if (elem == null && urlbar && urlbar.inputField == this._lastFocus) util.threadYield(true); // Why? --Kris - while (modes.main.ownsFocus && !modes.topOfStack.params.holdFocus) + while (modes.main.ownsFocus && modes.topOfStack.params.ownsFocus != elem + && !modes.topOfStack.params.holdFocus) modes.pop(null, { fromFocus: true }); } finally { this._lastFocus = elem; + + if (modes.main.ownsFocus) + modes.topOfStack.params.ownsFocus = elem; } }, diff --git a/common/content/modes.js b/common/content/modes.js index f9b93625..8eb76aab 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -411,14 +411,14 @@ var Modes = Module("modes", { prev = stack && stack.pop || this.topOfStack; if (push) this._modeStack.push(push); + }); - if (stack && stack.pop) - for (let { obj, prop, value, test } in values(this.topOfStack.saved)) - if (!test || !test(stack, prev)) - dactyl.trapErrors(function () { obj[prop] = value }); + if (stack && stack.pop) + for (let { obj, prop, value, test } in values(this.topOfStack.saved)) + if (!test || !test(stack, prev)) + dactyl.trapErrors(function () { obj[prop] = value }); - this.show(); - }); + this.show(); if (this.topOfStack.params.enter && prev) dactyl.trapErrors("enter", this.topOfStack.params, diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index a22b2842..74ce3cf6 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -500,27 +500,14 @@ else addon = this.wrapAddon(addon); return callback(addon); }, + wrapAddon: function wrapAddon(addon) { addon = Object.create(addon.QueryInterface(Ci.nsIUpdateItem)); - function getRdfProperty(item, property) { - let resource = services.rdf.GetResource("urn:mozilla:item:" + item.id); - let value = ""; - - if (resource) { - let target = services.extensionManager.datasource.GetTarget(resource, - services.rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true); - if (target && target instanceof Ci.nsIRDFLiteral) - value = target.Value; - } - - return value; - } - ["aboutURL", "creator", "description", "developers", "homepageURL", "installDate", "optionsURL", "releaseNotesURI", "updateDate"].forEach(function (item) { - memoize(addon, item, function (item) getRdfProperty(this, item)); + memoize(addon, item, function (item) this.getProperty(item)); }); update(addon, { @@ -529,19 +516,33 @@ else appDisabled: false, + getProperty: function getProperty(property) { + let resource = services.rdf.GetResource("urn:mozilla:item:" + this.id); + + if (resource) { + let target = services.extensionManager.datasource.GetTarget(resource, + services.rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true); + + if (target && target instanceof Ci.nsIRDFLiteral) + return target.Value; + } + + return ""; + }, + installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)), getResourceURI: function getResourceURI(path) { let file = this.installLocation.getItemFile(this.id, path); return services.io.newFileURI(file); }, - isActive: getRdfProperty(addon, "isDisabled") != "true", + get isActive() this.getProperty("isDisabled") != "true", uninstall: function uninstall() { services.extensionManager.uninstallItem(this.id); }, - get userDisabled() getRdfProperty(addon, "userDisabled") === "true", + get userDisabled() this.getProperty("userDisabled") === "true", set userDisabled(val) { services.extensionManager[val ? "disableItem" : "enableItem"](this.id); } @@ -549,6 +550,7 @@ else return addon; }, + getAddonsByTypes: function (types, callback) { let res = []; for (let [, type] in Iterator(types)) @@ -560,6 +562,7 @@ else util.timeout(function () { callback(res); }); return res; }, + getInstallForFile: function (file, callback, mimetype) { callback({ addListener: function () {}, @@ -568,9 +571,11 @@ else } }); }, + getInstallForURL: function (url, callback, mimetype) { util.assert(false, _("error.unavailable", config.host, services.runtime.version)); }, + observers: [], addAddonListener: function (listener) { observer.listener = listener; diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index 523033de..8d883a06 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -372,6 +372,7 @@ var Contexts = Module("contexts", { let rhs = args.literalArg; let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce(function (a, b) args[b] ? b : a, default_); + switch (type) { case "-builtin": let noremap = true; @@ -385,6 +386,7 @@ var Contexts = Module("contexts", { } action.macro = util.compileMacro(rhs, true); break; + case "-ex": action = function action() modules.commands .execute(action.macro, makeParams(this, arguments), @@ -392,6 +394,7 @@ var Contexts = Module("contexts", { action.macro = util.compileMacro(rhs, true); action.context = this.context && update({}, this.context); break; + case "-javascript": if (callable(params)) action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })"); @@ -402,6 +405,7 @@ var Contexts = Module("contexts", { action.makeParams = makeParams; break; } + action.toString = function toString() (type === default_ ? "" : type + " ") + rhs; args = null; return action; -- cgit v1.2.3