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

Muck with buffer.findLink against my better judgement. Closes issue #607. Closes issue #200.

This commit is contained in:
Kris Maglione
2011-08-06 08:04:09 -04:00
parent b1042eb74c
commit 99f3840b72
3 changed files with 26 additions and 14 deletions

View File

@@ -498,10 +498,6 @@ var Buffer = Module("buffer", {
* @param {bool} follow Whether to follow the matching link.
* @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 findLink(rel, regexps, count, follow, path) {
let selector = path || options.get("hinttags").stringDefaultValue;
@@ -520,15 +516,16 @@ var Buffer = Module("buffer", {
for (let elem in iter(elems))
yield elem;
let res = frame.document.querySelectorAll(selector);
for (let regexp in values(regexps)) {
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;
}
}
function a(regexp, elem) regexp.test(elem.textContent) === regexp.result ||
Array.some(elem.childNodes, function (child) regexp.test(child.alt) === regexp.result);
function b(regexp, elem) regexp.test(elem.title);
let res = Array.filter(frame.document.querySelectorAll(selector), Hints.isVisible);
for (let test in values([a, b]))
for (let regexp in values(regexps))
for (let i in util.range(res.length, 0, -1))
if (test(regexp, res[i]))
yield res[i];
}
for (let frame in values(this.allFrames(null, true)))
@@ -542,6 +539,10 @@ var Buffer = Module("buffer", {
if (follow)
dactyl.beep();
},
followDocumentRelationship: deprecated("buffer.findLink",
function followDocumentRelationship(rel) {
this.findLink(rel, options[rel + "pattern"], 0, true);
}),
/**
* Fakes a click on a link.

View File

@@ -1077,6 +1077,18 @@ var Hints = Module("hints", {
this.hintSession = HintSession(mode, opts);
}
}, {
isVisible: function isVisible(elem) {
let rect = elem.getBoundingClientRect();
if (!rect.width || !rect.height)
if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && util.computedStyle(elem).float != "none" && isVisible(elem)))
return false;
let computedStyle = util.computedStyle(elem, null);
if (computedStyle.visibility != "visible" || computedStyle.display == "none")
return false;
return true;
},
translitTable: Class.memoize(function () {
const table = {};
[

View File

@@ -16,7 +16,6 @@ FEATURES:
locations in the history list).
9 clean up error message codes and document
9 option groups, including buffer-local and site-specific
9 proper motion maps
8 wherever possible: get rid of dialogs and ask console-like dialog questions
or write error prompts directly on the webpage or with :echo()
8 add search capability to MOW