From 127ed4cfc2d1c351e59458621eb02618661b7943 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 12 Feb 2011 12:15:02 -0500 Subject: [PATCH] Fix pressing in content-editable windows. Closes issue #not-in-the-tracker-for-some-reason. --- common/content/buffer.js | 4 +++- common/content/dactyl.js | 1 + common/content/editor.js | 19 ++++++++++--------- common/content/events.js | 3 ++- common/modules/styles.jsm | 1 + 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 7b2d20e1..6dbd4915 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -221,7 +221,9 @@ var Buffer = Module("buffer", { */ get lastInputField() { let field = this.localStore.lastInputField && this.localStore.lastInputField.get(); - return field && field.ownerDocument == field.ownerDocument.defaultView.document ? field : null; + let doc = field && field.ownerDocument; + let win = doc && doc.defaultView; + return win && doc === win.document ? field : null; }, set lastInputField(value) { this.localStore.lastInputField = value && Cu.getWeakReference(value); }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index f720ec6f..22c9c629 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1368,6 +1368,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { dactyl.echoerr(template.linkifyHelp(error.message)); else dactyl.beep(); + util.reportError(error); return; } if (error.result == Cr.NS_BINDING_ABORTED) diff --git a/common/content/editor.js b/common/content/editor.js index 1e5a62b3..41811221 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -375,19 +375,20 @@ var Editor = Module("editor", { * @see Abbreviation#expand */ expandAbbreviation: function (mode) { - let editor = Editor.getEditor(); - if (!(editor && editor.value)) + let elem = dactyl.focusedElement; + if (!(elem && elem.value)) return; - let text = editor.value; - let start = editor.selectionStart; - let end = editor.selectionEnd; + + let text = elem.value; + let start = elem.selectionStart; + let end = elem.selectionEnd; let abbrev = abbreviations.match(mode, text.substring(0, start).replace(/.*\s/g, "")); if (abbrev) { let len = abbrev.lhs.length; - let rhs = abbrev.expand(editor); - editor.value = text.substring(0, start - len) + rhs + text.substring(start); - editor.selectionStart = start - len + rhs.length; - editor.selectionEnd = end - len + rhs.length; + let rhs = abbrev.expand(elem); + elem.value = text.substring(0, start - len) + rhs + text.substring(start); + elem.selectionStart = start - len + rhs.length; + elem.selectionEnd = end - len + rhs.length; } }, }, { diff --git a/common/content/events.js b/common/content/events.js index dbbb0f34..3c508f53 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1277,7 +1277,8 @@ var Events = Module("events", { return; } - if (elem instanceof HTMLTextAreaElement || (elem && util.computedStyle(elem).MozUserModify == "read-write") + if (elem instanceof HTMLTextAreaElement + || elem instanceof Element && util.computedStyle(elem).MozUserModify === "read-write" || elem == null && win && Editor.getEditor(win)) { if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart) diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index c80f8da7..d9da6c68 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -574,6 +574,7 @@ var Styles = Module("Styles", { } }, { + bang: true, completer: function (context, args) { let compl = []; let sheet = args["-group"].get(args["-name"]);