diff --git a/binary/src/subscriptLoader.cpp b/binary/src/subscriptLoader.cpp index 5b3aa483..82769cba 100644 --- a/binary/src/subscriptLoader.cpp +++ b/binary/src/subscriptLoader.cpp @@ -523,7 +523,7 @@ dactylUtils::LoadSubScript (const PRUnichar * aURL nsCAutoString cachePath; cachePath.Append("jssubloader/"); - cachePath.Append(version); + cachePath.AppendInt(version); if (charset) { cachePath.Append("/"); cachePath.Append(NS_ConvertUTF16toUTF8( diff --git a/common/content/buffer.js b/common/content/buffer.js index fab4283e..176c6053 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1316,16 +1316,19 @@ var Buffer = Module("buffer", { * * @param {Element} elem The element to scroll. * @param {number|null} left The left absolute pixel offset. If - * null, to not alter the horizontal scroll offset. + * null, to not alter the horizontal scroll offset. * @param {number|null} top The top absolute pixel offset. If - * null, to not alter the vertical scroll offset. + * null, to not alter the vertical scroll offset. * @param {string} reason The reason for the scroll event. See - * {@link marks.push}. @optional + * {@link marks.push}. @optional */ scrollTo: function scrollTo(elem, left, top, reason) { if (~[elem, elem.document, elem.ownerDocument].indexOf(buffer.focusedFrame.document)) marks.push(reason); + if (options["scrollsteps"] > 1) + return this.smoothScrollTo(elem, left, top); + elem = Buffer.Scrollable(elem); if (left != null) elem.scrollLeft = left; @@ -1338,6 +1341,39 @@ var Buffer = Module("buffer", { .redraw(); }, + /** + * Like scrollTo, but scrolls more smoothly and does not update + * marks. + */ + smoothScrollTo: function smoothScrollTo(elem, x, y) { + let time = options["scrolltime"]; + let steps = options["scrollsteps"]; + + let data = elem; + elem = Buffer.Scrollable(elem); + + if (data.dactylScrollTimer) + data.dactylScrollTimer.cancel(); + + x = data.dactylScrollDestX = Math.min(x, elem.scrollWidth - elem.clientWidth); + y = data.dactylScrollDestY = Math.min(y, elem.scrollHeight - elem.clientHeight); + let [startX, startY] = [elem.scrollLeft, elem.scrollTop]; + let n = 0; + (function next() { + if (n++ === steps) { + elem.scrollLeft = x; + elem.scrollTop = y; + delete data.dactylScrollDestX; + delete data.dactylScrollDestY; + } + else { + elem.scrollLeft = startX + (x - startX) / steps * n; + elem.scrollTop = startY + (y - startY) / steps * n; + data.dactylScrollTimer = util.timeout(next, time / steps); + } + }).call(this); + }, + /** * Scrolls the currently given element horizontally. * @@ -1353,6 +1389,7 @@ var Buffer = Module("buffer", { scrollHorizontal: function scrollHorizontal(elem, unit, number) { let fontSize = parseInt(DOM(elem).style.fontSize); + let data = elem; elem = Buffer.Scrollable(elem); let increment; if (unit == "columns") @@ -1364,8 +1401,8 @@ var Buffer = Module("buffer", { dactyl.assert(number < 0 ? elem.scrollLeft > 0 : elem.scrollLeft < elem.scrollWidth - elem.clientWidth); - let left = elem.dactylScrollDestX !== undefined ? elem.dactylScrollDestX : elem.scrollLeft; - elem.dactylScrollDestX = undefined; + let left = data.dactylScrollDestX !== undefined ? data.dactylScrollDestX : elem.scrollLeft; + data.dactylScrollDestX = undefined; Buffer.scrollTo(elem, left + number * increment, null, "h-" + unit); }, @@ -1385,6 +1422,7 @@ var Buffer = Module("buffer", { scrollVertical: function scrollVertical(elem, unit, number) { let fontSize = parseInt(DOM(elem).style.lineHeight); + let data = elem; elem = Buffer.Scrollable(elem); let increment; if (unit == "lines") @@ -1396,8 +1434,8 @@ var Buffer = Module("buffer", { dactyl.assert(number < 0 ? elem.scrollTop > 0 : elem.scrollTop < elem.scrollHeight - elem.clientHeight); - let top = elem.dactylScrollDestY !== undefined ? elem.dactylScrollDestY : elem.scrollTop; - elem.dactylScrollDestY = undefined; + let top = data.dactylScrollDestY !== undefined ? data.dactylScrollDestY : elem.scrollTop; + data.dactylScrollDestY = undefined; Buffer.scrollTo(elem, null, top + number * increment, "v-" + unit); }, @@ -2234,6 +2272,28 @@ var Buffer = Module("buffer", { } }); + options.add(["scrolltime", "st"], + "The time, in milliseconds, in which to smooth scroll to a new position", + "number", 100); + + options.add(["scrollsteps", "ss"], + "The number of steps in which to smooth scroll to a new position", + "number", 5, + { + PREF: "general.smoothScroll", + + initValue: function () {}, + + getter: function getter(value) !prefs.get(this.PREF) ? 1 : value, + + setter: function setter(value) { + prefs.set(this.PREF, value > 1); + return value > 1 ? value : this.globalValue; + }, + + validator: function (value) value > 0 + }); + options.add(["usermode", "um"], "Show current website without styling defined by the author", "boolean", false, diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index 9fdb0554..f1a9975a 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -1381,6 +1381,28 @@ + + 'ss' 'scrollsteps' + 'scrollsteps' 'ss' + &option.scrollsteps.type; + &option.scrollsteps.default; + +

+ The number of steps in which to smooth scroll to a new position. If + set to 1, smooth scrolling is not used. +

+
+
+ + 'st' 'scrolltime' + 'scrolltime' 'st' + &option.scrolltime.type; + &option.scrolltime.default; + +

The time, in milliseconds, in which to smooth scroll to a new position.

+
+
+ 'spl' 'spelllang' 'spelllang' 'spl' diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 6bfa0ccd..d86a1d73 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -329,7 +329,11 @@ var File = Class("File", { /** * @property {nsIFileURL} Returns the nsIFileURL object for this file. */ - get URI() services.io.newFileURI(this).QueryInterface(Ci.nsIFileURL), + URI: Class.Memoize(function () { + let uri = services.io.newFileURI(this).QueryInterface(Ci.nsIFileURL); + uri.QueryInterface(Ci.nsIMutable).mutable = false; + return uri; + }), /** * Iterates over the objects in this directory. diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 3f6ecbe9..dc7697aa 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -73,6 +73,7 @@ • Improved [macro-string] support, including automatic elision of optional elements, and array subscripts. [b4][b7] • Add -pentadactyl-remote command-line option. [b8] + • Moved the smooth-scroll plugin to the core. [b8] • Improvements to marks: - Marks are now stored as line and column ordinals rather than percentages. [b8] - Marks now store the marked element and ensure its visibility when followed. [b8] @@ -218,6 +219,7 @@ - Added 'passunknown' option. [b7] - Changed 'urlseparator' default value to "|". [b3] - Added "errorconsole", "passwords", and "venkman" dialogs to :dialog. [b2][b8] + - Added 'scrollsteps' and 'scrolltime' options. [b8] - Added 'spelllang' option. [b8] - Make 'showmode' a [stringlist] option. [b7] - Added 'wildanchor' option. [b2]