⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 169068 in webkit


Ignore:
Timestamp:
May 19, 2014, 2:42:38 PM (12 years ago)
Author:
benjamin@webkit.org
Message:

[iOS][WK2] When a page relayout on dynamic resize, keep the same relative width in view
​https://bugs.webkit.org/show_bug.cgi?id=133026
<rdar://problem/16833971>

Patch by Benjamin Poulain <​bpoulain@apple.com> on 2014-05-19
Reviewed by Simon Fraser.

When a page does not relayout, we keep the same width in view.
When a page relayout, we should keep the same relative width in view.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::isResponsiveDesignWithContentLargerThanLayout):
(WebKit::WebPage::dynamicViewportSizeUpdate):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r169066 r169068  
     12014-05-19  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [iOS][WK2] When a page relayout on dynamic resize, keep the same relative width in view
     4        https://bugs.webkit.org/show_bug.cgi?id=133026
     5        <rdar://problem/16833971>
     6
     7        Reviewed by Simon Fraser.
     8
     9        When a page does not relayout, we keep the same width in view.
     10        When a page relayout, we should keep the same relative width in view.
     11
     12        * WebProcess/WebPage/ios/WebPageIOS.mm:
     13        (WebKit::isResponsiveDesignWithContentLargerThanLayout):
     14        (WebKit::WebPage::dynamicViewportSizeUpdate):
     15
    1162014-05-19  Benjamin Poulain  <benjamin@webkit.org>
    217
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r169064 r169068  
    19421942
    19431943    RefPtr<Node> oldNodeAtCenter;
     1944    double visibleHorizontalFraction = 1;
    19441945    float relativeHorizontalPositionInNodeAtCenter = 0;
    19451946    float relativeVerticalPositionInNodeAtCenter = 0;
    19461947    {
    19471948        IntRect unobscuredContentRect = frameView.unobscuredContentRect();
     1949        visibleHorizontalFraction = static_cast<float>(unobscuredContentRect.width()) / oldContentSize.width();
    19481950        IntPoint unobscuredContentRectCenter = unobscuredContentRect.center();
    19491951
    … …  
    19781980    else
    19791981        scale = std::max(std::min(targetScale, m_viewportConfiguration.maximumScale()), m_viewportConfiguration.minimumScale());
     1982
     1983    if (m_userHasChangedPageScaleFactor && newContentSize.width() != oldContentSize.width()) {
     1984        // When the content size change, we keep the same relative horizontal content width in view, otherwise we would
     1985        // end up zoom to far in landscape->portrait, and too close in portrait->landscape.
     1986        float widthToKeepInView = visibleHorizontalFraction * newContentSize.width();
     1987        double newScale = targetUnobscuredRectInScrollViewCoordinates.width() / widthToKeepInView;
     1988        scale = std::max(std::min(newScale, m_viewportConfiguration.maximumScale()), m_viewportConfiguration.minimumScale());
     1989    }
    19801990
    19811991    FloatRect newUnobscuredContentRect = targetUnobscuredRect;
Note: See TracChangeset for help on using the changeset viewer.