From 1b1dc6a39a91af885873336ec4639c4f316a2c4b Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Sun, 8 Sep 2024 21:37:19 +0000 Subject: [PATCH] Bug 1915051 - Early-exit UpdateResolutionForViewportSizeChange in fullscreen mode. r=hiro Depends on D221391 Differential Revision: https://phabricator.services.mozilla.com/D221392 --- gfx/layers/apz/test/gtest/mvm/TestMobileViewportManager.cpp | 1 + layout/base/GeckoMVMContext.cpp | 5 +++++ layout/base/GeckoMVMContext.h | 1 + layout/base/MVMContext.h | 1 + layout/base/MobileViewportManager.cpp | 2 +- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gfx/layers/apz/test/gtest/mvm/TestMobileViewportManager.cpp b/gfx/layers/apz/test/gtest/mvm/TestMobileViewportManager.cpp index ef4c316ceee9..516112f6957e 100644 --- a/gfx/layers/apz/test/gtest/mvm/TestMobileViewportManager.cpp +++ b/gfx/layers/apz/test/gtest/mvm/TestMobileViewportManager.cpp @@ -81,6 +81,7 @@ class MockMVMContext : public MVMContext { bool AllowZoomingForDocument() const { return true; } bool IsInReaderMode() const { return false; } bool IsDocumentLoading() const { return false; } + bool IsDocumentFullscreen() const { return false; } void SetResolutionAndScaleTo(float aResolution, ResolutionChangeOrigin aOrigin) { diff --git a/layout/base/GeckoMVMContext.cpp b/layout/base/GeckoMVMContext.cpp index 011ca3d97738..5bb918d9cd66 100644 --- a/layout/base/GeckoMVMContext.cpp +++ b/layout/base/GeckoMVMContext.cpp @@ -143,6 +143,11 @@ bool GeckoMVMContext::IsDocumentLoading() const { return mDocument->GetReadyStateEnum() == dom::Document::READYSTATE_LOADING; } +bool GeckoMVMContext::IsDocumentFullscreen() const { + MOZ_ASSERT(mDocument); + return mDocument->Fullscreen(); +} + void GeckoMVMContext::SetResolutionAndScaleTo(float aResolution, ResolutionChangeOrigin aOrigin) { MOZ_ASSERT(mPresShell); diff --git a/layout/base/GeckoMVMContext.h b/layout/base/GeckoMVMContext.h index ddd66c627dc1..d6c39305da78 100644 --- a/layout/base/GeckoMVMContext.h +++ b/layout/base/GeckoMVMContext.h @@ -50,6 +50,7 @@ class GeckoMVMContext final : public MVMContext { bool AllowZoomingForDocument() const override; bool IsInReaderMode() const override; bool IsDocumentLoading() const override; + bool IsDocumentFullscreen() const override; void SetResolutionAndScaleTo(float aResolution, ResolutionChangeOrigin aOrigin) override; diff --git a/layout/base/MVMContext.h b/layout/base/MVMContext.h index dc64b6b0316b..7119caf9a5a7 100644 --- a/layout/base/MVMContext.h +++ b/layout/base/MVMContext.h @@ -57,6 +57,7 @@ class MVMContext { virtual bool AllowZoomingForDocument() const = 0; virtual bool IsInReaderMode() const = 0; virtual bool IsDocumentLoading() const = 0; + virtual bool IsDocumentFullscreen() const = 0; virtual void SetResolutionAndScaleTo(float aResolution, ResolutionChangeOrigin aOrigin) = 0; diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index 58d6f19be960..6572ed362841 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -352,7 +352,7 @@ void MobileViewportManager::UpdateResolutionForViewportSizeChange( // viewport tag is added or removed) // 4. neither screen size nor CSS viewport changes - if (!aDisplayWidthChangeRatio) { + if (!aDisplayWidthChangeRatio || mContext->IsDocumentFullscreen()) { UpdateVisualViewportSize(zoom); return; }