From aa788251334e2dfd2b29aefd60b30a64256b79e2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 3 Sep 2011 21:13:51 -0400 Subject: [PATCH] Fix crappy add-on manager icons. --- common/Makefile | 2 +- common/modules/dom.jsm | 30 +++++++++++++++++++++++++----- common/modules/io.jsm | 30 +++++++++++++++++------------- common/modules/overlay.jsm | 6 +++--- common/modules/protocol.jsm | 2 +- common/modules/template.jsm | 5 +++-- common/modules/util.jsm | 7 +++++-- pentadactyl/icon.png | Bin 0 -> 731 bytes pentadactyl/icon64.png | Bin 0 -> 1363 bytes pentadactyl/install.rdf | 1 - 10 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 pentadactyl/icon.png create mode 100644 pentadactyl/icon64.png diff --git a/common/Makefile b/common/Makefile index b9e80228..1c563678 100644 --- a/common/Makefile +++ b/common/Makefile @@ -40,7 +40,7 @@ CHROME = $(MANGLE)/ JAR = $(CHROME)$(NAME).jar XPI_BASES = $(JAR_BASES) $(TOP)/.. -XPI_FILES = bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt +XPI_FILES = icon.png icon64.png bootstrap.js TODO AUTHORS Donors NEWS LICENSE.txt XPI_DIRS = components $(MANGLE) defaults XPI_TEXTS = js jsm $(JAR_TEXTS) XPI_BINS = $(JAR_BINS) diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 8c7c0bda..fb007282 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -16,6 +16,16 @@ var XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator"); default xml namespace = XHTML; +function BooleanAttribute(attr) ({ + get: function (elem) elem.getAttribute(attr) == "true", + set: function (elem, val) { + if (val === "false" || !val) + elem.removeAttribute(attr); + else + elem.setAttribute(attr, true); + } +}); + /** * @class * @@ -73,7 +83,11 @@ var DOM = Class("DOM", { attrHooks: array.toObject([ ["", { href: { get: function (elem) elem.href || elem.getAttribute("href") }, - src: { get: function (elem) elem.src || elem.getAttribute("src") } + src: { get: function (elem) elem.src || elem.getAttribute("src") }, + collapsed: BooleanAttribute("collapsed"), + disabled: BooleanAttribute("disabled"), + hidden: BooleanAttribute("hidden"), + readonly: BooleanAttribute("readonly") }] ]), @@ -140,6 +154,10 @@ var DOM = Class("DOM", { return this.map(function (elem) elem.querySelectorAll(val)); }, + findAnon: function findAnon(attr, val) { + return this.map(function (elem) elem.ownerDocument.getAnonymousElementByAttribute(elem, attr, val)); + }, + filter: function filter(val, self) { let res = this.Empty(); @@ -507,7 +525,7 @@ var DOM = Class("DOM", { return this.each(function (elem) { for (let [k, v] in Iterator(key)) if (Set.has(hooks, k) && hooks[k].set) - hooks[k].set.call(this, elem, v); + hooks[k].set.call(this, elem, v, k); else if (v == null) elem.removeAttributeNS(ns, k); else @@ -518,7 +536,7 @@ var DOM = Class("DOM", { return null; if (Set.has(hooks, key) && hooks[key].get) - return hooks[key].get.call(this, this[0]); + return hooks[key].get.call(this, this[0], key); if (!this[0].hasAttributeNS(ns, key)) return null; @@ -526,6 +544,7 @@ var DOM = Class("DOM", { return this[0].getAttributeNS(ns, key); }, + css: update(function css(key, val) { if (val !== undefined) key = array.toObject([[key, val]]); @@ -811,9 +830,10 @@ var DOM = Class("DOM", { types: Class.Memoize(function () iter( { - Mouse: "click mousedown mouseout mouseover mouseup", + Mouse: "click mousedown mouseout mouseover mouseup " + + "popupshowing popupshown popuphiding popuphidden", Key: "keydown keypress keyup", - "": "change dactyl-input input submit " + + "": "change command dactyl-input input submit " + "load unload pageshow pagehide DOMContentLoaded" } ).map(function ([k, v]) v.split(" ").map(function (v) [v, k])) diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 948167d9..18029944 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -21,14 +21,14 @@ defineModule("io", { * @instance io */ var IO = Module("io", { - init: function () { + init: function init() { this._processDir = services.directory.get("CurWorkD", Ci.nsIFile); this._cwd = this._processDir.path; this._oldcwd = null; this.config = config; }, - Local: function (dactyl, modules, window) let ({ io, plugins } = modules) ({ + Local: function Local(dactyl, modules, window) let ({ io, plugins } = modules) ({ init: function init() { this.config = modules.config; @@ -292,7 +292,7 @@ var IO = Module("io", { * @default $HOME. * @returns {nsIFile} The RC file or null if none is found. */ - getRCFile: function (dir, always) { + getRCFile: function getRCFile(dir, always) { dir = this.File(dir || "~"); let rcFile1 = dir.child("." + config.name + "rc"); @@ -316,7 +316,7 @@ var IO = Module("io", { * * @returns {File} */ - createTempFile: function () { + createTempFile: function createTempFile() { let file = services.directory.get("TmpD", Ci.nsIFile); file.append(this.config.tempFile); file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(600)); @@ -337,6 +337,9 @@ var IO = Module("io", { isJarURL: function isJarURL(url) { try { let uri = util.newURI(util.fixURI(url)); + if (uri instanceof Ci.nsIJARURI) + return uri; + let channel = services.io.newChannelFromURI(uri); channel.cancel(Cr.NS_BINDING_ABORTED); if (channel instanceof Ci.nsIJARChannel) @@ -373,7 +376,7 @@ var IO = Module("io", { } }, - readHeredoc: function (end) { + readHeredoc: function readHeredoc(end) { return ""; }, @@ -387,8 +390,9 @@ var IO = Module("io", { * name and searched for in turn. * * @param {string} bin The name of the executable to find. + * @returns {File|null} */ - pathSearch: function (bin) { + pathSearch: function pathSearch(bin) { if (bin instanceof File || File.isAbsolutePath(bin)) return this.File(bin); @@ -426,7 +430,7 @@ var IO = Module("io", { * @param {File|string} program The program to run. * @param {[string]} args An array of arguments to pass to *program*. */ - run: function (program, args, blocking, self) { + run: function run(program, args, blocking, self) { args = args || []; let file = this.pathSearch(program); @@ -474,7 +478,7 @@ var IO = Module("io", { * the command completes. @optional * @returns {object|null} */ - system: function (command, input, callback) { + system: function system(command, input, callback) { util.dactyl.echomsg(_("io.callingShell", command), 4); let { shellEscape } = util.closure; @@ -533,7 +537,7 @@ var IO = Module("io", { * @returns {boolean} false if temp files couldn't be created, * otherwise, the return value of *func*. */ - withTempFiles: function (func, self, checked) { + withTempFiles: function withTempFiles(func, self, checked) { let args = array(util.range(0, func.length)).map(this.closure.createTempFile).array; try { if (!args.every(util.identity)) @@ -566,7 +570,7 @@ var IO = Module("io", { */ PATH_SEP: deprecated("File.PATH_SEP", { get: function PATH_SEP() File.PATH_SEP }) }, { - commands: function (dactyl, modules, window) { + commands: function init_commands(dactyl, modules, window) { const { commands, completion, io } = modules; commands.add(["cd", "chd[ir]"], @@ -858,7 +862,7 @@ unlet s:cpo_save literal: 0 }); }, - completion: function (dactyl, modules, window) { + completion: function init_completion(dactyl, modules, window) { const { completion, io } = modules; completion.charset = function (context) { @@ -1006,7 +1010,7 @@ unlet s:cpo_save completion.file(context, full); }); }, - javascript: function (dactyl, modules, window) { + javascript: function init_javascript(dactyl, modules, window) { modules.JavaScript.setCompleter([File, File.expandPath], [function (context, obj, args) { context.quote[2] = ""; @@ -1025,7 +1029,7 @@ unlet s:cpo_save input: true }); }, - options: function (dactyl, modules, window) { + options: function init_options(dactyl, modules, window) { const { completion, options } = modules; var shell, shellcmdflag; diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index 64e056cc..6cc124d4 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -460,9 +460,9 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen if (doc.readyState === "complete") load(); else - doc.addEventListener("load", util.wrapCallback(function onLoad(event) { - if (event.originalTarget === event.target) { - doc.removeEventListener("load", onLoad.wrapper, true); + window.addEventListener("load", util.wrapCallback(function onLoad(event) { + if (event.originalTarget === doc) { + window.removeEventListener("load", onLoad.wrapper, true); load(event); } }), true); diff --git a/common/modules/protocol.jsm b/common/modules/protocol.jsm index cf9f905d..da0ce1f3 100644 --- a/common/modules/protocol.jsm +++ b/common/modules/protocol.jsm @@ -104,7 +104,7 @@ ProtocolBase.prototype = { | Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE, newURI: function newURI(spec, charset, baseURI) { - if (baseURI && baseURI.host === "data") + if (baseURI && (!(baseURI instanceof Ci.nsIURL) || baseURI.host === "data")) baseURI = null; return services.URL(services.URL.URLTYPE_AUTHORITY, this.defaultPort, spec, charset, baseURI); diff --git a/common/modules/template.jsm b/common/modules/template.jsm index b15e92e5..5cb06e43 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -275,7 +275,7 @@ var Template = Module("Template", { // if "processStrings" is true, any passed strings will be surrounded by " and // any line breaks are displayed as \n - highlight: function highlight(arg, processStrings, clip) { + highlight: function highlight(arg, processStrings, clip, bw) { XML.ignoreWhitespace = false; XML.prettyPrinting = false; // some objects like window.JSON or getBrowsers()._browsers need the try/catch try { @@ -302,7 +302,8 @@ var Template = Module("Template", { return {arg}; case "object": if (arg instanceof Ci.nsIDOMElement) - return util.objectToString(arg, true); + 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)) diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 39a9094d..1e7feacb 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -624,6 +624,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), if (uri instanceof Ci.nsIFileURL) return File(uri.file); + if (uri instanceof Ci.nsIFile) + return File(uri); + let channel = services.io.newChannelFromURI(uri); channel.cancel(Cr.NS_BINDING_ABORTED); if (channel instanceof Ci.nsIFileChannel) @@ -902,7 +905,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } } - value = template.highlight(value, true, 150); + value = template.highlight(value, true, 150, !color); let key = {i}; if (!isNaN(i)) i = parseInt(i); @@ -1137,7 +1140,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * along with a stack trace and other relevant information. The * error is appended to {@seeĀ #errors}. */ - reportError: function (error) { + reportError: function reportError(error) { if (error.noTrace) return; diff --git a/pentadactyl/icon.png b/pentadactyl/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..862a3bdc876908daa915bb56a40bf0c16544d573 GIT binary patch literal 731 zcmV<10wn#3P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L02hb=02hb>P|Str00007bV*G`2ipk* z0Sp>uN^dIw00LV{L_t(o!`0W{YmIRn2k_UkAB>f4!Y*u@!VN`=68-?mm6D4Y7v|i! zv1@9DTqu%Kn{A@ia>IoSx!DC;OEHQ3C{jkVnph^9oyW!VoSYqJ>zp~~jCVaf-{!x5RBQI@aqOVnjC z4wXp`f+nIIaU0j-ar0~$vY0V^Grrei&3q6T zNgFSm4+5J~Wg0I^O`r!r1s@eCsi(p;QUUmYi)LuicUH#(>bc_3=zd}p+S zqY3U$BQVLCl<_p|{6;(4GUUtSoIe|S&eIqC4#yN$l+o48)@H`jKf(4HHrkOz7UENu zVl*13=pGDKM~N%j;w9hMfPr)ZudpnO^2;oHe8{obyqZCt40t^)3Ia~xbB6J;sOOj) z)^Y>=S*A|4Mx}dtKhVX}B>S)`;BAuY3BF|1f|GHD%cPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L05Q}605Q}7ts`m200007bV*G`2ipk* z0R$$2{F$Tx00h%XL_t(|+U?t2h*eb-2k_syGi9cYCYc`?38hj9S^1FmlB9`Lq!wk7 zrlsRoQ4vHMS*q=97UK^Z`eEJcT$Bg` zs<{>8@@zJ|ffBj=BqtZKtEUDjc6x`lZ36Z2Uok7FHj&3VKydY zi78CP;v^H$f*ly2g@mQJIOzlshRA2eln)A>&EyjRA7D#N`Q4>L0K6DeHXfIj3IX5X za7I}fZYUK3()co_d`PJf0KdkR4K5`DF3I9Xmka?{#grW_6$1K4K0+q;mkI&1W9f zYgk^%)=ng%k1(y~Ufkb?l+JF^{#9H!gvuHo4X9{csfM~WtUSuvDo$s1a!$x;H4g?X zb2hvci-7HE7S0bdx-zi>k7tzC;D;Pbv47;=4#R~xNLqrIU@c?Pyo%vD+8hX2RLOU- z1gvIyke@>NdL+|h#4C<~jzS|I!COMbFg(RaGQN5ns4HXgTz)=B32vYwh<7#H!q}Sl zAVp{43*6i?`DpOZ=P`MxXk__+c7cDwOsvojn`ei}z8RWg;UABsFLVL+`a`2ngEPCUULG zWu&We*IU)1v^vl-Ds;@sTI~j@h=5%M_O+|XcEK6+Vo$m-5*oD1Lrz7e*0yY-mSYL5 z*F~7a3A|T8(|22M->ImxQz@R7$9a63&*sNRX^V!kP^15rN0ZtVFU0x+^Fr(HG2wZC zE_@nL*;V4-YRt7w;r)Yy?WlgRi5c@UB>fySvoidmlhSMn;?2gIfG3Xf(ELzicR3bO z(}&w41MGNAmE%}Z&ZI@5MVj3dZjG1e-IvkLp)+){nf>j&$q{D>F6ro9AP!ZehH_1F zlxUse$PxBb6*<+WqfUp57HBAG^bpWPKo0>u1e7$&JD`toQJ|tFRW|PAW}@&OU|JZ= z+^!3*$#w=7C@j~n3Dc55z;=ZvJZ?;a4mh7n&Igkq0apqWrt9 Kris Maglione, Doug Kearns