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

Fix [[/]].

This commit is contained in:
Kris Maglione
2011-02-18 14:43:39 -05:00
parent 8fc61fb863
commit be5c6a4525
3 changed files with 46 additions and 45 deletions

View File

@@ -421,14 +421,14 @@ var Buffer = Module("buffer", {
* @param {[RegExp]} regexps The regular expressions to search for.
* @param {number} count The nth matching link to follow.
* @param {bool} follow Whether to follow the matching link.
* @param {string} path The XPath to use for the search. @optional
* @param {string} path The CSS to use for the search. @optional
*/
followDocumentRelationship: deprecated("buffer.findLink",
function followDocumentRelationship(rel) {
this.findLink(rel, options[rel + "pattern"], 0, true);
}),
findLink: function (rel, regexps, count, follow, path) {
path = path || options.get("hinttags").defaultValue;
let selector = path || options.get("hinttags").stringDefaultValue;
function followFrame(frame) {
function iter(elems) {
@@ -447,10 +447,10 @@ var Buffer = Module("buffer", {
for (let elem in iter(elems))
yield elem;
let res = util.evaluateXPath(path, frame.document);
let res = frame.document.querySelectorAll(selector);
for (let regexp in values(regexps)) {
for (let i in util.range(res.snapshotLength, 0, -1)) {
let elem = res.snapshotItem(i);
for (let i in util.range(res.length, 0, -1)) {
let elem = res[i];
if (regexp.test(elem.textContent) === regexp.result || regexp.test(elem.title) === regexp.result ||
Array.some(elem.childNodes, function (child) regexp.test(child.alt) === regexp.result))
yield elem;

View File

@@ -670,41 +670,6 @@ var HintSession = Class("HintSession", CommandMode, {
},
});
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(" | ")
});
}
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;
});
}
var Hints = Module("hints", {
init: function init() {
this.resizeTimer = Timer(100, 500, function () {
@@ -1044,6 +1009,42 @@ var Hints = Module("hints", {
this.hintSession = HintSession(mode, opts);
}
}, {
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;
});
},
translitTable: Class.memoize(function () {
const table = {};
[
@@ -1214,10 +1215,10 @@ var Hints = Module("hints", {
res ? res.matcher : default_,
setter: function (vals) {
for (let value in values(vals))
value.matcher = compileMatcher(Option.splitList(value.result));
value.matcher = Hints.compileMatcher(Option.splitList(value.result));
return vals;
},
validator: validateMatcher
validator: Hints.validateMatcher
});
options.add(["hinttags", "ht"],
@@ -1227,10 +1228,10 @@ var Hints = Module("hints", {
"[tabindex],[role=link],[role=button]",
{
setter: function (values) {
this.matcher = compileMatcher(values);
this.matcher = Hints.compileMatcher(values);
return values;
},
validator: validateMatcher
validator: Hints.validateMatcher
});
options.add(["hintkeys", "hk"],

View File

@@ -254,7 +254,7 @@ var Styles = Module("Styles", {
services["dactyl:"].providers["style"] = function styleProvider(uri) {
let id = /^\/(\d*)/.exec(uri.path)[1];
if (set.has(styles.allSheets, id))
return ["text/css", styles.allSheets[id].fullCSS];
return ["text/css", unescape(encodeURI(styles.allSheets[id].fullCSS))];
return null;
};
},