Changeset 290151 in webkit
- Timestamp:
- Feb 18, 2022, 12:21:56 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r290150 r290151 1 2022-02-18 Tim Horton <timothy_horton@apple.com> 2 3 Client-set minimum effective device width is not respected if AllowViewportShrinkToFitContent is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=236822 5 6 Reviewed by Wenson Hsieh. 7 8 New test: fast/viewport/ios/shrink-to-fit-content-with-wider-minimum-device-width.html 9 10 Re-instate the functionality of -[WKWebView _setMinimumEffectiveDeviceWidth:] 11 after it was intentionally broken in favor of shrink-to-fit in r244849. 12 13 It turns out that clients sometimes need a larger manually-set minimum 14 than the one shrink-to-fit will choose, so instead of picking between 15 them, we just take the maximum of the two. 16 17 * page/ViewportConfiguration.cpp: 18 (WebCore::ViewportConfiguration::setViewLayoutSize): 19 Rename the client-set mEDW to `m_minimumEffectiveDeviceWidthForView`. 20 21 (WebCore::ViewportConfiguration::nativeWebpageParameters): 22 (WebCore::ViewportConfiguration::setMinimumEffectiveDeviceWidthForShrinkToFit): 23 Rename to shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit to be clear that 24 it's only about ignoring the shrink-to-fit mEDW, not the client-set one. 25 26 Rename the shrink-to-fit-set mEDW to `m_minimumEffectiveDeviceWidthForShrinkToFit`. 27 28 (WebCore::ViewportConfiguration::description const): 29 (WebCore::ViewportConfiguration::setMinimumEffectiveDeviceWidth): Deleted. 30 * page/ViewportConfiguration.h: 31 (WebCore::ViewportConfiguration::minimumEffectiveDeviceWidth const): 32 The effective-mEDW now takes the client-set value into account in all cases, 33 taking the maximum-of-minimums as the effective value. 34 35 (WebCore::ViewportConfiguration::shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit const): 36 (WebCore::ViewportConfiguration::shouldIgnoreMinimumEffectiveDeviceWidth const): Deleted. 37 1 38 2022-02-18 Zan Dobersek <zdobersek@igalia.com> 2 39 -
trunk/Source/WebCore/page/ViewportConfiguration.cpp
r279830 r290151 124 124 } 125 125 126 bool ViewportConfiguration::setViewLayoutSize(const FloatSize& viewLayoutSize, std::optional<double>&& scaleFactor, std::optional<double>&& minimumEffectiveDeviceWidth )126 bool ViewportConfiguration::setViewLayoutSize(const FloatSize& viewLayoutSize, std::optional<double>&& scaleFactor, std::optional<double>&& minimumEffectiveDeviceWidthFromClient) 127 127 { 128 128 double newScaleFactor = scaleFactor.value_or(m_layoutSizeScaleFactor); 129 double newEffectiveWidth = minimumEffectiveDeviceWidth .value_or(m_minimumEffectiveDeviceWidth);130 if (m_viewLayoutSize == viewLayoutSize && m_layoutSizeScaleFactor == newScaleFactor && newEffectiveWidth == m_minimumEffectiveDeviceWidth )129 double newEffectiveWidth = minimumEffectiveDeviceWidthFromClient.value_or(m_minimumEffectiveDeviceWidthForView); 130 if (m_viewLayoutSize == viewLayoutSize && m_layoutSizeScaleFactor == newScaleFactor && newEffectiveWidth == m_minimumEffectiveDeviceWidthForView) 131 131 return false; 132 132 133 133 m_layoutSizeScaleFactor = newScaleFactor; 134 134 m_viewLayoutSize = viewLayoutSize; 135 m_minimumEffectiveDeviceWidth = newEffectiveWidth;135 m_minimumEffectiveDeviceWidthForView = newEffectiveWidth; 136 136 137 137 updateMinimumLayoutSize(); … … 357 357 ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParameters() 358 358 { 359 if (m_canIgnoreScalingConstraints || !shouldIgnoreMinimumEffectiveDeviceWidth ())359 if (m_canIgnoreScalingConstraints || !shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit()) 360 360 return ViewportConfiguration::nativeWebpageParametersWithShrinkToFit(); 361 361 … … 619 619 } 620 620 621 bool ViewportConfiguration::setMinimumEffectiveDeviceWidth (double width)622 { 623 if (WTF::areEssentiallyEqual(m_minimumEffectiveDeviceWidth , width))624 return false; 625 626 m_minimumEffectiveDeviceWidth = width;627 628 if (shouldIgnoreMinimumEffectiveDeviceWidth ())621 bool ViewportConfiguration::setMinimumEffectiveDeviceWidthForShrinkToFit(double width) 622 { 623 if (WTF::areEssentiallyEqual(m_minimumEffectiveDeviceWidthForShrinkToFit, width)) 624 return false; 625 626 m_minimumEffectiveDeviceWidthForShrinkToFit = width; 627 628 if (shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit()) 629 629 return false; 630 630 … … 722 722 ts.dumpProperty("ignoring vertical scaling constraints", shouldIgnoreVerticalScalingConstraints() ? "true" : "false"); 723 723 ts.dumpProperty("avoids unsafe area", avoidsUnsafeArea() ? "true" : "false"); 724 ts.dumpProperty("minimum effective device width", m_minimumEffectiveDeviceWidth); 724 ts.dumpProperty("minimum effective device width (for view)", m_minimumEffectiveDeviceWidthForView); 725 ts.dumpProperty("minimum effective device width (for shrink-to-fit)", m_minimumEffectiveDeviceWidthForShrinkToFit); 725 726 ts.dumpProperty("known to lay out wider than viewport", m_isKnownToLayOutWiderThanViewport ? "true" : "false"); 726 727 -
trunk/Source/WebCore/page/ViewportConfiguration.h
r278253 r290151 90 90 91 91 WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidthWhenIgnoringScalingConstraints(double); 92 WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidth (double);92 WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidthForShrinkToFit(double); 93 93 constexpr double minimumEffectiveDeviceWidth() const 94 94 { 95 if (shouldIgnoreMinimumEffectiveDeviceWidth()) 96 return 0; 97 return m_canIgnoreScalingConstraints ? m_minimumEffectiveDeviceWidthWhenIgnoringScalingConstraints : m_minimumEffectiveDeviceWidth; 95 double minimumEffectiveDeviceWidth = m_minimumEffectiveDeviceWidthForView; 96 97 if (!shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit()) 98 minimumEffectiveDeviceWidth = std::max(minimumEffectiveDeviceWidth, m_canIgnoreScalingConstraints ? m_minimumEffectiveDeviceWidthWhenIgnoringScalingConstraints : m_minimumEffectiveDeviceWidthForShrinkToFit); 99 100 return minimumEffectiveDeviceWidth; 98 101 } 99 102 … … 101 104 WEBCORE_EXPORT bool setIsKnownToLayOutWiderThanViewport(bool value); 102 105 103 constexpr bool shouldIgnoreMinimumEffectiveDeviceWidth () const106 constexpr bool shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit() const 104 107 { 105 108 if (shouldShrinkToFitMinimumEffectiveDeviceWidthWhenIgnoringScalingConstraints()) … … 201 204 202 205 double m_layoutSizeScaleFactor { 1 }; 203 double m_minimumEffectiveDeviceWidth { 0 }; 206 double m_minimumEffectiveDeviceWidthForView { 0 }; 207 double m_minimumEffectiveDeviceWidthForShrinkToFit { 0 }; 204 208 double m_minimumEffectiveDeviceWidthWhenIgnoringScalingConstraints { 0 }; 205 209 bool m_canIgnoreScalingConstraints; -
trunk/Source/WebKit/ChangeLog
r290149 r290151 1 2022-02-18 Tim Horton <timothy_horton@apple.com> 2 3 Client-set minimum effective device width is not respected if AllowViewportShrinkToFitContent is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=236822 5 6 Reviewed by Wenson Hsieh. 7 8 * WebProcess/WebPage/ios/WebPageIOS.mm: 9 (WebKit::WebPage::setViewportConfigurationViewLayoutSize): 10 Reset the separate shrink-to-fit mEDW if shrink-to-fit is not engaged. 11 12 (WebKit::WebPage::shrinkToFitContent): 13 1 14 2022-02-18 Brandon Stewart <brandonstewart@apple.com> 2 15 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r289818 r290151 3544 3544 LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_identifier << " setViewportConfigurationViewLayoutSize " << size << " scaleFactor " << scaleFactor << " minimumEffectiveDeviceWidth " << minimumEffectiveDeviceWidth); 3545 3545 3546 if (!m_viewportConfiguration.isKnownToLayOutWiderThanViewport()) 3547 m_viewportConfiguration.setMinimumEffectiveDeviceWidthForShrinkToFit(0); 3548 3546 3549 auto previousLayoutSizeScaleFactor = m_viewportConfiguration.layoutSizeScaleFactor(); 3547 auto clampedMinimumEffectiveDevice = m_viewportConfiguration.isKnownToLayOutWiderThanViewport() ? std::nullopt : std::optional<double>(minimumEffectiveDeviceWidth); 3548 if (!m_viewportConfiguration.setViewLayoutSize(size, scaleFactor, WTFMove(clampedMinimumEffectiveDevice))) 3550 if (!m_viewportConfiguration.setViewLayoutSize(size, scaleFactor, minimumEffectiveDeviceWidth)) 3549 3551 return; 3550 3552 … … 3898 3900 3899 3901 auto changeMinimumEffectiveDeviceWidth = [this, mainDocument] (int targetLayoutWidth) -> bool { 3900 if (m_viewportConfiguration.setMinimumEffectiveDeviceWidth (targetLayoutWidth)) {3902 if (m_viewportConfiguration.setMinimumEffectiveDeviceWidthForShrinkToFit(targetLayoutWidth)) { 3901 3903 viewportConfigurationChanged(); 3902 3904 mainDocument->updateLayout();
Note:
See TracChangeset
for help on using the changeset viewer.