summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2009-02-09 16:18:10 -0500
committerKris Maglione <maglione.k@gmail.com>2009-02-09 16:18:24 -0500
commitc9c708f636e6f25a54c301c85911c420f81a9dba (patch)
tree7f5db3f72a8b679d2694aec7be85973ffbadbb20 /common
parentc5c5e90f0e31bc222adec24a1eb85c18fdf8c89d (diff)
downloadpentadactyl-c9c708f636e6f25a54c301c85911c420f81a9dba.tar.gz
Fix some bugs, generally.
Diffstat (limited to 'common')
-rw-r--r--common/content/completion.js38
-rw-r--r--common/content/liberator.js2
-rw-r--r--common/content/style.js21
-rw-r--r--common/content/template.js2
-rw-r--r--common/content/ui.js7
-rw-r--r--common/content/util.js7
6 files changed, 44 insertions, 33 deletions
diff --git a/common/content/completion.js b/common/content/completion.js
index c7906969..9cd8010a 100644
--- a/common/content/completion.js
+++ b/common/content/completion.js
@@ -726,22 +726,22 @@ function Completion() //{{{
this.completers = {};
- this.iter = function iter(obj)
+ // Some object members are only accessible as function calls
+ function getKey(obj, key)
{
- let iterator = (function objIter()
+ try
{
- 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</>]
- }
- })();
+ return obj[key];
+ }
+ 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.
diff --git a/common/content/liberator.js b/common/content/liberator.js
index 2e3e1d7c..66dc43bf 100644
--- a/common/content/liberator.js
+++ b/common/content/liberator.js
@@ -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);
diff --git a/common/content/style.js b/common/content/style.js
index 50a38f5c..d994dbd6 100644
--- a/common/content/style.js
+++ b/common/content/style.js
@@ -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");
diff --git a/common/content/template.js b/common/content/template.js
index 981f72f8..b4f14bfd 100644
--- a/common/content/template.js
+++ b/common/content/template.js
@@ -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":
diff --git a/common/content/ui.js b/common/content/ui.js
index 9e3112ca..f9b90b4f 100644
--- a/common/content/ui.js
+++ b/common/content/ui.js
@@ -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)
diff --git a/common/content/util.js b/common/content/util.js
index 090de789..5409d0c9 100644
--- a/common/content/util.js
+++ b/common/content/util.js
@@ -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":