mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 22:37:58 +01:00
Death to E4X and stuff.
This commit is contained in:
@@ -418,7 +418,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (isObject(str) && "echoerr" in str)
|
||||
str = str.echoerr;
|
||||
else if (isinstance(str, ["Error", FailedAssertion]) && str.fileName)
|
||||
str = <>{str.fileName.replace(/^.* -> /, "")}: {str.lineNumber}: {str}</>;
|
||||
str = util.Magic([str.fileName.replace(/^.* -> /, ""), ": ", str.lineNumber, ": ", str].join(""));
|
||||
|
||||
if (options["errorbells"])
|
||||
dactyl.beep();
|
||||
|
||||
@@ -279,8 +279,6 @@ var AddonList = Class("AddonList", {
|
||||
},
|
||||
|
||||
message: Class.Memoize(function () {
|
||||
|
||||
XML.ignoreWhitespace = true;
|
||||
DOM.fromJSON(["table", { highlight: "Addons", key: "list" },
|
||||
["tr", { highlight: "AddonHead" },
|
||||
["td", {}, _("title.Name")],
|
||||
|
||||
@@ -159,6 +159,9 @@ this.lazyRequire("util", ["FailedAssertion", "util"]);
|
||||
|
||||
function literal(/* comment */) {
|
||||
let { caller } = Components.stack;
|
||||
while (caller && caller.language != 2)
|
||||
caller = caller.caller;
|
||||
|
||||
let file = caller.filename.replace(/.* -> /, "");
|
||||
let key = "literal:" + file + ":" + caller.line;
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||
var XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator");
|
||||
default xml namespace = XHTML;
|
||||
|
||||
function BooleanAttribute(attr) ({
|
||||
get: function (elem) elem.getAttribute(attr) == "true",
|
||||
@@ -117,7 +116,6 @@ var DOM = Class("DOM", {
|
||||
},
|
||||
|
||||
eachDOM: function eachDOM(val, fn, self) {
|
||||
XML.prettyPrinting = XML.ignoreWhitespace = false;
|
||||
if (isString(val))
|
||||
val = XML(val);
|
||||
|
||||
|
||||
@@ -223,8 +223,6 @@ var DownloadList = Class("DownloadList",
|
||||
|
||||
message: Class.Memoize(function () {
|
||||
|
||||
XML.ignoreWhitespace = true;
|
||||
XML.prettyPrinting = false;
|
||||
DOM.fromJSON(["table", { highlight: "Downloads", key: "list" },
|
||||
["tr", { highlight: "DownloadHead", key: "head" },
|
||||
["span", {}, _("title.Title")],
|
||||
|
||||
@@ -119,7 +119,8 @@ var JavaScript = Module("javascript", {
|
||||
|
||||
context[JavaScript.EVAL_TMP] = tmp;
|
||||
try {
|
||||
cache[key] = this.modules.dactyl.userEval(arg, context, /*L*/"[Command Line Completion]", 1);
|
||||
cache[key] = this.modules.dactyl.userEval(arg, context,
|
||||
/*L*/"[Command Line Completion]", 1);
|
||||
|
||||
return cache[key];
|
||||
}
|
||||
|
||||
@@ -90,20 +90,13 @@ var Modules = function Modules(window) {
|
||||
Module.list = [];
|
||||
Module.constructors = {};
|
||||
|
||||
const create = window.Object.create || (function () {
|
||||
window.__dactyl_eval_string = "(function (proto) ({ __proto__: proto }))";
|
||||
JSMLoader.loadSubScript(BASE + "eval.js", window);
|
||||
|
||||
let res = window.__dactyl_eval_result;
|
||||
delete window.__dactyl_eval_string;
|
||||
delete window.__dactyl_eval_result;
|
||||
return res;
|
||||
})();
|
||||
const create = window.Object.create.bind(window.Object);
|
||||
|
||||
|
||||
const BASES = [BASE, "resource://dactyl-local-content/"];
|
||||
|
||||
const jsmodules = { NAME: "jsmodules" };
|
||||
jsmodules = Cu.createObjectIn(window);
|
||||
jsmodules.NAME = "jsmodules";
|
||||
const modules = update(create(jsmodules), {
|
||||
yes_i_know_i_should_not_report_errors_in_these_branches_thanks: [],
|
||||
|
||||
|
||||
@@ -1295,24 +1295,7 @@ var Options = Module("options", {
|
||||
function fmt(value) (typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ") + value;
|
||||
if (!args || args == "g:") {
|
||||
let str =
|
||||
<table>
|
||||
{
|
||||
template.map(globalVariables, function ([i, value]) {
|
||||
return <tr>
|
||||
<td style="width: 200px;">{i}</td>
|
||||
<td>{fmt(value)}</td>
|
||||
</tr>;
|
||||
})
|
||||
}
|
||||
</table>;
|
||||
if (str.text().length() == str.*.length())
|
||||
dactyl.echomsg(_("variable.none"));
|
||||
else
|
||||
dactyl.echo(str, modules.commandline.FORCE_MULTILINE);
|
||||
return;
|
||||
}
|
||||
util.assert(!(!args || args == "g:"));
|
||||
|
||||
let matches = args.match(/^([a-z]:)?([\w]+)(?:\s*([-+.])?=\s*(.*)?)?$/);
|
||||
if (matches) {
|
||||
|
||||
@@ -157,9 +157,20 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
getData: function getData(obj, key, constructor) {
|
||||
|
||||
if (!this.weakMap.has(obj))
|
||||
this.weakMap.set(obj, {});
|
||||
try {
|
||||
this.weakMap.set(obj, {});
|
||||
}
|
||||
catch (e if e instanceof TypeError) {
|
||||
// util.dump("Bad WeakMap key: " + obj + " " + Components.stack.caller);
|
||||
let { id } = this;
|
||||
|
||||
let data = this.weakMap.get(obj);
|
||||
if (!(id in obj && obj[id]))
|
||||
obj[id] = {};
|
||||
|
||||
var data = obj[id];
|
||||
}
|
||||
|
||||
data = data || this.weakMap.get(obj);
|
||||
|
||||
if (arguments.length == 1)
|
||||
return data;
|
||||
|
||||
@@ -359,6 +359,8 @@ var File = Class("File", {
|
||||
return File.DoesNotExist(path, e);
|
||||
}
|
||||
}
|
||||
this.file = file;
|
||||
|
||||
let self = XPCSafeJSObjectWrapper(file.QueryInterface(Ci.nsILocalFile));
|
||||
self.__proto__ = this;
|
||||
return self;
|
||||
|
||||
@@ -35,9 +35,9 @@ Sheet.liveProperty("css");
|
||||
Sheet.liveProperty("sites");
|
||||
update(Sheet.prototype, {
|
||||
formatSites: function (uris)
|
||||
template.map(this.sites,
|
||||
function (filter) <span highlight={uris.some(Styles.matchFilter(filter)) ? "Filter" : ""}>{filter}</span>,
|
||||
<>,</>),
|
||||
template_.map(this.sites,
|
||||
function (filter) ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter],
|
||||
","),
|
||||
|
||||
remove: function () { this.hive.remove(this); },
|
||||
|
||||
|
||||
@@ -317,6 +317,8 @@ var Template = Module("Template", {
|
||||
case "object":
|
||||
if (arg instanceof Ci.nsIDOMElement)
|
||||
return util.objectToString(arg, !bw);
|
||||
if (arg instanceof util.Magic)
|
||||
return <>{arg}</>;
|
||||
|
||||
// for java packages value.toString() would crash so badly
|
||||
// that we cannot even try/catch it
|
||||
@@ -718,6 +720,8 @@ var Template_ = Module("Template_", {
|
||||
case "object":
|
||||
if (arg instanceof Ci.nsIDOMElement)
|
||||
return util.objectToString(arg, !bw);
|
||||
if (arg instanceof Magic)
|
||||
return String(arg);
|
||||
|
||||
if (processStrings && false)
|
||||
str = template._highlightFilter(str, "\n",
|
||||
|
||||
@@ -17,6 +17,14 @@ lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("storage", ["File", "storage"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var Magic = Class("Magic", {
|
||||
init: function init(str) {
|
||||
this.str = str;
|
||||
},
|
||||
|
||||
toString: function () this.str
|
||||
});
|
||||
|
||||
var FailedAssertion = Class("FailedAssertion", ErrorBase, {
|
||||
init: function init(message, level, noTrace) {
|
||||
if (noTrace !== undefined)
|
||||
@@ -52,6 +60,8 @@ var wrapCallback = function wrapCallback(fn, isEvent) {
|
||||
}
|
||||
|
||||
var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
Magic: Magic,
|
||||
|
||||
init: function () {
|
||||
this.Array = array;
|
||||
|
||||
@@ -997,7 +1007,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
keyIter = keys(object)
|
||||
|
||||
for (let i in keyIter) {
|
||||
let value = <![CDATA[<no value>]]>;
|
||||
let value = Magic("<no value>");
|
||||
try {
|
||||
value = object[i];
|
||||
}
|
||||
@@ -1204,7 +1214,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
|
||||
// Replace replacement <tokens>.
|
||||
if (tokens)
|
||||
expr = String.replace(expr, /(\(?P)?<(\w+)>/g, function (m, n1, n2) !n1 && Set.has(tokens, n2) ? tokens[n2].dactylSource || tokens[n2].source || tokens[n2] : m);
|
||||
expr = String.replace(expr, /(\(?P)?<(\w+)>/g,
|
||||
function (m, n1, n2) !n1 && Set.has(tokens, n2) ? tokens[n2].dactylSource
|
||||
|| tokens[n2].source
|
||||
|| tokens[n2]
|
||||
: m);
|
||||
|
||||
// Strip comments and white space.
|
||||
if (/x/.test(flags))
|
||||
@@ -1322,7 +1336,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
|
||||
let obj = update({}, error, {
|
||||
toString: function () String(error),
|
||||
stack: <>{util.stackLines(String(error.stack || Error().stack)).join("\n").replace(/^/mg, "\t")}</>
|
||||
stack: Magic(util.stackLines(String(error.stack || Error().stack)).join("\n").replace(/^/mg, "\t"))
|
||||
});
|
||||
|
||||
services.console.logStringMessage(obj.stack);
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
<em:targetApplication>
|
||||
<Description
|
||||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
||||
em:minVersion="6.0"
|
||||
em:maxVersion="14.*"/>
|
||||
em:minVersion="8.0"
|
||||
em:maxVersion="17.*"/>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
||||
|
||||
Reference in New Issue
Block a user