Bug 1634556 Part 1: Make web extension sidebars listen to zoom enlarge/reduce events. r=mixedpuppy

These events are fired for all parent process documents by the code that
handles native mousewheel events. This change adds listeners to those events
and handles them similarly to how they are handled for browsers.

Differential Revision: https://phabricator.services.mozilla.com/D84767
This commit is contained in:
Brad Werth 2020-10-26 16:20:59 +00:00
parent d77c6c3700
commit 5b1f5cfb74
3 changed files with 34 additions and 1 deletions

View File

@ -70,6 +70,33 @@ function getBrowser(panel) {
stack.appendChild(browser);
browser.addEventListener(
"DoZoomEnlargeBy10",
() => {
let { ZoomManager } = browser.ownerGlobal;
let zoom = browser.fullZoom;
zoom += 0.1;
if (zoom > ZoomManager.MAX) {
zoom = ZoomManager.MAX;
}
browser.fullZoom = zoom;
},
true
);
browser.addEventListener(
"DoZoomReduceBy10",
() => {
let { ZoomManager } = browser.ownerGlobal;
let zoom = browser.fullZoom;
zoom -= 0.1;
if (zoom < ZoomManager.MIN) {
zoom = ZoomManager.MIN;
}
browser.fullZoom = zoom;
},
true
);
return readyPromise.then(() => {
ExtensionParent.apiManager.emit(
"extension-browser-inserted",

View File

@ -338,7 +338,7 @@ var PanelMultiView = class extends AssociatedToNode {
return (
doc.getElementById(id) ||
viewCacheTemplate.content.querySelector("#" + id)
viewCacheTemplate?.content.querySelector("#" + id)
);
}

View File

@ -133,6 +133,12 @@ async function updateZoomUI(aBrowser, aAnimate = false) {
win.document,
"appMenu-zoomReset-button"
);
// Exit early if UI elements aren't present.
if (!appMenuZoomReset) {
return;
}
let customizableZoomControls = win.document.getElementById("zoom-controls");
let customizableZoomReset = win.document.getElementById("zoom-reset-button");
let urlbarZoomButton = win.document.getElementById("urlbar-zoom-button");