diff --git a/common/content/buffer.js b/common/content/buffer.js index 44ff76f4..80700aac 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -83,9 +83,9 @@ function Buffer() //{{{ function findScrollable(dir, horiz) { - let pos = "scrollTop", size = "clientHeight", max = "scrollHeight"; + let pos = "scrollTop", size = "offsetHeight", max = "scrollHeight"; if (horiz) - pos = "scrollLeft", size = "clientWidth", max = "scrollWidth"; + pos = "scrollLeft", size = "offsetWidth", max = "scrollWidth"; function find(elem) { @@ -106,36 +106,36 @@ function Buffer() //{{{ return elem; } - function scrollVert(elem, type, num) + function scrollVertical(elem, increment, number) { - elem = elem || findScrollable(num, false); + elem = elem || findScrollable(number, false); let fontSize = parseInt(util.computedStyle(elem).fontSize); let increment; - if (type == "lines") + if (increment == "lines") increment = fontSize; - else if (type == "pages") + else if (increment == "pages") increment = elem.clientHeight - fontSize; else throw Error() - elem.scrollTop += num * increment; + elem.scrollTop += number * increment; } - function scrollHoriz(elem, type, num) + function scrollHorizontal(elem, increment, number) { - elem = elem || findScrollable(num, true); + elem = elem || findScrollable(number, true); let fontSize = parseInt(util.computedStyle(elem).fontSize); let increment; - if (type == "columns") + if (increment == "columns") increment = fontSize; // Good enough, I suppose. - else if (type == "pages") + else if (increment == "pages") increment = elem.clientWidth - fontSize; else throw Error() - elem.scrollLeft += num * increment; + elem.scrollLeft += number * increment; } - function scrollElemToPercentiles(elem, horizontal, vertical) + function scrollElemToPercent(elem, horizontal, vertical) { elem = elem || findScrollable(); marks.add("'", true); @@ -147,7 +147,7 @@ function Buffer() //{{{ elem.scrollTop = (elem.scrollHeight - elem.clientHeight) * (vertical / 100); } - function scrollToPercentiles(horizontal, vertical) + function scrollToPercent(horizontal, vertical) { let win = findScrollableWindow(); let h, v; @@ -293,12 +293,12 @@ function Buffer() //{{{ mappings.add(myModes, ["gg", ""], "Go to the top of the document", - function (count) { buffer.scrollToPercentiles(buffer.scrollXPercent, Math.max(count, 0)); }, + function (count) { buffer.scrollToPercent(buffer.scrollXPercent, Math.max(count, 0)); }, { count: true }); mappings.add(myModes, ["G", ""], "Go to the end of the document", - function (count) { buffer.scrollToPercentiles(buffer.scrollXPercent, count >= 0 ? count : 100); }, + function (count) { buffer.scrollToPercent(buffer.scrollXPercent, count >= 0 ? count : 100); }, { count: true }); mappings.add(myModes, ["%"], @@ -306,7 +306,7 @@ function Buffer() //{{{ function (count) { if (count > 0 && count <= 100) - buffer.scrollToPercentiles(buffer.scrollXPercent, count); + buffer.scrollToPercent(buffer.scrollXPercent, count); else liberator.beep(); }, @@ -1324,7 +1324,7 @@ function Buffer() //{{{ */ scrollBottom: function () { - scrollToPercentiles(null, 100); + scrollToPercent(null, 100); }, /** @@ -1335,7 +1335,7 @@ function Buffer() //{{{ */ scrollColumns: function (cols) { - scrollHoriz(null, "columns", cols); + scrollHorizontal(null, "columns", cols); }, /** @@ -1343,7 +1343,7 @@ function Buffer() //{{{ */ scrollEnd: function () { - scrollToPercentiles(100, null); + scrollToPercent(100, null); }, /** @@ -1354,7 +1354,7 @@ function Buffer() //{{{ */ scrollLines: function (lines) { - scrollVert(null, "lines", lines); + scrollVertical(null, "lines", lines); }, /** @@ -1365,7 +1365,7 @@ function Buffer() //{{{ */ scrollPages: function (pages) { - scrollVert(null, "pages", pages); + scrollVertical(null, "pages", pages); }, /** @@ -1396,9 +1396,9 @@ function Buffer() //{{{ * @param {number} x The horizontal page percentile. * @param {number} y The vertical page percentile. */ - scrollToPercentiles: function (x, y) + scrollToPercent: function (x, y) { - scrollToPercentiles(x, y); + scrollToPercent(x, y); }, /** @@ -1418,7 +1418,7 @@ function Buffer() //{{{ */ scrollStart: function () { - scrollToPercentiles(0, null); + scrollToPercent(0, null); }, /** @@ -1426,7 +1426,7 @@ function Buffer() //{{{ */ scrollTop: function () { - scrollToPercentiles(null, 0); + scrollToPercent(null, 0); }, // TODO: allow callback for filtering out unwanted frames? User defined? @@ -1661,7 +1661,7 @@ function Marks() //{{{ { if (win && win.location.href == mark.location) { - buffer.scrollToPercentiles(mark.position.x * 100, mark.position.y * 100); + buffer.scrollToPercent(mark.position.x * 100, mark.position.y * 100); pendingJumps.splice(i, 1); return; } @@ -1970,7 +1970,7 @@ function Marks() //{{{ return; } liberator.log("Jumping to URL mark: " + markToString(mark, slice), 5); - buffer.scrollToPercentiles(slice.position.x * 100, slice.position.y * 100); + buffer.scrollToPercent(slice.position.x * 100, slice.position.y * 100); ok = true; } } @@ -1985,7 +1985,7 @@ function Marks() //{{{ if (win.location.href == lmark.location) { liberator.log("Jumping to local mark: " + markToString(mark, lmark), 5); - buffer.scrollToPercentiles(lmark.position.x * 100, lmark.position.y * 100); + buffer.scrollToPercent(lmark.position.x * 100, lmark.position.y * 100); ok = true; break; } diff --git a/common/content/liberator.js b/common/content/liberator.js index f59f228e..10b6afeb 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -1075,10 +1075,13 @@ const liberator = (function () //{{{ * * @param {string|Object} msg The message to print. */ - dump: function (msg) + dump: function () { - if (typeof msg == "object") - msg = util.objectToString(msg); + let msg = Array.map(arguments, function (msg) { + if (typeof msg == "object") + msg = util.objectToString(msg); + return msg; + }).join(", "); msg = String.replace(msg, /\n?$/, "\n"); window.dump(msg.replace(/^./gm, ("config" in modules && config.name.toLowerCase()) + ": $&")); },