mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 12:38:00 +01:00
Fix deleting files after viewing them from source links in :list*.
This commit is contained in:
@@ -8,7 +8,7 @@ GOOGLE_PROJ = dactyl
|
|||||||
GOOGLE = https://$(GOOGLE_PROJ).googlecode.com/files
|
GOOGLE = https://$(GOOGLE_PROJ).googlecode.com/files
|
||||||
VERSION ?= $(shell sed -n 's/.*em:version\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
|
VERSION ?= $(shell sed -n 's/.*em:version\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
|
||||||
UUID := $(shell sed -n 's/.*em:id\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
|
UUID := $(shell sed -n 's/.*em:id\(>\|="\)\(.*\)["<].*/\2/p' $(TOP)/install.rdf | sed 1q)
|
||||||
MANGLE := $(shell date | md5sum - | awk '{ print $$1 }')
|
MANGLE := $(shell date '+%s' | awk '{ printf "%x", $$1 }')
|
||||||
|
|
||||||
LOCALEDIR = locale
|
LOCALEDIR = locale
|
||||||
DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
|
DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
|
||||||
@@ -163,7 +163,7 @@ $(XPI): $(CHROME)
|
|||||||
@echo "Building XPI..."
|
@echo "Building XPI..."
|
||||||
mkdir -p $(XPI_PATH)
|
mkdir -p $(XPI_PATH)
|
||||||
|
|
||||||
$(AWK) -v 'name=$(NAME)' -v 'chrome=$(MANGLE)' \
|
$(AWK) -v 'name=$(NAME)' -v 'suffix=$(MANGLE)' \
|
||||||
-f $(BASE)/process_manifest.awk \
|
-f $(BASE)/process_manifest.awk \
|
||||||
$(TOP)/chrome.manifest >$(XPI_PATH)/chrome.manifest
|
$(TOP)/chrome.manifest >$(XPI_PATH)/chrome.manifest
|
||||||
|
|
||||||
|
|||||||
16
common/bootstrap.js
vendored
16
common/bootstrap.js
vendored
@@ -47,7 +47,6 @@ let basePath = null;
|
|||||||
let components = {};
|
let components = {};
|
||||||
let getURI = null;
|
let getURI = null;
|
||||||
storage.set("dactyl.bootstrap", this);
|
storage.set("dactyl.bootstrap", this);
|
||||||
var JSMLoader = storage.get("dactyl.JSMLoader", { get load() Cu.import });
|
|
||||||
|
|
||||||
function startup(data, reason) {
|
function startup(data, reason) {
|
||||||
dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n");
|
dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n");
|
||||||
@@ -62,7 +61,7 @@ function startup(data, reason) {
|
|||||||
AddonManager.getAddonByID(addon.id, function (a) { addon = a; });
|
AddonManager.getAddonByID(addon.id, function (a) { addon = a; });
|
||||||
|
|
||||||
// Temporary hack.
|
// Temporary hack.
|
||||||
if (basePath.isDirectory() && JSMLoader.bump == null)
|
if (basePath.isDirectory() && false && JSMLoader.bump == null)
|
||||||
JSMLoader.bump = 1;
|
JSMLoader.bump = 1;
|
||||||
|
|
||||||
if (basePath.isDirectory())
|
if (basePath.isDirectory())
|
||||||
@@ -147,17 +146,26 @@ function init() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "resource":
|
case "resource":
|
||||||
|
let str = "dactyl-";
|
||||||
|
if (fields[1].indexOf(str) == 0)
|
||||||
|
var prefix = fields[1].substr(str.length);
|
||||||
|
|
||||||
resourceProto.setSubstitution(fields[1], getURI(fields[2]));
|
resourceProto.setSubstitution(fields[1], getURI(fields[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSMLoader.load("resource://dactyl/base.jsm", global);
|
if (typeof JSMLoader === "undefined")
|
||||||
|
Cu.import("resource://dactyl/bootstrap.jsm", global);
|
||||||
|
else {
|
||||||
|
Cu.import("resource://dactyl/bootstrap.jsm", {}).JSMLoader = JSMLoader;
|
||||||
|
JSMLoader.load("resource://dactyl/bootstrap.jsm", global);
|
||||||
|
}
|
||||||
|
|
||||||
for each (let component in components)
|
for each (let component in components)
|
||||||
component.register();
|
component.register();
|
||||||
|
|
||||||
Services.obs.notifyObservers(null, "dactyl-rehash", null);
|
Services.obs.notifyObservers(null, "dactyl-rehash", null);
|
||||||
JSMLoader.load("resource://dactyl/base.jsm", global);
|
JSMLoader.load("resource://dactyl/bootstrap.jsm", global);
|
||||||
|
|
||||||
require(global, "services");
|
require(global, "services");
|
||||||
|
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ var Buffer = Module("buffer", {
|
|||||||
* buffer. Only returns style sheets for the 'screen' media type.
|
* buffer. Only returns style sheets for the 'screen' media type.
|
||||||
*/
|
*/
|
||||||
get alternateStyleSheets() {
|
get alternateStyleSheets() {
|
||||||
let stylesheets = window.getAllStyleSheets(buffer.focusedFrame);
|
let stylesheets = window.getAllStyleSheets(this.focusedFrame);
|
||||||
|
|
||||||
return stylesheets.filter(
|
return stylesheets.filter(
|
||||||
function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title)
|
function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title)
|
||||||
@@ -362,7 +362,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @property {number} True when the buffer is fully loaded.
|
* @property {number} True when the buffer is fully loaded.
|
||||||
*/
|
*/
|
||||||
get loaded() Math.min.apply(null,
|
get loaded() Math.min.apply(null,
|
||||||
buffer.allFrames()
|
this.allFrames()
|
||||||
.map(function (frame) ["loading", "interactive", "complete"]
|
.map(function (frame) ["loading", "interactive", "complete"]
|
||||||
.indexOf(frame.document.readyState))),
|
.indexOf(frame.document.readyState))),
|
||||||
|
|
||||||
@@ -425,7 +425,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @property {number} The buffer's horizontal scroll percentile.
|
* @property {number} The buffer's horizontal scroll percentile.
|
||||||
*/
|
*/
|
||||||
get scrollXPercent() {
|
get scrollXPercent() {
|
||||||
let elem = buffer.findScrollable(0, true);
|
let elem = this.findScrollable(0, true);
|
||||||
if (elem.scrollWidth - elem.clientWidth === 0)
|
if (elem.scrollWidth - elem.clientWidth === 0)
|
||||||
return 0;
|
return 0;
|
||||||
return elem.scrollLeft * 100 / (elem.scrollWidth - elem.clientWidth);
|
return elem.scrollLeft * 100 / (elem.scrollWidth - elem.clientWidth);
|
||||||
@@ -435,7 +435,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @property {number} The buffer's vertical scroll percentile.
|
* @property {number} The buffer's vertical scroll percentile.
|
||||||
*/
|
*/
|
||||||
get scrollYPercent() {
|
get scrollYPercent() {
|
||||||
let elem = buffer.findScrollable(0, false);
|
let elem = this.findScrollable(0, false);
|
||||||
if (elem.scrollHeight - elem.clientHeight === 0)
|
if (elem.scrollHeight - elem.clientHeight === 0)
|
||||||
return 0;
|
return 0;
|
||||||
return elem.scrollTop * 100 / (elem.scrollHeight - elem.clientHeight);
|
return elem.scrollTop * 100 / (elem.scrollHeight - elem.clientHeight);
|
||||||
@@ -491,7 +491,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getCurrentWord: function (win) {
|
getCurrentWord: function (win) {
|
||||||
win = win || buffer.focusedFrame || content;
|
win = win || this.focusedFrame || content;
|
||||||
let selection = win.getSelection();
|
let selection = win.getSelection();
|
||||||
if (selection.rangeCount == 0)
|
if (selection.rangeCount == 0)
|
||||||
return "";
|
return "";
|
||||||
@@ -545,7 +545,7 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
if (elem instanceof HTMLInputElement && elem.type == "file") {
|
if (elem instanceof HTMLInputElement && elem.type == "file") {
|
||||||
Buffer.openUploadPrompt(elem);
|
Buffer.openUploadPrompt(elem);
|
||||||
buffer.lastInputField = elem;
|
this.lastInputField = elem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isinstance(elem, [HTMLInputElement, XULTextBoxElement]))
|
if (isinstance(elem, [HTMLInputElement, XULTextBoxElement]))
|
||||||
@@ -635,11 +635,11 @@ var Buffer = Module("buffer", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let frame in values(buffer.allFrames(null, true)))
|
for (let frame in values(this.allFrames(null, true)))
|
||||||
for (let elem in followFrame(frame))
|
for (let elem in followFrame(frame))
|
||||||
if (count-- === 0) {
|
if (count-- === 0) {
|
||||||
if (follow)
|
if (follow)
|
||||||
buffer.followLink(elem, dactyl.CURRENT_TAB);
|
this.followLink(elem, dactyl.CURRENT_TAB);
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,7 +660,7 @@ var Buffer = Module("buffer", {
|
|||||||
let { left: offsetX, top: offsetY } = elem.getBoundingClientRect();
|
let { left: offsetX, top: offsetY } = elem.getBoundingClientRect();
|
||||||
|
|
||||||
if (isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]))
|
if (isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]))
|
||||||
return buffer.focusElement(elem);
|
return this.focusElement(elem);
|
||||||
if (isinstance(elem, HTMLLinkElement))
|
if (isinstance(elem, HTMLLinkElement))
|
||||||
return dactyl.open(elem.href, where);
|
return dactyl.open(elem.href, where);
|
||||||
|
|
||||||
@@ -690,7 +690,7 @@ var Buffer = Module("buffer", {
|
|||||||
dactyl.log("Invalid where argument for followLink()", 0);
|
dactyl.log("Invalid where argument for followLink()", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.focusElement(elem);
|
this.focusElement(elem);
|
||||||
|
|
||||||
prefs.withContext(function () {
|
prefs.withContext(function () {
|
||||||
prefs.set("browser.tabs.loadInBackground", true);
|
prefs.set("browser.tabs.loadInBackground", true);
|
||||||
@@ -758,7 +758,7 @@ var Buffer = Module("buffer", {
|
|||||||
_scrollByScrollSize: function _scrollByScrollSize(count, direction) {
|
_scrollByScrollSize: function _scrollByScrollSize(count, direction) {
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
options["scroll"] = count;
|
options["scroll"] = count;
|
||||||
buffer.scrollByScrollSize(direction);
|
this.scrollByScrollSize(direction);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -774,7 +774,7 @@ var Buffer = Module("buffer", {
|
|||||||
count = count || 1;
|
count = count || 1;
|
||||||
|
|
||||||
if (options["scroll"] > 0)
|
if (options["scroll"] > 0)
|
||||||
this.scrollLines(options["scroll"] * direction);
|
this.scrollVertical("lines", options["scroll"] * direction);
|
||||||
else
|
else
|
||||||
this.scrollVertical("pages", direction / 2);
|
this.scrollVertical("pages", direction / 2);
|
||||||
},
|
},
|
||||||
@@ -790,14 +790,14 @@ var Buffer = Module("buffer", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var elem = buffer.focusedFrame.document.activeElement;
|
var elem = this.focusedFrame.document.activeElement;
|
||||||
if (elem == elem.ownerDocument.body)
|
if (elem == elem.ownerDocument.body)
|
||||||
elem = null;
|
elem = null;
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var sel = buffer.focusedFrame.getSelection();
|
var sel = this.focusedFrame.getSelection();
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
if (!elem && sel && sel.rangeCount)
|
if (!elem && sel && sel.rangeCount)
|
||||||
@@ -806,11 +806,11 @@ var Buffer = Module("buffer", {
|
|||||||
elem = find(elem);
|
elem = find(elem);
|
||||||
|
|
||||||
if (!(elem instanceof Element)) {
|
if (!(elem instanceof Element)) {
|
||||||
let doc = buffer.findScrollableWindow().document;
|
let doc = this.findScrollableWindow().document;
|
||||||
elem = find(doc.body || doc.getElementsByTagName("body")[0] ||
|
elem = find(doc.body || doc.getElementsByTagName("body")[0] ||
|
||||||
doc.documentElement);
|
doc.documentElement);
|
||||||
}
|
}
|
||||||
let doc = buffer.focusedFrame.document;
|
let doc = this.focusedFrame.document;
|
||||||
return elem || doc.body || doc.documentElement;
|
return elem || doc.body || doc.documentElement;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -846,7 +846,7 @@ var Buffer = Module("buffer", {
|
|||||||
if (!(content.document instanceof HTMLDocument))
|
if (!(content.document instanceof HTMLDocument))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let frames = buffer.allFrames();
|
let frames = this.allFrames();
|
||||||
|
|
||||||
if (frames.length == 0) // currently top is always included
|
if (frames.length == 0) // currently top is always included
|
||||||
return;
|
return;
|
||||||
@@ -858,7 +858,7 @@ var Buffer = Module("buffer", {
|
|||||||
rect.width && rect.height);
|
rect.width && rect.height);
|
||||||
|
|
||||||
// find the currently focused frame index
|
// find the currently focused frame index
|
||||||
let current = Math.max(0, frames.indexOf(buffer.focusedFrame));
|
let current = Math.max(0, frames.indexOf(this.focusedFrame));
|
||||||
|
|
||||||
// calculate the next frame to focus
|
// calculate the next frame to focus
|
||||||
let next = current + count;
|
let next = current + count;
|
||||||
@@ -921,7 +921,7 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
let option = sections || options["pageinfo"];
|
let option = sections || options["pageinfo"];
|
||||||
let list = template.map(option, function (option) {
|
let list = template.map(option, function (option) {
|
||||||
let opt = buffer.pageInfo[option];
|
let opt = this.pageInfo[option];
|
||||||
return opt ? template.table(opt[1], opt[0](true)) : undefined;
|
return opt ? template.table(opt[1], opt[0](true)) : undefined;
|
||||||
}, <br/>);
|
}, <br/>);
|
||||||
dactyl.echo(list, commandline.FORCE_MULTILINE);
|
dactyl.echo(list, commandline.FORCE_MULTILINE);
|
||||||
@@ -945,7 +945,7 @@ var Buffer = Module("buffer", {
|
|||||||
// copied (and tuned somewhat) from browser.jar -> nsContextMenu.js
|
// copied (and tuned somewhat) from browser.jar -> nsContextMenu.js
|
||||||
let win = document.commandDispatcher.focusedWindow;
|
let win = document.commandDispatcher.focusedWindow;
|
||||||
if (win == window)
|
if (win == window)
|
||||||
win = buffer.focusedFrame;
|
win = this.focusedFrame;
|
||||||
|
|
||||||
let charset = win ? "charset=" + win.document.characterSet : null;
|
let charset = win ? "charset=" + win.document.characterSet : null;
|
||||||
|
|
||||||
@@ -964,7 +964,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @param {boolean} useExternalEditor View the source in the external editor.
|
* @param {boolean} useExternalEditor View the source in the external editor.
|
||||||
*/
|
*/
|
||||||
viewSource: function (url, useExternalEditor) {
|
viewSource: function (url, useExternalEditor) {
|
||||||
let doc = buffer.focusedFrame.document;
|
let doc = this.focusedFrame.document;
|
||||||
|
|
||||||
if (isArray(url)) {
|
if (isArray(url)) {
|
||||||
if (options.get("editor").has("line"))
|
if (options.get("editor").has("line"))
|
||||||
@@ -1006,9 +1006,9 @@ var Buffer = Module("buffer", {
|
|||||||
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
|
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
|
||||||
init: function (doc, callback) {
|
init: function (doc, callback) {
|
||||||
this.callback = callable(callback) ? callback :
|
this.callback = callable(callback) ? callback :
|
||||||
function (file) {
|
function (file, temp) {
|
||||||
editor.editFileExternally({ file: file.path, line: callback },
|
editor.editFileExternally({ file: file.path, line: callback },
|
||||||
function () { file.remove(false); });
|
function () { temp && file.remove(false); });
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1019,12 +1019,12 @@ var Buffer = Module("buffer", {
|
|||||||
let encoder = services.HtmlEncoder();
|
let encoder = services.HtmlEncoder();
|
||||||
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
||||||
temp.write(encoder.encodeToString(), ">");
|
temp.write(encoder.encodeToString(), ">");
|
||||||
return this.callback(temp);
|
return this.callback(temp, true);
|
||||||
}, this, true);
|
}, this, true);
|
||||||
|
|
||||||
let file = util.getFile(uri);
|
let file = util.getFile(uri);
|
||||||
if (file)
|
if (file)
|
||||||
this.callback(file);
|
this.callback(file, false);
|
||||||
else {
|
else {
|
||||||
this.file = io.createTempFile();
|
this.file = io.createTempFile();
|
||||||
var persist = services.Persist();
|
var persist = services.Persist();
|
||||||
@@ -1038,7 +1038,7 @@ var Buffer = Module("buffer", {
|
|||||||
onStateChange: function (progress, request, flag, status) {
|
onStateChange: function (progress, request, flag, status) {
|
||||||
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
||||||
try {
|
try {
|
||||||
var ok = this.callback(this.file);
|
var ok = this.callback(this.file, true);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (ok !== true)
|
if (ok !== true)
|
||||||
@@ -1056,7 +1056,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @param {boolean} fullZoom Whether to use full zoom or text zoom.
|
* @param {boolean} fullZoom Whether to use full zoom or text zoom.
|
||||||
*/
|
*/
|
||||||
zoomIn: function (steps, fullZoom) {
|
zoomIn: function (steps, fullZoom) {
|
||||||
buffer.bumpZoomLevel(steps, fullZoom);
|
this.bumpZoomLevel(steps, fullZoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1066,7 +1066,7 @@ var Buffer = Module("buffer", {
|
|||||||
* @param {boolean} fullZoom Whether to use full zoom or text zoom.
|
* @param {boolean} fullZoom Whether to use full zoom or text zoom.
|
||||||
*/
|
*/
|
||||||
zoomOut: function (steps, fullZoom) {
|
zoomOut: function (steps, fullZoom) {
|
||||||
buffer.bumpZoomLevel(-steps, fullZoom);
|
this.bumpZoomLevel(-steps, fullZoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
setZoom: function setZoom(value, fullZoom) {
|
setZoom: function setZoom(value, fullZoom) {
|
||||||
@@ -1099,11 +1099,12 @@ var Buffer = Module("buffer", {
|
|||||||
if (i == cur && fullZoom == ZoomManager.useFullZoom)
|
if (i == cur && fullZoom == ZoomManager.useFullZoom)
|
||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
|
|
||||||
buffer.setZoom(Math.round(values[i] * 100), fullZoom);
|
this.setZoom(Math.round(values[i] * 100), fullZoom);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
|
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
|
||||||
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
|
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
|
||||||
|
|
||||||
setZoom: deprecated("Please use buffer.setZoom instead", function setZoom() buffer.setZoom.apply(buffer, arguments)),
|
setZoom: deprecated("Please use buffer.setZoom instead", function setZoom() buffer.setZoom.apply(buffer, arguments)),
|
||||||
bumpZoomLevel: deprecated("Please use buffer.bumpZoomLevel instead", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),
|
bumpZoomLevel: deprecated("Please use buffer.bumpZoomLevel instead", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ var StatusLine = Module("statusline", {
|
|||||||
if (progress <= 0)
|
if (progress <= 0)
|
||||||
progressStr = "[ Loading... ]";
|
progressStr = "[ Loading... ]";
|
||||||
else if (progress < 1) {
|
else if (progress < 1) {
|
||||||
progress = Math.floor(progress * 20);
|
progress = Math.round(progress * 20);
|
||||||
progressStr = "["
|
progressStr = "["
|
||||||
+ "===================> "
|
+ "===================> "
|
||||||
.substr(20 - progress, 20)
|
.substr(20 - progress, 20)
|
||||||
|
|||||||
@@ -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
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"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 Cc = Components.classes;
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
var Cr = Components.results;
|
var Cr = Components.results;
|
||||||
var Cu = Components.utils;
|
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");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
try {
|
try {
|
||||||
var ctypes;
|
var ctypes;
|
||||||
@@ -161,8 +99,10 @@ if (!Object.keys)
|
|||||||
let use = {};
|
let use = {};
|
||||||
let loaded = {};
|
let loaded = {};
|
||||||
let currentModule;
|
let currentModule;
|
||||||
function defineModule(name, params) {
|
let global = this;
|
||||||
let module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
|
function defineModule(name, params, module) {
|
||||||
|
if (!module)
|
||||||
|
module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
|
||||||
|
|
||||||
module.NAME = name;
|
module.NAME = name;
|
||||||
module.EXPORTED_SYMBOLS = params.exports || [];
|
module.EXPORTED_SYMBOLS = params.exports || [];
|
||||||
@@ -230,7 +170,7 @@ function endModule() {
|
|||||||
function require(obj, name, from) {
|
function require(obj, name, from) {
|
||||||
try {
|
try {
|
||||||
defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
|
defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
|
||||||
JSMLoader.load("resource://dactyl/" + name + ".jsm", obj);
|
JSMLoader.load(name + ".jsm", obj);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
||||||
@@ -252,7 +192,7 @@ defineModule("base", {
|
|||||||
"require", "set", "update", "values", "withCallerGlobal"
|
"require", "set", "update", "values", "withCallerGlobal"
|
||||||
],
|
],
|
||||||
use: ["config", "services", "util"]
|
use: ["config", "services", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
function Runnable(self, func, args) {
|
function Runnable(self, func, args) {
|
||||||
return {
|
return {
|
||||||
@@ -329,12 +269,14 @@ function deprecated(reason, fn) {
|
|||||||
|
|
||||||
function deprecatedMethod() {
|
function deprecatedMethod() {
|
||||||
let frame = Components.stack.caller;
|
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(/.* -> /, "");
|
let filename = frame.filename.replace(/.* -> /, "");
|
||||||
if (!set.add(deprecatedMethod.seen, filename))
|
if (!set.add(deprecatedMethod.seen, filename))
|
||||||
util.dactyl(fn).echoerr(
|
util.dactyl(fn).echoerr(
|
||||||
util.urlPath(filename || "unknown") + ":" + frame.lineNumber + ": " +
|
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);
|
return func.apply(this, arguments);
|
||||||
}
|
}
|
||||||
deprecatedMethod.seen = {
|
deprecatedMethod.seen = {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("bookmarkcache", {
|
defineModule("bookmarkcache", {
|
||||||
exports: ["Bookmark", "BookmarkCache", "Keyword", "bookmarkcache"],
|
exports: ["Bookmark", "BookmarkCache", "Keyword", "bookmarkcache"],
|
||||||
require: ["services", "storage", "util"]
|
require: ["services", "storage", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "charset", "id");
|
var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "charset", "id");
|
||||||
var Keyword = Struct("keyword", "title", "icon", "url");
|
var Keyword = Struct("keyword", "title", "icon", "url");
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("completion", {
|
defineModule("completion", {
|
||||||
exports: ["CompletionContext", "Completion", "completion"],
|
exports: ["CompletionContext", "Completion", "completion"],
|
||||||
use: ["config", "template", "util"]
|
use: ["config", "template", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new completion context.
|
* Creates a new completion context.
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("config", {
|
defineModule("config", {
|
||||||
exports: ["ConfigBase", "Config", "config"],
|
exports: ["ConfigBase", "Config", "config"],
|
||||||
require: ["highlight", "services", "storage", "util", "template"],
|
require: ["highlight", "services", "storage", "util", "template"],
|
||||||
use: ["io"]
|
use: ["io"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var ConfigBase = Class("ConfigBase", {
|
var ConfigBase = Class("ConfigBase", {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("finder", {
|
defineModule("finder", {
|
||||||
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
||||||
use: ["prefs", "services", "util"]
|
use: ["prefs", "services", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
/** @instance rangefinder */
|
/** @instance rangefinder */
|
||||||
var RangeFinder = Module("rangefinder", {
|
var RangeFinder = Module("rangefinder", {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("highlight", {
|
defineModule("highlight", {
|
||||||
exports: ["Highlight", "Highlights", "highlight"],
|
exports: ["Highlight", "Highlights", "highlight"],
|
||||||
require: ["services", "styles", "util"],
|
require: ["services", "styles", "util"],
|
||||||
use: ["template"]
|
use: ["template"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var Highlight = Struct("class", "selector", "sites",
|
var Highlight = Struct("class", "selector", "sites",
|
||||||
"defaultExtends", "defaultValue",
|
"defaultExtends", "defaultValue",
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("io", {
|
defineModule("io", {
|
||||||
exports: ["IO", "io"],
|
exports: ["IO", "io"],
|
||||||
require: ["services"],
|
require: ["services"],
|
||||||
use: ["config", "storage", "styles", "template", "util"]
|
use: ["config", "storage", "styles", "template", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
// TODO: why are we passing around strings rather than file objects?
|
// TODO: why are we passing around strings rather than file objects?
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("javascript", {
|
defineModule("javascript", {
|
||||||
exports: ["JavaScript", "javascript"],
|
exports: ["JavaScript", "javascript"],
|
||||||
use: ["services", "template", "util"],
|
use: ["services", "template", "util"],
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
// TODO: Clean this up.
|
// TODO: Clean this up.
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("overlay", {
|
defineModule("overlay", {
|
||||||
exports: ["ModuleBase"],
|
exports: ["ModuleBase"],
|
||||||
require: ["config", "sanitizer", "services", "util"]
|
require: ["config", "sanitizer", "services", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ModuleBase
|
* @class ModuleBase
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("prefs", {
|
defineModule("prefs", {
|
||||||
exports: ["Prefs", "localPrefs", "prefs"],
|
exports: ["Prefs", "localPrefs", "prefs"],
|
||||||
require: ["services", "util"],
|
require: ["services", "util"],
|
||||||
use: ["config", "template"]
|
use: ["config", "template"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||||
SAVED: "extensions.dactyl.saved.",
|
SAVED: "extensions.dactyl.saved.",
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("sanitizer", {
|
defineModule("sanitizer", {
|
||||||
exports: ["Range", "Sanitizer", "sanitizer"],
|
exports: ["Range", "Sanitizer", "sanitizer"],
|
||||||
require: ["prefs", "services", "storage", "template", "util"]
|
require: ["prefs", "services", "storage", "template", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
let tmp = {};
|
let tmp = {};
|
||||||
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
var global = this;
|
var global = this;
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("services", {
|
defineModule("services", {
|
||||||
exports: ["AddonManager", "services"],
|
exports: ["AddonManager", "services"],
|
||||||
use: ["util"]
|
use: ["util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lazily-instantiated XPCOM class and service cache.
|
* A lazily-instantiated XPCOM class and service cache.
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var myObject = Object;
|
var myObject = Object;
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("storage", {
|
defineModule("storage", {
|
||||||
exports: ["File", "storage"],
|
exports: ["File", "storage"],
|
||||||
require: ["services", "util"]
|
require: ["services", "util"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("styles", {
|
defineModule("styles", {
|
||||||
exports: ["Style", "Styles", "styles"],
|
exports: ["Style", "Styles", "styles"],
|
||||||
require: ["services", "util"],
|
require: ["services", "util"],
|
||||||
use: ["template"]
|
use: ["template"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||||
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("template", {
|
defineModule("template", {
|
||||||
exports: ["Template", "template"],
|
exports: ["Template", "template"],
|
||||||
require: ["util"],
|
require: ["util"],
|
||||||
use: ["services"]
|
use: ["services"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
default xml namespace = XHTML;
|
default xml namespace = XHTML;
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("util", {
|
defineModule("util", {
|
||||||
exports: ["FailedAssertion", "Math", "NS", "Point", "Util", "XBL", "XHTML", "XUL", "util"],
|
exports: ["FailedAssertion", "Math", "NS", "Point", "Util", "XBL", "XHTML", "XUL", "util"],
|
||||||
require: ["services"],
|
require: ["services"],
|
||||||
use: ["config", "highlight", "storage", "template"]
|
use: ["config", "highlight", "storage", "template"]
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||||
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
BEGIN { if (!chrome) chrome = "chrome" }
|
BEGIN {
|
||||||
|
chrome = "chrome"
|
||||||
|
if (suffix)
|
||||||
|
chrome = suffix
|
||||||
|
}
|
||||||
{ content = $1 ~ /^(content|skin|locale|resource)$/ }
|
{ content = $1 ~ /^(content|skin|locale|resource)$/ }
|
||||||
content && $NF ~ /^[a-z]/ { $NF = "/" name "/" $NF }
|
content && $NF ~ /^[a-z]/ { $NF = "/" name "/" $NF }
|
||||||
content {
|
content {
|
||||||
@@ -11,5 +15,10 @@ content {
|
|||||||
{
|
{
|
||||||
sub("^\\.\\./common/", "", $NF)
|
sub("^\\.\\./common/", "", $NF)
|
||||||
print
|
print
|
||||||
|
if (content && suffix && $1 == "resource") {
|
||||||
|
$2 = $2 "-" suffix
|
||||||
|
print
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# vim:se sts=4 sw=4 et ft=awk:
|
||||||
|
|||||||
Reference in New Issue
Block a user