mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 00:37:58 +01:00
Text zoom level rememberization magic.
This commit is contained in:
@@ -148,6 +148,8 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
|
||||
let win = webProgress.DOMWindow;
|
||||
if (win && uri) {
|
||||
Buffer(win).updateZoom();
|
||||
|
||||
let oldURI = overlay.getData(win.document)["uri"];
|
||||
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||
|
||||
@@ -1363,7 +1363,8 @@ var CommandLine = Module("commandline", {
|
||||
*/
|
||||
preview: function preview() {
|
||||
this.previewClear();
|
||||
if (this.wildIndex < 0 || this.suffix || !this.activeContexts.length || this.waiting)
|
||||
if (this.wildIndex < 0 || this.caret < this.input.value.length
|
||||
|| !this.activeContexts.length || this.waiting)
|
||||
return;
|
||||
|
||||
let substring = "";
|
||||
|
||||
@@ -13,8 +13,9 @@ defineModule("buffer", {
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("finder", ["RangeFind"]);
|
||||
this.lazyRequire("template", ["template"]);
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
this.lazyRequire("storage", ["storage"]);
|
||||
this.lazyRequire("template", ["template"]);
|
||||
|
||||
/**
|
||||
* A class to manage the primary web content buffer. The name comes
|
||||
@@ -1115,13 +1116,32 @@ var Buffer = Module("Buffer", {
|
||||
return dactyl.echoerr(_("zoom.illegal"));
|
||||
}
|
||||
|
||||
if (fullZoom && services.has("contentPrefs"))
|
||||
services.contentPrefs.setPref(this.uri, "browser.content.full-zoom",
|
||||
value);
|
||||
if (services.has("contentPrefs") && !storage.privateMode
|
||||
&& prefs.get("browser.zoom.siteSpecific")) {
|
||||
services.contentPrefs[value != 1 ? "setPref" : "removePref"]
|
||||
(this.uri, "browser.content.full-zoom", value);
|
||||
services.contentPrefs[value != 1 ? "setPref" : "removePref"]
|
||||
(this.uri, "dactyl.content.full-zoom", fullZoom);
|
||||
}
|
||||
|
||||
statusline.updateZoomLevel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the zoom level of this buffer from a content preference.
|
||||
*/
|
||||
updateZoom: util.wrapCallback(function updateZoom() {
|
||||
let self = this;
|
||||
let uri = this.uri;
|
||||
|
||||
if (services.has("contentPrefs") && prefs.get("browser.zoom.siteSpecific"))
|
||||
services.contentPrefs.getPref(uri, "dactyl.content.full-zoom", function (val) {
|
||||
if (uri.equals(self.uri) && val != prefs.get("browser.zoom.full"))
|
||||
[self.contentViewer.textZoom, self.contentViewer.fullZoom] =
|
||||
[self.contentViewer.fullZoom, self.contentViewer.textZoom];
|
||||
});
|
||||
}),
|
||||
|
||||
/**
|
||||
* Adjusts the page zoom of the current buffer relative to the
|
||||
* current zoom level.
|
||||
@@ -1142,7 +1162,7 @@ var Buffer = Module("Buffer", {
|
||||
fullZoom = ZoomManager.useFullZoom;
|
||||
|
||||
let values = ZoomManager.zoomValues;
|
||||
let cur = values.indexOf(ZoomManager.snap(ZoomManager.zoom));
|
||||
let cur = values.indexOf(ZoomManager.snap(this.zoom));
|
||||
let i = Math.constrain(cur + steps, 0, values.length - 1);
|
||||
|
||||
util.assert(i != cur || fullZoom != ZoomManager.useFullZoom);
|
||||
|
||||
Reference in New Issue
Block a user