Bug 1643522 - Use a sensible way to get the zoom for a browser in SelectParent.jsm. r=Gijs
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 05 Jun 2020 10:48:59 +0000
changeset 534118 8604456ea61eafc35ae28670d95e8595ee850f6e
parent 534117 cc8881b3128c07537ad0c9c0a0dd35b0d9ce8a99
child 534119 17218fef8f25a4f1d69a019fb1c37428676cce88
push id37483
push userapavel@mozilla.com
push dateFri, 05 Jun 2020 21:40:11 +0000
treeherdermozilla-central@dadc7312128e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1643522
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1643522 - Use a sensible way to get the zoom for a browser in SelectParent.jsm. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D78471
browser/base/content/test/forms/browser_selectpopup.js
toolkit/actors/SelectParent.jsm
--- a/browser/base/content/test/forms/browser_selectpopup.js
+++ b/browser/base/content/test/forms/browser_selectpopup.js
@@ -1154,16 +1154,61 @@ add_task(async function test_blur_hides_
 
   await popupHiddenPromise;
 
   ok(true, "Blur closed popup");
 
   BrowserTestUtils.removeTab(tab);
 });
 
+// Test zoom handling.
+add_task(async function test_zoom() {
+  const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL);
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
+
+  let menulist = document.getElementById("ContentSelectDropdown");
+  let selectPopup = menulist.menupopup;
+
+  info("Opening the popup");
+  await openSelectPopup(selectPopup, "click");
+
+  info("Opened the popup");
+  let nonZoomedFontSize = parseFloat(
+    getComputedStyle(selectPopup.querySelector("menuitem")).fontSize,
+    10
+  );
+
+  info("font-size is " + nonZoomedFontSize);
+  await hideSelectPopup(selectPopup);
+
+  info("Hid the popup");
+
+  FullZoom.setZoom(2.0, tab.linkedBrowser);
+
+  info("Opening popup again");
+  await openSelectPopup(selectPopup, "click");
+
+  let zoomedFontSize = parseFloat(
+    getComputedStyle(selectPopup.querySelector("menuitem")).fontSize,
+    10
+  );
+  info("Zoomed font-size is " + zoomedFontSize);
+
+  is(
+    zoomedFontSize,
+    nonZoomedFontSize * 2.0,
+    "Zoom should affect menu popup size"
+  );
+
+  await hideSelectPopup(selectPopup);
+  info("Hid the popup again");
+
+  BrowserTestUtils.removeTab(tab);
+});
+
 function getIsHandlingUserInput(browser, elementId, eventName) {
   return SpecialPowers.spawn(browser, [[elementId, eventName]], async function([
     contentElementId,
     contentEventName,
   ]) {
     let element = content.document.getElementById(contentElementId);
     let isHandlingUserInput = false;
     await ContentTaskUtils.waitForEvent(element, contentEventName, false, e => {
--- a/toolkit/actors/SelectParent.jsm
+++ b/toolkit/actors/SelectParent.jsm
@@ -715,35 +715,31 @@ class SelectParent extends JSWindowActor
           browser = browser.outerBrowser;
         }
 
         if (!browser.hasAttribute("selectmenulist")) {
           return;
         }
 
         let document = browser.ownerDocument;
+        let window = document.defaultView;
         let menulist = document.getElementById(
           browser.getAttribute("selectmenulist")
         );
 
         if (!this._menulist) {
           // Cache the menulist to have access to it
           // when the document is gone (eg: Tab closed)
           this._menulist = menulist;
         }
 
         let data = message.data;
         menulist.menupopup.style.direction = data.style.direction;
 
-        let useFullZoom =
-          !browser.isRemoteBrowser ||
-          Services.prefs.getBoolPref("browser.zoom.full") ||
-          browser.isSyntheticDocument;
-        let zoom = useFullZoom ? browser._fullZoom : browser._textZoom;
-
+        let zoom = window.ZoomManager.getZoomForBrowser(browser);
         SelectParentHelper.populate(
           menulist,
           data.options.options,
           data.options.uniqueStyles,
           data.selectedIndex,
           zoom,
           data.defaultStyle,
           data.style