1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 21:28:00 +01:00

Fix link listing in :hi output.

This commit is contained in:
Kris Maglione
2011-09-12 18:58:28 -04:00
parent 790af21b81
commit 50f0901412
6 changed files with 30 additions and 17 deletions

View File

@@ -106,10 +106,10 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
onStateChange: util.wrapCallback(function onStateChange(webProgress, request, flags, status) {
const L = Ci.nsIWebProgressListener;
if (flags & (L.STATE_IS_DOCUMENT | L.STATE_IS_WINDOW)) {
if (request)
dactyl.applyTriggerObserver("browser.stateChange", arguments);
if (flags & (L.STATE_IS_DOCUMENT | L.STATE_IS_WINDOW)) {
// This fires when the load event is initiated
// only thrown for the current tab, not when another tab changes
if (flags & L.STATE_START) {
@@ -148,13 +148,14 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
let win = webProgress.DOMWindow;
if (win && uri) {
let oldURI = win.document.dactylURI;
if (win.document.dactylLoadIdx === webProgress.loadedTransIndex
let oldURI = overlay.getData(win.document)["uri"];
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
for (let frame in values(buffer.allFrames(win)))
frame.document.dactylFocusAllowed = false;
win.document.dactylURI = uri.spec;
win.document.dactylLoadIdx = webProgress.loadedTransIndex;
overlay.setData(frame.document, "focus-allowed", false);
overlay.setData(win.document, "uri", uri.spec);
overlay.setData(win.document, "load-idx", webProgress.loadedTransIndex);
}
// Workaround for bugs 591425 and 606877, dactyl bug #81

View File

@@ -429,9 +429,11 @@ var Buffer = Module("buffer", {
let doc = elem.ownerDocument || elem.document || elem;
switch (options.get("strictfocus").getKey(doc.documentURIObject || util.newURI(doc.documentURI), "moderate")) {
case "despotic":
return elem.dactylFocusAllowed || elem.frameElement && elem.frameElement.dactylFocusAllowed;
return overlay.getData(elem)["focus-allowed"]
|| elem.frameElement && overlay.getData(elem.frameElement)["focus-allowed"];
case "moderate":
return doc.dactylFocusAllowed || elem.frameElement && elem.frameElement.ownerDocument.dactylFocusAllowed;
return overlay.getData(doc, "focus-allowed")
|| elem.frameElement && overlay.getData(elem.frameElement.ownerDocument)["focus-allowed"];
default:
return true;
}
@@ -446,13 +448,13 @@ var Buffer = Module("buffer", {
*/
focusElement: function focusElement(elem) {
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
elem.dactylFocusAllowed = true;
win.document.dactylFocusAllowed = true;
overlay.setData(elem, "focus-allowed", true);
overlay.setData(win.document, "focus-allowed", true);
if (isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]))
elem = elem.contentWindow;
if (elem.document)
elem.document.dactylFocusAllowed = true;
overlay.setData(elem.document, "focus-allowed", true);
if (elem instanceof HTMLInputElement && elem.type == "file") {
Buffer.openUploadPrompt(elem);

View File

@@ -801,8 +801,8 @@ var Events = Module("events", {
for (; win; win = win != win.parent && win.parent) {
for (; elem instanceof Element; elem = elem.parentNode)
elem.dactylFocusAllowed = true;
win.document.dactylFocusAllowed = true;
overlay.setData(elem, "focus-allowed", true);
overlay.setData(win.document, "focus-allowed", true);
}
},

View File

@@ -120,6 +120,10 @@ var DOM = Class("DOM", {
},
eachDOM: function eachDOM(val, fn, self) {
XML.prettyPrinting = XML.ignoreWhitespace = false;
if (isString(val))
val = XML(val);
if (typeof val == "xml")
return this.each(function (elem, i) {
fn.call(this, DOM.fromXML(val, elem.ownerDocument), elem, i);
@@ -127,13 +131,16 @@ var DOM = Class("DOM", {
let dom = this;
function munge(val) {
if (val instanceof Ci.nsIDOMRange)
return val.extractContents();
if (typeof val == "xml")
val = dom.constructor(val, dom.document);
if (isObject(val) && "length" in val) {
let frag = dom.document.createDocumentFragment();
for (let i = 0; i < val.length; i++)
frag.appendChild(val[i]);
frag.appendChild(munge(val[i]));
return frag;
}
return val;

View File

@@ -348,7 +348,7 @@ var Highlights = Module("Highlight", {
"text-align: center"],
([h.class,
<span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>,
template.map(h.extends, template.highlight),
template.map(h.extends, function (s) template.highlight(s)),
template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
function (match) <span highlight={match[0] == "/" ? "Comment" : "Key"}>{match}</span>)
]

View File

@@ -153,6 +153,9 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
if (!(id in obj && obj[id]))
obj[id] = {};
if (arguments.length == 1)
return obj[id];
if (obj[id][key] === undefined)
if (constructor === undefined || callable(constructor))
obj[id][key] = (constructor || Array)();