Changeset 246852 in webkit


Ignore:
Timestamp:
Jun 26, 2019 4:10:21 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[iPadOS] eddm.usps.com scrolls horizontally due to explicit width set in viewport meta tag
https://bugs.webkit.org/show_bug.cgi?id=199219
<rdar://problem/50425765>

Reviewed by Tim Horton.

Source/WebKit:

Currently, the heuristic to determine whether the page should be shrunk to fit the content width after loading
works by checking whether the page's content is wider than the layout width we've provided for the page.
However, in the case where an explicit width larger than the true view width is specified by the page's meta
viewport, we'll end up believing that the page's content is not wider than the layout width, which is dictated
by the fixed meta viewport width. Instead, we can shrink the page down in this scenario by comparing the content
width against the scaled size of the view when computing the amount of horizontal overflow.

Test: fast/viewport/ios/shrink-to-fit-content-large-constant-width.html

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::immediatelyShrinkToFitContent):

LayoutTests:

Add a new test to verify that if the meta viewport tag specifies a wide fixed width value, we will still try to
shrink the page down to fit within the viewport.

  • fast/viewport/ios/shrink-to-fit-content-large-constant-width-expected.txt: Added.
  • fast/viewport/ios/shrink-to-fit-content-large-constant-width.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246850 r246852  
     12019-06-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] eddm.usps.com scrolls horizontally due to explicit width set in viewport meta tag
     4        https://bugs.webkit.org/show_bug.cgi?id=199219
     5        <rdar://problem/50425765>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a new test to verify that if the meta viewport tag specifies a wide fixed width value, we will still try to
     10        shrink the page down to fit within the viewport.
     11
     12        * fast/viewport/ios/shrink-to-fit-content-large-constant-width-expected.txt: Added.
     13        * fast/viewport/ios/shrink-to-fit-content-large-constant-width.html: Added.
     14
    1152019-06-26  Joseph Pecoraro  <pecoraro@apple.com>
    216
  • trunk/Source/WebKit/ChangeLog

    r246835 r246852  
     12019-06-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] eddm.usps.com scrolls horizontally due to explicit width set in viewport meta tag
     4        https://bugs.webkit.org/show_bug.cgi?id=199219
     5        <rdar://problem/50425765>
     6
     7        Reviewed by Tim Horton.
     8
     9        Currently, the heuristic to determine whether the page should be shrunk to fit the content width after loading
     10        works by checking whether the page's content is wider than the layout width we've provided for the page.
     11        However, in the case where an explicit width larger than the true view width is specified by the page's meta
     12        viewport, we'll end up believing that the page's content is not wider than the layout width, which is dictated
     13        by the fixed meta viewport width. Instead, we can shrink the page down in this scenario by comparing the content
     14        width against the scaled size of the view when computing the amount of horizontal overflow.
     15
     16        Test: fast/viewport/ios/shrink-to-fit-content-large-constant-width.html
     17
     18        * WebProcess/WebPage/ios/WebPageIOS.mm:
     19        (WebKit::WebPage::immediatelyShrinkToFitContent):
     20
    1212019-06-26  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r246835 r246852  
    33183318    static const int toleratedHorizontalScrollingDistance = 20;
    33193319    static const int maximumExpandedLayoutWidth = 1280;
     3320
     3321    auto scaledViewWidth = [&] () -> int {
     3322        return std::round(m_viewportConfiguration.viewLayoutSize().width() / m_viewportConfiguration.initialScale());
     3323    };
     3324
    33203325    int originalContentWidth = view->contentsWidth();
     3326    int originalViewWidth = scaledViewWidth();
    33213327    int originalLayoutWidth = m_viewportConfiguration.layoutWidth();
    3322     int originalHorizontalOverflowAmount = originalContentWidth - originalLayoutWidth;
    3323     if (originalHorizontalOverflowAmount <= toleratedHorizontalScrollingDistance || originalLayoutWidth >= maximumExpandedLayoutWidth || originalContentWidth <= m_viewportConfiguration.viewLayoutSize().width())
     3328    int originalHorizontalOverflowAmount = originalContentWidth - originalViewWidth;
     3329    if (originalHorizontalOverflowAmount <= toleratedHorizontalScrollingDistance || originalLayoutWidth >= maximumExpandedLayoutWidth || originalContentWidth <= originalViewWidth)
    33243330        return false;
    33253331
     
    33353341    m_viewportConfiguration.setIsKnownToLayOutWiderThanViewport(true);
    33363342    double originalMinimumDeviceWidth = m_viewportConfiguration.minimumEffectiveDeviceWidth();
    3337     if (changeMinimumEffectiveDeviceWidth(std::min(maximumExpandedLayoutWidth, originalContentWidth)) && view->contentsWidth() - m_viewportConfiguration.layoutWidth() > originalHorizontalOverflowAmount) {
     3343    if (changeMinimumEffectiveDeviceWidth(std::min(maximumExpandedLayoutWidth, originalContentWidth)) && view->contentsWidth() - scaledViewWidth() > originalHorizontalOverflowAmount) {
    33383344        changeMinimumEffectiveDeviceWidth(originalMinimumDeviceWidth);
    33393345        m_viewportConfiguration.setIsKnownToLayOutWiderThanViewport(false);
Note: See TracChangeset for help on using the changeset viewer.