1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-13 23:45:47 +01:00

Death to E4X and stuff. Also fix some bugs.

This commit is contained in:
Kris Maglione
2012-11-30 19:12:51 -08:00
parent 0c4a25ca86
commit 81b41176b6
12 changed files with 45 additions and 30 deletions

View File

@@ -154,6 +154,7 @@ this.lazyRequire("cache", ["cache"]);
this.lazyRequire("config", ["config"]);
this.lazyRequire("messages", ["_", "Messages"]);
this.lazyRequire("services", ["services"]);
this.lazyRequire("storage", ["File"]);
this.lazyRequire("util", ["FailedAssertion", "util"]);
function literal(/* comment */) {
@@ -161,7 +162,7 @@ function literal(/* comment */) {
let file = caller.filename.replace(/.* -> /, "");
let key = "literal:" + file + ":" + caller.line;
let source = util.httpGet(file).responseText;
let source = File.readURL(file);
let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);

View File

@@ -4,7 +4,7 @@
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
/* use strict */
"use strict";
try {

View File

@@ -660,6 +660,7 @@ var CompletionContext = Class("CompletionContext", {
}
catch (e) {
util.reportError(e);
util.dump(util.prettifyJSON(this.createRow(this.items[idx]), null, true));
cache[idx] = DOM.fromJSON(
["div", { highlight: "CompItem", style: "white-space: nowrap" },
["li", { highlight: "CompResult" }, this.text + "\u00a0"],

View File

@@ -422,9 +422,9 @@ var ConfigBase = Class("ConfigBase", {
"xmlns.html": "http://www.w3.org/1999/xhtml",
"xmlns.xul": "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"tag.command-line": <link topic="command-line">command line</link>,
"tag.status-line": <link topic="status-line">status line</link>,
"mode.command-line": <link topic="command-line-mode">Command Line</link>,
"tag.command-line": ["link", { xmlns: "dactyl", topic: "command-line" }, "command line"],
"tag.status-line": ["link", { xmlns: "dactyl", topic: "status-line" }, "status line"],
"mode.command-line": ["link", { xmlns: "dactyl", topic: "command-line-mode" }, "Command Line"]
},
dtdStrings: [

View File

@@ -1643,6 +1643,14 @@ var DOM = Class("DOM", {
}
}),
toXML: function toXML(xml) {
// Meh. For now.
let doc = services.XMLDocument();
let node = this.fromJSON(xml, doc);
return services.XMLSerializer()
.serializeToString(node);
},
parseNamespace: function parseNamespace(name) {
var m = /^(?:(.*):)?(.*)$/.exec(name);
return [DOM.fromJSON.namespaces[m[1]], m[2]];

View File

@@ -107,6 +107,7 @@ var Services = Module("Services", {
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", [], "open");
this.addClass("XPathEvaluator", "@mozilla.org/dom/xpath-evaluator;1", "nsIDOMXPathEvaluator");
this.addClass("XMLDocument", "@mozilla.org/xml/xml-document;1", ["nsIDOMXMLDocument", "nsIDOMNodeSelector"]);
this.addClass("XMLSerializer","@mozilla.org/xmlextras/xmlserializer;1", ["nsIDOMSerializer"]);
this.addClass("ZipReader", "@mozilla.org/libjar/zip-reader;1", "nsIZipReader", "open", false);
this.addClass("ZipWriter", "@mozilla.org/zipwriter;1", "nsIZipWriter", "open", false);
},

View File

@@ -714,15 +714,11 @@ var Template_ = Module("Template_", {
arg = String(arg).replace("/* use strict */ \n", "/* use strict */ ");
return arg;
case "undefined":
return ["span", { highlight: "Null" }, arg];
return ["span", { highlight: "Null" }, "undefined"];
case "object":
if (arg instanceof Ci.nsIDOMElement)
return util.objectToString(arg, !bw);
// for java packages value.toString() would crash so badly
// that we cannot even try/catch it
if (/^\[JavaPackage.*\]$/.test(arg))
return "[JavaPackage]";
if (processStrings && false)
str = template._highlightFilter(str, "\n",
function () ["span", { highlight: "NonText" },

View File

@@ -902,12 +902,21 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* for *obj*.
*/
makeDTD: let (map = { "'": "&apos;", '"': "&quot;", "%": "&#x25;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })
function makeDTD(obj) iter(obj)
.map(function ([k, v]) ["<!ENTITY ", k, " '", String.replace(v == null ? "null" : typeof v == "xml" ? v.toXMLString() : v,
typeof v == "xml" ? /['%]/g : /['"%&<>]/g,
function (m) map[m]),
"'>"].join(""))
.join("\n"),
function makeDTD(obj) {
function escape(val) {
let isDOM = DOM.isJSONXML(val);
return String.replace(val == null ? "null" :
isDOM ? DOM.toXML(val)
: val,
isDOM ? /['%]/g
: /['"%&<>]/g,
function (m) map[m]);
}
return iter(obj).map(function ([k, v])
["<!ENTITY ", k, " '", escape(v), "'>"].join(""))
.join("\n");
},
/**
* Converts a URI string into a URI object.