1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 03:24:11 +01:00

Make 'strictfocus' a currently undocumented sitemap option.

This commit is contained in:
Kris Maglione
2011-03-12 14:36:07 -05:00
parent 9ba3635bc1
commit b7822c5cb2
5 changed files with 41 additions and 10 deletions

View File

@@ -352,8 +352,16 @@ var Buffer = Module("buffer", {
focusAllowed: function focusAllowed(elem) {
if (elem instanceof Window && !Editor.getEditor(elem))
return true;
let doc = elem.ownerDocument || elem.document || elem;
return !options["strictfocus"] || doc.dactylFocusAllowed;
switch (options.get("strictfocus").getKey(doc.documentURI, "moderate")) {
case "despotic":
return elem.dactylFocusAllowed;
case "moderate":
return doc.dactylFocusAllowed;
default:
return true;
}
},
/**
@@ -365,6 +373,7 @@ var Buffer = Module("buffer", {
*/
focusElement: function focusElement(elem) {
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
elem.dactylFocusAllowed = true;
win.document.dactylFocusAllowed = true;
if (isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]))
@@ -1655,7 +1664,7 @@ var Buffer = Module("buffer", {
let elem = buffer.lastInputField;
if (args.count >= 1 || !elem || !events.isContentNode(elem)) {
let xpath = ["frame", "iframe", "input", "textarea[not(@disabled) and not(@readonly)]"];
let xpath = ["frame", "iframe", "input", "xul:textbox", "textarea[not(@disabled) and not(@readonly)]"];
let frames = buffer.allFrames(null, true);
@@ -1670,7 +1679,8 @@ var Buffer = Module("buffer", {
let computedStyle = util.computedStyle(elem);
let rect = elem.getBoundingClientRect();
return computedStyle.visibility != "hidden" && computedStyle.display != "none" &&
computedStyle.MozUserFocus != "ignore" && rect.width && rect.height;
(elem instanceof Ci.nsIDOMXULTextBoxElement || computedStyle.MozUserFocus != "ignore") &&
rect.width && rect.height;
});
dactyl.assert(elements.length > 0);

View File

@@ -654,7 +654,10 @@ var Editor = Module("editor", {
});
mappings.add([modes.INPUT],
["<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>"],
["<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>",
"<Home>", "<End>", "<PageUp>", "<PageDown>",
"<C-BS>", "<C-Del>", "<C-Left>", "<C-Right>", "<C-Up>", "<C-Down>",
"<C-Home>", "<C-End>", "<C-PageUp>", "<C-PageDown>"],
"Handled by " + config.host,
function () Events.PASS);

View File

@@ -1135,14 +1135,19 @@ var Events = Module("events", {
let win = (elem.ownerDocument || elem).defaultView || elem;
if (events.isContentNode(elem) && !buffer.focusAllowed(elem)
&& !(services.focus.getLastFocusMethod(win) & 0x7000)
if (!(services.focus.getLastFocusMethod(win) & 0x7000)
&& events.isContentNode(elem)
&& !buffer.focusAllowed(elem)
&& isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement, Window])) {
if (elem.frameElement)
dactyl.focusContent(true);
else if (!(elem instanceof Window) || Editor.getEditor(elem))
dactyl.focus(window);
}
if (elem instanceof Element)
elem.dactylFocusAllowed = undefined;
},
/*
@@ -1329,8 +1334,11 @@ var Events = Module("events", {
let elem = event.target;
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
for (; win; win = win != win.parent && win.parent)
for (; win; win = win != win.parent && win.parent) {
for (; elem instanceof Element; elem = elem.parentNode)
elem.dactylFocusAllowed = true;
win.document.dactylFocusAllowed = true;
}
},
popupshown: function onPopupShown(event) {
@@ -1650,7 +1658,14 @@ var Events = Module("events", {
options.add(["strictfocus", "sf"],
"Prevent scripts from focusing input elements without user intervention",
"boolean", true);
"sitemap", "*:moderate",
{
values: {
despotic: "Only allow focus changes when explicitly requested by the user",
moderate: "Allow focus changes after user-initiated focus change",
"laisses-faire": "Always allow focus changes"
}
});
options.add(["timeout", "tmo"],
"Whether to execute a shorter key command after a timeout when a longer command exists",