1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-27 16:35:46 +01:00

Fix hint generation after closing a window.

This commit is contained in:
Kris Maglione
2011-03-06 19:04:25 -05:00
parent b9ab68edb9
commit 7bf3f40ab0
3 changed files with 40 additions and 41 deletions

View File

@@ -405,6 +405,42 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return stack.top;
},
compileMatcher: function compileMatcher(list) {
let xpath = [], css = [];
for (let elem in values(list))
if (/^xpath:/.test(elem))
xpath.push(elem.substr(6));
else
css.push(elem);
return update(
function matcher(node) {
if (matcher.xpath)
for (let elem in util.evaluateXPath(matcher.xpath, node))
yield elem;
if (matcher.css)
for (let [, elem] in iter(node.querySelectorAll(matcher.css)))
yield elem;
}, {
css: css.join(", "),
xpath: xpath.join(" | ")
});
},
validateMatcher: function validateMatcher(values) {
let evaluator = services.XPathEvaluator();
let node = util.xmlToDom(<div/>, document);
return this.testValues(values, function (value) {
if (/^xpath:/.test(value))
evaluator.createExpression(value.substr(6), util.evaluateXPath.resolver);
else
node.querySelector(value);
return true;
});
},
/**
* Returns an object representing a Node's computed CSS style.
*