diff --git a/Source/WebCore/page/ViewportConfiguration.cpp b/Source/WebCore/page/ViewportConfiguration.cpp index ff99fa579729c..5a12fa3c348f0 100644 --- a/Source/WebCore/page/ViewportConfiguration.cpp +++ b/Source/WebCore/page/ViewportConfiguration.cpp @@ -148,7 +148,17 @@ bool ViewportConfiguration::setContentsSize(const IntSize& contentSize) bool ViewportConfiguration::setViewLayoutSize(const FloatSize& viewLayoutSize, std::optional&& scaleFactor, std::optional&& minimumEffectiveDeviceWidthFromClient) { double newScaleFactor = scaleFactor.value_or(m_layoutSizeScaleFactor); - double newEffectiveWidth = minimumEffectiveDeviceWidthFromClient.value_or(m_minimumEffectiveDeviceWidthForView); + double newEffectiveWidth = [&] { + if (!m_configuration.shouldHonorMinimumEffectiveDeviceWidthFromClient) + return m_minimumEffectiveDeviceWidthForView; + + if (!minimumEffectiveDeviceWidthFromClient) + return m_minimumEffectiveDeviceWidthForView; + + m_minimumEffectiveDeviceWidthWasSetByClient = true; + return *minimumEffectiveDeviceWidthFromClient; + }(); + if (m_viewLayoutSize == viewLayoutSize && m_layoutSizeScaleFactor == newScaleFactor && newEffectiveWidth == m_minimumEffectiveDeviceWidthForView) return false; @@ -427,6 +437,7 @@ ViewportConfiguration::Parameters ViewportConfiguration::pluginDocumentParameter parameters.initialScale = 1; parameters.initialScaleIgnoringLayoutScaleFactor = 1; parameters.initialScaleIsSet = true; + parameters.shouldHonorMinimumEffectiveDeviceWidthFromClient = false; return parameters; } #endif @@ -537,6 +548,9 @@ void ViewportConfiguration::updateConfiguration() m_configuration.heightIsSet = viewportArgumentsOverridesHeight; } + if (!m_configuration.shouldHonorMinimumEffectiveDeviceWidthFromClient && std::exchange(m_minimumEffectiveDeviceWidthWasSetByClient, false)) + m_minimumEffectiveDeviceWidthForView = 0; + if (m_configuration.initialScaleIsSet && m_minimumEffectiveDeviceWidthForView > m_viewLayoutSize.width()) m_configuration.ignoreInitialScaleForLayoutWidth = true; @@ -717,6 +731,8 @@ TextStream& operator<<(TextStream& ts, const ViewportConfiguration::Parameters& ts.dumpProperty("allowsUserScaling", parameters.allowsUserScaling); ts.dumpProperty("allowsShrinkToFit", parameters.allowsShrinkToFit); ts.dumpProperty("avoidsUnsafeArea", parameters.avoidsUnsafeArea); + ts.dumpProperty("ignoreInitialScaleForLayoutWidth", parameters.ignoreInitialScaleForLayoutWidth); + ts.dumpProperty("shouldHonorMinimumEffectiveDeviceWidthFromClient", parameters.shouldHonorMinimumEffectiveDeviceWidthFromClient); return ts; } diff --git a/Source/WebCore/page/ViewportConfiguration.h b/Source/WebCore/page/ViewportConfiguration.h index ad183977c371c..996efc0f7d66b 100644 --- a/Source/WebCore/page/ViewportConfiguration.h +++ b/Source/WebCore/page/ViewportConfiguration.h @@ -61,6 +61,8 @@ class ViewportConfiguration { bool ignoreInitialScaleForLayoutWidth { false }; + bool shouldHonorMinimumEffectiveDeviceWidthFromClient { true }; + friend bool operator==(const Parameters&, const Parameters&) = default; }; @@ -215,6 +217,7 @@ class ViewportConfiguration { bool m_isKnownToLayOutWiderThanViewport { false }; bool m_prefersHorizontalScrollingBelowDesktopViewportWidths { false }; bool m_canIgnoreViewportArgumentsToAvoidExcessiveZoom { false }; + bool m_minimumEffectiveDeviceWidthWasSetByClient { false }; }; WTF::TextStream& operator<<(WTF::TextStream&, const ViewportConfiguration::Parameters&);