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

View File

@@ -1077,6 +1077,18 @@ var Hints = Module("hints", {
this.hintSession = HintSession(mode, opts); 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 () { translitTable: Class.memoize(function () {
const table = {}; const table = {};
[ [

View File

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