mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:17:59 +01:00
Fix some bugs, generally.
This commit is contained in:
@@ -726,22 +726,22 @@ function Completion() //{{{
|
||||
|
||||
this.completers = {};
|
||||
|
||||
this.iter = function iter(obj)
|
||||
{
|
||||
let iterator = (function objIter()
|
||||
{
|
||||
for (let k in obj)
|
||||
{
|
||||
// Some object members are only accessible as function calls
|
||||
function getKey(obj, key)
|
||||
{
|
||||
try
|
||||
{
|
||||
yield [k, obj[k]];
|
||||
continue;
|
||||
return obj[key];
|
||||
}
|
||||
catch (e) {}
|
||||
yield [k, <>inaccessable</>]
|
||||
catch (e)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
this.iter = function iter(obj)
|
||||
{
|
||||
let iterator = ([k, getKey(obj, k)] for (k in obj));
|
||||
try
|
||||
{
|
||||
// The point of 'for k in obj' is to get keys
|
||||
@@ -781,21 +781,21 @@ function Completion() //{{{
|
||||
// available in the object itself.
|
||||
let orig = obj;
|
||||
|
||||
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
||||
// objects are problematic, to say the least.
|
||||
if (modules.isPrototypeOf(obj))
|
||||
compl = [v for (v in Iterator(obj))];
|
||||
else
|
||||
{
|
||||
if (obj.wrappedJSObject)
|
||||
if (getKey(obj, 'wrappedJSObject'))
|
||||
obj = obj.wrappedJSObject;
|
||||
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
||||
// objects are problematic, to say the least.
|
||||
compl = [v for (v in this.iter(obj))
|
||||
if ((typeof orig == "object" && v[0] in orig) || orig[v[0]] !== undefined)];
|
||||
if ((typeof orig == "object" && v[0] in orig) || getKey(orig, v[0]) !== undefined)];
|
||||
}
|
||||
|
||||
// And if wrappedJSObject happens to be available,
|
||||
// return that, too.
|
||||
if (orig.wrappedJSObject)
|
||||
if (getKey(orig, 'wrappedJSObject'))
|
||||
compl.push(["wrappedJSObject", obj]);
|
||||
|
||||
// Add keys for sorting later.
|
||||
|
||||
@@ -121,7 +121,7 @@ const liberator = (function () //{{{
|
||||
let class = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
|
||||
|
||||
if (class.length)
|
||||
styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }");
|
||||
styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }", true);
|
||||
else
|
||||
styles.removeSheet(true, "scrollbar");
|
||||
options.safeSetPref("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2);
|
||||
|
||||
@@ -182,7 +182,7 @@ function Highlights(name, store, serial)
|
||||
{
|
||||
css = style.selector + " { " + css + " }";
|
||||
|
||||
let error = styles.addSheet(true, style.selector, style.filter, css);
|
||||
let error = styles.addSheet(true, style.selector, style.filter, css, true);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
@@ -235,6 +235,7 @@ function Highlights(name, store, serial)
|
||||
this.set(class);
|
||||
}
|
||||
};
|
||||
this.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +258,7 @@ function Styles(name, store, serial)
|
||||
const namespace = '@namespace html "' + XHTML + '";\n' +
|
||||
'@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' +
|
||||
'@namespace liberator "' + NS.uri + '";\n';
|
||||
const Sheet = new Struct("name", "sites", "css", "ref");
|
||||
const Sheet = new Struct("name", "sites", "css", "ref", "agent");
|
||||
|
||||
let cssUri = function (css) "chrome-data:text/css," + window.encodeURI(css);
|
||||
|
||||
@@ -285,7 +286,7 @@ function Styles(name, store, serial)
|
||||
* "*" is matched as a prefix.
|
||||
* @param {string} css The CSS to be applied.
|
||||
*/
|
||||
this.addSheet = function (system, name, filter, css)
|
||||
this.addSheet = function (system, name, filter, css, agent)
|
||||
{
|
||||
let sheets = system ? systemSheets : userSheets;
|
||||
let names = system ? systemNames : userNames;
|
||||
@@ -294,7 +295,7 @@ function Styles(name, store, serial)
|
||||
|
||||
let sheet = sheets.filter(function (s) s.sites.join(",") == filter && s.css == css)[0];
|
||||
if (!sheet)
|
||||
sheet = new Sheet(name, filter.split(",").filter(util.identity), css, null);
|
||||
sheet = new Sheet(name, filter.split(",").filter(util.identity), css, null, agent);
|
||||
|
||||
if (sheet.ref == null) // Not registered yet
|
||||
{
|
||||
@@ -302,6 +303,7 @@ function Styles(name, store, serial)
|
||||
try
|
||||
{
|
||||
this.registerSheet(cssUri(wrapCSS(sheet)));
|
||||
if (sheet.agent)
|
||||
this.registerAgentSheet(cssUri(wrapCSS(sheet)))
|
||||
}
|
||||
catch (e)
|
||||
@@ -410,7 +412,7 @@ function Styles(name, store, serial)
|
||||
{
|
||||
let sites = sheet.sites.filter(function (f) f != filter);
|
||||
if (sites.length)
|
||||
this.addSheet(system, name, sites.join(","), css);
|
||||
this.addSheet(system, name, sites.join(","), css, sheet.agent);
|
||||
}
|
||||
}
|
||||
return matches.length;
|
||||
@@ -514,8 +516,11 @@ const styles = storage.newObject("styles", Styles, false);
|
||||
*/
|
||||
const highlight = storage.newObject("highlight", Highlights, false);
|
||||
|
||||
if (highlight.CSS != Highlights.prototype.CSS)
|
||||
{
|
||||
highlight.CSS = Highlights.prototype.CSS;
|
||||
highlight.reload();
|
||||
}
|
||||
|
||||
liberator.triggerObserver("load_styles", "styles");
|
||||
liberator.triggerObserver("load_highlight", "highlight");
|
||||
|
||||
@@ -133,9 +133,9 @@ const template = {
|
||||
highlight: function highlight(arg, processStrings, clip)
|
||||
{
|
||||
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
|
||||
let str = clip ? util.clip(String(arg), clip) : String(arg);
|
||||
try
|
||||
{
|
||||
let str = clip ? util.clip(String(arg), clip) : String(arg);
|
||||
switch (arg == null ? "undefined" : typeof arg)
|
||||
{
|
||||
case "number":
|
||||
|
||||
@@ -997,10 +997,9 @@ function CommandLine() //{{{
|
||||
set silent(val)
|
||||
{
|
||||
silent = val;
|
||||
if (silent)
|
||||
storage.styles.addSheet(true, "silent-mode", "chrome://*", "#liberator-commandline > * { opacity: 0 }");
|
||||
else
|
||||
storage.styles.removeSheet(true, "silent-mode");
|
||||
Array.forEach(document.getElementById("liberator-commandline").childNodes, function (node) {
|
||||
node.style.opacity = silent ? "0" : "";
|
||||
});
|
||||
},
|
||||
|
||||
runSilently: function (fn, self)
|
||||
|
||||
@@ -672,6 +672,13 @@ const util = { //{{{
|
||||
xmlToDom: function xmlToDom(node, doc, nodes)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
if (node.length() != 1)
|
||||
{
|
||||
let domnode = doc.createDocumentFragment();
|
||||
for each (let child in node)
|
||||
domnode.appendChild(arguments.callee(child, doc, nodes));
|
||||
return domnode;
|
||||
}
|
||||
switch (node.nodeKind())
|
||||
{
|
||||
case "text":
|
||||
|
||||
Reference in New Issue
Block a user