Changeset 231168 in webkit


Ignore:
Timestamp:
Apr 30, 2018 1:56:39 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[Extra zoom mode] Respect the existing shrink-to-fit attribute instead of using min-device-width
https://bugs.webkit.org/show_bug.cgi?id=185132
<rdar://problem/39834562>

Reviewed by Tim Horton.

Source/WebCore:

Removes the min-device-width attribute added in r231095. Instead, we key this behavior off of the
shrink-to-fit attribute introduced for multitasking on iPad, such that shrink-to-fit=no achieves the same
behavior as min-device-width=0 in extra zoom mode. See comments below for more detail.

Adjusted an existing layout test: fast/viewport/extrazoom/viewport-change-min-device-width.html.

  • dom/ViewportArguments.cpp:

(WebCore::setViewportFeature):
(WebCore::operator<<):

  • dom/ViewportArguments.h:

Removes the minDeviceWidth viewport argument.

  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::setMinDeviceWidthEnabled): Deleted.
(WebCore::RuntimeEnabledFeatures::minDeviceWidthEnabled const): Deleted.

Removes the runtime switch for min-device-width.

  • page/ViewportConfiguration.cpp:

(WebCore::platformDeviceWidthOverride):

Hard-code the override device width in extra zoom mode.

(WebCore::ViewportConfiguration::shouldOverrideDeviceWidthAndShrinkToFit const):

In extra zoom mode, override the device width only if shrink-to-fit has not been expliticly disabled, and the
device width is less than the override device width.

(WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints const):
(WebCore::ViewportConfiguration::shouldIgnoreScalingConstraintsRegardlessOfContentSize const):
(WebCore::ViewportConfiguration::updateConfiguration):
(WebCore::ViewportConfiguration::updateMinimumLayoutSize):

Do not override the minimum layout size if shrink-to-fit has been explicitly explicitly disabled, or if the
device width is greater than the override device width.

(WebCore::computedMinDeviceWidth): Deleted.
(WebCore::ViewportConfiguration::shouldOverrideDeviceWidthWithMinDeviceWidth const): Deleted.

  • page/ViewportConfiguration.h:

Source/WebKit:

Remove the experimental feature for min-device-width.

  • Shared/WebPreferences.yaml:

LayoutTests:

Modifies an existing layout test to try out different values of shrink-to-fit instead of using the
min-device-width attribute. This test now begins with the default viewport configuration, then explicitly
disables shrink-to-fit by setting the attribute to a few different values (which should all achieve the same
effect), and lastly explicitly re-enables shrink-to-fit by setting the attribute value to several values that
should behave the same as shrink-to-fit=yes.

  • fast/viewport/extrazoom/viewport-change-min-device-width.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r231165 r231168  
     12018-04-30  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Respect the existing shrink-to-fit attribute instead of using min-device-width
     4        https://bugs.webkit.org/show_bug.cgi?id=185132
     5        <rdar://problem/39834562>
     6
     7        Reviewed by Tim Horton.
     8
     9        Modifies an existing layout test to try out different values of `shrink-to-fit` instead of using the
     10        `min-device-width` attribute. This test now begins with the default viewport configuration, then explicitly
     11        disables `shrink-to-fit` by setting the attribute to a few different values (which should all achieve the same
     12        effect), and lastly explicitly re-enables `shrink-to-fit` by setting the attribute value to several values that
     13        should behave the same as `shrink-to-fit=yes`.
     14
     15        * fast/viewport/extrazoom/viewport-change-min-device-width.html:
     16
    1172018-04-30  Chris Nardi  <cnardi@chromium.org>
    218
  • trunk/LayoutTests/fast/viewport/extrazoom/viewport-change-min-device-width.html

    r231095 r231168  
    3030            }
    3131
    32             debug("1. Initial min-device-width");
     32            debug("1. Default viewport");
    3333            await logWindowDimensionsAfterSettingViewportContent("width=150");
    3434            await logWindowDimensionsAfterSettingViewportContent("width=device-width");
    35             scaleAtDeviceWidthForInitialMinDeviceWidth = parseFloat(await UIHelper.zoomScale()).toFixed(3);
     35            scaleAtDeviceWidthWithInitialShrinkToFit = parseFloat(await UIHelper.zoomScale()).toFixed(3);
    3636            await logWindowDimensionsAfterSettingViewportContent("width=600");
    3737
    38             debug("\n2. min-device-width=0");
    39             await logWindowDimensionsAfterSettingViewportContent("width=150, min-device-width=0");
    40             await logWindowDimensionsAfterSettingViewportContent("width=device-width, min-device-width=0");
    41             scaleAtDeviceWidthForMinDeviceWidth0 = parseFloat(await UIHelper.zoomScale()).toFixed(3);
    42             await logWindowDimensionsAfterSettingViewportContent("width=600, min-device-width=0");
     38            debug("\n2. shrink-to-fit explicitly disabled");
     39            await logWindowDimensionsAfterSettingViewportContent("width=150, shrink-to-fit=no");
     40            await logWindowDimensionsAfterSettingViewportContent("width=device-width, shrink-to-fit=0");
     41            scaleAtDeviceWidthWithShrinkToFitDisabled = parseFloat(await UIHelper.zoomScale()).toFixed(3);
     42            await logWindowDimensionsAfterSettingViewportContent("width=600, shrink-to-fit=-0.5");
    4343
    44             debug("\n3. min-device-width=500");
    45             await logWindowDimensionsAfterSettingViewportContent("width=150, min-device-width=500");
    46             await logWindowDimensionsAfterSettingViewportContent("width=device-width, min-device-width=500");
    47             scaleAtDeviceWidthForMinDeviceWidth500 = parseFloat(await UIHelper.zoomScale()).toFixed(3);
    48             await logWindowDimensionsAfterSettingViewportContent("width=600, min-device-width=500");
     44            debug("\n3. shrink-to-fit explicitly enabled");
     45            await logWindowDimensionsAfterSettingViewportContent("width=150, shrink-to-fit=yes");
     46            await logWindowDimensionsAfterSettingViewportContent("width=device-width, shrink-to-fit=1");
     47            scaleAtDeviceWidthWithShrinkToFitEnabled = parseFloat(await UIHelper.zoomScale()).toFixed(3);
     48            await logWindowDimensionsAfterSettingViewportContent("width=600, shrink-to-fit=device-width");
    4949
    50             shouldBe("scaleAtDeviceWidthForInitialMinDeviceWidth", "'0.488'");
    51             shouldBe("scaleAtDeviceWidthForMinDeviceWidth0", "'1.000'");
    52             shouldBe("scaleAtDeviceWidthForMinDeviceWidth500", "'0.312'");
     50            shouldBe("scaleAtDeviceWidthWithInitialShrinkToFit", "'0.488'");
     51            shouldBe("scaleAtDeviceWidthWithShrinkToFitDisabled", "'1.000'");
     52            shouldBe("scaleAtDeviceWidthWithShrinkToFitEnabled", "'0.488'");
    5353
    5454            finishJSTest();
  • trunk/Source/WebCore/ChangeLog

    r231165 r231168  
     12018-04-30  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Respect the existing shrink-to-fit attribute instead of using min-device-width
     4        https://bugs.webkit.org/show_bug.cgi?id=185132
     5        <rdar://problem/39834562>
     6
     7        Reviewed by Tim Horton.
     8
     9        Removes the `min-device-width` attribute added in r231095. Instead, we key this behavior off of the
     10        `shrink-to-fit` attribute introduced for multitasking on iPad, such that `shrink-to-fit=no` achieves the same
     11        behavior as `min-device-width=0` in extra zoom mode. See comments below for more detail.
     12
     13        Adjusted an existing layout test: fast/viewport/extrazoom/viewport-change-min-device-width.html.
     14
     15        * dom/ViewportArguments.cpp:
     16        (WebCore::setViewportFeature):
     17        (WebCore::operator<<):
     18        * dom/ViewportArguments.h:
     19
     20        Removes the `minDeviceWidth` viewport argument.
     21
     22        * page/RuntimeEnabledFeatures.h:
     23        (WebCore::RuntimeEnabledFeatures::setMinDeviceWidthEnabled): Deleted.
     24        (WebCore::RuntimeEnabledFeatures::minDeviceWidthEnabled const): Deleted.
     25
     26        Removes the runtime switch for `min-device-width`.
     27
     28        * page/ViewportConfiguration.cpp:
     29        (WebCore::platformDeviceWidthOverride):
     30
     31        Hard-code the override device width in extra zoom mode.
     32
     33        (WebCore::ViewportConfiguration::shouldOverrideDeviceWidthAndShrinkToFit const):
     34
     35        In extra zoom mode, override the device width only if shrink-to-fit has not been expliticly disabled, and the
     36        device width is less than the override device width.
     37
     38        (WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints const):
     39        (WebCore::ViewportConfiguration::shouldIgnoreScalingConstraintsRegardlessOfContentSize const):
     40        (WebCore::ViewportConfiguration::updateConfiguration):
     41        (WebCore::ViewportConfiguration::updateMinimumLayoutSize):
     42
     43        Do not override the minimum layout size if `shrink-to-fit` has been explicitly explicitly disabled, or if the
     44        device width is greater than the override device width.
     45
     46        (WebCore::computedMinDeviceWidth): Deleted.
     47        (WebCore::ViewportConfiguration::shouldOverrideDeviceWidthWithMinDeviceWidth const): Deleted.
     48        * page/ViewportConfiguration.h:
     49
    1502018-04-30  Chris Nardi  <cnardi@chromium.org>
    251
  • trunk/Source/WebCore/dom/ViewportArguments.cpp

    r231106 r231168  
    422422    else if (equalLettersIgnoringASCIICase(key, "viewport-fit") && document.settings().viewportFitEnabled())
    423423        arguments.viewportFit = parseViewportFitValue(document, key, value);
    424     else if (equalLettersIgnoringASCIICase(key, "min-device-width") && RuntimeEnabledFeatures::sharedFeatures().minDeviceWidthEnabled())
    425         arguments.minDeviceWidth = numericPrefix(document, key, value);
    426424    else
    427425        reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, key);
     
    479477    TextStream::IndentScope indentScope(ts);
    480478
    481     ts << "\n" << indent << "(width " << viewportArguments.width << ", minWidth " << viewportArguments.minWidth << ", maxWidth " << viewportArguments.maxWidth << ", minDeviceWidth " << viewportArguments.minDeviceWidth << ")";
     479    ts << "\n" << indent << "(width " << viewportArguments.width << ", minWidth " << viewportArguments.minWidth << ", maxWidth " << viewportArguments.maxWidth << ")";
    482480    ts << "\n" << indent << "(height " << viewportArguments.height << ", minHeight " << viewportArguments.minHeight << ", maxHeight " << viewportArguments.maxHeight << ")";
    483481    ts << "\n" << indent << "(zoom " << viewportArguments.zoom << ", minZoom " << viewportArguments.minZoom << ", maxZoom " << viewportArguments.maxZoom << ")";
  • trunk/Source/WebCore/dom/ViewportArguments.h

    r231095 r231168  
    9494    float minWidth { ValueAuto };
    9595    float maxWidth { ValueAuto };
    96     float minDeviceWidth { ValueAuto };
    9796    float height { ValueAuto };
    9897    float minHeight { ValueAuto };
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r231149 r231168  
    254254    bool fromOriginResponseHeaderEnabled() const { return m_fromOriginResponseHeaderEnabled; }
    255255
    256     void setMinDeviceWidthEnabled(bool isEnabled) { m_minDeviceWidthEnabled = isEnabled; }
    257     bool minDeviceWidthEnabled() const { return m_minDeviceWidthEnabled; }
    258 
    259256    WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures();
    260257
  • trunk/Source/WebCore/page/ViewportConfiguration.cpp

    r231097 r231168  
    4646#endif
    4747
    48 static float computedMinDeviceWidth(float minDeviceWidth)
    49 {
    50     if (minDeviceWidth != ViewportArguments::ValueAuto)
    51         return minDeviceWidth;
    52 
     48static float platformDeviceWidthOverride()
     49{
    5350#if ENABLE(EXTRA_ZOOM_MODE)
    5451    return 320;
     
    136133}
    137134
    138 bool ViewportConfiguration::shouldOverrideDeviceWidthWithMinDeviceWidth() const
    139 {
    140     return m_viewLayoutSize.width() < computedMinDeviceWidth(m_viewportArguments.minDeviceWidth);
     135bool ViewportConfiguration::shouldOverrideDeviceWidthAndShrinkToFit() const
     136{
     137    auto viewWidth = m_viewLayoutSize.width();
     138    return m_viewportArguments.shrinkToFit != 0. && 0 < viewWidth && viewWidth < platformDeviceWidthOverride();
    141139}
    142140
     
    146144        return false;
    147145
    148     if (shouldOverrideDeviceWidthWithMinDeviceWidth())
     146    if (shouldOverrideDeviceWidthAndShrinkToFit())
    149147        return true;
    150148
     
    184182bool ViewportConfiguration::shouldIgnoreScalingConstraintsRegardlessOfContentSize() const
    185183{
    186     return m_canIgnoreScalingConstraints && shouldOverrideDeviceWidthWithMinDeviceWidth();
     184    return m_canIgnoreScalingConstraints && shouldOverrideDeviceWidthAndShrinkToFit();
    187185}
    188186
     
    372370
    373371    if (booleanViewportArgumentIsSet(m_viewportArguments.shrinkToFit))
    374         m_configuration.allowsShrinkToFit = shouldOverrideDeviceWidthWithMinDeviceWidth() || m_viewportArguments.shrinkToFit != 0.;
     372        m_configuration.allowsShrinkToFit = m_viewportArguments.shrinkToFit != 0.;
    375373
    376374    m_configuration.avoidsUnsafeArea = m_viewportArguments.viewportFit != ViewportFit::Cover;
     
    381379void ViewportConfiguration::updateMinimumLayoutSize()
    382380{
    383     if (!m_viewLayoutSize.width() || !shouldOverrideDeviceWidthWithMinDeviceWidth()) {
     381    if (!shouldOverrideDeviceWidthAndShrinkToFit()) {
    384382        m_minimumLayoutSize = m_viewLayoutSize;
    385383        return;
    386384    }
    387385
    388     auto minDeviceWidth = computedMinDeviceWidth(m_viewportArguments.minDeviceWidth);
     386    float minDeviceWidth = platformDeviceWidthOverride();
    389387    m_minimumLayoutSize = FloatSize(minDeviceWidth, std::roundf(m_viewLayoutSize.height() * (minDeviceWidth / m_viewLayoutSize.width())));
    390388}
  • trunk/Source/WebCore/page/ViewportConfiguration.h

    r231097 r231168  
    8383    WEBCORE_EXPORT bool setViewportArguments(const ViewportArguments&);
    8484
    85     bool shouldOverrideDeviceWidthWithMinDeviceWidth() const;
     85    bool shouldOverrideDeviceWidthAndShrinkToFit() const;
    8686
    8787    WEBCORE_EXPORT bool setCanIgnoreScalingConstraints(bool);
  • trunk/Source/WebKit/ChangeLog

    r231163 r231168  
     12018-04-30  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Respect the existing shrink-to-fit attribute instead of using min-device-width
     4        https://bugs.webkit.org/show_bug.cgi?id=185132
     5        <rdar://problem/39834562>
     6
     7        Reviewed by Tim Horton.
     8
     9        Remove the experimental feature for `min-device-width`.
     10
     11        * Shared/WebPreferences.yaml:
     12
    1132018-04-30  Keith Rollin  <krollin@apple.com>
    214
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r231106 r231168  
    12491249    category: experimental
    12501250    webcoreBinding: RuntimeEnabledFeatures
    1251 
    1252 MinDeviceWidthEnabled:
    1253   type: bool
    1254   defaultValue: DEFAULT_MIN_DEVICE_WIDTH_ENABLED
    1255   humanReadableName: "Minimum device width"
    1256   humanReadableDescription: "Enable the min-device-width viewport parameter"
    1257   category: experimental
    1258   webcoreBinding: RuntimeEnabledFeatures
Note: See TracChangeset for help on using the changeset viewer.