mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 21:37:57 +01:00
Fix <A-Tab>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(<div highlight="FrameIndicator"/>, doc);
|
||||
(doc.body || doc.documentElement || doc).appendChild(indicator);
|
||||
let indicator = DOM(<div highlight="FrameIndicator"/>, 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");
|
||||
|
||||
@@ -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,7 +1577,9 @@ var DOM = Class("DOM", {
|
||||
});
|
||||
|
||||
Object.keys(DOM.Event.types).forEach(function (event) {
|
||||
DOM.prototype[event.replace(/-(.)/g, function (m, m1) m1.toUpperCase())] =
|
||||
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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user