mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:47:58 +01:00
Replace horrible chrome-data URLs with somewhat more comprehensible dactyl://style/ URLs.
This commit is contained in:
@@ -37,6 +37,9 @@ function makeChannel(url, orig) {
|
|||||||
if (typeof url === "function")
|
if (typeof url === "function")
|
||||||
return let ([type, data] = url()) StringChannel(data, type, orig);
|
return let ([type, data] = url()) StringChannel(data, type, orig);
|
||||||
|
|
||||||
|
if (isArray(url))
|
||||||
|
return let ([type, data] = url) StringChannel(data, type, orig);
|
||||||
|
|
||||||
let uri = ioService.newURI(url, null, null);
|
let uri = ioService.newURI(url, null, null);
|
||||||
return (new XMLChannel(uri)).channel;
|
return (new XMLChannel(uri)).channel;
|
||||||
}
|
}
|
||||||
@@ -114,6 +117,7 @@ function Dactyl() {
|
|||||||
this.OVERLAY_MAP = {};
|
this.OVERLAY_MAP = {};
|
||||||
|
|
||||||
this.pages = {};
|
this.pages = {};
|
||||||
|
this.providers = {};
|
||||||
|
|
||||||
Cu.import("resource://dactyl/bootstrap.jsm");
|
Cu.import("resource://dactyl/bootstrap.jsm");
|
||||||
if (!JSMLoader.initialized)
|
if (!JSMLoader.initialized)
|
||||||
@@ -162,6 +166,9 @@ Dactyl.prototype = {
|
|||||||
if (/^help/.test(uri.host) && !("all" in this.FILE_MAP))
|
if (/^help/.test(uri.host) && !("all" in this.FILE_MAP))
|
||||||
return redirect(uri.spec, uri, 1);
|
return redirect(uri.spec, uri, 1);
|
||||||
|
|
||||||
|
if (uri.host in this.providers)
|
||||||
|
return makeChannel(this.providers[uri.host](uri), uri);
|
||||||
|
|
||||||
let path = decodeURIComponent(uri.path.replace(/^\/|#.*/g, ""));
|
let path = decodeURIComponent(uri.path.replace(/^\/|#.*/g, ""));
|
||||||
switch(uri.host) {
|
switch(uri.host) {
|
||||||
case "content":
|
case "content":
|
||||||
@@ -182,7 +189,9 @@ Dactyl.prototype = {
|
|||||||
return makeChannel(["resource://dactyl-local-locale", config.locale, path].join("/"), uri);
|
return makeChannel(["resource://dactyl-local-locale", config.locale, path].join("/"), uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
util.reportError(e);
|
||||||
|
}
|
||||||
return fakeChannel(uri);
|
return fakeChannel(uri);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
|
|||||||
defineModule("config", {
|
defineModule("config", {
|
||||||
exports: ["ConfigBase", "Config", "config"],
|
exports: ["ConfigBase", "Config", "config"],
|
||||||
require: ["highlight", "services", "storage", "util", "template"],
|
require: ["highlight", "services", "storage", "util", "template"],
|
||||||
use: ["io"]
|
use: ["highlight", "io"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var ConfigBase = Class("ConfigBase", {
|
var ConfigBase = Class("ConfigBase", {
|
||||||
@@ -23,6 +23,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
*/
|
*/
|
||||||
init: function init() {
|
init: function init() {
|
||||||
|
|
||||||
|
this.timeout(function () {
|
||||||
highlight.styleableChrome = this.styleableChrome;
|
highlight.styleableChrome = this.styleableChrome;
|
||||||
highlight.loadCSS(this.CSS);
|
highlight.loadCSS(this.CSS);
|
||||||
highlight.loadCSS(this.helpCSS);
|
highlight.loadCSS(this.helpCSS);
|
||||||
@@ -36,6 +37,7 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
|
text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
|
||||||
}
|
}
|
||||||
]]>);
|
]]>);
|
||||||
|
});
|
||||||
|
|
||||||
this.features.push = deprecated("set.add", function push(feature) set.add(this, feature));
|
this.features.push = deprecated("set.add", function push(feature) set.add(this, feature));
|
||||||
if (util.haveGecko("2b"))
|
if (util.haveGecko("2b"))
|
||||||
|
|||||||
@@ -38,23 +38,22 @@ update(Sheet.prototype, {
|
|||||||
|
|
||||||
remove: function () { this.hive.remove(this); },
|
remove: function () { this.hive.remove(this); },
|
||||||
|
|
||||||
get uri() cssUri(this.fullCSS),
|
get uri() "dactyl://style/" + this.id + "/" + this.hive.name + "/" + (this.name || ""),
|
||||||
|
|
||||||
get enabled() this._enabled,
|
get enabled() this._enabled,
|
||||||
set enabled(on) {
|
set enabled(on) {
|
||||||
if (on != this._enabled || this.uri != this._uri) {
|
if (on != this._enabled || this.fullCSS != this._fullCSS) {
|
||||||
if (on)
|
if (on)
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
else if (!this._uri)
|
else if (!this._uri)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let meth = on ? "registerSheet" : "unregisterSheet";
|
let meth = on ? "registerSheet" : "unregisterSheet";
|
||||||
styles[meth](on ? this.uri : this._uri,
|
styles[meth](this.uri, on ? this.agent : this._agent);
|
||||||
on ? this.agent : this._agent);
|
|
||||||
|
|
||||||
this._agent = this.agent;
|
this._agent = this.agent;
|
||||||
this._enabled = Boolean(on);
|
this._enabled = Boolean(on);
|
||||||
this._uri = this.uri;
|
this._fullCSS = this.fullCSS;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -82,7 +81,8 @@ update(Sheet.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var Hive = Class("Hive", {
|
var Hive = Class("Hive", {
|
||||||
init: function () {
|
init: function (name) {
|
||||||
|
this.name = name;
|
||||||
this.sheets = [];
|
this.sheets = [];
|
||||||
this.names = {};
|
this.names = {};
|
||||||
},
|
},
|
||||||
@@ -125,6 +125,8 @@ var Hive = Class("Hive", {
|
|||||||
this.sheets.push(sheet);
|
this.sheets.push(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
styles.allSheets[sheet.id] = sheet;
|
||||||
|
|
||||||
if (!lazy)
|
if (!lazy)
|
||||||
sheet.enabled = true;
|
sheet.enabled = true;
|
||||||
|
|
||||||
@@ -208,6 +210,7 @@ var Hive = Class("Hive", {
|
|||||||
sheet.enabled = false;
|
sheet.enabled = false;
|
||||||
if (sheet.name)
|
if (sheet.name)
|
||||||
delete this.names[sheet.name];
|
delete this.names[sheet.name];
|
||||||
|
delete styles.allSheets[sheet.id];
|
||||||
}
|
}
|
||||||
this.sheets = this.sheets.filter(function (s) matches.indexOf(s) == -1);
|
this.sheets = this.sheets.filter(function (s) matches.indexOf(s) == -1);
|
||||||
return matches.length;
|
return matches.length;
|
||||||
@@ -224,8 +227,16 @@ try {
|
|||||||
var Styles = Module("Styles", {
|
var Styles = Module("Styles", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._id = 0;
|
this._id = 0;
|
||||||
this.user = Hive();
|
this.user = Hive("user");
|
||||||
this.system = Hive();
|
this.system = Hive("system");
|
||||||
|
this.allSheets = {};
|
||||||
|
|
||||||
|
services["dactyl:"].providers["style"] = function styleProvider(uri) {
|
||||||
|
let id = /^\/(\d*)/.exec(uri.path)[1];
|
||||||
|
if (set.has(styles.allSheets, id))
|
||||||
|
return ["text/css", styles.allSheets[id].fullCSS];
|
||||||
|
return null;
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
|
|||||||
Reference in New Issue
Block a user