Changeset 67771 in webkit


Ignore:
Timestamp:
Sep 17, 2010 7:13:48 PM (14 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=45993, convert printing to the new pagination model.

Reviewed by Simon Fraser.

WebCore:

Make printing store the page height in the RenderView and push that into the layout state to
use the new pagination model. The old pagination model is retained because it is still used
for embedded WebViews.

  • page/FrameView.cpp:

(WebCore::FrameView::reset):
(WebCore::FrameView::layout):
(WebCore::FrameView::forceLayout):
(WebCore::FrameView::forceLayoutForPagination):
(WebCore::FrameView::adjustPageHeight):

  • page/FrameView.h:
  • page/PrintContext.cpp:

(WebCore::PrintContext::computePageRectsWithPageSizeInternal):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::paintChildren):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::calcHeight):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::paintReplaced):

  • rendering/RenderLineBoxList.cpp:

(WebCore::RenderLineBoxList::paint):

  • rendering/RenderVideo.cpp:

(WebCore::RenderVideo::paintReplaced):

  • rendering/RenderView.cpp:

(WebCore::RenderView::RenderView):
(WebCore::RenderView::layout):
(WebCore::RenderView::paint):
(WebCore::RenderView::setBestTruncatedAt):

  • rendering/RenderView.h:

(WebCore::RenderView::popLayoutState):
(WebCore::RenderView::pageHeight):
(WebCore::RenderView::setPageHeight):
(WebCore::RenderView::bestTruncatedAt):
(WebCore::RenderView::truncatedAt):
(WebCore::RenderView::setTruncatedAt):
(WebCore::RenderView::printRect):
(WebCore::RenderView::setPrintRect):
(WebCore::RenderView::pushLayoutState):
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):
(WebCore::LayoutStateMaintainer::pop):

WebKit/mac:

Make printing store the page height in the RenderView and push that into the layout state to
use the new pagination model. The old pagination model is retained because it is still used
for embedded WebViews.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _adjustedBottomOfPageWithTop:bottom:limit:]):

LayoutTests:

Remove the overflow test, since the new model treats overflow:auto/scroll as unsplittable.

  • printing/page-break-always-for-overflow-expected.txt: Removed.
  • printing/page-break-always-for-overflow.html: Removed.
Location:
trunk
Files:
2 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r67770 r67771  
     12010-09-17  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=45993, convert printing to the new pagination model.
     6
     7        Remove the overflow test, since the new model treats overflow:auto/scroll as unsplittable.
     8
     9        * printing/page-break-always-for-overflow-expected.txt: Removed.
     10        * printing/page-break-always-for-overflow.html: Removed.
     11
    1122010-09-17  Dan Bernstein  <mitz@apple.com>
    213
  • trunk/LayoutTests/platform/mac/printing/media-queries-print-expected.txt

    r64409 r67771  
    1 layer at (0,0) size 1000x600
    2   RenderView at (0,0) size 1000x600
    3 layer at (0,0) size 1000x600
    4   RenderBlock {HTML} at (0,0) size 1000x600
    5     RenderBody {BODY} at (8,8) size 984x584
     1layer at (0,0) size 1000x134
     2  RenderView at (0,0) size 1000x134
     3layer at (0,0) size 1000x134
     4  RenderBlock {HTML} at (0,0) size 1000x134
     5    RenderBody {BODY} at (8,8) size 984x118
    66      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
    77      RenderBlock (anonymous) at (0,100) size 984x18
  • trunk/LayoutTests/printing/page-break-margin-collapsed-expected.txt

    r64409 r67771  
    66
    77PASS: page number of "page1" is 1
    8 FAIL: expected page number of "page2" is 2. Was 134
     8PASS: page number of "page2" is 2
     9All tests passed
    910
    1011PASS successfullyParsed is true
  • trunk/WebCore/ChangeLog

    r67770 r67771  
     12010-09-17  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=45993, convert printing to the new pagination model.
     6
     7        Make printing store the page height in the RenderView and push that into the layout state to
     8        use the new pagination model.  The old pagination model is retained because it is still used
     9        for embedded WebViews.
     10
     11        * page/FrameView.cpp:
     12        (WebCore::FrameView::reset):
     13        (WebCore::FrameView::layout):
     14        (WebCore::FrameView::forceLayout):
     15        (WebCore::FrameView::forceLayoutForPagination):
     16        (WebCore::FrameView::adjustPageHeight):
     17        * page/FrameView.h:
     18        * page/PrintContext.cpp:
     19        (WebCore::PrintContext::computePageRectsWithPageSizeInternal):
     20        * rendering/RenderBlock.cpp:
     21        (WebCore::RenderBlock::paintChildren):
     22        * rendering/RenderBox.cpp:
     23        (WebCore::RenderBox::calcHeight):
     24        * rendering/RenderImage.cpp:
     25        (WebCore::RenderImage::paintReplaced):
     26        * rendering/RenderLineBoxList.cpp:
     27        (WebCore::RenderLineBoxList::paint):
     28        * rendering/RenderVideo.cpp:
     29        (WebCore::RenderVideo::paintReplaced):
     30        * rendering/RenderView.cpp:
     31        (WebCore::RenderView::RenderView):
     32        (WebCore::RenderView::layout):
     33        (WebCore::RenderView::paint):
     34        (WebCore::RenderView::setBestTruncatedAt):
     35        * rendering/RenderView.h:
     36        (WebCore::RenderView::popLayoutState):
     37        (WebCore::RenderView::pageHeight):
     38        (WebCore::RenderView::setPageHeight):
     39        (WebCore::RenderView::bestTruncatedAt):
     40        (WebCore::RenderView::truncatedAt):
     41        (WebCore::RenderView::setTruncatedAt):
     42        (WebCore::RenderView::printRect):
     43        (WebCore::RenderView::setPrintRect):
     44        (WebCore::RenderView::pushLayoutState):
     45        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
     46        (WebCore::LayoutStateMaintainer::push):
     47        (WebCore::LayoutStateMaintainer::pop):
     48
    1492010-09-17  Dan Bernstein  <mitz@apple.com>
    250
  • trunk/WebCore/WebCore.exp.in

    r67762 r67771  
    769769__ZN7WebCore9FrameView14setTransparentEb
    770770__ZN7WebCore9FrameView15setMarginHeightEi
    771 __ZN7WebCore9FrameView16adjustPageHeightEPffff
     771__ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff
    772772__ZN7WebCore9FrameView16setPaintBehaviorEj
    773773__ZN7WebCore9FrameView18updateControlTintsEv
  • trunk/WebCore/page/FrameView.cpp

    r67762 r67771  
    206206    m_lastLayoutSize = IntSize();
    207207    m_lastZoomFactor = 1.0f;
    208     m_pageHeight = 0;
    209208    m_deferringRepaints = 0;
    210209    m_repaintCount = 0;
     
    771770    if (subtree) {
    772771        RenderView* view = root->view();
    773         view->popLayoutState();
     772        view->popLayoutState(root);
    774773        if (disableLayoutState)
    775774            view->enableLayoutState();
     
    20772076{
    20782077    layout(allowSubtree);
    2079     // We cannot unschedule a pending relayout, since the force can be called with
    2080     // a tiny rectangle from a drawRect update.  By unscheduling we in effect
    2081     // "validate" and stop the necessary full repaint from occurring.  Basically any basic
    2082     // append/remove DHTML is broken by this call.  For now, I have removed the optimization
    2083     // until we have a better invalidation stategy. -dwh
    2084     //unscheduleRelayout();
    20852078}
    20862079
     
    20922085    if (root) {
    20932086        int pageW = ceilf(pageSize.width());
    2094         m_pageHeight = pageSize.height() ? pageSize.height() : visibleHeight();
    20952087        root->setWidth(pageW);
     2088        root->setPageHeight(pageSize.height());
    20962089        root->setNeedsLayoutAndPrefWidthsRecalc();
    20972090        forceLayout();
     
    21052098            pageW = std::min<int>(rightmostPos, ceilf(pageSize.width() * maximumShrinkFactor));
    21062099            if (pageSize.height())
    2107                 m_pageHeight = pageW / pageSize.width() * pageSize.height();
     2100                root->setPageHeight(pageW / pageSize.width() * pageSize.height());
    21082101            root->setWidth(pageW);
    21092102            root->setNeedsLayoutAndPrefWidthsRecalc();
     
    21142107    if (shouldAdjustViewSize)
    21152108        adjustViewSize();
    2116     m_pageHeight = 0;
    2117 }
    2118 
    2119 void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/)
     2109}
     2110
     2111void FrameView::adjustPageHeightDeprecated(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/)
    21202112{
    21212113    RenderView* root = m_frame->contentRenderer();
     
    21252117        root->setTruncatedAt((int)floorf(oldBottom));
    21262118        IntRect dirtyRect(0, (int)floorf(oldTop), root->rightLayoutOverflow(), (int)ceilf(oldBottom - oldTop));
     2119        root->setPrintRect(dirtyRect);
    21272120        root->layer()->paint(&context, dirtyRect);
    21282121        *newBottom = root->bestTruncatedAt();
    21292122        if (*newBottom == 0)
    21302123            *newBottom = oldBottom;
     2124        root->setPrintRect(IntRect());
    21312125    } else
    21322126        *newBottom = oldBottom;
  • trunk/WebCore/page/FrameView.h

    r67762 r67771  
    201201    void forceLayout(bool allowSubtree = false);
    202202    void forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot);
    203     int pageHeight() const { return m_pageHeight; }
    204 
    205     void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
     203
     204    // FIXME: This method is retained because of embedded WebViews in AppKit.  When a WebView is embedded inside
     205    // some enclosing view with auto-pagination, no call happens to resize the view.  The new pagination model
     206    // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
     207    // resize around that view.  Auto-pagination uses the bounds of the actual view that's being printed to determine
     208    // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
     209    // web document's bounds.
     210    //
     211    // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
     212    // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
     213    // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
     214    // page size, it can't actually paginate correctly during _layoutForPrinting.
     215    //
     216    // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
     217    // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
     218    //
     219    // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
     220    void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
    206221
    207222    bool scrollToFragment(const KURL&);
     
    331346    String m_mediaTypeWhenNotPrinting;
    332347
    333     int m_pageHeight;
    334 
    335348    unsigned m_enqueueEvents;
    336349    Vector<ScheduledEvent*> m_scheduledEvents;
  • trunk/WebCore/page/PrintContext.cpp

    r65137 r67771  
    9696    if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer())
    9797        return;
     98
    9899    RenderView* root = toRenderView(m_frame->document()->renderer());
    99100
    100     const float pageWidth = pageSizeInPixels.width();
    101     const float docWidth = root->layer()->width();
    102     const float docHeight = root->layer()->height();
    103     float currPageHeight = pageSizeInPixels.height();
    104 
    105     // always return at least one page, since empty files should print a blank page
    106     float printedPagesHeight = 0;
    107     do {
    108         float proposedBottom = std::min(docHeight, printedPagesHeight + pageSizeInPixels.height());
    109         m_frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight);
    110         currPageHeight = max(1.0f, proposedBottom - printedPagesHeight);
     101    int docWidth = root->layer()->width();
     102    int docHeight = root->layer()->height();
     103    int pageWidth = pageSizeInPixels.width();
     104    int pageHeight = pageSizeInPixels.height();
     105
     106    unsigned pageCount = ceilf((float)docHeight / pageHeight);
     107    for (unsigned i = 0; i < pageCount; ++i) {
    111108        if (allowHorizontalMultiPages) {
    112             for (float curWidth = 0; curWidth < docWidth; curWidth += pageWidth)
    113                 m_pageRects.append(IntRect(curWidth, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight));
     109            for (int currWidth = 0; currWidth < docWidth; currWidth += pageWidth)
     110                m_pageRects.append(IntRect(currWidth, i * pageHeight, pageWidth, pageHeight));
    114111        } else
    115             m_pageRects.append(IntRect(0, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight));
    116         printedPagesHeight += currPageHeight;
    117     } while (printedPagesHeight < docHeight);
     112            m_pageRects.append(IntRect(0, i * pageHeight, pageWidth, pageHeight));
     113    }
    118114}
    119115
  • trunk/WebCore/rendering/RenderBlock.cpp

    r67673 r67771  
    22092209    info.updatePaintingRootForChildren(this);
    22102210   
     2211    // FIXME: Paint-time pagination is obsolete and is now only used by embedded WebViews inside AppKit
     2212    // NSViews.  Do not add any more code for this.
    22112213    RenderView* renderView = view();
    22122214    bool usePrintRect = !renderView->printRect().isEmpty();
    22132215   
    2214     bool checkPageBreaks = document()->paginated() && !document()->settings()->paginateDuringLayoutEnabled();
    2215 
    22162216    for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {       
    22172217        // Check for page-break-before: always, and if it's set, break and bail.
    2218         bool checkBeforeAlways = !childrenInline() && (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS);
     2218        bool checkBeforeAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakBefore() == PBALWAYS);
    22192219        if (checkBeforeAlways
    22202220            && (ty + child->y()) > paintInfo.rect.y()
     
    22392239
    22402240        // Check for page-break-after: always, and if it's set, break and bail.
    2241         bool checkAfterAlways = !childrenInline() && (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS);
     2241        bool checkAfterAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakAfter() == PBALWAYS);
    22422242        if (checkAfterAlways
    22432243            && (ty + child->y() + child->height()) > paintInfo.rect.y()
     
    59085908    // FIXME: Add page break checking here when we support printing.
    59095909    bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
    5910     bool checkBeforeAlways = checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS;
     5910    bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageHeight; // FIXME: Once columns can print we have to check this.
     5911    bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS);
    59115912    if (checkBeforeAlways && inNormalFlow(child)) {
    59125913        if (checkColumnBreaks)
     
    59215922    // FIXME: Add page break checking here when we support printing.
    59225923    bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
    5923     bool checkAfterAlways = checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS;
     5924    bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageHeight; // FIXME: Once columns can print we have to check this.
     5925    bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS);
    59245926    if (checkAfterAlways && inNormalFlow(child)) {
    59255927        marginInfo.setBottomQuirk(true); // Cause margins to be discarded for any following content.
  • trunk/WebCore/rendering/RenderBox.cpp

    r67660 r67771  
    15161516    // height since we don't set a height in RenderView when we're printing. So without this quirk, the
    15171517    // height has nothing to be a percentage of, and it ends up being 0. That is bad.
    1518     bool paginatedContentNeedsBaseHeight = document()->paginated() && h.isPercent()
     1518    bool paginatedContentNeedsBaseHeight = document()->printing() && h.isPercent()
    15191519        && (isRoot() || (isBody() && document()->documentElement()->renderer()->style()->height().isPercent()));
    15201520    if (stretchesToViewHeight() || paginatedContentNeedsBaseHeight) {
    15211521        int margins = collapsedMarginTop() + collapsedMarginBottom();
    1522         int visHeight = document()->printing() ? view()->frameView()->pageHeight() : view()->viewHeight();
     1522        int visHeight = document()->printing() ? view()->pageHeight() : view()->viewHeight();
    15231523        if (isRoot())
    15241524            setHeight(max(height(), visHeight - margins));
  • trunk/WebCore/rendering/RenderImage.cpp

    r67770 r67771  
    215215    int topPad = paddingTop();
    216216
    217     if (document()->printing() && !view()->printImages())
    218         return;
    219 
    220217    GraphicsContext* context = paintInfo.context;
    221218
  • trunk/WebCore/rendering/RenderLineBoxList.cpp

    r67660 r67771  
    160160        return;
    161161
     162    // FIXME: Paint-time pagination is obsolete and is now only used by embedded WebViews inside AppKit
     163    // NSViews.  Do not add any more code for this.
    162164    RenderView* v = renderer->view();
    163165    bool usePrintRect = !v->printRect().isEmpty();
  • trunk/WebCore/rendering/RenderVideo.cpp

    r67770 r67771  
    189189    bool displayingPoster = videoElement()->shouldDisplayPosterImage();
    190190
    191     if (displayingPoster && document()->printing() && !view()->printImages())
    192         return;
    193 
    194191    if (!displayingPoster) {
    195192        if (!mediaPlayer)
  • trunk/WebCore/rendering/RenderView.cpp

    r67762 r67771  
    4949    , m_selectionStartPos(-1)
    5050    , m_selectionEndPos(-1)
    51     , m_printImages(true)
    5251    , m_maximalOutlineSize(0)
    53     , m_bestTruncatedAt(0)
    54     , m_truncatorWidth(0)
    55     , m_forcedPageBreak(false)
     52    , m_pageHeight(0)
    5653    , m_layoutState(0)
    5754    , m_layoutStateDisableCount(0)
     
    10198void RenderView::layout()
    10299{
     100    if (!document()->paginated())
     101        setPageHeight(0);
     102
    103103    if (printing())
    104104        m_minPrefWidth = m_maxPrefWidth = width();
     
    118118    // FIXME: May be better to push a clip and avoid issuing offscreen repaints.
    119119    state.m_clipped = false;
     120    state.m_pageHeight = m_pageHeight;
    120121    m_layoutState = &state;
    121122
     
    126127    m_overflow.clear();
    127128    addLayoutOverflow(IntRect(0, 0, docWidth(), docHeight()));
    128 
    129129
    130130    ASSERT(layoutDelta() == IntSize());
     
    155155    // If we ever require layout but receive a paint anyway, something has gone horribly wrong.
    156156    ASSERT(!needsLayout());
    157 
    158     // Cache the print rect because the dirty rect could get changed during painting.
    159     if (document()->paginated())
    160         setPrintRect(paintInfo.rect);
    161     else
    162         setPrintRect(IntRect());
    163157    paintObject(paintInfo, tx, ty);
    164158}
     
    669663}
    670664
    671 // The idea here is to take into account what object is moving the pagination point, and
    672 // thus choose the best place to chop it.
    673 void RenderView::setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak)
    674 {
    675     // Nobody else can set a page break once we have a forced break.
    676     if (m_forcedPageBreak)
    677         return;
    678 
    679     // Forced breaks always win over unforced breaks.
    680     if (forcedBreak) {
    681         m_forcedPageBreak = true;
    682         m_bestTruncatedAt = y;
    683         return;
    684     }
    685 
    686     // Prefer the widest object that tries to move the pagination point
    687     IntRect boundingBox = forRenderer->borderBoundingBox();
    688     if (boundingBox.width() > m_truncatorWidth) {
    689         m_truncatorWidth = boundingBox.width();
    690         m_bestTruncatedAt = y;
    691     }
    692 }
    693 
    694665void RenderView::pushLayoutState(RenderObject* root)
    695666{
     
    725696}
    726697
     698// FIXME: This function is obsolete and only used by embedded WebViews inside AppKit NSViews.
     699// Do not add callers of this function!
     700// The idea here is to take into account what object is moving the pagination point, and
     701// thus choose the best place to chop it.
     702void RenderView::setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak)
     703{
     704    // Nobody else can set a page break once we have a forced break.
     705    if (m_legacyPrinting.m_forcedPageBreak)
     706        return;
     707
     708    // Forced breaks always win over unforced breaks.
     709    if (forcedBreak) {
     710        m_legacyPrinting.m_forcedPageBreak = true;
     711        m_legacyPrinting.m_bestTruncatedAt = y;
     712        return;
     713    }
     714
     715    // Prefer the widest object that tries to move the pagination point
     716    IntRect boundingBox = forRenderer->borderBoundingBox();
     717    if (boundingBox.width() > m_legacyPrinting.m_truncatorWidth) {
     718        m_legacyPrinting.m_truncatorWidth = boundingBox.width();
     719        m_legacyPrinting.m_bestTruncatedAt = y;
     720    }
     721}
     722
    727723#if USE(ACCELERATED_COMPOSITING)
    728724bool RenderView::usesCompositing() const
  • trunk/WebCore/rendering/RenderView.h

    r67660 r67771  
    7878
    7979    bool printing() const;
    80     void setPrintImages(bool enable) { m_printImages = enable; }
    81     bool printImages() const { return m_printImages; }
    82 
    83     IntRect printRect() const { return m_printRect; }
    84     void setPrintRect(const IntRect& r) { m_printRect = r; }
    85 
    86     void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; m_forcedPageBreak = false; }
    87     void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false);
    88     int bestTruncatedAt() const { return m_bestTruncatedAt; }
    89    
    90     int truncatedAt() const { return m_truncatedAt; }
    9180
    9281    virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
     
    121110    bool doingFullRepaint() const { return m_frameView->needsFullRepaint(); }
    122111
    123     void pushLayoutState(RenderBox* renderer, const IntSize& offset, int pageHeight = 0, ColumnInfo* colInfo = 0)
    124     {
    125         // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
    126         if (!doingFullRepaint() || renderer->hasColumns() || m_layoutState->isPaginated())
    127             m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, colInfo);
    128     }
    129 
     112    // Subtree push/pop
    130113    void pushLayoutState(RenderObject*);
    131 
    132     void popLayoutState()
    133     {
    134         LayoutState* state = m_layoutState;
    135         if (doingFullRepaint() && !m_layoutState->isPaginated())
    136             return;
    137         m_layoutState = state->m_next;
    138         state->destroy(renderArena());
    139     }
     114    void popLayoutState(RenderObject*) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical.
    140115
    141116    bool shouldDisableLayoutStateForSubtree(RenderObject*) const;
     
    154129    virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
    155130
     131    unsigned pageHeight() const { return m_pageHeight; }
     132    void setPageHeight(unsigned height)
     133    {
     134        if (m_pageHeight != height) {
     135            m_pageHeight = height;
     136            markDescendantBlocksAndLinesForLayout();
     137        }
     138    }
     139
     140    // FIXME: These functions are deprecated. No code should be added that uses these.
     141    int bestTruncatedAt() const { return m_legacyPrinting.m_bestTruncatedAt; }
     142    void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false);
     143    int truncatedAt() const { return m_legacyPrinting.m_truncatedAt; }
     144    void setTruncatedAt(int y)
     145    {
     146        m_legacyPrinting.m_truncatedAt = y;
     147        m_legacyPrinting.m_bestTruncatedAt = 0;
     148        m_legacyPrinting.m_truncatorWidth = 0;
     149        m_legacyPrinting.m_forcedPageBreak = false;
     150    }
     151    const IntRect& printRect() const { return m_legacyPrinting.m_printRect; }
     152    void setPrintRect(const IntRect& r) { m_legacyPrinting.m_printRect = r; }
     153    // End deprecated functions.
     154
    156155    // Notifications that this view became visible in a window, or will be
    157156    // removed from the window.
     
    174173    int docWidth() const;
    175174
     175    // These functions may only be accessed by LayoutStateMaintainer.
     176    bool pushLayoutState(RenderBox* renderer, const IntSize& offset, int pageHeight = 0, ColumnInfo* colInfo = 0)
     177    {
     178        // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
     179        if (!doingFullRepaint() || renderer->hasColumns() || m_layoutState->isPaginated()) {
     180            m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, colInfo);
     181            return true;
     182        }
     183        return false;
     184    }
     185
     186    void popLayoutState()
     187    {
     188        LayoutState* state = m_layoutState;
     189        m_layoutState = state->m_next;
     190        state->destroy(renderArena());
     191    }
     192   
     193    friend class LayoutStateMaintainer;
     194       
    176195protected:
    177196    FrameView* m_frameView;
     
    182201    int m_selectionEndPos;
    183202
    184     // used to ignore viewport width when printing to the printer
    185     bool m_printImages;
    186     int m_truncatedAt;
     203    // FIXME: Only used by embedded WebViews inside AppKit NSViews.  Find a way to remove.
     204    struct LegacyPrinting {
     205        LegacyPrinting()
     206            : m_bestTruncatedAt(0)
     207            , m_truncatedAt(0)
     208            , m_truncatorWidth(0)
     209            , m_forcedPageBreak(false)
     210        { }
     211
     212        int m_bestTruncatedAt;
     213        int m_truncatedAt;
     214        int m_truncatorWidth;
     215        IntRect m_printRect;
     216        bool m_forcedPageBreak;
     217    };
     218    LegacyPrinting m_legacyPrinting;
     219    // End deprecated members.
    187220
    188221    int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
    189     IntRect m_printRect; // Used when printing.
    190222
    191223    typedef HashSet<RenderWidget*> RenderWidgetSet;
    192 
    193224    RenderWidgetSet m_widgets;
    194 
     225   
    195226private:
    196     int m_bestTruncatedAt;
    197     int m_truncatorWidth;
    198     bool m_forcedPageBreak;
     227    unsigned m_pageHeight;
    199228    LayoutState* m_layoutState;
    200229    unsigned m_layoutStateDisableCount;
     
    229258        , m_didStart(false)
    230259        , m_didEnd(false)
     260        , m_didCreateLayoutState(false)
    231261    {
    232262        push(root, offset, pageHeight, colInfo);
     
    239269        , m_didStart(false)
    240270        , m_didEnd(false)
     271        , m_didCreateLayoutState(false)
    241272    {
    242273    }
     
    251282        ASSERT(!m_didStart);
    252283        // We push state even if disabled, because we still need to store layoutDelta
    253         m_view->pushLayoutState(root, offset, pageHeight, colInfo);
    254         if (m_disabled)
     284        m_didCreateLayoutState = m_view->pushLayoutState(root, offset, pageHeight, colInfo);
     285        if (m_disabled && m_didCreateLayoutState)
    255286            m_view->disableLayoutState();
    256287        m_didStart = true;
     
    261292        if (m_didStart) {
    262293            ASSERT(!m_didEnd);
    263             m_view->popLayoutState();
    264             if (m_disabled)
    265                 m_view->enableLayoutState();
     294            if (m_didCreateLayoutState) {
     295                m_view->popLayoutState();
     296                if (m_disabled)
     297                    m_view->enableLayoutState();
     298            }
     299           
    266300            m_didEnd = true;
    267301        }
     
    275309    bool m_didStart : 1;        // true if we did a push or disable
    276310    bool m_didEnd : 1;          // true if we popped or re-enabled
     311    bool m_didCreateLayoutState : 1; // true if we actually made a layout state.
    277312};
    278313
  • trunk/WebKit/mac/ChangeLog

    r67762 r67771  
     12010-09-17  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=45993, convert printing to the new pagination model.
     6
     7        Make printing store the page height in the RenderView and push that into the layout state to
     8        use the new pagination model.  The old pagination model is retained because it is still used
     9        for embedded WebViews.
     10
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _adjustedBottomOfPageWithTop:bottom:limit:]):
     13
    1142010-09-17  Darin Adler  <darin@apple.com>
    215
  • trunk/WebKit/mac/WebView/WebHTMLView.mm

    r67691 r67771  
    23032303
    23042304    float newBottom;
    2305     view->adjustPageHeight(&newBottom, top, bottom, bottomLimit);
     2305    view->adjustPageHeightDeprecated(&newBottom, top, bottom, bottomLimit);
    23062306
    23072307#ifdef __LP64__
Note: See TracChangeset for help on using the changeset viewer.