mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-02 05:45:47 +01:00
Stagger loading of :style sheets to improve perceived startup time. Fix :mksyn bug.
This commit is contained in:
@@ -356,17 +356,39 @@ const Styles = Module("Styles", {
|
|||||||
}, {
|
}, {
|
||||||
commands: function (dactyl, modules, window) {
|
commands: function (dactyl, modules, window) {
|
||||||
const commands = modules.commands;
|
const commands = modules.commands;
|
||||||
|
|
||||||
|
const queue = [];
|
||||||
|
const timer = Timer(10, 10, function () {
|
||||||
|
let args = queue.shift()
|
||||||
|
let [filter, css] = args;
|
||||||
|
if ("-append" in args) {
|
||||||
|
let sheet = styles.user.get(args["-name"]);
|
||||||
|
if (sheet) {
|
||||||
|
filter = sheet.sites.concat(filter).join(",");
|
||||||
|
css = sheet.css + " " + css;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styles.user.add(args["-name"], filter, css, args["-agent"]);
|
||||||
|
|
||||||
|
if (queue.length)
|
||||||
|
timer.tell();
|
||||||
|
});
|
||||||
commands.add(["sty[le]"],
|
commands.add(["sty[le]"],
|
||||||
"Add or list user styles",
|
"Add or list user styles",
|
||||||
function (args) {
|
function (args) {
|
||||||
let [filter, css] = args;
|
let [filter, css] = args;
|
||||||
let name = args["-name"];
|
|
||||||
|
|
||||||
if (!css) {
|
if (css) {
|
||||||
|
queue.push(args);
|
||||||
|
timer.tell(args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
let list = styles.user.sheets.slice()
|
let list = styles.user.sheets.slice()
|
||||||
.sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name)
|
.sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name)
|
||||||
: !!b.name - !!a.name || a.id - b.id);
|
: !!b.name - !!a.name || a.id - b.id);
|
||||||
let uris = util.visibleURIs(window.content);
|
let uris = util.visibleURIs(window.content);
|
||||||
|
let name = args["-name"];
|
||||||
modules.commandline.commandOutput(
|
modules.commandline.commandOutput(
|
||||||
template.tabular(["", "Name", "Filter", "CSS"],
|
template.tabular(["", "Name", "Filter", "CSS"],
|
||||||
["min-width: 1em; text-align: center; color: red; font-weight: bold;",
|
["min-width: 1em; text-align: center; color: red; font-weight: bold;",
|
||||||
@@ -379,17 +401,6 @@ const Styles = Module("Styles", {
|
|||||||
for (sheet in values(list))
|
for (sheet in values(list))
|
||||||
if ((!filter || sheet.sites.indexOf(filter) >= 0) && (!name || sheet.name == name)))));
|
if ((!filter || sheet.sites.indexOf(filter) >= 0) && (!name || sheet.name == name)))));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if ("-append" in args) {
|
|
||||||
let sheet = styles.user.get(name);
|
|
||||||
if (sheet) {
|
|
||||||
filter = sheet.sites.concat(filter).join(",");
|
|
||||||
css = sheet.css + " " + css;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
styles.user.add(name, filter, css, args["-agent"]);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
|
|||||||
@@ -292,10 +292,10 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
([^]*?) // 1
|
([^]*?) // 1
|
||||||
(?:
|
(?:
|
||||||
(<\[) | // 2
|
(<\[) | // 2
|
||||||
(< (.*?) >) | // 3 4
|
(< ((?:[a-z]-)?[a-z-]*?) >) | // 3 4
|
||||||
(\]>) // 5
|
(\]>) // 5
|
||||||
)
|
)
|
||||||
]]>, "gy");
|
]]>, "giy");
|
||||||
while (match = re.exec(macro)) {
|
while (match = re.exec(macro)) {
|
||||||
let [, prefix, open, full, macro, close] = match;
|
let [, prefix, open, full, macro, close] = match;
|
||||||
end += match[0].length;
|
end += match[0].length;
|
||||||
|
|||||||
Reference in New Issue
Block a user