From 12a6b7ee05514af289cde99ac27246c6464fb23c Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 7 Oct 2008 14:46:18 +0000 Subject: [PATCH] Get rid of *style options and add highlight groups --- content/buffer.js | 19 ++++++++++++++----- content/find.js | 10 +--------- content/hints.js | 6 +----- content/liberator.js | 26 ++++++++------------------ 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/content/buffer.js b/content/buffer.js index d4cdb129..48dbbe39 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -37,7 +37,11 @@ liberator.Buffer = function () //{{{ const highlightClasses = ["Boolean", "ErrorMsg", "Function", "InfoMsg", "Keyword", "LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question", "StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "Tag", - "Title", "URL", "WarningMsg"]; + "Title", "URL", "WarningMsg", + ["Hint", ".liberator-hint", "*"] + ["Search", ".__liberator-search", "*"], + ["Bell", "#liberator-visualbell"], + ]; let name = liberator.config.name.toLowerCase(); const highlightDocs = "chrome://" + name + "/content/buffer.xhtml,chrome://browser/content/browser.xul"; @@ -1092,22 +1096,27 @@ liberator.Buffer = function () //{{{ { let [, class, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/); - if (highlightClasses.indexOf(class) == -1) + let class = highlightClasses.filter(function (i) i == class || i[0] == class)[0]; + if (!class) { liberator.echoerr("Unknown highlight keyword"); return; } + if (!(class instanceof Array)) + class = [class]; + let cssClass = class[1] || ".hl-" + class[0]; + let scope = class[2] || highlightDocs; - let getCSS = function (style) ".hl-" + class + selectors + " { " + style.replace(/(?:!\s*important\s*)?(?:;|;?$)/g, "!important;") + " }"; + let getCSS = function (style) cssClass + selectors + " { " + style.replace(/(?:!\s*important\s*)?(?:;|;?$)/g, "!important;") + " }"; let css = getCSS(style); if (highlight.get(key)) - styles.removeSheet(highlightDocs, getCSS(highlight.get(key)), true); + styles.removeSheet(scope, getCSS(highlight.get(key)), true); if (/^\s*$/.test(style)) return highlight.remove(key); - let error = styles.addSheet(highlightDocs, css, true, force); + let error = styles.addSheet(scope, css, true, force); if (error) liberator.echoerr(error); else diff --git a/content/find.js b/content/find.js index 60990a79..73f28f6c 100644 --- a/content/find.js +++ b/content/find.js @@ -176,9 +176,7 @@ liberator.Search = function () //{{{ return; } - var baseNode = + var baseNode = baseNode = liberator.util.xmlToDom(baseNode, window.content.document); var body = doc.body; @@ -245,12 +243,6 @@ liberator.Search = function () //{{{ } }); - // TODO: use Search highlight group instead when we have proper highlight - // support - liberator.options.add(["hlsearchstyle", "hlss"], - "CSS specification of highlighted search items", - "string", "color: black; background-color: yellow; padding: 0; display: inline;"); - liberator.options.add(["ignorecase", "ic"], "Ignore case in search patterns", "boolean", true); diff --git a/content/hints.js b/content/hints.js index 41d4ab73..4a751533 100644 --- a/content/hints.js +++ b/content/hints.js @@ -88,7 +88,7 @@ liberator.Hints = function () //{{{ var scrollY = doc.defaultView.scrollY; var baseNodeAbsolute = liberator.util.xmlToDom( - , doc); + , doc); var elem, tagname, text, span, rect; var res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true); @@ -555,10 +555,6 @@ liberator.Hints = function () //{{{ "XPath string of hintable elements activated by ';'", "string", DEFAULT_HINTTAGS); - liberator.options.add(["hintstyle", "hs"], - "CSS specification of unfocused hints", - "string", "z-index:5000; font-family:monospace; font-size:10px; font-weight: bold; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;"); - liberator.options.add(["hinttags", "ht"], "XPath string of hintable elements activated by 'f' and 'F'", "string", DEFAULT_HINTTAGS); diff --git a/content/liberator.js b/content/liberator.js index 52b4f515..b264034c 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -123,11 +123,6 @@ const liberator = (function () //{{{ return value; } }); - - liberator.options.add(["visualbellstyle", "t_vb"], - "CSS specification of the visual bell", - "string", "border: none; background-color: black;" - ); } function addMappings() @@ -663,20 +658,15 @@ const liberator = (function () //{{{ { if (liberator.options["visualbell"]) { - var vbs = liberator.options["visualbellstyle"]; - if (vbs) - { - // flash the visual bell - var popup = document.getElementById("liberator-visualbell"); - var win = liberator.config.visualbellWindow; - var box = document.getBoxObjectFor(win); + // flash the visual bell + var popup = document.getElementById("liberator-visualbell"); + var win = liberator.config.visualbellWindow; + var box = document.getBoxObjectFor(win); - popup.style.cssText = vbs; - popup.height = box.height; - popup.width = box.width; - popup.openPopup(win, "overlap", 0, 0, false, false); - setTimeout(function () { popup.hidePopup(); }, 50); - } + popup.height = box.height; + popup.width = box.width; + popup.openPopup(win, "overlap", 0, 0, false, false); + setTimeout(function () { popup.hidePopup(); }, 50); } else {