From 54b5fa04f20f8f273c29f82e31f4c153196efbf8 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 19 Feb 2014 19:55:04 -0800 Subject: [PATCH] Stop unexpectedly going into INSERT mode on Facebook. --- common/content/events.js | 30 +++++++++++++++++------------- common/modules/base.jsm | 11 ++++++++--- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 7d4fae56..3ae757c9 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -875,19 +875,23 @@ var Events = Module("events", { let haveInput = modes.stack.some(m => m.main.input); if (DOM(elem || win).isEditable) { - if (!haveInput) - if (!isinstance(modes.main, [modes.INPUT, modes.TEXT_EDIT, modes.VISUAL])) - if (options["insertmode"]) - modes.push(modes.INSERT); - else { - modes.push(modes.TEXT_EDIT); - if (elem.selectionEnd - elem.selectionStart > 0) - modes.push(modes.VISUAL); - } + let e = elem || win; + if (!(e instanceof Ci.nsIDOMWindow && + DOM(e.document.activeElement).style.MozUserModify != "read-write")) { + if (!haveInput) + if (!isinstance(modes.main, [modes.INPUT, modes.TEXT_EDIT, modes.VISUAL])) + if (options["insertmode"]) + modes.push(modes.INSERT); + else { + modes.push(modes.TEXT_EDIT); + if (elem.selectionEnd - elem.selectionStart > 0) + modes.push(modes.VISUAL); + } - if (hasHTMLDocument(win)) - buffer.lastInputField = elem || win; - return; + if (hasHTMLDocument(win)) + buffer.lastInputField = elem || win; + return; + } } if (elem && Events.isInputElement(elem)) { @@ -969,7 +973,7 @@ var Events = Module("events", { }, isInputElement: function isInputElement(elem) { - return DOM(elem).isEditable || + return elem instanceof Ci.nsIDOMElement && DOM(elem).isEditable || isinstance(elem, [Ci.nsIDOMHTMLEmbedElement, Ci.nsIDOMHTMLObjectElement, Ci.nsIDOMHTMLSelectElement]); diff --git a/common/modules/base.jsm b/common/modules/base.jsm index add25aec..e71407cb 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -977,9 +977,14 @@ Class.prototype = { callback.call(this); } catch (e) { - util.dump("Error invoking timer callback registered at " + - [frame.filename, frame.lineNumber, ""].join(":")); - Cu.reportError(e); + try { + util.dump("Error invoking timer callback registered at " + + [frame.filename, frame.lineNumber, ""].join(":")); + util.reportError(e); + } + catch (e) { + Cu.reportError(e); + } } }; let frame = Components.stack.caller;