Changeset 229063 in webkit


Ignore:
Timestamp:
Feb 27, 2018 9:16:31 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[Extra zoom mode] Implement additional SPI for adjusting viewport shrink-to-fit behavior
https://bugs.webkit.org/show_bug.cgi?id=183100
<rdar://problem/37840987>

Reviewed by Tim Horton.

Source/WebCore:

Introduce new customization options to ViewportConfiguration. The first is m_forceHorizontalShrinkToFit, which
(when set to true) forces the viewport to scale using shrink-to-fit heuristics, regardless of whether
"shrink-to-fit=no" is specified via viewport parameters or if content width did not exceed minimum layout size.
The second is m_viewSize, which reflects the true size of the viewport. See WebKit ChangeLog for more details.

Tests: ViewportSizingTests.ForceShrinkToFitViewportOverridesViewportParameters

ViewportSizingTests.ShrinkToFitViewportWithMinimumAllowedLayoutWidth

  • page/ViewportConfiguration.cpp:

(WebCore::ViewportConfiguration::ViewportConfiguration):
(WebCore::ViewportConfiguration::setMinimumLayoutSize):

Plumb the real size of the view alongside the minimum layout size when updating the minimum layout size.

(WebCore::ViewportConfiguration::setForceHorizontalShrinkToFit):
(WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints const):

Bail early and return true if forceHorizontalShrinkToFit is set. This forces shrink-to-fit even in cases where
"shrink-to-fit" is set to "no", or content dimensions don't exceed layout dimensions.

(WebCore::ViewportConfiguration::initialScaleFromSize const):

Use view dimensions rather than minimum layout dimensions when computing the initial scale. Minimum layout size
is no longer always equal to the size of the view if the client has specified a minimum allowed layout width. As
such, when computing the initial scale, to ensure that the content (which was laid out using the minimum layout
size) fits within the real viewport, we need to divide real viewport dimensions by content dimensions.

(WebCore::ViewportConfiguration::minimumScale const):

Similarly, use view size instead of minimum layout size to compute minimum scale.

(WebCore::ViewportConfiguration::description const):

  • page/ViewportConfiguration.h:

Source/WebKit:

Add new SPI hooks to provide finer control over certain aspects of the shrink-to-fit viewport heuristic.
Currently, in certain cases of iPad multitasking, Safari allows shrinking content to fit by default. This means
that even when "width=device-width" is used, if the contents of the page are too wide to fit within the
viewport's width, we'll adjust the initial scale such that the viewport can fit all of the content.

However, in certain viewport dimensions, this heuristic is insufficient to ensure that pages are laid out and
displayed properly within the viewport. Namely, one could imagine that an element with a hard-coded width that
is larger than the real viewport width would cause all other elements with dimensions relative to the body to be
excessively shrunk down once shrink-to-fit is applied, so the page would still look broken even if the contents
of the page all fit within the viewport.

To mitigate this, we decouple the notions of minimum layout size from the size of the actual viewport (which we
simply refer to as "view size"). This allows us to introduce a mechanism where we lay out the page at a given
minimum layout size that is larger than the size of the view; later, when we determine the initial scale, we
then apply shrink-to-fit scaling using the view size rather than the minimum layout size. This grants us the
ability to lay out content as if our view were large, but still ensure that the contents of the page fit within
the actual view.

  • Shared/VisibleContentRectUpdateInfo.cpp:

(WebKit::VisibleContentRectUpdateInfo::encode const):
(WebKit::VisibleContentRectUpdateInfo::decode):
(WebKit::operator<<):

  • Shared/VisibleContentRectUpdateInfo.h:

(WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
(WebKit::VisibleContentRectUpdateInfo::forceHorizontalShrinkToFit const):
(WebKit::operator==):

Plumb the forceHorizontalShrinkToFit flag through VisibleContentRectUpdateInfo.

  • Shared/WebPageCreationParameters.cpp:

(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):

  • Shared/WebPageCreationParameters.h:

Plumb viewSize through IPC to WebPage.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):

Start off WKWebView flags at their initial values.

(-[WKWebView _minimumAllowedLayoutWidth]):
(-[WKWebView _setMinimumAllowedLayoutWidth:]):

This provides the minimum width at which the page will lay out, such that if the view width dips below this
value, we'll use this minimum allowed layout width instead. 0 by default.

(-[WKWebView activeMinimumLayoutSizes:]):

Refactor this from a static function to a helper method on WKWebView that computes both the minimum layout size
(which takes minimum allowed layout width into account) as well as the real view size. Refactor all call sites
to use this new method, and also propagate the view size down via IPC, alongside the minimum layout size.

(-[WKWebView _dispatchSetMinimumLayoutSize:viewSize:]):
(-[WKWebView _frameOrBoundsChanged]):
(-[WKWebView _setMinimumLayoutSizeOverride:]):
(-[WKWebView _setForceHorizontalViewportShrinkToFit:]):
(-[WKWebView _forceHorizontalViewportShrinkToFit]):

Setting this flag to YES forces us to always shrink-to-fit in the horizontal axis. NO by default.

(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _endAnimatedResize]):
(activeMinimumLayoutSize): Deleted.

More refactoring to replace activeMinimumLayoutSize() with -activeMinimumLayoutSizes:.

(-[WKWebView _dispatchSetMinimumLayoutSize:]): Deleted.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::creationParameters):

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentView.mm:

(-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):

Pass _forceHorizontalViewportShrinkToFit into the visible content rect update.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
(WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):

Plumb viewSize alongside the existing minimumLayoutSize.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::m_credentialsMessenger):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::setViewportConfigurationMinimumLayoutSize):
(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::updateVisibleContentRects):

Set forceHorizontalShrinkToFit on the viewport configuration here.

Tools:

Add API tests that exercise -_setMinimumAllowedLayoutWidth: and -_setForceHorizontalViewportShrinkToFit:. See
WebKit ChangeLog for more detail.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/ViewportSizingTests.mm: Added.

(TestWebKitAPI::while):
(viewportTestPageMarkup):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r229062 r229063  
     12018-02-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Implement additional SPI for adjusting viewport shrink-to-fit behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=183100
     5        <rdar://problem/37840987>
     6
     7        Reviewed by Tim Horton.
     8
     9        Introduce new customization options to ViewportConfiguration. The first is m_forceHorizontalShrinkToFit, which
     10        (when set to true) forces the viewport to scale using shrink-to-fit heuristics, regardless of whether
     11        "shrink-to-fit=no" is specified via viewport parameters or if content width did not exceed minimum layout size.
     12        The second is m_viewSize, which reflects the true size of the viewport. See WebKit ChangeLog for more details.
     13
     14        Tests: ViewportSizingTests.ForceShrinkToFitViewportOverridesViewportParameters
     15               ViewportSizingTests.ShrinkToFitViewportWithMinimumAllowedLayoutWidth
     16
     17        * page/ViewportConfiguration.cpp:
     18        (WebCore::ViewportConfiguration::ViewportConfiguration):
     19        (WebCore::ViewportConfiguration::setMinimumLayoutSize):
     20
     21        Plumb the real size of the view alongside the minimum layout size when updating the minimum layout size.
     22
     23        (WebCore::ViewportConfiguration::setForceHorizontalShrinkToFit):
     24        (WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints const):
     25
     26        Bail early and return true if forceHorizontalShrinkToFit is set. This forces shrink-to-fit even in cases where
     27        "shrink-to-fit" is set to "no", or content dimensions don't exceed layout dimensions.
     28
     29        (WebCore::ViewportConfiguration::initialScaleFromSize const):
     30
     31        Use view dimensions rather than minimum layout dimensions when computing the initial scale. Minimum layout size
     32        is no longer always equal to the size of the view if the client has specified a minimum allowed layout width. As
     33        such, when computing the initial scale, to ensure that the content (which was laid out using the minimum layout
     34        size) fits within the real viewport, we need to divide real viewport dimensions by content dimensions.
     35
     36        (WebCore::ViewportConfiguration::minimumScale const):
     37
     38        Similarly, use view size instead of minimum layout size to compute minimum scale.
     39
     40        (WebCore::ViewportConfiguration::description const):
     41        * page/ViewportConfiguration.h:
     42
    1432018-02-27  Wenson Hsieh  <wenson_hsieh@apple.com>
    244
  • trunk/Source/WebCore/page/ViewportConfiguration.cpp

    r225449 r229063  
    5050    , m_canIgnoreScalingConstraints(false)
    5151    , m_forceAlwaysUserScalable(false)
     52    , m_forceHorizontalShrinkToFit(false)
    5253{
    5354    // Setup a reasonable default configuration to avoid computing infinite scale/sizes.
     
    8384}
    8485
    85 bool ViewportConfiguration::setMinimumLayoutSize(const FloatSize& minimumLayoutSize)
    86 {
    87     if (m_minimumLayoutSize == minimumLayoutSize)
     86bool ViewportConfiguration::setMinimumLayoutSize(const FloatSize& minimumLayoutSize, const FloatSize& viewSize)
     87{
     88    if (m_minimumLayoutSize == minimumLayoutSize && m_viewSize == viewSize)
    8889        return false;
    8990
    9091    m_minimumLayoutSize = minimumLayoutSize;
     92    m_viewSize = viewSize;
     93
    9194    updateConfiguration();
    9295    return true;
     
    104107}
    105108
     109bool ViewportConfiguration::setForceHorizontalShrinkToFit(bool forceHorizontalShrinkToFit)
     110{
     111    if (m_forceHorizontalShrinkToFit == forceHorizontalShrinkToFit)
     112        return false;
     113
     114    m_forceHorizontalShrinkToFit = forceHorizontalShrinkToFit;
     115    return true;
     116}
     117
    106118bool ViewportConfiguration::setCanIgnoreScalingConstraints(bool canIgnoreScalingConstraints)
    107119{
     
    124136        return false;
    125137
     138    if (m_forceHorizontalShrinkToFit)
     139        return true;
     140
    126141    if (!m_configuration.allowsShrinkToFit)
    127142        return false;
     
    168183    // If not, it is up to us to determine the initial scale.
    169184    // We want a scale small enough to fit the document width-wise.
    170     const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
    171185    double initialScale = 0;
    172186    if (width > 0 && !shouldIgnoreVerticalScalingConstraints())
    173         initialScale = minimumLayoutSize.width() / width;
     187        initialScale = m_viewSize.width() / width;
    174188
    175189    // Prevent the initial scale from shrinking to a height smaller than our view's minimum height.
    176     if (height > 0 && height * initialScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
    177         initialScale = minimumLayoutSize.height() / height;
     190    if (height > 0 && height * initialScale < m_viewSize.height() && !shouldIgnoreHorizontalScalingConstraints())
     191        initialScale = m_viewSize.height() / height;
     192
    178193    return std::min(std::max(initialScale, shouldIgnoreScalingConstraints ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale), m_configuration.maximumScale);
    179194}
     
    201216        minimumScale = std::min(minimumScale, forceAlwaysUserScalableMinimumScale);
    202217
    203     const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
    204218    double contentWidth = m_contentSize.width();
    205     if (contentWidth > 0 && contentWidth * minimumScale < minimumLayoutSize.width() && !shouldIgnoreVerticalScalingConstraints())
    206         minimumScale = minimumLayoutSize.width() / contentWidth;
     219    if (contentWidth > 0 && contentWidth * minimumScale < m_viewSize.width() && !shouldIgnoreVerticalScalingConstraints())
     220        minimumScale = m_viewSize.width() / contentWidth;
    207221
    208222    double contentHeight = m_contentSize.height();
    209     if (contentHeight > 0 && contentHeight * minimumScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
    210         minimumScale = minimumLayoutSize.height() / contentHeight;
     223    if (contentHeight > 0 && contentHeight * minimumScale < m_viewSize.height() && !shouldIgnoreHorizontalScalingConstraints())
     224        minimumScale = m_viewSize.height() / contentHeight;
    211225
    212226    minimumScale = std::min(std::max(minimumScale, m_configuration.minimumScale), m_configuration.maximumScale);
     
    491505    ts.dumpProperty("ignoring vertical scaling constraints", shouldIgnoreVerticalScalingConstraints() ? "true" : "false");
    492506    ts.dumpProperty("avoids unsafe area", avoidsUnsafeArea() ? "true" : "false");
     507    ts.dumpProperty("force horizontal shrink to fit", m_forceHorizontalShrinkToFit ? "true" : "false");
    493508   
    494509    ts.endGroup();
  • trunk/Source/WebCore/page/ViewportConfiguration.h

    r225449 r229063  
    7676
    7777    const FloatSize& minimumLayoutSize() const { return m_minimumLayoutSize; }
    78     WEBCORE_EXPORT bool setMinimumLayoutSize(const FloatSize&);
     78    WEBCORE_EXPORT bool setMinimumLayoutSize(const FloatSize&, const FloatSize& viewSize);
    7979
    8080    const ViewportArguments& viewportArguments() const { return m_viewportArguments; }
    8181    WEBCORE_EXPORT bool setViewportArguments(const ViewportArguments&);
     82
     83    WEBCORE_EXPORT bool setForceHorizontalShrinkToFit(bool);
    8284
    8385    WEBCORE_EXPORT bool setCanIgnoreScalingConstraints(bool);
     
    121123    IntSize m_contentSize;
    122124    FloatSize m_minimumLayoutSize;
     125    FloatSize m_viewSize;
    123126    ViewportArguments m_viewportArguments;
    124127
    125128    bool m_canIgnoreScalingConstraints;
    126129    bool m_forceAlwaysUserScalable;
     130    bool m_forceHorizontalShrinkToFit;
    127131};
    128132
  • trunk/Source/WebKit/ChangeLog

    r229055 r229063  
     12018-02-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Implement additional SPI for adjusting viewport shrink-to-fit behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=183100
     5        <rdar://problem/37840987>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add new SPI hooks to provide finer control over certain aspects of the shrink-to-fit viewport heuristic.
     10        Currently, in certain cases of iPad multitasking, Safari allows shrinking content to fit by default. This means
     11        that even when "width=device-width" is used, if the contents of the page are too wide to fit within the
     12        viewport's width, we'll adjust the initial scale such that the viewport can fit all of the content.
     13
     14        However, in certain viewport dimensions, this heuristic is insufficient to ensure that pages are laid out and
     15        displayed properly within the viewport. Namely, one could imagine that an element with a hard-coded width that
     16        is larger than the real viewport width would cause all other elements with dimensions relative to the body to be
     17        excessively shrunk down once shrink-to-fit is applied, so the page would still look broken even if the contents
     18        of the page all fit within the viewport.
     19
     20        To mitigate this, we decouple the notions of minimum layout size from the size of the actual viewport (which we
     21        simply refer to as "view size"). This allows us to introduce a mechanism where we lay out the page at a given
     22        minimum layout size that is larger than the size of the view; later, when we determine the initial scale, we
     23        then apply shrink-to-fit scaling using the view size rather than the minimum layout size. This grants us the
     24        ability to lay out content as if our view were large, but still ensure that the contents of the page fit within
     25        the actual view.
     26
     27        * Shared/VisibleContentRectUpdateInfo.cpp:
     28        (WebKit::VisibleContentRectUpdateInfo::encode const):
     29        (WebKit::VisibleContentRectUpdateInfo::decode):
     30        (WebKit::operator<<):
     31        * Shared/VisibleContentRectUpdateInfo.h:
     32        (WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
     33        (WebKit::VisibleContentRectUpdateInfo::forceHorizontalShrinkToFit const):
     34        (WebKit::operator==):
     35
     36        Plumb the forceHorizontalShrinkToFit flag through VisibleContentRectUpdateInfo.
     37
     38        * Shared/WebPageCreationParameters.cpp:
     39        (WebKit::WebPageCreationParameters::encode const):
     40        (WebKit::WebPageCreationParameters::decode):
     41        * Shared/WebPageCreationParameters.h:
     42
     43        Plumb viewSize through IPC to WebPage.
     44
     45        * UIProcess/API/Cocoa/WKWebView.mm:
     46        (-[WKWebView _initializeWithConfiguration:]):
     47
     48        Start off WKWebView flags at their initial values.
     49
     50        (-[WKWebView _minimumAllowedLayoutWidth]):
     51        (-[WKWebView _setMinimumAllowedLayoutWidth:]):
     52
     53        This provides the minimum width at which the page will lay out, such that if the view width dips below this
     54        value, we'll use this minimum allowed layout width instead. 0 by default.
     55
     56        (-[WKWebView activeMinimumLayoutSizes:]):
     57
     58        Refactor this from a static function to a helper method on WKWebView that computes both the minimum layout size
     59        (which takes minimum allowed layout width into account) as well as the real view size. Refactor all call sites
     60        to use this new method, and also propagate the view size down via IPC, alongside the minimum layout size.
     61
     62        (-[WKWebView _dispatchSetMinimumLayoutSize:viewSize:]):
     63        (-[WKWebView _frameOrBoundsChanged]):
     64        (-[WKWebView _setMinimumLayoutSizeOverride:]):
     65        (-[WKWebView _setForceHorizontalViewportShrinkToFit:]):
     66        (-[WKWebView _forceHorizontalViewportShrinkToFit]):
     67
     68        Setting this flag to YES forces us to always shrink-to-fit in the horizontal axis. NO by default.
     69
     70        (-[WKWebView _beginAnimatedResizeWithUpdates:]):
     71        (-[WKWebView _endAnimatedResize]):
     72        (activeMinimumLayoutSize): Deleted.
     73
     74        More refactoring to replace activeMinimumLayoutSize() with -activeMinimumLayoutSizes:.
     75
     76        (-[WKWebView _dispatchSetMinimumLayoutSize:]): Deleted.
     77        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     78        * UIProcess/WebPageProxy.cpp:
     79        (WebKit::WebPageProxy::creationParameters):
     80        * UIProcess/WebPageProxy.h:
     81        * UIProcess/ios/WKContentView.mm:
     82        (-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):
     83
     84        Pass _forceHorizontalViewportShrinkToFit into the visible content rect update.
     85
     86        * UIProcess/ios/WebPageProxyIOS.mm:
     87        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
     88        (WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):
     89
     90        Plumb viewSize alongside the existing minimumLayoutSize.
     91
     92        * WebProcess/WebPage/WebPage.cpp:
     93        (WebKit::m_credentialsMessenger):
     94        * WebProcess/WebPage/WebPage.h:
     95        * WebProcess/WebPage/WebPage.messages.in:
     96        * WebProcess/WebPage/ios/WebPageIOS.mm:
     97        (WebKit::WebPage::setViewportConfigurationMinimumLayoutSize):
     98        (WebKit::WebPage::dynamicViewportSizeUpdate):
     99        (WebKit::WebPage::updateVisibleContentRects):
     100
     101        Set forceHorizontalShrinkToFit on the viewport configuration here.
     102
    11032018-02-27  Tim Horton  <timothy_horton@apple.com>
    2104
  • trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.cpp

    r225715 r229063  
    5454    encoder << m_isChangingObscuredInsetsInteractively;
    5555    encoder << m_allowShrinkToFit;
     56    encoder << m_forceHorizontalShrinkToFit;
    5657    encoder << m_enclosedInScrollableAncestorView;
    5758}
     
    9394    if (!decoder.decode(result.m_allowShrinkToFit))
    9495        return false;
     96    if (!decoder.decode(result.m_forceHorizontalShrinkToFit))
     97        return false;
    9598    if (!decoder.decode(result.m_enclosedInScrollableAncestorView))
    9699        return false;
     
    131134
    132135    ts.dumpProperty("timestamp", info.timestamp().secondsSinceEpoch().value());
     136    ts.dumpProperty("allowShrinkToFit", info.allowShrinkToFit());
     137    ts.dumpProperty("forceHorizontalShrinkToFit", info.forceHorizontalShrinkToFit());
    133138    if (info.horizontalVelocity())
    134139        ts.dumpProperty("horizontalVelocity", info.horizontalVelocity());
  • trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h

    r225715 r229063  
    4646    VisibleContentRectUpdateInfo() = default;
    4747
    48     VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedContentRect, const WebCore::FloatRect& unobscuredContentRect, const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds, const WebCore::FloatRect& customFixedPositionRect, const WebCore::FloatBoxExtent& obscuredInsets, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double scale, bool inStableState, bool isFirstUpdateForNewViewSize, bool isChangingObscuredInsetsInteractively, bool allowShrinkToFit, bool enclosedInScrollableAncestorView, MonotonicTime timestamp, double horizontalVelocity, double verticalVelocity, double scaleChangeRate, uint64_t lastLayerTreeTransactionId)
     48    VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedContentRect, const WebCore::FloatRect& unobscuredContentRect, const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds, const WebCore::FloatRect& customFixedPositionRect, const WebCore::FloatBoxExtent& obscuredInsets, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double scale, bool inStableState, bool isFirstUpdateForNewViewSize, bool isChangingObscuredInsetsInteractively, bool allowShrinkToFit, bool forceHorizontalShrinkToFit, bool enclosedInScrollableAncestorView, MonotonicTime timestamp, double horizontalVelocity, double verticalVelocity, double scaleChangeRate, uint64_t lastLayerTreeTransactionId)
    4949        : m_exposedContentRect(exposedContentRect)
    5050        , m_unobscuredContentRect(unobscuredContentRect)
     
    6464        , m_isChangingObscuredInsetsInteractively(isChangingObscuredInsetsInteractively)
    6565        , m_allowShrinkToFit(allowShrinkToFit)
     66        , m_forceHorizontalShrinkToFit(forceHorizontalShrinkToFit)
    6667        , m_enclosedInScrollableAncestorView(enclosedInScrollableAncestorView)
    6768    {
     
    8182    bool isChangingObscuredInsetsInteractively() const { return m_isChangingObscuredInsetsInteractively; }
    8283    bool allowShrinkToFit() const { return m_allowShrinkToFit; }
     84    bool forceHorizontalShrinkToFit() const { return m_forceHorizontalShrinkToFit; }
    8385    bool enclosedInScrollableAncestorView() const { return m_enclosedInScrollableAncestorView; }
    8486
     
    113115    bool m_isChangingObscuredInsetsInteractively { false };
    114116    bool m_allowShrinkToFit { false };
     117    bool m_forceHorizontalShrinkToFit { false };
    115118    bool m_enclosedInScrollableAncestorView { false };
    116119};
     
    131134        && a.isFirstUpdateForNewViewSize() == b.isFirstUpdateForNewViewSize()
    132135        && a.allowShrinkToFit() == b.allowShrinkToFit()
     136        && a.forceHorizontalShrinkToFit() == b.forceHorizontalShrinkToFit()
    133137        && a.enclosedInScrollableAncestorView() == b.enclosedInScrollableAncestorView();
    134138}
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp

    r228188 r229063  
    8989    encoder << ignoresViewportScaleLimits;
    9090    encoder << viewportConfigurationMinimumLayoutSize;
     91    encoder << viewportConfigurationViewSize;
    9192    encoder << maximumUnobscuredSize;
    9293#endif
     
    245246    if (!decoder.decode(parameters.viewportConfigurationMinimumLayoutSize))
    246247        return std::nullopt;
     248    if (!decoder.decode(parameters.viewportConfigurationViewSize))
     249        return std::nullopt;
    247250    if (!decoder.decode(parameters.maximumUnobscuredSize))
    248251        return std::nullopt;
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.h

    r228188 r229063  
    146146    bool ignoresViewportScaleLimits;
    147147    WebCore::FloatSize viewportConfigurationMinimumLayoutSize;
     148    WebCore::FloatSize viewportConfigurationViewSize;
    148149    WebCore::FloatSize maximumUnobscuredSize;
    149150#endif
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r229055 r229063  
    190190};
    191191
     192struct ActiveViewportLayoutSizes {
     193    WebCore::FloatSize minimumLayoutSize;
     194    WebCore::FloatSize viewSize;
     195};
     196
    192197#endif // PLATFORM(IOS)
    193198
     
    303308
    304309    BOOL _allowsViewportShrinkToFit;
     310    BOOL _forceHorizontalViewportShrinkToFit;
     311    CGFloat _minimumAllowedLayoutWidth;
    305312
    306313    BOOL _hasCommittedLoadForMainFrame;
     
    699706#if PLATFORM(IOS)
    700707    _dragInteractionPolicy = _WKDragInteractionPolicyDefault;
    701 #endif
     708#if ENABLE(EXTRA_ZOOM_MODE)
     709    _minimumAllowedLayoutWidth = 320;
     710    _allowsViewportShrinkToFit = YES;
     711    _forceHorizontalViewportShrinkToFit = YES;
     712#else
     713    _minimumAllowedLayoutWidth = 0;
     714    _allowsViewportShrinkToFit = NO;
     715    _forceHorizontalViewportShrinkToFit = NO;
     716#endif
     717#endif // PLATFORM(IOS)
    702718}
    703719
     
    24822498}
    24832499
    2484 static WebCore::FloatSize activeMinimumLayoutSize(WKWebView *webView, const CGRect& bounds)
    2485 {
    2486     if (webView->_overridesMinimumLayoutSize)
    2487         return WebCore::FloatSize(webView->_minimumLayoutSizeOverride);
    2488 
     2500- (CGFloat)_minimumAllowedLayoutWidth
     2501{
     2502    return _minimumAllowedLayoutWidth;
     2503}
     2504
     2505- (void)_setMinimumAllowedLayoutWidth:(CGFloat)minimumAllowedLayoutWidth
     2506{
     2507    if (_minimumAllowedLayoutWidth == minimumAllowedLayoutWidth)
     2508        return;
     2509
     2510    _minimumAllowedLayoutWidth = minimumAllowedLayoutWidth;
     2511
     2512    auto sizes = [self activeMinimumLayoutSizes:self.bounds];
     2513    [self _dispatchSetMinimumLayoutSize:sizes.minimumLayoutSize viewSize:sizes.viewSize];
     2514}
     2515
     2516- (ActiveViewportLayoutSizes)activeMinimumLayoutSizes:(const CGRect&)bounds
     2517{
     2518    if (_overridesMinimumLayoutSize)
     2519        return { WebCore::FloatSize(_minimumLayoutSizeOverride), WebCore::FloatSize(_minimumLayoutSizeOverride) };
     2520
     2521    ActiveViewportLayoutSizes sizes;
    24892522#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    2490     return WebCore::FloatSize(UIEdgeInsetsInsetRect(CGRectMake(0, 0, bounds.size.width, bounds.size.height), webView._scrollViewSystemContentInset).size);
     2523    sizes.viewSize = WebCore::FloatSize(UIEdgeInsetsInsetRect(CGRectMake(0, 0, bounds.size.width, bounds.size.height), self._scrollViewSystemContentInset).size);
    24912524#else
    2492     return WebCore::FloatSize(bounds.size);
    2493 #endif
    2494 }
    2495 
    2496 - (void)_dispatchSetMinimumLayoutSize:(WebCore::FloatSize)minimumLayoutSize
     2525    sizes.viewSize = WebCore::FloatSize { bounds.size };
     2526#endif
     2527
     2528    sizes.minimumLayoutSize = { std::max<float>(sizes.viewSize.width(), self._minimumAllowedLayoutWidth), sizes.viewSize.height() };
     2529    return sizes;
     2530}
     2531
     2532- (void)_dispatchSetMinimumLayoutSize:(WebCore::FloatSize)minimumLayoutSize viewSize:(WebCore::FloatSize)viewSize
    24972533{
    24982534    if (_lastSentMinimumLayoutSize && CGSizeEqualToSize(_lastSentMinimumLayoutSize.value(), minimumLayoutSize))
    24992535        return;
    25002536
    2501     LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _dispatchSetMinimumLayoutSize:] " << minimumLayoutSize << " contentZoomScale " << contentZoomScale(self));
    2502     _page->setViewportConfigurationMinimumLayoutSize(minimumLayoutSize);
     2537    LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _dispatchSetMinimumLayoutSize:] " << minimumLayoutSize << " viewSize " << viewSize << " contentZoomScale " << contentZoomScale(self));
     2538    _page->setViewportConfigurationMinimumLayoutSize(minimumLayoutSize, viewSize);
    25032539    _lastSentMinimumLayoutSize = minimumLayoutSize;
    25042540}
     
    25282564
    25292565    if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) {
    2530         if (!_overridesMinimumLayoutSize)
    2531             [self _dispatchSetMinimumLayoutSize:activeMinimumLayoutSize(self, self.bounds)];
     2566        if (!_overridesMinimumLayoutSize) {
     2567            auto sizes = [self activeMinimumLayoutSizes:self.bounds];
     2568            [self _dispatchSetMinimumLayoutSize:sizes.minimumLayoutSize viewSize:sizes.viewSize];
     2569        }
    25322570        if (!_overridesMaximumUnobscuredSize)
    25332571            [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(bounds.size)];
     
    49034941
    49044942    if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
    4905         [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(minimumLayoutSizeOverride)];
     4943        [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(minimumLayoutSizeOverride) viewSize:WebCore::FloatSize(minimumLayoutSizeOverride)];
    49064944
    49074945}
     
    50105048}
    50115049
     5050- (void)_setForceHorizontalViewportShrinkToFit:(BOOL)forceHorizontalViewportShrinkToFit
     5051{
     5052    if (_forceHorizontalViewportShrinkToFit == forceHorizontalViewportShrinkToFit)
     5053        return;
     5054
     5055    _forceHorizontalViewportShrinkToFit = forceHorizontalViewportShrinkToFit;
     5056    [self _scheduleVisibleContentRectUpdate];
     5057}
     5058
     5059- (BOOL)_forceHorizontalViewportShrinkToFit
     5060{
     5061    return _forceHorizontalViewportShrinkToFit;
     5062}
     5063
    50125064- (void)_setAllowsViewportShrinkToFit:(BOOL)allowShrinkToFit
    50135065{
     
    50515103    _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithAnimation;
    50525104
    5053     WebCore::FloatSize oldMinimumLayoutSize = activeMinimumLayoutSize(self, oldBounds);
    5054     WebCore::FloatSize oldMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, oldBounds);
     5105    auto oldSizes = [self activeMinimumLayoutSizes:self.bounds];
     5106    auto oldMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, oldBounds);
    50555107    int32_t oldOrientation = activeOrientation(self);
    50565108    UIEdgeInsets oldObscuredInsets = _obscuredInsets;
     
    50595111
    50605112    CGRect newBounds = self.bounds;
    5061     WebCore::FloatSize newMinimumLayoutSize = activeMinimumLayoutSize(self, newBounds);
    5062     WebCore::FloatSize newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
     5113    auto newSizes = [self activeMinimumLayoutSizes:newBounds];
     5114    auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
    50635115    int32_t newOrientation = activeOrientation(self);
    50645116    UIEdgeInsets newObscuredInsets = _obscuredInsets;
     
    50665118    CGRect contentViewBounds = [_contentView bounds];
    50675119
    5068     ASSERT_WITH_MESSAGE(!(_overridesMinimumLayoutSize && newMinimumLayoutSize.isEmpty()), "Clients controlling the layout size should maintain a valid layout size to minimize layouts.");
    5069     if (CGRectIsEmpty(newBounds) || newMinimumLayoutSize.isEmpty() || CGRectIsEmpty(futureUnobscuredRectInSelfCoordinates) || CGRectIsEmpty(contentViewBounds)) {
     5120    ASSERT_WITH_MESSAGE(!(_overridesMinimumLayoutSize && newSizes.minimumLayoutSize.isEmpty()), "Clients controlling the layout size should maintain a valid layout size to minimize layouts.");
     5121    if (CGRectIsEmpty(newBounds) || newSizes.minimumLayoutSize.isEmpty() || CGRectIsEmpty(futureUnobscuredRectInSelfCoordinates) || CGRectIsEmpty(contentViewBounds)) {
    50705122        _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
    50715123        [self _frameOrBoundsChanged];
    50725124        if (_overridesMinimumLayoutSize)
    5073             [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(newMinimumLayoutSize)];
     5125            [self _dispatchSetMinimumLayoutSize:newSizes.minimumLayoutSize viewSize:newSizes.viewSize];
    50745126        if (_overridesMaximumUnobscuredSize)
    50755127            [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
     
    50825134
    50835135    if (CGRectEqualToRect(oldBounds, newBounds)
    5084         && oldMinimumLayoutSize == newMinimumLayoutSize
     5136        && oldSizes.minimumLayoutSize == newSizes.minimumLayoutSize
    50855137        && oldMaximumUnobscuredSize == newMaximumUnobscuredSize
    50865138        && oldOrientation == newOrientation
     
    51025154
    51035155    CGSize contentSizeInContentViewCoordinates = contentViewBounds.size;
    5104     [_scrollView setMinimumZoomScale:std::min(newMinimumLayoutSize.width() / contentSizeInContentViewCoordinates.width, [_scrollView minimumZoomScale])];
    5105     [_scrollView setMaximumZoomScale:std::max(newMinimumLayoutSize.width() / contentSizeInContentViewCoordinates.width, [_scrollView maximumZoomScale])];
     5156    [_scrollView setMinimumZoomScale:std::min(newSizes.minimumLayoutSize.width() / contentSizeInContentViewCoordinates.width, [_scrollView minimumZoomScale])];
     5157    [_scrollView setMaximumZoomScale:std::max(newSizes.minimumLayoutSize.width() / contentSizeInContentViewCoordinates.width, [_scrollView maximumZoomScale])];
    51065158
    51075159    // Compute the new scale to keep the current content width in the scrollview.
    51085160    CGFloat oldWebViewWidthInContentViewCoordinates = oldUnobscuredContentRect.width();
    51095161    CGFloat visibleContentViewWidthInContentCoordinates = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates);
    5110     CGFloat targetScale = newMinimumLayoutSize.width() / visibleContentViewWidthInContentCoordinates;
     5162    CGFloat targetScale = newSizes.minimumLayoutSize.width() / visibleContentViewWidthInContentCoordinates;
    51115163    CGFloat resizeAnimationViewAnimationScale = targetScale / contentZoomScale(self);
    51125164    [_resizeAnimationView setTransform:CGAffineTransformMakeScale(resizeAnimationViewAnimationScale, resizeAnimationViewAnimationScale)];
     
    51485200    WebCore::FloatBoxExtent unobscuredSafeAreaInsetsExtent(unobscuredSafeAreaInsets.top, unobscuredSafeAreaInsets.right, unobscuredSafeAreaInsets.bottom, unobscuredSafeAreaInsets.left);
    51495201
    5150     _lastSentMinimumLayoutSize = newMinimumLayoutSize;
     5202    _lastSentMinimumLayoutSize = newSizes.minimumLayoutSize;
    51515203    _lastSentMaximumUnobscuredSize = newMaximumUnobscuredSize;
    51525204    _lastSentDeviceOrientation = newOrientation;
    51535205
    5154     _page->dynamicViewportSizeUpdate(newMinimumLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation);
     5206    _page->dynamicViewportSizeUpdate(newSizes.minimumLayoutSize, newSizes.viewSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation);
    51555207    if (WebKit::DrawingAreaProxy* drawingArea = _page->drawingArea())
    51565208        drawingArea->setSize(WebCore::IntSize(newBounds.size));
     
    52175269
    52185270    CGRect newBounds = self.bounds;
    5219     WebCore::FloatSize newMinimumLayoutSize = activeMinimumLayoutSize(self, newBounds);
    5220     WebCore::FloatSize newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
     5271    auto newSizes = [self activeMinimumLayoutSizes:newBounds];
     5272    auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
    52215273    int32_t newOrientation = activeOrientation(self);
    52225274
    5223     if (!_lastSentMinimumLayoutSize || newMinimumLayoutSize != _lastSentMinimumLayoutSize.value())
    5224         [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(newMinimumLayoutSize)];
     5275    if (!_lastSentMinimumLayoutSize || newSizes.minimumLayoutSize != _lastSentMinimumLayoutSize.value())
     5276        [self _dispatchSetMinimumLayoutSize:newSizes.minimumLayoutSize viewSize:newSizes.viewSize];
    52255277    if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value())
    52265278        [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r227765 r229063  
    205205
    206206@property (nonatomic, setter=_setAllowsViewportShrinkToFit:) BOOL _allowsViewportShrinkToFit;
     207@property (nonatomic, setter=_setForceHorizontalViewportShrinkToFit:) BOOL _forceHorizontalViewportShrinkToFit WK_API_AVAILABLE(ios(WK_IOS_TBA));
     208@property (nonatomic, setter=_setMinimumAllowedLayoutWidth:) CGFloat _minimumAllowedLayoutWidth WK_API_AVAILABLE(ios(WK_IOS_TBA));
    207209
    208210// FIXME: Remove these three properties once we expose WKWebViewContentProvider as API.
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r228887 r229063  
    58545854    parameters.ignoresViewportScaleLimits = m_forceAlwaysUserScalable;
    58555855    parameters.viewportConfigurationMinimumLayoutSize = m_viewportConfigurationMinimumLayoutSize;
     5856    parameters.viewportConfigurationViewSize = m_viewportConfigurationViewSize;
    58565857    parameters.maximumUnobscuredSize = m_maximumUnobscuredSize;
    58575858#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r228857 r229063  
    533533    void overflowScrollDidEndScroll();
    534534
    535     void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation);
     535    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& viewSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation);
    536536    void synchronizeDynamicViewportUpdate();
    537537
    538     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
     538    void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&, const WebCore::FloatSize& viewSize);
    539539    void setMaximumUnobscuredSize(const WebCore::FloatSize&);
    540540    void setDeviceOrientation(int32_t);
     
    20892089    bool m_forceAlwaysUserScalable { false };
    20902090    WebCore::FloatSize m_viewportConfigurationMinimumLayoutSize;
     2091    WebCore::FloatSize m_viewportConfigurationViewSize;
    20912092    WebCore::FloatSize m_maximumUnobscuredSize;
    20922093#endif
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r224313 r229063  
    426426        isChangingObscuredInsetsInteractively,
    427427        _webView._allowsViewportShrinkToFit,
     428        _webView._forceHorizontalViewportShrinkToFit,
    428429        enclosedInScrollableAncestorView,
    429430        timestamp,
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r228857 r229063  
    305305}
    306306
    307 void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation)
     307void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const FloatSize& viewSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation)
    308308{
    309309    if (!isValid())
     
    314314    m_dynamicViewportSizeUpdateWaitingForTarget = true;
    315315    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true;
    316     m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID);
     316    m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, viewSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID);
    317317}
    318318
     
    354354}
    355355
    356 void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize& size)
     356void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize& size, const WebCore::FloatSize& viewSize)
    357357{
    358358    m_viewportConfigurationMinimumLayoutSize = size;
     359    m_viewportConfigurationViewSize = viewSize;
    359360
    360361    if (isValid())
    361         m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
     362        m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size, viewSize), m_pageID);
    362363}
    363364
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r229037 r229063  
    605605
    606606#if PLATFORM(IOS)
    607     setViewportConfigurationMinimumLayoutSize(parameters.viewportConfigurationMinimumLayoutSize);
     607    setViewportConfigurationMinimumLayoutSize(parameters.viewportConfigurationMinimumLayoutSize, parameters.viewportConfigurationViewSize);
    608608    setMaximumUnobscuredSize(parameters.maximumUnobscuredSize);
    609609#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r228602 r229063  
    868868
    869869#if PLATFORM(IOS)
    870     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
     870    void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&, const WebCore::FloatSize& viewSize);
    871871    void setMaximumUnobscuredSize(const WebCore::FloatSize&);
    872872    void setDeviceOrientation(int32_t);
    873     void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
     873    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& viewSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
    874874    void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
    875875    std::optional<float> scaleFromUIProcess(const VisibleContentRectUpdateInfo&) const;
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r228602 r229063  
    4242    MouseEvent(WebKit::WebMouseEvent event)
    4343#if PLATFORM(IOS)
    44     SetViewportConfigurationMinimumLayoutSize(WebCore::FloatSize size)
     44    SetViewportConfigurationMinimumLayoutSize(WebCore::FloatSize size, WebCore::FloatSize viewSize)
    4545    SetMaximumUnobscuredSize(WebCore::FloatSize size)
    4646    SetDeviceOrientation(int32_t deviceOrientation)
    47     DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
     47    DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize viewSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
    4848    SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
    4949
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r228933 r229063  
    28522852}
    28532853
    2854 void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size)
    2855 {
    2856     LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_pageID << " setViewportConfigurationMinimumLayoutSize " << size);
    2857     if (m_viewportConfiguration.setMinimumLayoutSize(size))
     2854void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size, const FloatSize& viewSize)
     2855{
     2856    LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_pageID << " setViewportConfigurationMinimumLayoutSize " << size << " viewSize " << viewSize);
     2857    if (m_viewportConfiguration.setMinimumLayoutSize(size, viewSize))
    28582858        viewportConfigurationChanged();
    28592859}
     
    28902890}
    28912891
    2892 void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
     2892void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const FloatSize& viewSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
    28932893{
    28942894    SetForScope<bool> dynamicSizeUpdateGuard(m_inDynamicSizeUpdate, true);
    28952895    // FIXME: this does not handle the cases where the content would change the content size or scroll position from JavaScript.
    28962896    // To handle those cases, we would need to redo this computation on every change until the next visible content rect update.
    2897     LOG_WITH_STREAM(VisibleRects, stream << "\nWebPage::dynamicViewportSizeUpdate - minimumLayoutSize " << minimumLayoutSize << " targetUnobscuredRect " << targetUnobscuredRect << " targetExposedContentRect " << targetExposedContentRect << " targetScale " << targetScale);
     2897    LOG_WITH_STREAM(VisibleRects, stream << "\nWebPage::dynamicViewportSizeUpdate - minimumLayoutSize " << minimumLayoutSize << " viewSize " << viewSize << " targetUnobscuredRect " << targetUnobscuredRect << " targetExposedContentRect " << targetExposedContentRect << " targetScale " << targetScale);
    28982898
    28992899    FrameView& frameView = *m_page->mainFrame().view();
     
    29282928
    29292929    LOG_WITH_STREAM(VisibleRects, stream << "WebPage::dynamicViewportSizeUpdate setting minimum layout size to " << minimumLayoutSize);
    2930     m_viewportConfiguration.setMinimumLayoutSize(minimumLayoutSize);
     2930    m_viewportConfiguration.setMinimumLayoutSize(minimumLayoutSize, viewSize);
    29312931    IntSize newLayoutSize = m_viewportConfiguration.layoutSize();
    29322932
     
    33083308        m_dynamicSizeUpdateHistory.clear();
    33093309
    3310     if (m_viewportConfiguration.setCanIgnoreScalingConstraints(m_ignoreViewportScalingConstraints && visibleContentRectUpdateInfo.allowShrinkToFit()))
     3310    bool didUpdateForceHorizontalShrinkToFit = m_viewportConfiguration.setForceHorizontalShrinkToFit(visibleContentRectUpdateInfo.forceHorizontalShrinkToFit());
     3311    bool didUpdateCanIgnoreViewportScalingConstraints = m_viewportConfiguration.setCanIgnoreScalingConstraints(m_ignoreViewportScalingConstraints && visibleContentRectUpdateInfo.allowShrinkToFit());
     3312    if (didUpdateForceHorizontalShrinkToFit || didUpdateCanIgnoreViewportScalingConstraints)
    33113313        viewportConfigurationChanged();
    33123314
  • trunk/Tools/ChangeLog

    r229057 r229063  
     12018-02-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Implement additional SPI for adjusting viewport shrink-to-fit behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=183100
     5        <rdar://problem/37840987>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add API tests that exercise -_setMinimumAllowedLayoutWidth: and -_setForceHorizontalViewportShrinkToFit:. See
     10        WebKit ChangeLog for more detail.
     11
     12        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     13        * TestWebKitAPI/Tests/ios/ViewportSizingTests.mm: Added.
     14        (TestWebKitAPI::while):
     15        (viewportTestPageMarkup):
     16        (TestWebKitAPI::TEST):
     17
    1182018-02-27  Yusuke Suzuki  <utatane.tea@gmail.com>
    219
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r228569 r229063  
    9191                2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */; };
    9292                2E1B7B021D41B1B9007558B4 /* large-video-hides-controls-after-seek-to-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */; };
     93                2E1B881F2040EE5300FFF6A9 /* ViewportSizingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E1B881E2040EE5300FFF6A9 /* ViewportSizingTests.mm */; };
    9394                2E1DFDED1D42A51100714A00 /* large-videos-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */; };
    9495                2E1DFDEF1D42A6F200714A00 /* large-videos-with-audio-autoplay.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */; };
     
    12221223                2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-after-ending.html"; sourceTree = "<group>"; };
    12231224                2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-hides-controls-after-seek-to-end.html"; sourceTree = "<group>"; };
     1225                2E1B881E2040EE5300FFF6A9 /* ViewportSizingTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewportSizingTests.mm; sourceTree = "<group>"; };
    12241226                2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-with-audio.html"; sourceTree = "<group>"; };
    12251227                2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-with-audio-autoplay.html"; sourceTree = "<group>"; };
     
    23042306                                7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
    23052307                                F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
     2308                                2E1B881E2040EE5300FFF6A9 /* ViewportSizingTests.mm */,
    23062309                                514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */,
    23072310                        );
     
    36673670                                7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
    36683671                                115EB3431EE0BA03003C2C0A /* ViewportSizeForViewportUnits.mm in Sources */,
     3672                                2E1B881F2040EE5300FFF6A9 /* ViewportSizingTests.mm in Sources */,
    36693673                                6356FB221EC4E0BA0044BF18 /* VisibleContentRect.mm in Sources */,
    36703674                                83779C381F82FECE007CDA8A /* VisitedLinkStore.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.