diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-09-12 18:58:28 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-09-12 18:58:28 -0400 |
commit | 50f0901412d004840753246cef5b913734861a7a (patch) | |
tree | 1fe0886c51c5d878628db715dae32e6b2f0f1e96 /common | |
parent | 790af21b81a81acb43f84e1e653f9b186cb6fdc8 (diff) | |
download | pentadactyl-50f0901412d004840753246cef5b913734861a7a.tar.gz |
Fix link listing in :hi output.
Diffstat (limited to 'common')
-rw-r--r-- | common/content/browser.js | 17 | ||||
-rw-r--r-- | common/content/buffer.js | 12 | ||||
-rw-r--r-- | common/content/events.js | 4 | ||||
-rw-r--r-- | common/modules/dom.jsm | 9 | ||||
-rw-r--r-- | common/modules/highlight.jsm | 2 | ||||
-rw-r--r-- | common/modules/overlay.jsm | 3 |
6 files changed, 30 insertions, 17 deletions
diff --git a/common/content/browser.js b/common/content/browser.js index 1aaecedf..cbe82316 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -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 (request) - dactyl.applyTriggerObserver("browser.stateChange", arguments); - if (flags & (L.STATE_IS_DOCUMENT | L.STATE_IS_WINDOW)) { + if (request) + dactyl.applyTriggerObserver("browser.stateChange", arguments); + // 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 diff --git a/common/content/buffer.js b/common/content/buffer.js index 78a4e54f..e587c158 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -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); diff --git a/common/content/events.js b/common/content/events.js index 0cab480a..bf9774db 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -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); } }, diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 4be465ec..7735759f 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -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; diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index 1d4c4b3f..a603906e 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -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>) ] diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index 3fa30c6b..6cb81718 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -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)(); |