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;
|
let win = webProgress.DOMWindow;
|
||||||
if (win && uri) {
|
if (win && uri) {
|
||||||
|
Buffer(win).updateZoom();
|
||||||
|
|
||||||
let oldURI = overlay.getData(win.document)["uri"];
|
let oldURI = overlay.getData(win.document)["uri"];
|
||||||
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
||||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||||
|
|||||||
@@ -1363,7 +1363,8 @@ var CommandLine = Module("commandline", {
|
|||||||
*/
|
*/
|
||||||
preview: function preview() {
|
preview: function preview() {
|
||||||
this.previewClear();
|
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;
|
return;
|
||||||
|
|
||||||
let substring = "";
|
let substring = "";
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ defineModule("buffer", {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.lazyRequire("finder", ["RangeFind"]);
|
this.lazyRequire("finder", ["RangeFind"]);
|
||||||
this.lazyRequire("template", ["template"]);
|
|
||||||
this.lazyRequire("overlay", ["overlay"]);
|
this.lazyRequire("overlay", ["overlay"]);
|
||||||
|
this.lazyRequire("storage", ["storage"]);
|
||||||
|
this.lazyRequire("template", ["template"]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to manage the primary web content buffer. The name comes
|
* 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"));
|
return dactyl.echoerr(_("zoom.illegal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullZoom && services.has("contentPrefs"))
|
if (services.has("contentPrefs") && !storage.privateMode
|
||||||
services.contentPrefs.setPref(this.uri, "browser.content.full-zoom",
|
&& prefs.get("browser.zoom.siteSpecific")) {
|
||||||
value);
|
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();
|
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
|
* Adjusts the page zoom of the current buffer relative to the
|
||||||
* current zoom level.
|
* current zoom level.
|
||||||
@@ -1142,7 +1162,7 @@ var Buffer = Module("Buffer", {
|
|||||||
fullZoom = ZoomManager.useFullZoom;
|
fullZoom = ZoomManager.useFullZoom;
|
||||||
|
|
||||||
let values = ZoomManager.zoomValues;
|
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);
|
let i = Math.constrain(cur + steps, 0, values.length - 1);
|
||||||
|
|
||||||
util.assert(i != cur || fullZoom != ZoomManager.useFullZoom);
|
util.assert(i != cur || fullZoom != ZoomManager.useFullZoom);
|
||||||
|
|||||||
Reference in New Issue
Block a user