1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 04:07:58 +01:00

Simplify isolation of hints from page styles.

This commit is contained in:
Kris Maglione
2010-12-20 15:53:56 -05:00
parent f03656fd87
commit 11d938f0b8
3 changed files with 58 additions and 63 deletions

View File

@@ -13,9 +13,14 @@
</content> </content>
</binding> </binding>
<binding id="magic" inheritstyle="false"> <binding id="hints" inheritstyle="false">
<implementation>
<field name="hints">
document.getAnonymousElementByAttribute(this, "anonid", "hints");
</field>
</implementation>
<content> <content>
<html:span xbl:inherits="dactyl:highlight=dactyl:highlight,number,style,text" /> <html:div anonid="hints"/>
</content> </content>
</binding> </binding>

View File

@@ -287,14 +287,18 @@ const Hints = Module("hints", {
return true; return true;
} }
let baseNodeAbsolute = util.xmlToDom(<span highlight="Hint" dactyl:class="magic" xmlns:dactyl={NS}/>, doc); let body = doc.body || util.evaluateXPath(["body"], doc).snapshotItem(0);
if (body) {
let fragment = util.xmlToDom(<div highlight="hints"/>, doc);
body.appendChild(fragment);
let baseNodeAbsolute = util.xmlToDom(<span highlight="Hint"/>, doc);
let mode = this._hintMode; let mode = this._hintMode;
let res = util.evaluateXPath(mode.xpath, doc, null, true); let res = util.evaluateXPath(mode.xpath, doc, null, true);
if (mode.filter) if (mode.filter)
res = let (orig = res) (e for (e in orig) if (mode.filter(e))); res = let (orig = res) (e for (e in orig) if (mode.filter(e)));
let fragment = util.xmlToDom(<div highlight="hints"/>, doc);
let start = this._pageHints.length; let start = this._pageHints.length;
for (let elem in res) { for (let elem in res) {
let hint = { elem: elem, showText: false }; let hint = { elem: elem, showText: false };
@@ -322,14 +326,11 @@ const Hints = Module("hints", {
hint.span.style.left = leftPos + "px"; hint.span.style.left = leftPos + "px";
hint.span.style.top = topPos + "px"; hint.span.style.top = topPos + "px";
fragment.appendChild(hint.span); fragment.wrappedJSObject.hints.appendChild(hint.span);
this._pageHints.push(hint); this._pageHints.push(hint);
} }
let body = doc.body || util.evaluateXPath(["body"], doc).snapshotItem(0);
if (body) {
body.appendChild(fragment);
this._docs.push({ doc: doc, start: start, end: this._pageHints.length - 1 }); this._docs.push({ doc: doc, start: start, end: this._pageHints.length - 1 });
} }
@@ -420,7 +421,7 @@ const Hints = Module("hints", {
if (!rect) if (!rect)
continue; continue;
hint.imgSpan = util.xmlToDom(<span dactyl:class="magic" highlight="Hint" dactyl:hl="HintImage" xmlns:dactyl={NS}/>, doc); hint.imgSpan = util.xmlToDom(<span highlight="Hint" dactyl:hl="HintImage"/>, doc);
hint.imgSpan.style.left = (rect.left + offsetX) + "px"; hint.imgSpan.style.left = (rect.left + offsetX) + "px";
hint.imgSpan.style.top = (rect.top + offsetY) + "px"; hint.imgSpan.style.top = (rect.top + offsetY) + "px";
hint.imgSpan.style.width = (rect.right - rect.left) + "px"; hint.imgSpan.style.width = (rect.right - rect.left) + "px";
@@ -453,12 +454,12 @@ const Hints = Module("hints", {
if (options["usermode"]) { if (options["usermode"]) {
let css = []; let css = [];
// FIXME: Broken for imgspans. for (let hint in values(this._pageHints)) {
for (let { doc } in values(this._docs)) { let selector = highlight.selector("Hint") + "[number=" + hint.span.getAttribute("number").quote() + "]";
for (let elem in util.evaluateXPath("//*[@dactyl:highlight and @number]", doc)) { let imgSpan = "[dactyl|hl=HintImage]";
let group = elem.getAttributeNS(NS, "highlight"); css.push(selector + ":not(" + imgSpan + ") { " + hint.span.style.cssText + " }");
css.push(highlight.selector(group) + "[number=" + elem.getAttribute("number").quote() + "] { " + elem.style.cssText + " }"); if (hint.imgSpan)
} css.push(selector + imgSpan + " { " + hint.span.style.cssText + " }");
} }
styles.addSheet(true, "hint-positions", "*", css.join("\n")); styles.addSheet(true, "hint-positions", "*", css.join("\n"));
} }

View File

@@ -7,26 +7,15 @@
-moz-binding: url(chrome://dactyl/content/bindings.xml#frame) !important; -moz-binding: url(chrome://dactyl/content/bindings.xml#frame) !important;
} }
[dactyl|class~=magic] > [dactyl|highlight=Hint] { [dactyl|highlight~=hints] {
visibility: visible !important; -moz-binding: url(chrome://dactyl/content/bindings.xml#hints) !important;
}
[dactyl|class~=magic] {
-moz-binding: url(chrome://dactyl/content/bindings.xml#magic) !important;
visibility: hidden !important;
position: absolute !important;
top: 0 !important;
left: 0 !important;
width: 4000px !important;
} }
[dactyl|highlight~=HintImage], [dactyl|highlight~=HintImage],
[dactyl|highlight~=Hint] { [dactyl|highlight~=Hint] {
z-index: 5000; z-index: 50000;
position: absolute !important; position: absolute !important;
} }
[dactyl|highlight~=Search] {
display: inline !important;
}
/* Applied only to completion buffer and MOW */ /* Applied only to completion buffer and MOW */
@-moz-document @-moz-document