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

Changeset 219121 in webkit


Ignore:
Timestamp:
Jul 4, 2017, 10:58:36 AM (9 years ago)
Author:
Antti Koivisto
Message:

FrameView should not set RenderView::logicalWidth directly for printing
​https://bugs.webkit.org/show_bug.cgi?id=174135

Reviewed by Zalan Bujtas.

Source/WebCore:

Renderer logicalWidth should be set by layout. Direct override by RenderView when printing means
that we don't layout children in all cases when the width changes. This is currently mostly hidden
by spurious layouts but causes problems when trying to fix other things that reduces those.

  • page/FrameView.cpp:

(WebCore::FrameView::forceLayoutForPagination):

Instead of calling setLogicalWidth directly call the new setPageLogicalSize that sets both the width
and the height uniformly.

  • rendering/RenderView.cpp:

(WebCore::RenderView::updateLogicalWidth):

Use pageLogicalSize->width() in printing state instead of skipping the logical width update entirely.
This ensures that the layout will progress to children when the page logical width changes.

(WebCore::RenderView::initializeLayoutState):
(WebCore::RenderView::layout):
(WebCore::RenderView::pageOrViewLogicalHeight):
(WebCore::RenderView::setPageLogicalSize):

  • rendering/RenderView.h:

Replace the existing m_pageLogicalHeight with std::optional m_pageLogicalSize.

LayoutTests:

  • platform/mac/printing/width-overflow-expected.txt:

This is a progression, view and root element sizes now match.
Printing output is not affected.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219114 r219121  
     12017-07-04  Antti Koivisto  <antti@apple.com>
     2
     3        FrameView should not set RenderView::logicalWidth directly for printing
     4        https://bugs.webkit.org/show_bug.cgi?id=174135
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * platform/mac/printing/width-overflow-expected.txt:
     9
     10            This is a progression, view and root element sizes now match.
     11            Printing output is not affected.
     12
    1132017-07-03  Saam Barati  <sbarati@apple.com>
    214
  • trunk/LayoutTests/platform/mac/printing/width-overflow-expected.txt

    r177774 r219121  
    11layer at (0,0) size 1300x2284
    22  RenderView at (0,0) size 1300x2284
    3 layer at (0,0) size 981x2284
    4   RenderBlock {HTML} at (0,0) size 981x2284
    5     RenderBody {BODY} at (0,16) size 981x2252
    6       RenderBlock {P} at (0,0) size 981x18
     3layer at (0,0) size 1300x2284
     4  RenderBlock {HTML} at (0,0) size 1300x2284
     5    RenderBody {BODY} at (0,16) size 1300x2252
     6      RenderBlock {P} at (0,0) size 1300x18
    77        RenderText {#text} at (0,0) size 765x18
    88          text run at (0,0) width 765: "To run this test manually, print this page. If the right side of any lines is printed without being truncated, the test passes."
  • trunk/Source/WebCore/ChangeLog

    r219116 r219121  
     12017-07-04  Antti Koivisto  <antti@apple.com>
     2
     3        FrameView should not set RenderView::logicalWidth directly for printing
     4        https://bugs.webkit.org/show_bug.cgi?id=174135
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Renderer logicalWidth should be set by layout. Direct override by RenderView when printing means
     9        that we don't layout children in all cases when the width changes. This is currently mostly hidden
     10        by spurious layouts but causes problems when trying to fix other things that reduces those.
     11
     12        * page/FrameView.cpp:
     13        (WebCore::FrameView::forceLayoutForPagination):
     14
     15            Instead of calling setLogicalWidth directly call the new setPageLogicalSize that sets both the width
     16            and the height uniformly.
     17
     18        * rendering/RenderView.cpp:
     19        (WebCore::RenderView::updateLogicalWidth):
     20
     21            Use pageLogicalSize->width() in printing state instead of skipping the logical width update entirely.
     22            This ensures that the layout will progress to children when the page logical width changes.
     23
     24        (WebCore::RenderView::initializeLayoutState):
     25        (WebCore::RenderView::layout):
     26        (WebCore::RenderView::pageOrViewLogicalHeight):
     27        (WebCore::RenderView::setPageLogicalSize):
     28        * rendering/RenderView.h:
     29
     30            Replace the existing m_pageLogicalHeight with std::optional m_pageLogicalSize.
     31
    1322017-07-04  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    233
  • trunk/Source/WebCore/page/FrameView.cpp

    r219108 r219121  
    46774677        float pageLogicalHeight = renderView->style().isHorizontalWritingMode() ? pageSize.height() : pageSize.width();
    46784678
    4679         renderView->setLogicalWidth(floor(pageLogicalWidth));
    4680         renderView->setPageLogicalHeight(floor(pageLogicalHeight));
     4679        renderView->setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
    46814680        renderView->setNeedsLayoutAndPrefWidthsRecalc();
    46824681        forceLayout();
    … …  
    46964695            pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
    46974696
    4698             renderView->setLogicalWidth(floor(pageLogicalWidth));
    4699             renderView->setPageLogicalHeight(floor(pageLogicalHeight));
     4697            renderView->setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
    47004698            renderView->setNeedsLayoutAndPrefWidthsRecalc();
    47014699            forceLayout();
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r218480 r219121  
    218218void RenderView::updateLogicalWidth()
    219219{
    220     if (!shouldUsePrintingLayout())
    221         setLogicalWidth(viewLogicalWidth());
     220    setLogicalWidth(shouldUsePrintingLayout() ? m_pageLogicalSize->width() : LayoutUnit(viewLogicalWidth()));
    222221}
    223222
    … …  
    269268    state.m_clipped = false;
    270269
    271     state.m_pageLogicalHeight = m_pageLogicalHeight;
     270    state.m_pageLogicalHeight = m_pageLogicalSize ? m_pageLogicalSize->height() : LayoutUnit(0);
    272271    state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged;
    273272    ASSERT(state.m_pageLogicalHeight >= 0);
    … …  
    340339    StackStats::LayoutCheckPoint layoutCheckPoint;
    341340    if (!document().paginated())
    342         setPageLogicalHeight(0);
    343 
    344     if (shouldUsePrintingLayout())
    345         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth();
     341        m_pageLogicalSize = { };
     342
     343    if (shouldUsePrintingLayout()) {
     344        ASSERT(m_pageLogicalSize);
     345        m_minPreferredLogicalWidth = m_pageLogicalSize->width();
     346        m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth;
     347    }
    346348
    347349    // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account.
    … …  
    387389{
    388390    if (document().printing())
    389         return pageLogicalHeight();
     391        return m_pageLogicalSize->height();
    390392   
    391393    if (multiColumnFlowThread() && !style().hasInlineColumnAxis()) {
    … …  
    12201222}
    12211223
     1224void RenderView::setPageLogicalSize(LayoutSize size)
     1225{
     1226    if (!m_pageLogicalSize || m_pageLogicalSize->height() != size.height())
     1227        m_pageLogicalHeightChanged = true;
     1228
     1229    m_pageLogicalSize = size;
     1230}
     1231
    12221232float RenderView::zoomFactor() const
    12231233{
  • trunk/Source/WebCore/rendering/RenderView.h

    r216001 r219121  
    142142    void updateHitTestResult(HitTestResult&, const LayoutPoint&) override;
    143143
    144     LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
    145     void setPageLogicalHeight(LayoutUnit height)
    146     {
    147         if (m_pageLogicalHeight != height) {
    148             m_pageLogicalHeight = height;
    149             m_pageLogicalHeightChanged = true;
    150         }
    151     }
     144    void setPageLogicalSize(LayoutSize);
    152145    LayoutUnit pageOrViewLogicalHeight() const;
    153146
    … …  
    372365
    373366    std::unique_ptr<ImageQualityController> m_imageQualityController;
    374     LayoutUnit m_pageLogicalHeight;
     367    std::optional<LayoutSize> m_pageLogicalSize;
    375368    bool m_pageLogicalHeightChanged { false };
    376369    std::unique_ptr<LayoutState> m_layoutState;
Note: See TracChangeset for help on using the changeset viewer.