mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-23 16:15:46 +01:00
Fix sanitizer.
--HG-- branch : testing
This commit is contained in:
@@ -1490,8 +1490,8 @@ const Buffer = Module("buffer", {
|
||||
|
||||
liberator.assert(elements.length > 0);
|
||||
let elem = elements[util.Math.constrain(count, 1, elements.length) - 1];
|
||||
elem.scrollIntoView();
|
||||
buffer.focusElement(elem);
|
||||
util.scrollIntoView(elem);
|
||||
}
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
@@ -1034,7 +1034,7 @@ const CommandLine = Module("commandline", {
|
||||
sanitize: function (timespan) {
|
||||
let range = [0, Number.MAX_VALUE];
|
||||
if (liberator.has("sanitizer") && (timespan || options["sanitizetimespan"]))
|
||||
range = sanitizer.getClearRange(timespan || options["sanitizetimespan"]);
|
||||
range = Sanitizer.getClearRange(timespan || options["sanitizetimespan"]);
|
||||
|
||||
const self = this;
|
||||
this.store.mutate("filter", function (item) {
|
||||
|
||||
@@ -19,6 +19,7 @@ const Sanitizer = Module("sanitizer", {
|
||||
init: function () {
|
||||
const self = this;
|
||||
liberator.loadScript("chrome://browser/content/sanitize.js", Sanitizer);
|
||||
Sanitizer.getClearRange = Sanitizer.Sanitizer.getClearRange;
|
||||
this.__proto__.__proto__ = new Sanitizer.Sanitizer; // Good enough.
|
||||
|
||||
// TODO: remove this version test
|
||||
|
||||
@@ -673,6 +673,20 @@ const Util = Module("util", {
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Scrolls an element into view if and only if it's not already
|
||||
* fully visible.
|
||||
*
|
||||
* @param {Node} elem The element to make visible.
|
||||
*/
|
||||
scrollIntoView: function scrollIntoView(elem) {
|
||||
let win = elem.ownerDocument.defaultView;
|
||||
let rect = elem.getBoundingClientRect();
|
||||
if (!(rect && rect.top < win.innerHeight && rect.bottom >= 0 && rect.left < win.innerWidth && rect.right >= 0))
|
||||
elem.scrollIntoView();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of URLs parsed from <b>str</b>.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user