1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 04:27:59 +01:00

Add util.makeXPath for constructing XPath expressions.

--HG--
extra : transplant_source : G%A7_%1B%9B%7BN%9C%FF%14%A9g%BA%04%99%B3%8B%23%ED%F2
This commit is contained in:
Doug Kearns
2009-09-25 15:57:20 +10:00
parent 378fe9de1d
commit 4daa9ace53
3 changed files with 24 additions and 20 deletions

View File

@@ -336,24 +336,16 @@ function Buffer() //{{{
buffer.focusElement(buffer.lastInputField);
else
{
let elements = [];
let matches = buffer.evaluateXPath(
"//input[not(@type) or @type='text' or @type='password' or @type='file'] | //textarea[not(@disabled) and not(@readonly)] |" +
"//xhtml:input[not(@type) or @type='text' or @type='password' or @type='file'] | //xhtml:textarea[not(@disabled) and not(@readonly)]"
);
let xpath = util.makeXPath(["input[not(@type) or @type='text' or @type='password' or @type='file']",
"textarea[not(@disabled) and not(@readonly)]"]);
for (let match in matches)
{
let elements = [m for (m in buffer.evaluateXPath(xpath))].filter(function (match) {
let computedStyle = util.computedStyle(match);
if (computedStyle.visibility != "hidden" && computedStyle.display != "none")
elements.push(match);
}
return computedStyle.visibility != "hidden" && computedStyle.display != "none";
});
if (elements.length > 0)
{
count = util.Math.constrain(count, 1, elements.length);
buffer.focusElement(elements[count - 1]);
}
buffer.focusElement(elements[util.Math.constrain(count, 1, elements.length) - 1]);
else
liberator.beep();
}