From e769c21566168947fdbe2b6d422271ddf539e930 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 3 Feb 2011 12:35:37 -0500 Subject: [PATCH] Fix lost key presses when starting find mode during page load. --- common/content/commandline.js | 15 ++++++++------- common/content/dactyl.js | 1 + common/modules/finder.jsm | 9 +++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index 8d31e16a..7e18b736 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -102,7 +102,7 @@ var CommandWidgets = Class("CommandWidgets", { }, getElement: CommandWidgets.getEditor, getGroup: function (value) this.activeGroup.commandline, - onChange: function (elem) { + onChange: function (elem, value) { if (elem.inputField != dactyl.focusedElement) try { elem.selectionStart = elem.value.length; @@ -113,7 +113,10 @@ var CommandWidgets = Class("CommandWidgets", { if (!elem.collapsed) dactyl.focus(elem); }, - onVisibility: function (elem, visible) { visible && dactyl.focus(elem); } + onVisibility: function (elem, visible) { + if (visible) + dactyl.focus(elem); + } }); this.addElement({ @@ -191,7 +194,7 @@ var CommandWidgets = Class("CommandWidgets", { .join(" ")); elem.value = val[1]; if (obj.onChange) - obj.onChange.call(this, elem); + obj.onChange.call(this, elem, val); } }, this); @@ -799,10 +802,8 @@ var CommandLine = Module("commandline", { ]).toObject(), { blur: function onBlur(event) { - this.timeout(function () { - if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField) - dactyl.focus(this.widgets.active.command.inputField); - }); + if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField) + dactyl.focus(this.widgets.active.command.inputField); }, focus: function onFocus(event) { if (!this.commandMode diff --git a/common/content/dactyl.js b/common/content/dactyl.js index d2b4510f..e499abf2 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -510,6 +510,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { } catch (e) {} + util.dumpStack(" ================ FOCUS CONTENT ================ "); if (clearFocusedElement) { if (dactyl.focusedElement) dactyl.focusedElement.blur(); diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index cbb323ca..eacd647c 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -29,6 +29,7 @@ var RangeFinder = Module("rangefinder", { get options() this.modules.options, openPrompt: function (mode) { + this.commandline; this.CommandMode(mode).open(); if (this.rangeFind && this.rangeFind.window.get() === this.window) @@ -318,6 +319,8 @@ var RangeFind = Class("RangeFind", { this.lastString = ""; }, + get store() this.content.document.dactylStore = this.content.document.dactylStore || {}, + get backward() this.finder.findBackwards, get matchCase() this.finder.caseSensitive, @@ -336,9 +339,7 @@ var RangeFind = Class("RangeFind", { get findString() this.lastString, get selectedRange() { - let win = this.content, store = this.content.document.dactylStore;; - if (store) - win = store.focusedFrame && store.focusedFrame.get() || win; + let win = this.store.focusedFrame && this.store.focusedFrame.get() || this.content; let selection = win.getSelection(); return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange(); @@ -349,7 +350,7 @@ var RangeFind = Class("RangeFind", { this.range.selectionController.scrollSelectionIntoView( this.range.selectionController.SELECTION_NORMAL, 0, false); - services.focus.focusedWindow = range.startContainer.ownerDocument.defaultView; + this.store.focusedFrame = Cu.getWeakReference(range.startContainer.ownerDocument.defaultView); }, cancel: function () {