diff --git a/common/content/commandline.js b/common/content/commandline.js index 1ed66749..45bfb6a1 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1381,6 +1381,7 @@ var CommandLine = Module("commandline", { if (this.context.waitingForTab || this.wildIndex == -1) this.complete(true, true); + this.wildtypes = wildmode; let count = Math.abs(offset); let steps = Math.constrain(this.wildtypes.length - this.wildIndex, 1, count); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index f3260f42..f62a1110 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -565,19 +565,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, focus: function focus(elem, flags) { - flags = flags || services.focus.FLAG_BYMOUSE; - try { - if (elem instanceof Document) - elem = elem.defaultView; - if (elem instanceof Element) - services.focus.setFocus(elem, flags); - else if (elem instanceof Window) - services.focus.focusedWindow = elem; - } - catch (e) { - util.dump(elem); - util.reportError(e); - } + DOM(elem).focus(flags); }, /** diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 83b31f51..d58e0faf 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -289,8 +289,6 @@ var Buffer = Module("Buffer", { * @param {Node} elem The element to focus. */ focusElement: function focusElement(elem) { - let { Editor, dactyl } = this.modules; - let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; overlay.setData(elem, "focus-allowed", true); overlay.setData(win.document, "focus-allowed", true); @@ -313,15 +311,17 @@ var Buffer = Module("Buffer", { else flags = services.focus.FLAG_SHOWRING; + // Hack to deal with current versions of Firefox misplacing + // the caret if (!overlay.getData(elem, "had-focus", false) && elem.value && elem instanceof Ci.nsIDOMHTMLInputElement && - Editor.getEditor(elem) && + DOM(elem).isEditable && elem.selectionStart != null && elem.selectionStart == elem.selectionEnd) elem.selectionStart = elem.selectionEnd = elem.value.length; - dactyl.focus(elem, flags); + DOM(elem).focus(flags); if (elem instanceof Ci.nsIDOMWindow) { let sel = elem.getSelection(); @@ -813,8 +813,6 @@ var Buffer = Module("Buffer", { * count skips backwards. */ shiftFrameFocus: function shiftFrameFocus(count) { - let { dactyl } = this.modules; - if (!(this.doc instanceof Ci.nsIDOMHTMLDocument)) return; @@ -835,20 +833,21 @@ var Buffer = Module("Buffer", { // calculate the next frame to focus let next = current + count; if (next < 0 || next >= frames.length) + util.dactyl.beep(); dactyl.beep(); next = Math.constrain(next, 0, frames.length - 1); // focus next frame and scroll into view - dactyl.focus(frames[next]); + DOM(frames[next]).focus(); if (frames[next] != this.win) DOM(frames[next].frameElement).scrollIntoView(); // add the frame indicator let doc = frames[next].document; - let indicator = util.xmlToDom(
, doc); - (doc.body || doc.documentElement || doc).appendChild(indicator); + let indicator = DOM(
, doc) + .appendTo(doc.body || doc.documentElement || doc); - util.timeout(function () { doc.body.removeChild(indicator); }, 500); + util.timeout(function () { indicator.remove(); }, 500); // Doesn't unattach //doc.body.setAttributeNS(NS.uri, "activeframe", "true"); diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 24fb5714..8a2440e4 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -358,9 +358,16 @@ var DOM = Class("DOM", { scrollPos: function scrollPos(left, top) { if (arguments.length == 0) { if (this[0] instanceof Ci.nsIDOMElement) - return { top: this[0].scrollTop, left: this[0].scrollLeft }; + return { top: this[0].scrollTop, left: this[0].scrollLeft, + height: this[0].scrollHeight, width: this[0].scrollWidth, + innerHeight: this[0].clientHeight, innerWidth: this[0].innerWidth }; + if (this[0] instanceof Ci.nsIDOMWindow) - return { top: this[0].scrollY, left: this[0].scrollX }; + return { top: this[0].scrollY, left: this[0].scrollX, + height: this[0].scrollMaxY + this[0].innerHeight, + width: this[0].scrollMaxX + this[0].innerWidth, + innerHeight: this[0].innerHeight, innerWidth: this[0].innerWidth }; + return null; } let func = callable(left) && left; @@ -818,7 +825,21 @@ var DOM = Class("DOM", { focus: function focus(arg, extra) { if (callable(arg)) return this.listen("focus", arg, extra); - services.focus.setFocus(this[0], extra || services.focus.FLAG_BYMOUSE); + + let elem = this[0]; + let flags = arg || services.focus.FLAG_BYMOUSE; + try { + if (elem instanceof Ci.nsIDOMDocument) + elem = elem.defaultView; + if (elem instanceof Ci.nsIDOMElement) + services.focus.setFocus(elem, flags); + else if (elem instanceof Ci.nsIDOMWindow) + services.focus.focusedWindow = elem; + } + catch (e) { + util.dump(elem); + util.reportError(e); + } return this; }, blur: function blur(arg, extra) { @@ -1556,10 +1577,12 @@ var DOM = Class("DOM", { }); Object.keys(DOM.Event.types).forEach(function (event) { - DOM.prototype[event.replace(/-(.)/g, function (m, m1) m1.toUpperCase())] = - function _event(arg, extra) { - return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra); - }; + let name = event.replace(/-(.)/g, function (m, m1) m1.toUpperCase()); + if (!Set.has(DOM.prototype, name)) + DOM.prototype[name] = + function _event(arg, extra) { + return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra); + }; }); var $ = DOM;