1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-09 02:25:47 +01:00

Try to find a scrollable element rather than requiring a click when one has not been selected. Closes issue #907.

This commit is contained in:
Kris Maglione
2013-04-21 21:14:26 -07:00
parent 84dc52345c
commit b375af9357
2 changed files with 53 additions and 2 deletions

View File

@@ -787,8 +787,26 @@ var Buffer = Module("Buffer", {
var sel = this.focusedFrame.getSelection();
}
catch (e) {}
if (!elem && sel && sel.rangeCount)
elem = sel.getRangeAt(0).startContainer;
if (!elem) {
let area = -1;
for (let e in DOM(Buffer.SCROLLABLE_SEARCH_SELECTOR,
this.focusedFrame.document)) {
if (Buffer.isScrollable(e, dir, horizontal)) {
let r = DOM(e).rect;
let a = r.width * r.height;
if (a > area) {
area = a;
elem = e;
}
}
}
if (elem)
util.trapErrors("focus", elem);
}
if (elem)
elem = find(elem);
@@ -1255,6 +1273,12 @@ var Buffer = Module("Buffer", {
scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) this.win.scrollTo(x, y)),
textZoom: deprecated("buffer.zoomValue/buffer.fullZoom", function textZoom() this.contentViewer.markupDocumentViewer.textZoom * 100)
}, {
/**
* The pattern used to search for a scrollable element when we have
* no starting point.
*/
SCROLLABLE_SEARCH_SELECTOR: "div",
PageInfo: Struct("PageInfo", "name", "title", "action")
.localize("title"),