mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-28 21:32:27 +01:00
Death to E4X and stuff.
This commit is contained in:
@@ -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";
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
@@ -1215,22 +1215,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
for (let [, context] in Iterator(plugins.contexts))
|
||||
try {
|
||||
let info = contexts.getDocs(context);
|
||||
if (info instanceof XML) {
|
||||
if (info.*.@lang.length()) {
|
||||
let lang = config.bestLocale(String(a) for each (a in info.*.@lang));
|
||||
|
||||
info.* = info.*.(function::attribute("lang").length() == 0 || @lang == lang);
|
||||
|
||||
for each (let elem in info.NS::info)
|
||||
for (let attr in values(["@name", "@summary", "@href"]))
|
||||
if (elem[attr].length())
|
||||
info[attr] = elem[attr];
|
||||
}
|
||||
body.push(["h2", { xmlns: "dactyl", tag: info.@name + '-plugin' },
|
||||
String(info.@summary)]);
|
||||
body.push(info);
|
||||
}
|
||||
else if (DOM.isJSONXML(info)) {
|
||||
if (DOM.isJSONXML(info)) {
|
||||
let langs = info.slice(2).filter(function (e) isArray(e) && isObject(e[1]) && e[1].lang);
|
||||
if (langs) {
|
||||
let lang = config.bestLocale(l[1].lang for each (l in langs));
|
||||
|
||||
@@ -875,8 +875,8 @@ var Buffer = Module("Buffer", {
|
||||
util.timeout(function () { indicator.remove(); }, 500);
|
||||
|
||||
// Doesn't unattach
|
||||
//doc.body.setAttributeNS(NS.uri, "activeframe", "true");
|
||||
//util.timeout(function () { doc.body.removeAttributeNS(NS.uri, "activeframe"); }, 500);
|
||||
//doc.body.setAttributeNS(NS, "activeframe", "true");
|
||||
//util.timeout(function () { doc.body.removeAttributeNS(NS, "activeframe"); }, 500);
|
||||
},
|
||||
|
||||
// similar to pageInfo
|
||||
|
||||
53
common/modules/dom-e4x.jsm
Normal file
53
common/modules/dom-e4x.jsm
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
|
||||
// Copyright (c) 2008-2012 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 */
|
||||
|
||||
defineModule("dom", {
|
||||
exports: ["fromXML"]
|
||||
});
|
||||
|
||||
lazyRequire("highlight", ["highlight"]);
|
||||
|
||||
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");
|
||||
|
||||
function fromXML(node, doc, nodes) {
|
||||
XML.ignoreWhitespace = XML.prettyPrinting = false;
|
||||
if (typeof node === "string") // Sandboxes can't currently pass us XML objects.
|
||||
node = XML(node);
|
||||
|
||||
if (node.length() != 1) {
|
||||
let domnode = doc.createDocumentFragment();
|
||||
for each (let child in node)
|
||||
domnode.appendChild(fromXML(child, doc, nodes));
|
||||
return domnode;
|
||||
}
|
||||
|
||||
switch (node.nodeKind()) {
|
||||
case "text":
|
||||
return doc.createTextNode(String(node));
|
||||
case "element":
|
||||
let domnode = doc.createElementNS(node.namespace(), node.localName());
|
||||
|
||||
for each (let attr in node.@*::*)
|
||||
if (attr.name() != "highlight")
|
||||
domnode.setAttributeNS(attr.namespace(), attr.localName(), String(attr));
|
||||
|
||||
for each (let child in node.*::*)
|
||||
domnode.appendChild(fromXML(child, doc, nodes));
|
||||
if (nodes && node.@key)
|
||||
nodes[node.@key] = domnode;
|
||||
|
||||
if ("@highlight" in node)
|
||||
highlight.highlightNode(domnode, String(node.@highlight), nodes || true);
|
||||
return domnode;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,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";
|
||||
|
||||
defineModule("dom", {
|
||||
exports: ["$", "DOM", "NS", "XBL", "XHTML", "XUL"]
|
||||
@@ -13,10 +13,10 @@ lazyRequire("highlight", ["highlight"]);
|
||||
lazyRequire("messages", ["_"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
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");
|
||||
var XBL = "http://www.mozilla.org/xbl";
|
||||
var XHTML = "http://www.w3.org/1999/xhtml";
|
||||
var XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var NS = "http://vimperator.org/namespaces/liberator";
|
||||
|
||||
function BooleanAttribute(attr) ({
|
||||
get: function (elem) elem.getAttribute(attr) == "true",
|
||||
@@ -116,14 +116,6 @@ var DOM = Class("DOM", {
|
||||
},
|
||||
|
||||
eachDOM: function eachDOM(val, fn, self) {
|
||||
if (isString(val))
|
||||
val = XML(val);
|
||||
|
||||
if (typeof val == "xml")
|
||||
return this.each(function (elem, i) {
|
||||
fn.call(this, DOM.fromXML(val, elem.ownerDocument), elem, i);
|
||||
}, self || this);
|
||||
|
||||
let dom = this;
|
||||
function munge(val, container, idx) {
|
||||
if (val instanceof Ci.nsIDOMRange)
|
||||
@@ -1524,40 +1516,9 @@ var DOM = Class("DOM", {
|
||||
* stored here, keyed to the value thereof.
|
||||
* @returns {Node}
|
||||
*/
|
||||
fromXML: function fromXML(node, doc, nodes) {
|
||||
XML.ignoreWhitespace = XML.prettyPrinting = false;
|
||||
if (typeof node === "string") // Sandboxes can't currently pass us XML objects.
|
||||
node = XML(node);
|
||||
|
||||
if (node.length() != 1) {
|
||||
let domnode = doc.createDocumentFragment();
|
||||
for each (let child in node)
|
||||
domnode.appendChild(fromXML(child, doc, nodes));
|
||||
return domnode;
|
||||
}
|
||||
|
||||
switch (node.nodeKind()) {
|
||||
case "text":
|
||||
return doc.createTextNode(String(node));
|
||||
case "element":
|
||||
let domnode = doc.createElementNS(node.namespace(), node.localName());
|
||||
|
||||
for each (let attr in node.@*::*)
|
||||
if (attr.name() != "highlight")
|
||||
domnode.setAttributeNS(attr.namespace(), attr.localName(), String(attr));
|
||||
|
||||
for each (let child in node.*::*)
|
||||
domnode.appendChild(fromXML(child, doc, nodes));
|
||||
if (nodes && node.@key)
|
||||
nodes[node.@key] = domnode;
|
||||
|
||||
if ("@highlight" in node)
|
||||
highlight.highlightNode(domnode, String(node.@highlight), nodes || true);
|
||||
return domnode;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
fromXML: Class.Memoize(function ()
|
||||
prefs.get("javascript.options.xml.chrome") !== false
|
||||
&& require("dom-e4x.xml").fromXML),
|
||||
|
||||
fromJSON: update(function fromJSON(xml, doc, nodes, namespaces) {
|
||||
if (!doc)
|
||||
@@ -1892,11 +1853,11 @@ var DOM = Class("DOM", {
|
||||
},
|
||||
|
||||
namespaces: {
|
||||
xul: XUL.uri,
|
||||
xhtml: XHTML.uri,
|
||||
html: XHTML.uri,
|
||||
xul: XUL,
|
||||
xhtml: XHTML,
|
||||
html: XHTML,
|
||||
xhtml2: "http://www.w3.org/2002/06/xhtml2",
|
||||
dactyl: NS.uri
|
||||
dactyl: NS
|
||||
},
|
||||
|
||||
namespaceNames: Class.Memoize(function ()
|
||||
|
||||
@@ -317,8 +317,8 @@ var Help = Module("Help", {
|
||||
|
||||
data.push("<", node.localName);
|
||||
if (node instanceof Ci.nsIDOMHTMLHtmlElement)
|
||||
data.push(" xmlns=" + XHTML.uri.quote(),
|
||||
" xmlns:dactyl=" + NS.uri.quote());
|
||||
data.push(" xmlns=" + XHTML.quote(),
|
||||
" xmlns:dactyl=" + NS.quote());
|
||||
|
||||
for (let { name, value } in array.iterValues(node.attributes)) {
|
||||
if (name == "dactyl:highlight") {
|
||||
|
||||
@@ -197,7 +197,7 @@ var Highlights = Module("Highlight", {
|
||||
* @param {string} group
|
||||
*/
|
||||
highlightNode: function highlightNode(node, group, applyBindings) {
|
||||
node.setAttributeNS(NS.uri, "highlight", group);
|
||||
node.setAttributeNS(NS, "highlight", group);
|
||||
|
||||
let groups = group.split(" ");
|
||||
for each (let group in groups)
|
||||
|
||||
@@ -2,7 +2,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 {
|
||||
|
||||
@@ -232,10 +232,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
function insert(key, fn) {
|
||||
if (obj[key]) {
|
||||
let iterator = Iterator(obj[key]);
|
||||
if (!isObject(obj[key]))
|
||||
iterator = ([elem.@id, elem.elements(), elem.@*::*.(function::name() != "id")]
|
||||
for each (elem in obj[key]));
|
||||
else if (isArray(obj[key])) {
|
||||
if (isArray(obj[key])) {
|
||||
iterator = ([elem[1].id, elem.slice(2), elem[1]]
|
||||
for each (elem in obj[key]))
|
||||
}
|
||||
@@ -270,13 +267,9 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
}
|
||||
|
||||
for (let attr in attrs || []) {
|
||||
let ns, name, localName, val;
|
||||
if (isXML(attr))
|
||||
ns = attr.namespace(), localName = attr.localName(),
|
||||
name = attr.name(), val = String(attr);
|
||||
else
|
||||
[ns, localName] = DOM.parseNamespace(attr),
|
||||
name = attr, val = attrs[attr];
|
||||
let [ns, localName] = DOM.parseNamespace(attr);
|
||||
let name = attr;
|
||||
let val = attrs[attr];
|
||||
|
||||
savedAttrs.push([elem, ns, name, getAttr(elem, ns, name), val]);
|
||||
if (name === "highlight")
|
||||
|
||||
@@ -13,9 +13,9 @@ lazyRequire("contexts", ["Contexts"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
"@namespace xul " + XUL.uri.quote() + ";\n" +
|
||||
"@namespace dactyl " + NS.uri.quote() + ";\n";
|
||||
var namespace = "@namespace html " + XHTML.quote() + ";\n" +
|
||||
"@namespace xul " + XUL.quote() + ";\n" +
|
||||
"@namespace dactyl " + NS.quote() + ";\n";
|
||||
|
||||
var Sheet = Struct("name", "id", "sites", "css", "hive", "agent");
|
||||
Sheet.liveProperty = function (name) {
|
||||
|
||||
Reference in New Issue
Block a user