mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 08:54:12 +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:
@@ -217,10 +217,37 @@ function properties(obj, prototypes, debugger_) {
|
|||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
|
function props(obj) {
|
||||||
|
// Grr.
|
||||||
|
try {
|
||||||
|
return Object.getOwnPropertyNames(obj);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e.result === Cr.NS_ERROR_FAILURE) {
|
||||||
|
// This is being thrown for PDF.js content windows,
|
||||||
|
// currently.
|
||||||
|
let filter = function filter(prop) {
|
||||||
|
try {
|
||||||
|
return k in obj;
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return array.uniq([k for (k in obj)].concat(
|
||||||
|
Object.getOwnPropertyNames(
|
||||||
|
XPCNativeWrapper.unwrap(obj))
|
||||||
|
.filter(filter)))
|
||||||
|
}
|
||||||
|
else if (!e.stack) {
|
||||||
|
throw Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (; obj; obj = prototypes && prototype(obj)) {
|
for (; obj; obj = prototypes && prototype(obj)) {
|
||||||
try {
|
try {
|
||||||
if (sandbox.Object.getOwnPropertyNames || !debugger_ || !services.debugger.isOn)
|
if (!debugger_ || !services.debugger.isOn)
|
||||||
var iter = (v for each (v in Object.getOwnPropertyNames(obj)));
|
var iter = (v for each (v in props(obj)));
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
if (!iter)
|
if (!iter)
|
||||||
|
|||||||
@@ -787,8 +787,26 @@ var Buffer = Module("Buffer", {
|
|||||||
var sel = this.focusedFrame.getSelection();
|
var sel = this.focusedFrame.getSelection();
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
if (!elem && sel && sel.rangeCount)
|
if (!elem && sel && sel.rangeCount)
|
||||||
elem = sel.getRangeAt(0).startContainer;
|
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)
|
if (elem)
|
||||||
elem = find(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)),
|
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)
|
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")
|
PageInfo: Struct("PageInfo", "name", "title", "action")
|
||||||
.localize("title"),
|
.localize("title"),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user