Changeset 186786 in webkit


Ignore:
Timestamp:
Jul 13, 2015 3:24:10 PM (9 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
https://bugs.webkit.org/show_bug.cgi?id=146918
rdar://problem/9222837

Reviewed by Tim Horton.

Use as input to the viewport scaling algorithm a contents size from the FrameView
that takes overflow on the viewport renderer into account. This prevents unexpected
viewports scaling on pages that have content that overflows their expressed contents size,
but apply overflow to the <body>.

Source/WebCore:

  • page/FrameView.cpp:

(WebCore::FrameView::contentsSizeRespectingOverflow): Look for overflow:hidden on each axis of
the m_viewportRenderer, which is computed post-layout by calculateScrollbarModesForLayout()
and is used for scrollbar logic on OS X. Clip unscaledDocumentRect on each axis, and then
apply page scale.

  • page/FrameView.h:

Source/WebKit2:

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::mainFrameDidLayout): Use contentsSizeRespectingOverflow(),
rather than raw contentsSize(), to determine scaling.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r186780 r186786  
     12015-07-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
     4        https://bugs.webkit.org/show_bug.cgi?id=146918
     5        rdar://problem/9222837
     6
     7        Reviewed by Tim Horton.
     8
     9        Use as input to the viewport scaling algorithm a contents size from the FrameView
     10        that takes overflow on the viewport renderer into account. This prevents unexpected
     11        viewports scaling on pages that have content that overflows their expressed contents size,
     12        but apply overflow to the <body>.
     13
     14        * page/FrameView.cpp:
     15        (WebCore::FrameView::contentsSizeRespectingOverflow): Look for overflow:hidden on each axis of
     16        the m_viewportRenderer, which is computed post-layout by calculateScrollbarModesForLayout()
     17        and is used for scrollbar logic on OS X. Clip unscaledDocumentRect on each axis, and then
     18        apply page scale.
     19        * page/FrameView.h:
     20
    1212015-07-13  Brent Fulgham  <bfulgham@apple.com>
    222
  • trunk/Source/WebCore/page/FrameView.cpp

    r186486 r186786  
    618618}
    619619
     620IntSize FrameView::contentsSizeRespectingOverflow() const
     621{
     622    RenderView* renderView = this->renderView();
     623    if (!renderView || !m_viewportRenderer || !is<RenderBox>(m_viewportRenderer) || !frame().isMainFrame())
     624        return contentsSize();
     625
     626    ASSERT(frame().view() == this);
     627
     628    FloatRect contentRect = renderView->unscaledDocumentRect();
     629    RenderBox& viewportRendererBox = downcast<RenderBox>(*m_viewportRenderer);
     630
     631    if (m_viewportRenderer->style().overflowX() == OHIDDEN)
     632        contentRect.setWidth(std::min<float>(contentRect.width(), viewportRendererBox.frameRect().width()));
     633
     634    if (m_viewportRenderer->style().overflowY() == OHIDDEN)
     635        contentRect.setHeight(std::min<float>(contentRect.height(), viewportRendererBox.frameRect().height()));
     636
     637    if (renderView->hasTransform())
     638        contentRect = renderView->layer()->currentTransform().mapRect(contentRect);
     639
     640    return IntSize(contentRect.size());
     641}
     642
    620643void FrameView::applyOverflowToViewport(RenderElement* renderer, ScrollbarMode& hMode, ScrollbarMode& vMode)
    621644{
  • trunk/Source/WebCore/page/FrameView.h

    r186392 r186786  
    106106    virtual void updateContentsSize() override;
    107107
     108    WEBCORE_EXPORT IntSize contentsSizeRespectingOverflow() const;
     109
    108110    void layout(bool allowSubtree = true);
    109111    WEBCORE_EXPORT bool didFirstLayout() const;
  • trunk/Source/WebKit2/ChangeLog

    r186779 r186786  
     12015-07-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
     4        https://bugs.webkit.org/show_bug.cgi?id=146918
     5        rdar://problem/9222837
     6
     7        Reviewed by Tim Horton.
     8
     9        Use as input to the viewport scaling algorithm a contents size from the FrameView
     10        that takes overflow on the viewport renderer into account. This prevents unexpected
     11        viewports scaling on pages that have content that overflows their expressed contents size,
     12        but apply overflow to the <body>.
     13
     14        * WebProcess/WebPage/WebPage.cpp:
     15        (WebKit::WebPage::mainFrameDidLayout): Use contentsSizeRespectingOverflow(),
     16        rather than raw contentsSize(), to determine scaling.
     17
    1182015-07-13  Dan Bernstein  <mitz@apple.com>
    219
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r186712 r186786  
    35093509#if PLATFORM(IOS)
    35103510    if (FrameView* frameView = mainFrameView()) {
    3511         IntSize newContentSize = frameView->contentsSize();
     3511        IntSize newContentSize = frameView->contentsSizeRespectingOverflow();
    35123512        if (m_viewportConfiguration.contentsSize() != newContentSize) {
    35133513            m_viewportConfiguration.setContentsSize(newContentSize);
Note: See TracChangeset for help on using the changeset viewer.