Bug 1791640 Comment 2 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

> devtools toolbox zoom handling conflicts with the default one from firefox?

I think that's it. If you zoom from the "View > Zoom" menu, then the zoom will persist when changing tabs. 
The devtools zoom is handled at https://searchfox.org/mozilla-central/source/devtools/client/shared/zoom-keys.js 
We basically override all the default zoom shortcuts and perform the following:

```javascript
  const zoomIn = function(event) {
    setZoom(zoomValue + 0.1);
    event.preventDefault();
  };

  const zoomOut = function(event) {
    setZoom(zoomValue - 0.1);
    event.preventDefault();
  };

  const zoomReset = function(event) {
    setZoom(1);
    event.preventDefault();
  };

  const setZoom = function(newValue) {
    // cap zoom value
    zoomValue = Math.max(newValue, MIN_ZOOM);
    zoomValue = Math.min(zoomValue, MAX_ZOOM);
    // Prevent the floating-point error. (e.g. 1.1 + 0.1 = 1.2000000000000002)
    zoomValue = Math.round(zoomValue * 10) / 10;

    bc.fullZoom = zoomValue;

    Services.prefs.setCharPref(ZOOM_PREF, zoomValue);
  };
```
Considering that we call `event.preventDefault();`, maybe we present the browser to correctly persist the zoom somewhere.
We might just disable those shortcuts when the toolbox is in a "page" host.
> devtools toolbox zoom handling conflicts with the default one from firefox?

I think that's it. If you zoom from the "View > Zoom" menu, then the zoom will persist when changing tabs. 
The devtools zoom is handled at https://searchfox.org/mozilla-central/source/devtools/client/shared/zoom-keys.js 
We basically override all the default zoom shortcuts and perform the following:

```javascript
  const zoomIn = function(event) {
    setZoom(zoomValue + 0.1);
    event.preventDefault();
  };

  const zoomOut = function(event) {
    setZoom(zoomValue - 0.1);
    event.preventDefault();
  };

  const zoomReset = function(event) {
    setZoom(1);
    event.preventDefault();
  };

  const setZoom = function(newValue) {
    // cap zoom value
    zoomValue = Math.max(newValue, MIN_ZOOM);
    zoomValue = Math.min(zoomValue, MAX_ZOOM);
    // Prevent the floating-point error. (e.g. 1.1 + 0.1 = 1.2000000000000002)
    zoomValue = Math.round(zoomValue * 10) / 10;

    bc.fullZoom = zoomValue;

    Services.prefs.setCharPref(ZOOM_PREF, zoomValue);
  };
```
Considering that we call `event.preventDefault();`, maybe we prevent the browser to correctly persist the zoom somewhere.
Edit: yes we prevent the event to reach https://searchfox.org/mozilla-central/rev/b1e5f2c7c96be36974262551978d54f457db2cae/browser/base/content/browser-fullZoom.js#564-587 which should persist the zoom value.

We might just disable those shortcuts when the toolbox is in a "page" host.

Back to Bug 1791640 Comment 2