1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:08:12 +01:00

Fix some bugs, generally.

This commit is contained in:
Kris Maglione
2009-02-09 16:18:10 -05:00
parent c5c5e90f0e
commit c9c708f636
6 changed files with 44 additions and 33 deletions

View File

@@ -726,22 +726,22 @@ function Completion() //{{{
this.completers = {};
// Some object members are only accessible as function calls
function getKey(obj, key)
{
try
{
return obj[key];
}
catch (e)
{
return undefined;
}
}
this.iter = function iter(obj)
{
let iterator = (function objIter()
{
for (let k in obj)
{
// Some object members are only accessible as function calls
try
{
yield [k, obj[k]];
continue;
}
catch (e) {}
yield [k, <>inaccessable</>]
}
})();
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.

View File

@@ -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);

View File

@@ -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,7 +303,8 @@ function Styles(name, store, serial)
try
{
this.registerSheet(cssUri(wrapCSS(sheet)));
this.registerAgentSheet(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);
highlight.CSS = Highlights.prototype.CSS;
highlight.reload();
if (highlight.CSS != Highlights.prototype.CSS)
{
highlight.CSS = Highlights.prototype.CSS;
highlight.reload();
}
liberator.triggerObserver("load_styles", "styles");
liberator.triggerObserver("load_highlight", "highlight");

View File

@@ -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":

View File

@@ -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)

View File

@@ -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":