Changeset 143256 in webkit


Ignore:
Timestamp:
Feb 18, 2013 1:20:27 PM (11 years ago)
Author:
hyatt@apple.com
Message:

Make seamless iframes paginate properly in their enclosing document's pagination context.
https://bugs.webkit.org/show_bug.cgi?id=106125
<rdar://problem/12922720> Text in iframe is clipped while printing

Reviewed by Simon Fraser.

Added new tests in fast/multicol and fast/region.

Source/WebCore:

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::clampToStartAndEndRegions):
Don't clamp when the RenderView is the containing block of an object in a RenderFlowThread.

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::containerForRepaint):
Don't attempt any repaint container antics when we're in a seamless iframe, since the ancestor
document will actually do the handoff into the flow thread.

  • rendering/RenderView.cpp:

(WebCore::enclosingSeamlessRenderer):
Heper function to test for an enclosing seamless iframe.

(WebCore::RenderView::addChild):
Subclass addChild on RenderView to properly set the inRenderFlowThread state for a seamless
child document so thta it will check regions.

(WebCore::RenderView::initializeLayoutState):
New helper method for setting up the initial layout state of a RenderView. If inside a seamless
paginated ancestor, set up the appropriate pagination information so the child document
knows about it. This method will expand to inherit info about line grids and exclusions eventually
also.

(WebCore::RenderView::layout):
Now calls initializeLayoutState to set up the layout state.

  • rendering/RenderView.h:

(WebCore::RenderView::pageLogicalHeight):
(WebCore::RenderView::setPageLogicalHeight):
(RenderView):
Fix the type of the page logical height methods to be LayoutUnit instead of unsigned.

LayoutTests:

  • fast/multicol/resources/ipad.jpg: Added.
  • fast/multicol/resources/seamless.html: Added.
  • fast/multicol/seamless-flowed-through-columns-expected.html: Added.
  • fast/multicol/seamless-flowed-through-columns.html: Added.
  • fast/regions/resources/ipad.jpg: Added.
  • fast/regions/resources/seamless.html: Added.
  • fast/regions/seamless-iframe-flowed-into-regions-expected.html: Added.
  • fast/regions/seamless-iframe-flowed-into-regions.html: Added.
Location:
trunk
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143241 r143256  
     12013-02-18  David Hyatt  <hyatt@apple.com>
     2
     3        Make seamless iframes paginate properly in their enclosing document's pagination context.
     4        https://bugs.webkit.org/show_bug.cgi?id=106125
     5        <rdar://problem/12922720> Text in iframe is clipped while printing
     6
     7        Reviewed by Simon Fraser.
     8
     9        Added new tests in fast/multicol and fast/region.
     10
     11        * fast/multicol/resources/ipad.jpg: Added.
     12        * fast/multicol/resources/seamless.html: Added.
     13        * fast/multicol/seamless-flowed-through-columns-expected.html: Added.
     14        * fast/multicol/seamless-flowed-through-columns.html: Added.
     15        * fast/regions/resources/ipad.jpg: Added.
     16        * fast/regions/resources/seamless.html: Added.
     17        * fast/regions/seamless-iframe-flowed-into-regions-expected.html: Added.
     18        * fast/regions/seamless-iframe-flowed-into-regions.html: Added.
     19
    1202013-02-17  Filip Pizlo  <fpizlo@apple.com>
    221
  • trunk/LayoutTests/platform/mac/TestExpectations

    r143110 r143256  
    446446fast/regions/style-scoped-in-flow-override-region-styling.html
    447447fast/regions/style-scoped-in-flow.html
     448
     449# seamless iframes exhibit odd repaint issues in regions and columns, but only in DumpRenderTree
     450fast/regions/seamless-iframe-flowed-into-regions.html
     451fast/multicol/seamless-flowed-through-columns.html
    448452
    449453# ENABLE(SHADOW_DOM) is disabled.
  • trunk/Source/WebCore/ChangeLog

    r143244 r143256  
     12013-02-18  David Hyatt  <hyatt@apple.com>
     2
     3        Make seamless iframes paginate properly in their enclosing document's pagination context.
     4        https://bugs.webkit.org/show_bug.cgi?id=106125
     5        <rdar://problem/12922720> Text in iframe is clipped while printing
     6
     7        Reviewed by Simon Fraser.
     8
     9        Added new tests in fast/multicol and fast/region.
     10
     11        * rendering/RenderBlock.cpp:
     12        (WebCore::RenderBlock::clampToStartAndEndRegions):
     13        Don't clamp when the RenderView is the containing block of an object in a RenderFlowThread.
     14
     15        * rendering/RenderObject.cpp:
     16        (WebCore::RenderObject::containerForRepaint):
     17        Don't attempt any repaint container antics when we're in a seamless iframe, since the ancestor
     18        document will actually do the handoff into the flow thread.
     19
     20        * rendering/RenderView.cpp:
     21        (WebCore::enclosingSeamlessRenderer):
     22        Heper function to test for an enclosing seamless iframe.
     23       
     24        (WebCore::RenderView::addChild):
     25        Subclass addChild on RenderView to properly set the inRenderFlowThread state for a seamless
     26        child document so thta it will check regions.
     27
     28        (WebCore::RenderView::initializeLayoutState):
     29        New helper method for setting up the initial layout state of a RenderView. If inside a seamless
     30        paginated ancestor, set up the appropriate pagination information so the child document
     31        knows about it. This method will expand to inherit info about line grids and exclusions eventually
     32        also.
     33
     34        (WebCore::RenderView::layout):
     35        Now calls initializeLayoutState to set up the layout state.
     36
     37        * rendering/RenderView.h:
     38        (WebCore::RenderView::pageLogicalHeight):
     39        (WebCore::RenderView::setPageLogicalHeight):
     40        (RenderView):
     41        Fix the type of the page logical height methods to be LayoutUnit instead of unsigned.
     42
    1432013-02-18  Sheriff Bot  <webkit.review.bot@gmail.com>
    244
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r143225 r143256  
    75707570RenderRegion* RenderBlock::clampToStartAndEndRegions(RenderRegion* region) const
    75717571{
    7572     ASSERT(region && inRenderFlowThread());
    7573    
     7572    ASSERT(isRenderView() || (region && inRenderFlowThread()));
     7573    if (isRenderView())
     7574        return region;
     7575
    75747576    // We need to clamp to the block, since we want any lines or blocks that overflow out of the
    75757577    // logical top or logical bottom of the block to size as though the border box in the first and
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r142956 r143256  
    12991299    if (inRenderFlowThread()) {
    13001300        RenderFlowThread* parentRenderFlowThread = enclosingRenderFlowThread();
     1301        // The ancestor document will do the reparenting when the repaint propagates further up.
     1302        // We're just a seamless child document, and we don't need to do the hacking.
     1303        if (parentRenderFlowThread && parentRenderFlowThread->document() != document())
     1304            return repaintContainer;
    13011305        // If we have already found a repaint container then we will repaint into that container only if it is part of the same
    13021306        // flow thread. Otherwise we will need to catch the repaint call and send it to the flow thread.
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r142885 r143256  
    3131#include "GraphicsContext.h"
    3232#include "HTMLFrameOwnerElement.h"
     33#include "HTMLIFrameElement.h"
    3334#include "HitTestResult.h"
    3435#include "Page.h"
     
    146147#endif
    147148
     149static RenderBox* enclosingSeamlessRenderer(Document* doc)
     150{
     151    if (!doc)
     152        return 0;
     153    Element* ownerElement = doc->seamlessParentIFrame();
     154    if (!ownerElement)
     155        return 0;
     156    return ownerElement->renderBox();
     157}
     158
     159void RenderView::addChild(RenderObject* newChild, RenderObject* beforeChild)
     160{
     161    // Seamless iframes are considered part of an enclosing render flow thread from the parent document. This is necessary for them to look
     162    // up regions in the parent document during layout.
     163    if (newChild && !newChild->isRenderFlowThread()) {
     164        RenderBox* seamlessBox = enclosingSeamlessRenderer(document());
     165        if (seamlessBox && seamlessBox->inRenderFlowThread())
     166            newChild->setInRenderFlowThread();
     167    }
     168    RenderBlock::addChild(newChild, beforeChild);
     169}
     170
     171bool RenderView::initializeLayoutState(LayoutState& state)
     172{
     173    bool isSeamlessAncestorInFlowThread = false;
     174
     175    // FIXME: May be better to push a clip and avoid issuing offscreen repaints.
     176    state.m_clipped = false;
     177   
     178    // Check the writing mode of the seamless ancestor. It has to match our document's writing mode, or we won't inherit any
     179    // pagination information.
     180    RenderBox* seamlessAncestor = enclosingSeamlessRenderer(document());
     181    LayoutState* seamlessLayoutState = seamlessAncestor ? seamlessAncestor->view()->layoutState() : 0;
     182    bool shouldInheritPagination = seamlessLayoutState && !m_pageLogicalHeight && seamlessAncestor->style()->writingMode() == style()->writingMode();
     183   
     184    state.m_pageLogicalHeight = shouldInheritPagination ? seamlessLayoutState->m_pageLogicalHeight : m_pageLogicalHeight;
     185    state.m_pageLogicalHeightChanged = shouldInheritPagination ? seamlessLayoutState->m_pageLogicalHeightChanged : m_pageLogicalHeightChanged;
     186    state.m_isPaginated = state.m_pageLogicalHeight;
     187    if (state.m_isPaginated && shouldInheritPagination) {
     188        // Set up the correct pagination offset. We can use a negative offset in order to push the top of the RenderView into its correct place
     189        // on a page. We can take the iframe's offset from the logical top of the first page and make the negative into the pagination offset within the child
     190        // view.
     191        bool isFlipped = seamlessAncestor->style()->isFlippedBlocksWritingMode();
     192        LayoutSize layoutOffset = seamlessLayoutState->layoutOffset();
     193        LayoutSize iFrameOffset(layoutOffset.width() + seamlessAncestor->x() + (!isFlipped ? seamlessAncestor->borderLeft() + seamlessAncestor->paddingLeft() :
     194            seamlessAncestor->borderRight() + seamlessAncestor->paddingRight()),
     195            layoutOffset.height() + seamlessAncestor->y() + (!isFlipped ? seamlessAncestor->borderTop() + seamlessAncestor->paddingTop() :
     196            seamlessAncestor->borderBottom() + seamlessAncestor->paddingBottom()));
     197       
     198        LayoutSize offsetDelta = seamlessLayoutState->m_pageOffset - iFrameOffset;
     199        state.m_pageOffset = offsetDelta;
     200       
     201        // Set the current render flow thread to point to our ancestor. This will allow the seamless document to locate the correct
     202        // regions when doing a layout.
     203        if (seamlessAncestor->inRenderFlowThread()) {
     204            flowThreadController()->setCurrentRenderFlowThread(seamlessAncestor->view()->flowThreadController()->currentRenderFlowThread());
     205            isSeamlessAncestorInFlowThread = true;
     206        }
     207    }
     208
     209    // FIXME: We need to make line grids and exclusions work with seamless iframes as well here. Basically all layout state information needs
     210    // to propagate here and not just pagination information.
     211    return isSeamlessAncestorInFlowThread;
     212}
     213
    148214// The algorithm to layout the flow thread content in auto height regions has to make sure
    149215// that when a two-pass layout is needed, the auto height regions always start the first
     
    204270
    205271    LayoutState state;
    206     // FIXME: May be better to push a clip and avoid issuing offscreen repaints.
    207     state.m_clipped = false;
    208     state.m_pageLogicalHeight = m_pageLogicalHeight;
    209     state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged;
    210     state.m_isPaginated = state.m_pageLogicalHeight;
     272    bool isSeamlessAncestorInFlowThread = initializeLayoutState(state);
     273
    211274    m_pageLogicalHeightChanged = false;
    212275    m_layoutState = &state;
     
    223286    m_layoutState = 0;
    224287    setNeedsLayout(false);
     288   
     289    if (isSeamlessAncestorInFlowThread)
     290        flowThreadController()->setCurrentRenderFlowThread(0);
    225291}
    226292
  • trunk/Source/WebCore/rendering/RenderView.h

    r142885 r143256  
    160160    virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
    161161
    162     unsigned pageLogicalHeight() const { return m_pageLogicalHeight; }
    163     void setPageLogicalHeight(unsigned height)
     162    LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
     163    void setPageLogicalHeight(LayoutUnit height)
    164164    {
    165165        if (m_pageLogicalHeight != height) {
     
    230230    void removeRenderCounter() { ASSERT(m_renderCounterCount > 0); m_renderCounterCount--; }
    231231    bool hasRenderCounters() { return m_renderCounterCount; }
     232   
     233    virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
    232234
    233235protected:
     
    236238    virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const;
    237239    virtual bool requiresColumns(int desiredColumnCount) const OVERRIDE;
    238 
     240   
    239241private:
     242    bool initializeLayoutState(LayoutState&);
     243
    240244    virtual void calcColumnWidth() OVERRIDE;
    241245    virtual ColumnInfo::PaginationUnit paginationUnit() const OVERRIDE;
     
    324328    bool shouldUsePrintingLayout() const;
    325329
    326     unsigned m_pageLogicalHeight;
     330    LayoutUnit m_pageLogicalHeight;
    327331    bool m_pageLogicalHeightChanged;
    328332    LayoutState* m_layoutState;
Note: See TracChangeset for help on using the changeset viewer.