From db4ed173eb280bf4fdb06a6e3ae0a77ff30070f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 1 Aug 2023 00:14:37 +0000 Subject: [PATCH] Bug 1846141 - Don't propagate zoom on replacement for site-specific zoom. r=nika As otherwise it can race with the front-end setting the right zoom. This is a bit sketchy, I'm open to other potential solutions? But we don't have access to per-site zoom prefs in Gecko, so... Depends on D184922 Differential Revision: https://phabricator.services.mozilla.com/D184923 --- docshell/base/CanonicalBrowsingContext.cpp | 9 +++++++-- layout/base/tests/test_zoom_restore_bfcache.html | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index 385d7f367c2e..fbf4aee1749c 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -331,8 +331,13 @@ void CanonicalBrowsingContext::ReplacedBy( txn.SetDisplayMode(GetDisplayMode()); txn.SetForceDesktopViewport(GetForceDesktopViewport()); txn.SetIsUnderHiddenEmbedderElement(GetIsUnderHiddenEmbedderElement()); - txn.SetFullZoom(GetFullZoom()); - txn.SetTextZoom(GetTextZoom()); + + // When using site-specific zoom, we let the front-end manage it, otherwise it + // can cause weirdness like bug 1846141. + if (!StaticPrefs::browser_zoom_siteSpecific()) { + txn.SetFullZoom(GetFullZoom()); + txn.SetTextZoom(GetTextZoom()); + } // Propagate the default load flags so that the TRR mode flags are forwarded // to the new browsing context. See bug 1828643. diff --git a/layout/base/tests/test_zoom_restore_bfcache.html b/layout/base/tests/test_zoom_restore_bfcache.html index f4654d4b1bb2..d1133a9b044b 100644 --- a/layout/base/tests/test_zoom_restore_bfcache.html +++ b/layout/base/tests/test_zoom_restore_bfcache.html @@ -120,8 +120,8 @@ function handlePageShow(persisted) { } } -// If Fission is disabled, the pref is no-op. -SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => { +// We want to test Gecko's zoom handling, not the front-end's. +SpecialPowers.pushPrefEnv({set: [["browser.zoom.siteSpecific", false]]}, () => { window.open('file_zoom_restore_bfcache.html', '_blank', 'noopener'); });