mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:07:59 +01:00
Merge branch 'master' into vimperator-2.1
Conflicts: common/content/buffer.js common/content/style.js
This commit is contained in:
@@ -46,8 +46,8 @@ function Buffer() //{{{
|
|||||||
let fontSize = util.computedStyle(document.getElementById(mainWindowID)).fontSize;
|
let fontSize = util.computedStyle(document.getElementById(mainWindowID)).fontSize;
|
||||||
|
|
||||||
styles.registerSheet("chrome://liberator/skin/liberator.css");
|
styles.registerSheet("chrome://liberator/skin/liberator.css");
|
||||||
let error = styles.addSheet("font-size", "chrome://liberator/content/buffer.xhtml",
|
let error = styles.addSheet(true, "font-size", "chrome://liberator/content/buffer.xhtml",
|
||||||
"body { font-size: " + fontSize + "; }", true);
|
"body { font-size: " + fontSize + "; }");
|
||||||
|
|
||||||
if ("ZoomManager" in window)
|
if ("ZoomManager" in window)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -920,8 +920,9 @@ function Completion() //{{{
|
|||||||
case "}": pop("{"); /* Fallthrough */
|
case "}": pop("{"); /* Fallthrough */
|
||||||
case ";":
|
case ";":
|
||||||
top[FULL_STATEMENTS].push(i);
|
top[FULL_STATEMENTS].push(i);
|
||||||
|
break;
|
||||||
case ",":
|
case ",":
|
||||||
top[COMMA];
|
top[COMMA].push(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,6 +1159,7 @@ function Completion() //{{{
|
|||||||
let [offset, obj, func] = getObjKey(-3);
|
let [offset, obj, func] = getObjKey(-3);
|
||||||
if (!obj.length)
|
if (!obj.length)
|
||||||
return;
|
return;
|
||||||
|
obj = obj.slice(0, 1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1176,7 +1178,7 @@ function Completion() //{{{
|
|||||||
{
|
{
|
||||||
let arg = str.substring(prev + 1, idx);
|
let arg = str.substring(prev + 1, idx);
|
||||||
prev = idx;
|
prev = idx;
|
||||||
args.__defineGetter__(i, function () self.eval(ret));
|
args.__defineGetter__(i, function () self.eval(arg));
|
||||||
}
|
}
|
||||||
let key = getKey();
|
let key = getKey();
|
||||||
args.push(key + string);
|
args.push(key + string);
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ function Hints() //{{{
|
|||||||
css.push(highlight.selector(group) + "[number='" + elem.getAttribute("number") + "'] { " + elem.style.cssText + " }");
|
css.push(highlight.selector(group) + "[number='" + elem.getAttribute("number") + "'] { " + elem.style.cssText + " }");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
styles.addSheet("hint-positions", "*", css.join("\n"), true, true);
|
styles.addSheet(true, "hint-positions", "*", css.join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -296,7 +296,7 @@ function Hints() //{{{
|
|||||||
if (timeout && firstElem)
|
if (timeout && firstElem)
|
||||||
setTimeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight"); }, timeout);
|
setTimeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight"); }, timeout);
|
||||||
}
|
}
|
||||||
styles.removeSheet("hint-positions", null, null, null, true);
|
styles.removeSheet(true, "hint-positions");
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ const liberator = (function () //{{{
|
|||||||
let class = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
|
let class = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
|
||||||
|
|
||||||
if (class.length)
|
if (class.length)
|
||||||
styles.addSheet("scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }", true, true);
|
styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }");
|
||||||
else
|
else
|
||||||
styles.removeSheet("scrollbar", null, null, null, true);
|
styles.removeSheet(true, "scrollbar");
|
||||||
options.safeSetPref("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2);
|
options.safeSetPref("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2);
|
||||||
},
|
},
|
||||||
validator: function (opts) (opts.indexOf("l") < 0 || opts.indexOf("r") < 0)
|
validator: function (opts) (opts.indexOf("l") < 0 || opts.indexOf("r") < 0)
|
||||||
@@ -140,7 +140,7 @@ const liberator = (function () //{{{
|
|||||||
{
|
{
|
||||||
let classes = [v[1] for ([k, v] in Iterator(this.opts)) if (opts.indexOf(k) < 0)];
|
let classes = [v[1] for ([k, v] in Iterator(this.opts)) if (opts.indexOf(k) < 0)];
|
||||||
let css = classes.length ? classes.join(",") + "{ display: none; }" : "";
|
let css = classes.length ? classes.join(",") + "{ display: none; }" : "";
|
||||||
styles.addSheet("taboptions", "chrome://*", css, true, true);
|
styles.addSheet(true, "taboptions", "chrome://*", css);
|
||||||
statusline.updateTabCount();
|
statusline.updateTabCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ function Highlights(name, store, serial)
|
|||||||
return "Unknown highlight keyword: " + class;
|
return "Unknown highlight keyword: " + class;
|
||||||
|
|
||||||
let style = highlight[key] || new Highlight(key);
|
let style = highlight[key] || new Highlight(key);
|
||||||
styles.removeSheet(style.selector, null, null, null, true);
|
styles.removeSheet(true, style.selector);
|
||||||
|
|
||||||
if (append)
|
if (append)
|
||||||
newStyle = (style.value || "").replace(/;?\s*$/, "; " + newStyle);
|
newStyle = (style.value || "").replace(/;?\s*$/, "; " + newStyle);
|
||||||
@@ -169,7 +169,7 @@ function Highlights(name, store, serial)
|
|||||||
if (style.default == null)
|
if (style.default == null)
|
||||||
{
|
{
|
||||||
delete highlight[style.class];
|
delete highlight[style.class];
|
||||||
styles.removeSheet(style.selector, null, null, null, true);
|
styles.removeSheet(true, style.selector);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
newStyle = style.default;
|
newStyle = style.default;
|
||||||
@@ -180,7 +180,7 @@ function Highlights(name, store, serial)
|
|||||||
.replace(";!important;", ";", "g"); // Seeming Spidermonkey bug
|
.replace(";!important;", ";", "g"); // Seeming Spidermonkey bug
|
||||||
css = style.selector + " { " + css + " }";
|
css = style.selector + " { " + css + " }";
|
||||||
|
|
||||||
let error = styles.addSheet(style.selector, style.filter, css, true);
|
let error = styles.addSheet(true, style.selector, style.filter, css);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
style.value = newStyle;
|
style.value = newStyle;
|
||||||
@@ -272,22 +272,23 @@ function Styles(name, store, serial)
|
|||||||
/**
|
/**
|
||||||
* Add a new stylesheet.
|
* Add a new stylesheet.
|
||||||
*
|
*
|
||||||
|
* @param {boolean} system Declares whether this is a system or
|
||||||
|
* user sheet. System sheets are used internally by
|
||||||
|
* @liberator.
|
||||||
|
>>>>>>> master:common/content/style.js
|
||||||
* @param {string} name The name given to the stylesheet by
|
* @param {string} name The name given to the stylesheet by
|
||||||
* which it may be later referenced.
|
* which it may be later referenced.
|
||||||
* @param {string} filter The sites to which this sheet will
|
* @param {string} filter The sites to which this sheet will
|
||||||
* apply. Can be a domain name or a URL. Any URL ending in
|
* apply. Can be a domain name or a URL. Any URL ending in
|
||||||
* "*" is matched as a prefix.
|
* "*" is matched as a prefix.
|
||||||
* @param {string} css The CSS to be applied.
|
* @param {string} css The CSS to be applied.
|
||||||
* @param {boolean} system Declares whether this is a system or
|
|
||||||
* user sheet. System sheets are used internally by
|
|
||||||
* @liberator.
|
|
||||||
*/
|
*/
|
||||||
this.addSheet = function (name, filter, css, system)
|
this.addSheet = function (system, name, filter, css)
|
||||||
{
|
{
|
||||||
let sheets = system ? systemSheets : userSheets;
|
let sheets = system ? systemSheets : userSheets;
|
||||||
let names = system ? systemNames : userNames;
|
let names = system ? systemNames : userNames;
|
||||||
if (name && name in names)
|
if (name && name in names)
|
||||||
this.removeSheet(name, null, null, null, system);
|
this.removeSheet(system, name);
|
||||||
|
|
||||||
let sheet = sheets.filter(function (s) s.sites.join(",") == filter && s.css == css)[0];
|
let sheet = sheets.filter(function (s) s.sites.join(",") == filter && s.css == css)[0];
|
||||||
if (!sheet)
|
if (!sheet)
|
||||||
@@ -315,11 +316,27 @@ function Styles(name, store, serial)
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a sheet with a given name or index.
|
||||||
|
*
|
||||||
|
* @param {boolean} system
|
||||||
|
* @param {string or number} sheet The sheet to retrieve. Strings indicate
|
||||||
|
* sheet names, while numbers indicate indices.
|
||||||
|
*/
|
||||||
|
this.get = function get(system, sheet)
|
||||||
|
{
|
||||||
|
let sheets = system ? systemSheets : userSheets;
|
||||||
|
let names = system ? systemNames : userNames;
|
||||||
|
if (typeof sheet == "number")
|
||||||
|
return sheets[sheet];
|
||||||
|
return names[sheet]
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find sheets matching the parameters. See {@link #addSheet}
|
* Find sheets matching the parameters. See {@link #addSheet}
|
||||||
* for parameters.
|
* for parameters.
|
||||||
*/
|
*/
|
||||||
this.findSheets = function (name, filter, css, index, system)
|
this.findSheets = function (system, name, filter, css, index)
|
||||||
{
|
{
|
||||||
let sheets = system ? systemSheets : userSheets;
|
let sheets = system ? systemSheets : userSheets;
|
||||||
let names = system ? systemNames : userNames;
|
let names = system ? systemNames : userNames;
|
||||||
@@ -343,7 +360,7 @@ function Styles(name, store, serial)
|
|||||||
* are removed from matching sheets. If any remain, the sheet is
|
* are removed from matching sheets. If any remain, the sheet is
|
||||||
* left in place.
|
* left in place.
|
||||||
*/
|
*/
|
||||||
this.removeSheet = function (name, filter, css, index, system)
|
this.removeSheet = function (system, name, filter, css, index)
|
||||||
{
|
{
|
||||||
let self = this;
|
let self = this;
|
||||||
let sheets = system ? systemSheets : userSheets;
|
let sheets = system ? systemSheets : userSheets;
|
||||||
@@ -351,12 +368,12 @@ function Styles(name, store, serial)
|
|||||||
|
|
||||||
if (filter && filter.indexOf(",") > -1)
|
if (filter && filter.indexOf(",") > -1)
|
||||||
return filter.split(",").reduce(
|
return filter.split(",").reduce(
|
||||||
function (n, f) n + self.removeSheet(name, f, index, system), 0);
|
function (n, f) n + self.removeSheet(system, name, f, index), 0);
|
||||||
|
|
||||||
if (filter == undefined)
|
if (filter == undefined)
|
||||||
filter = "";
|
filter = "";
|
||||||
|
|
||||||
let matches = this.findSheets(name, filter, css, index, system);
|
let matches = this.findSheets(system, name, filter, css, index);
|
||||||
if (matches.length == 0)
|
if (matches.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -379,7 +396,7 @@ function Styles(name, store, serial)
|
|||||||
{
|
{
|
||||||
let sites = sheet.sites.filter(function (f) f != filter);
|
let sites = sheet.sites.filter(function (f) f != filter);
|
||||||
if (sites.length)
|
if (sites.length)
|
||||||
this.addSheet(name, sites.join(","), css, system, true);
|
this.addSheet(system, name, sites.join(","), css);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return matches.length;
|
return matches.length;
|
||||||
@@ -451,7 +468,19 @@ function Styles(name, store, serial)
|
|||||||
let (array = util.Array)
|
let (array = util.Array)
|
||||||
{
|
{
|
||||||
Styles.prototype = {
|
Styles.prototype = {
|
||||||
get sites() array.uniq(array.flatten([v.sites for ([k, v] in this.userSheets)]))
|
get sites() array.uniq(array.flatten([v.sites for ([k, v] in this.userSheets)])),
|
||||||
|
completeSite: function (context, content)
|
||||||
|
{
|
||||||
|
let compl = [];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
compl.push([content.location.host, "Current Host"]);
|
||||||
|
compl.push([content.location.href, "Current URL"]);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
context.anchored = false;
|
||||||
|
context.completions = compl.concat([[s, ""] for each (s in styles.sites)]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +500,18 @@ highlight.reload();
|
|||||||
liberator.triggerObserver("load_styles", "styles");
|
liberator.triggerObserver("load_styles", "styles");
|
||||||
liberator.triggerObserver("load_highlight", "highlight");
|
liberator.triggerObserver("load_highlight", "highlight");
|
||||||
|
|
||||||
|
liberator.registerObserver("load_completion", function ()
|
||||||
|
{
|
||||||
|
completion.setFunctionCompleter(["get", "addSheet", "removeSheet", "findSheets"].map(function (m) styles[m]),
|
||||||
|
[ // Prototype: (system, name, filter, css, index)
|
||||||
|
null,
|
||||||
|
function (context, obj, args) args[0] ? styles.systemNames : styles.userNames,
|
||||||
|
function (context, obj, args) styles.completeSite(context, content),
|
||||||
|
null,
|
||||||
|
function (context, obj, args) args[0] ? styles.systemSheets : styles.userSheets
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
liberator.registerObserver("load_commands", function ()
|
liberator.registerObserver("load_commands", function ()
|
||||||
{
|
{
|
||||||
// TODO: :colo default needs :hi clear
|
// TODO: :colo default needs :hi clear
|
||||||
@@ -513,14 +554,14 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
{
|
{
|
||||||
if ("-append" in args)
|
if ("-append" in args)
|
||||||
{
|
{
|
||||||
let sheet = styles.findSheets(name, null, null, null, false)[0];
|
let sheet = styles.get(false, name);
|
||||||
if (sheet)
|
if (sheet)
|
||||||
{
|
{
|
||||||
filter = sheet.sites.concat(filter).join(",");
|
filter = sheet.sites.concat(filter).join(",");
|
||||||
css = sheet.css.replace(/;?\s*$/, "; " + css);
|
css = sheet.css.replace(/;?\s*$/, "; " + css);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let err = styles.addSheet(name, filter, css, false, args.bang);
|
let err = styles.addSheet(false, name, filter, css);
|
||||||
if (err)
|
if (err)
|
||||||
liberator.echoerr(err);
|
liberator.echoerr(err);
|
||||||
}
|
}
|
||||||
@@ -532,18 +573,11 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
let compl = [];
|
let compl = [];
|
||||||
if (args.completeArg == 0)
|
if (args.completeArg == 0)
|
||||||
{
|
{
|
||||||
try
|
styles.completeSite(context, content);
|
||||||
{
|
|
||||||
compl.push([content.location.host, "Current Host"]);
|
|
||||||
compl.push([content.location.href, "Current URL"]);
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
context.anchored = false;
|
|
||||||
context.completions = compl.concat([[s, ""] for each (s in styles.sites)]);
|
|
||||||
}
|
}
|
||||||
else if (args.completeArg == 1)
|
else if (args.completeArg == 1)
|
||||||
{
|
{
|
||||||
let sheet = styles.findSheets(args["-name"], null, null, null, false)[0];
|
let sheet = styles.get(false, args["-name"]);
|
||||||
if (sheet)
|
if (sheet)
|
||||||
context.completions = [[sheet.css, "Current Value"]];
|
context.completions = [[sheet.css, "Current Value"]];
|
||||||
}
|
}
|
||||||
@@ -567,7 +601,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
"Remove a user stylesheet",
|
"Remove a user stylesheet",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
styles.removeSheet(args["-name"], args[0], args.literalArg, args["-index"], false);
|
styles.removeSheet(false, args["-name"], args[0], args.literalArg, args["-index"]);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
completer: function (context) { context.completions = styles.sites.map(function (site) [site, ""]); },
|
completer: function (context) { context.completions = styles.sites.map(function (site) [site, ""]); },
|
||||||
|
|||||||
@@ -220,8 +220,8 @@ function Tabs() //{{{
|
|||||||
});
|
});
|
||||||
let fragment = liberator.has("MacUnix") ? "tab-mac" : "tab";
|
let fragment = liberator.has("MacUnix") ? "tab-mac" : "tab";
|
||||||
// TODO: Add option, or only apply when go~=[nN]
|
// TODO: Add option, or only apply when go~=[nN]
|
||||||
styles.addSheet("tab-binding", "chrome://browser/content/browser.xul",
|
styles.addSheet(true, "tab-binding", "chrome://browser/content/browser.xul",
|
||||||
".tabbrowser-tab { -moz-binding: url(chrome://liberator/content/bindings.xml#" + fragment + ") !important; }", true);
|
".tabbrowser-tab { -moz-binding: url(chrome://liberator/content/bindings.xml#" + fragment + ") !important; }");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -883,9 +883,9 @@ function CommandLine() //{{{
|
|||||||
set silent(val) {
|
set silent(val) {
|
||||||
silent = val;
|
silent = val;
|
||||||
if (silent)
|
if (silent)
|
||||||
storage.styles.addSheet("silent-mode", "chrome://*", "#liberator-commandline > * { opacity: 0 }", true, true);
|
storage.styles.addSheet(true, "silent-mode", "chrome://*", "#liberator-commandline > * { opacity: 0 }");
|
||||||
else
|
else
|
||||||
storage.styles.removeSheet("silent-mode", null, null, null, true);
|
storage.styles.removeSheet(true, "silent-mode");
|
||||||
},
|
},
|
||||||
|
|
||||||
runSilently: function (fn, self)
|
runSilently: function (fn, self)
|
||||||
|
|||||||
Reference in New Issue
Block a user