Changeset 290151 in webkit


Ignore:
Timestamp:
Feb 18, 2022, 12:21:56 PM (4 years ago)
Author:
timothy_horton@apple.com
Message:

Client-set minimum effective device width is not respected if AllowViewportShrinkToFitContent is enabled
https://bugs.webkit.org/show_bug.cgi?id=236822

Reviewed by Wenson Hsieh.

Source/WebCore:

New test: fast/viewport/ios/shrink-to-fit-content-with-wider-minimum-device-width.html

Re-instate the functionality of -[WKWebView _setMinimumEffectiveDeviceWidth:]
after it was intentionally broken in favor of shrink-to-fit in r244849.

It turns out that clients sometimes need a larger manually-set minimum
than the one shrink-to-fit will choose, so instead of picking between
them, we just take the maximum of the two.

  • page/ViewportConfiguration.cpp:

(WebCore::ViewportConfiguration::setViewLayoutSize):
Rename the client-set mEDW to m_minimumEffectiveDeviceWidthForView.

(WebCore::ViewportConfiguration::nativeWebpageParameters):
(WebCore::ViewportConfiguration::setMinimumEffectiveDeviceWidthForShrinkToFit):
Rename to shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit to be clear that
it's only about ignoring the shrink-to-fit mEDW, not the client-set one.

Rename the shrink-to-fit-set mEDW to m_minimumEffectiveDeviceWidthForShrinkToFit.

(WebCore::ViewportConfiguration::description const):
(WebCore::ViewportConfiguration::setMinimumEffectiveDeviceWidth): Deleted.

  • page/ViewportConfiguration.h:

(WebCore::ViewportConfiguration::minimumEffectiveDeviceWidth const):
The effective-mEDW now takes the client-set value into account in all cases,
taking the maximum-of-minimums as the effective value.

(WebCore::ViewportConfiguration::shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit const):
(WebCore::ViewportConfiguration::shouldIgnoreMinimumEffectiveDeviceWidth const): Deleted.

Source/WebKit:

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::setViewportConfigurationViewLayoutSize):
Reset the separate shrink-to-fit mEDW if shrink-to-fit is not engaged.

(WebKit::WebPage::shrinkToFitContent):

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r290150 r290151  
     12022-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
    1382022-02-18  Zan Dobersek  <zdobersek@igalia.com>
    239
  • trunk/Source/WebCore/page/ViewportConfiguration.cpp

    r279830 r290151  
    124124}
    125125
    126 bool ViewportConfiguration::setViewLayoutSize(const FloatSize& viewLayoutSize, std::optional<double>&& scaleFactor, std::optional<double>&& minimumEffectiveDeviceWidth)
     126bool ViewportConfiguration::setViewLayoutSize(const FloatSize& viewLayoutSize, std::optional<double>&& scaleFactor, std::optional<double>&& minimumEffectiveDeviceWidthFromClient)
    127127{
    128128    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)
    131131        return false;
    132132
    133133    m_layoutSizeScaleFactor = newScaleFactor;
    134134    m_viewLayoutSize = viewLayoutSize;
    135     m_minimumEffectiveDeviceWidth = newEffectiveWidth;
     135    m_minimumEffectiveDeviceWidthForView = newEffectiveWidth;
    136136
    137137    updateMinimumLayoutSize();
     
    357357ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParameters()
    358358{
    359     if (m_canIgnoreScalingConstraints || !shouldIgnoreMinimumEffectiveDeviceWidth())
     359    if (m_canIgnoreScalingConstraints || !shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit())
    360360        return ViewportConfiguration::nativeWebpageParametersWithShrinkToFit();
    361361
     
    619619}
    620620
    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())
     621bool ViewportConfiguration::setMinimumEffectiveDeviceWidthForShrinkToFit(double width)
     622{
     623    if (WTF::areEssentiallyEqual(m_minimumEffectiveDeviceWidthForShrinkToFit, width))
     624        return false;
     625
     626    m_minimumEffectiveDeviceWidthForShrinkToFit = width;
     627
     628    if (shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit())
    629629        return false;
    630630
     
    722722    ts.dumpProperty("ignoring vertical scaling constraints", shouldIgnoreVerticalScalingConstraints() ? "true" : "false");
    723723    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);
    725726    ts.dumpProperty("known to lay out wider than viewport", m_isKnownToLayOutWiderThanViewport ? "true" : "false");
    726727   
  • trunk/Source/WebCore/page/ViewportConfiguration.h

    r278253 r290151  
    9090
    9191    WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidthWhenIgnoringScalingConstraints(double);
    92     WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidth(double);
     92    WEBCORE_EXPORT bool setMinimumEffectiveDeviceWidthForShrinkToFit(double);
    9393    constexpr double minimumEffectiveDeviceWidth() const
    9494    {
    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;
    98101    }
    99102
     
    101104    WEBCORE_EXPORT bool setIsKnownToLayOutWiderThanViewport(bool value);
    102105
    103     constexpr bool shouldIgnoreMinimumEffectiveDeviceWidth() const
     106    constexpr bool shouldIgnoreMinimumEffectiveDeviceWidthForShrinkToFit() const
    104107    {
    105108        if (shouldShrinkToFitMinimumEffectiveDeviceWidthWhenIgnoringScalingConstraints())
     
    201204
    202205    double m_layoutSizeScaleFactor { 1 };
    203     double m_minimumEffectiveDeviceWidth { 0 };
     206    double m_minimumEffectiveDeviceWidthForView { 0 };
     207    double m_minimumEffectiveDeviceWidthForShrinkToFit { 0 };
    204208    double m_minimumEffectiveDeviceWidthWhenIgnoringScalingConstraints { 0 };
    205209    bool m_canIgnoreScalingConstraints;
  • trunk/Source/WebKit/ChangeLog

    r290149 r290151  
     12022-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
    1142022-02-18  Brandon Stewart  <brandonstewart@apple.com>
    215
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r289818 r290151  
    35443544    LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_identifier << " setViewportConfigurationViewLayoutSize " << size << " scaleFactor " << scaleFactor << " minimumEffectiveDeviceWidth " << minimumEffectiveDeviceWidth);
    35453545
     3546    if (!m_viewportConfiguration.isKnownToLayOutWiderThanViewport())
     3547        m_viewportConfiguration.setMinimumEffectiveDeviceWidthForShrinkToFit(0);
     3548
    35463549    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))
    35493551        return;
    35503552
     
    38983900
    38993901    auto changeMinimumEffectiveDeviceWidth = [this, mainDocument] (int targetLayoutWidth) -> bool {
    3900         if (m_viewportConfiguration.setMinimumEffectiveDeviceWidth(targetLayoutWidth)) {
     3902        if (m_viewportConfiguration.setMinimumEffectiveDeviceWidthForShrinkToFit(targetLayoutWidth)) {
    39013903            viewportConfigurationChanged();
    39023904            mainDocument->updateLayout();
Note: See TracChangeset for help on using the changeset viewer.