mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-24 08:55:45 +01:00
Handle "gi" properly on frameset documents when no last focused element.
This commit is contained in:
@@ -348,8 +348,8 @@ const Buffer = Module("buffer", {
|
|||||||
* @property {Node} The last focused input field in the buffer. Used
|
* @property {Node} The last focused input field in the buffer. Used
|
||||||
* by the "gi" key binding.
|
* by the "gi" key binding.
|
||||||
*/
|
*/
|
||||||
get lastInputField() window.content.document.lastInputField || null,
|
get lastInputField() this.localStore.lastInputField && this.localStore.lastInputField.get() || null,
|
||||||
set lastInputField(value) { window.content.document.lastInputField = value; },
|
set lastInputField(value) { this.localStore.lastInputField = value && Cu.getWeakReference(value); },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {string} The current top-level document's URL.
|
* @property {string} The current top-level document's URL.
|
||||||
@@ -1609,24 +1609,30 @@ const Buffer = Module("buffer", {
|
|||||||
mappings.add(myModes, ["gi"],
|
mappings.add(myModes, ["gi"],
|
||||||
"Focus last used input field",
|
"Focus last used input field",
|
||||||
function (count) {
|
function (count) {
|
||||||
if (count < 1 && buffer.lastInputField)
|
let elem = buffer.lastInputField;
|
||||||
buffer.focusElement(buffer.lastInputField);
|
|
||||||
else {
|
if (count >= 1 || !elem || !Events.isContentNode(elem)) {
|
||||||
let xpath = ["input", "textarea[not(@disabled) and not(@readonly)]"];
|
let xpath = ["input", "textarea[not(@disabled) and not(@readonly)]"];
|
||||||
|
|
||||||
let elements = [m for (m in util.evaluateXPath(xpath))].filter(function (elem) {
|
let frames = array([buffer.focusedFrame].concat(
|
||||||
|
buffer.allFrames().filter(function (f) f != buffer.focusedFrame)));
|
||||||
|
|
||||||
|
let elements = frames.map(function (win) [m for (m in util.evaluateXPath(xpath, win.document))])
|
||||||
|
.flatten().filter(function (elem) {
|
||||||
|
|
||||||
if (elem.readOnly || elem instanceof HTMLInputElement && !set.has(Events.editableInputs, elem.type))
|
if (elem.readOnly || elem instanceof HTMLInputElement && !set.has(Events.editableInputs, elem.type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let computedStyle = util.computedStyle(elem);
|
let computedStyle = util.computedStyle(elem);
|
||||||
return computedStyle.visibility != "hidden" && computedStyle.display != "none" &&
|
return computedStyle.visibility != "hidden" && computedStyle.display != "none" &&
|
||||||
computedStyle.MozUserFocus != "ignore";
|
computedStyle.MozUserFocus != "ignore";
|
||||||
});
|
});
|
||||||
|
|
||||||
dactyl.assert(elements.length > 0);
|
dactyl.assert(elements.length > 0);
|
||||||
let elem = elements[Math.constrain(count, 1, elements.length) - 1];
|
elem = elements[Math.constrain(count, 1, elements.length) - 1];
|
||||||
buffer.focusElement(elem);
|
|
||||||
util.scrollIntoView(elem);
|
|
||||||
}
|
}
|
||||||
|
buffer.focusElement(elem);
|
||||||
|
util.scrollIntoView(elem);
|
||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
|
|||||||
@@ -962,7 +962,7 @@ const array = Class("array", Array, {
|
|||||||
},
|
},
|
||||||
array: ary,
|
array: ary,
|
||||||
toString: function () this.array.toString(),
|
toString: function () this.array.toString(),
|
||||||
concat: function () this.array.concat.apply(this.array, arguments),
|
concat: function () this.__noSuchMethod__("concat", Array.slice(arguments)),
|
||||||
filter: function () this.__noSuchMethod__("filter", Array.slice(arguments)),
|
filter: function () this.__noSuchMethod__("filter", Array.slice(arguments)),
|
||||||
map: function () this.__noSuchMethod__("map", Array.slice(arguments))
|
map: function () this.__noSuchMethod__("map", Array.slice(arguments))
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user