mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-10 15:05:45 +01:00
Fix deleting files after viewing them from source links in :list*.
This commit is contained in:
@@ -1,76 +1,14 @@
|
||||
// Copyright (c) 2009-2010 by Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2009-2011 by Kris Maglione <maglione.k@gmail.com>
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
if (!JSMLoader || JSMLoader.bump != 1)
|
||||
var JSMLoader = {
|
||||
bump: 1,
|
||||
builtin: Components.utils.Sandbox(this),
|
||||
canonical: {},
|
||||
factories: [],
|
||||
globals: {},
|
||||
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService),
|
||||
manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar),
|
||||
stale: {},
|
||||
getTarget: function getTarget(url) {
|
||||
let chan = this.io.newChannel(url, null, null);
|
||||
chan.cancel(Components.results.NS_BINDING_ABORTED);
|
||||
return chan.name;
|
||||
},
|
||||
load: function load(url, target) {
|
||||
let stale = this.stale[url];
|
||||
if (stale) {
|
||||
delete this.stale[url];
|
||||
|
||||
let global = this.globals[url];
|
||||
for each (let prop in Object.getOwnPropertyNames(global))
|
||||
try {
|
||||
if (!(prop in this.builtin) &&
|
||||
[this, set].indexOf(Object.getOwnPropertyDescriptor(global, prop).value) < 0 &&
|
||||
!global.__lookupGetter__(prop))
|
||||
global[prop] = undefined;
|
||||
}
|
||||
catch (e) {
|
||||
dump("Deleting property " + prop + " on " + url + ":\n " + e + "\n");
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
if (stale === this.getTarget(url))
|
||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||
.loadSubScript(url, global);
|
||||
}
|
||||
|
||||
let global = Components.utils.import(url, target);
|
||||
return this.globals[url] = global;
|
||||
},
|
||||
cleanup: function unregister() {
|
||||
for each (let factory in this.factories.splice(0))
|
||||
this.manager.unregisterFactory(factory.classID, factory);
|
||||
},
|
||||
purge: function purge() {
|
||||
for (let [url, global] in Iterator(this.globals))
|
||||
this.stale[url] = this.getTarget(url);
|
||||
},
|
||||
registerFactory: function registerFactory(factory) {
|
||||
this.manager.registerFactory(factory.classID,
|
||||
String(factory.classID),
|
||||
factory.contractID,
|
||||
factory);
|
||||
this.factories.push(factory);
|
||||
}
|
||||
};
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication)
|
||||
.storage.set("dactyl.JSMLoader", JSMLoader);
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
try {
|
||||
var ctypes;
|
||||
@@ -161,8 +99,10 @@ if (!Object.keys)
|
||||
let use = {};
|
||||
let loaded = {};
|
||||
let currentModule;
|
||||
function defineModule(name, params) {
|
||||
let module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
|
||||
let global = this;
|
||||
function defineModule(name, params, module) {
|
||||
if (!module)
|
||||
module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
|
||||
|
||||
module.NAME = name;
|
||||
module.EXPORTED_SYMBOLS = params.exports || [];
|
||||
@@ -230,7 +170,7 @@ function endModule() {
|
||||
function require(obj, name, from) {
|
||||
try {
|
||||
defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
|
||||
JSMLoader.load("resource://dactyl/" + name + ".jsm", obj);
|
||||
JSMLoader.load(name + ".jsm", obj);
|
||||
}
|
||||
catch (e) {
|
||||
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
||||
@@ -252,7 +192,7 @@ defineModule("base", {
|
||||
"require", "set", "update", "values", "withCallerGlobal"
|
||||
],
|
||||
use: ["config", "services", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
function Runnable(self, func, args) {
|
||||
return {
|
||||
@@ -329,12 +269,14 @@ function deprecated(reason, fn) {
|
||||
|
||||
function deprecatedMethod() {
|
||||
let frame = Components.stack.caller;
|
||||
let obj = this.className || this.constructor.className;
|
||||
let obj = this.className ? this.className + "#" :
|
||||
this.constructor.className ? this.constructor.className + "#" :
|
||||
"";
|
||||
let filename = frame.filename.replace(/.* -> /, "");
|
||||
if (!set.add(deprecatedMethod.seen, filename))
|
||||
util.dactyl(fn).echoerr(
|
||||
util.urlPath(filename || "unknown") + ":" + frame.lineNumber + ": " +
|
||||
(obj ? obj + "." : "") + (fn.name || name) + " is deprecated: " + reason);
|
||||
obj + (fn.name || name) + " is deprecated: " + reason);
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
deprecatedMethod.seen = {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("bookmarkcache", {
|
||||
exports: ["Bookmark", "BookmarkCache", "Keyword", "bookmarkcache"],
|
||||
require: ["services", "storage", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "charset", "id");
|
||||
var Keyword = Struct("keyword", "title", "icon", "url");
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("completion", {
|
||||
exports: ["CompletionContext", "Completion", "completion"],
|
||||
use: ["config", "template", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
/**
|
||||
* Creates a new completion context.
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("config", {
|
||||
exports: ["ConfigBase", "Config", "config"],
|
||||
require: ["highlight", "services", "storage", "util", "template"],
|
||||
use: ["io"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var ConfigBase = Class("ConfigBase", {
|
||||
/**
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("finder", {
|
||||
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
||||
use: ["prefs", "services", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
/** @instance rangefinder */
|
||||
var RangeFinder = Module("rangefinder", {
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("highlight", {
|
||||
exports: ["Highlight", "Highlights", "highlight"],
|
||||
require: ["services", "styles", "util"],
|
||||
use: ["template"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var Highlight = Struct("class", "selector", "sites",
|
||||
"defaultExtends", "defaultValue",
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("io", {
|
||||
exports: ["IO", "io"],
|
||||
require: ["services"],
|
||||
use: ["config", "storage", "styles", "template", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
// TODO: why are we passing around strings rather than file objects?
|
||||
/**
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("javascript", {
|
||||
exports: ["JavaScript", "javascript"],
|
||||
use: ["services", "template", "util"],
|
||||
});
|
||||
}, this);
|
||||
|
||||
// TODO: Clean this up.
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("overlay", {
|
||||
exports: ["ModuleBase"],
|
||||
require: ["config", "sanitizer", "services", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
/**
|
||||
* @class ModuleBase
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("prefs", {
|
||||
exports: ["Prefs", "localPrefs", "prefs"],
|
||||
require: ["services", "util"],
|
||||
use: ["config", "template"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
SAVED: "extensions.dactyl.saved.",
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("sanitizer", {
|
||||
exports: ["Range", "Sanitizer", "sanitizer"],
|
||||
require: ["prefs", "services", "storage", "template", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
let tmp = {};
|
||||
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
try {
|
||||
|
||||
var global = this;
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("services", {
|
||||
exports: ["AddonManager", "services"],
|
||||
use: ["util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
/**
|
||||
* A lazily-instantiated XPCOM class and service cache.
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
"use strict";
|
||||
|
||||
var myObject = Object;
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("storage", {
|
||||
exports: ["File", "storage"],
|
||||
require: ["services", "util"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("styles", {
|
||||
exports: ["Style", "Styles", "styles"],
|
||||
require: ["services", "util"],
|
||||
use: ["template"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("template", {
|
||||
exports: ["Template", "template"],
|
||||
require: ["util"],
|
||||
use: ["services"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
default xml namespace = XHTML;
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("util", {
|
||||
exports: ["FailedAssertion", "Math", "NS", "Point", "Util", "XBL", "XHTML", "XUL", "util"],
|
||||
require: ["services"],
|
||||
use: ["config", "highlight", "storage", "template"]
|
||||
});
|
||||
}, this);
|
||||
|
||||
var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||
|
||||
Reference in New Issue
Block a user