From eef79f2ba823dd9287f018e744a27bae32772481 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 28 Dec 2010 22:54:36 -0500 Subject: [PATCH] Treat XUL Tree and TextBox elements as input elements. --- common/content/buffer.js | 14 ++++++-------- common/content/events.js | 27 +++++++++++++++------------ common/modules/styles.jsm | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 0d8df89f..e2d9ca58 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -118,7 +118,7 @@ var Buffer = Module("buffer", { } yield ["Title", doc.title]; - yield ["URL", template.highlightURL(doc.location.toString(), true)]; + yield ["URL", template.highlightURL(doc.location.href, true)]; let ref = "referrer" in doc && doc.referrer; if (ref) @@ -171,7 +171,7 @@ var Buffer = Module("buffer", { if (!(uri || doc.location)) return; - uri = uri || util.newURI(doc.location.href); + uri = uri || doc.documentURIObject; let args = { url: { toString: function () uri.spec, valueOf: function () uri }, title: doc.title @@ -224,7 +224,7 @@ var Buffer = Module("buffer", { else { // code which should happen for all (also background) newly loaded tabs goes here: if (doc != config.browser.contentDocument) - dactyl.echomsg({ domains: [util.getHost(doc.location.href)], message: "Background tab loaded: " + doc.title || doc.location.href }, 3); + dactyl.echomsg({ domains: [doc.location.host], message: "Background tab loaded: " + (doc.title || doc.location.href) }, 3); this._triggerLoadAutocmd("PageLoad", doc); } @@ -911,7 +911,7 @@ var Buffer = Module("buffer", { showPageInfo: function (verbose, sections) { // Ctrl-g single line output if (!verbose) { - let file = content.document.location.pathname.split("/").pop() || "[No Name]"; + let file = content.location.pathname.split("/").pop() || "[No Name]"; let title = content.document.title || "[No Title]"; let info = template.map("gf", @@ -1009,9 +1009,7 @@ var Buffer = Module("buffer", { return true; } - let url = isString(doc) ? doc : doc.location.href; - let uri = util.newURI(url, charset); - let charset = isString(doc) ? null : doc.characterSet; + let url = isString(doc) ? util.newURI(doc) : doc.documentURIObject; if (!isString(doc)) return io.withTempFiles(function (temp) { @@ -1357,7 +1355,7 @@ var Buffer = Module("buffer", { dactyl.assert(args.bang || !file.exists(), "E13: File exists (add ! to override)"); - chosenData = { file: file, uri: window.makeURI(doc.location.href, doc.characterSet) }; + chosenData = { file: file, uri: doc.documentURIObject }; } // if browser.download.useDownloadDir = false then the "Save As" diff --git a/common/content/events.js b/common/content/events.js index cd69ff3b..bac7c073 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -798,9 +798,12 @@ var Events = Module("events", { if (elem && elem.readOnly) return; - if (elem instanceof HTMLInputElement && set.has(util.editableInputs, elem.type) || - elem instanceof HTMLSelectElement || - elem instanceof Window && Editor.getEditor(elem)) { + if (isinstance(elem, [HTMLEmbedElement, HTMLEmbedElement])) { + modes.push(modes.EMBED); + return; + } + + if (Events.isInputElem(elem)) { if (!(modes.main & (modes.INSERT | modes.TEXT_EDIT | modes.VISUAL))) modes.push(modes.INSERT); @@ -809,11 +812,6 @@ var Events = Module("events", { return; } - if (isinstance(elem, [HTMLEmbedElement, HTMLEmbedElement])) { - dactyl.mode = modes.EMBED; - return; - } - if (elem instanceof HTMLTextAreaElement || (elem && util.computedStyle(elem).MozUserModify == "read-write") || elem == null && win && Editor.getEditor(win)) { @@ -1183,12 +1181,17 @@ var Events = Module("events", { let (key = isString(event) ? event : events.toString(event)) key === "" || key === "", - isInputElemFocused: function isInputElemFocused() { - let elem = dactyl.focusedElement; + isInputElem: function isInputElem(elem) { return elem instanceof HTMLInputElement && set.has(util.editableInputs, elem.type) || isinstance(elem, [HTMLIsIndexElement, HTMLEmbedElement, - HTMLObjectElement, HTMLTextAreaElement]); - } + HTMLObjectElement, HTMLSelectElement, + HTMLTextAreaElement, + Ci.nsIDOMXULTreeElement, Ci.nsIDOMXULTextBoxElement]) || + elem instanceof Window && Editor.getEditor(elem); + }, + + isInputElemFocused: function isInputElemFocused() this.isInputElem(dactyl.focusedElement) + }, { commands: function () { commands.add(["delmac[ros]"], diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index b31df65a..1e7f5485 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -315,7 +315,7 @@ var Styles = Module("Styles", { else if (/[\/:]/.test(filter)) function test(uri) uri.spec === filter; else - function test(uri) { try { return uri.host === filter } catch (e) { return false } }; + function test(uri) { try { return util.isSubdomain(uri.host, filter); } catch (e) { return false; } }; test.toString = function toString() filter; if (arguments.length < 2) return test;