Changeset 99613 in webkit


Ignore:
Timestamp:
Nov 8, 2011 1:14:55 PM (12 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/10262225> Allow RenderView to have columns
https://bugs.webkit.org/show_bug.cgi?id=71840

Source/WebCore:

Reviewed by Simon Fraser.

Tests: fast/multicol/pagination-h-horizontal-bt.html

fast/multicol/pagination-h-horizontal-tb.html
fast/multicol/pagination-h-vertical-lr.html
fast/multicol/pagination-h-vertical-rl.html
fast/multicol/pagination-v-horizontal-bt.html
fast/multicol/pagination-v-horizontal-tb.html
fast/multicol/pagination-v-vertical-lr.html
fast/multicol/pagination-v-vertical-rl.html

  • WebCore.exp.in: Export Page::setPagination() for WebCoreTestSupport.
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::styleForDocument): Set the column axis and the column gap in the
document style if the view is paginated.

  • page/Page.cpp:

(WebCore::Page::setPagination): Added this setter.

  • page/Page.h:

(WebCore::Page::Pagination::Pagination):
(WebCore::Page::pagination): Added this getter.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::requiresColumns): Added and moved some logic to here from...
(WebCore::RenderBlock::setDesiredColumnCountAndWidth): ...here.

  • rendering/RenderBlock.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintRootBoxFillLayers): Changed to use the new RenderView::backgroundRect()
instead of unscaledDocumentRect().

  • rendering/RenderView.cpp:

(WebCore::RenderView::requiresColumns): Added this override that always returns true if the view
is paginated.
(WebCore::RenderView::backgroundRect): Added. In the paginated case, returns a rectangle stretching
across all columns.

  • rendering/RenderView.h:
  • testing/Internals.cpp:

(WebCore::Internals::reset): Also reset pagination.
(WebCore::Internals::setPagination): Added this setter for testing.

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit2:

  • win/WebKit2.def: Export Page::setPagination() for WebCoreTestSupport.

LayoutTests:

Reviewed by Simon Fraser.

  • fast/multicol/pagination-h-horizontal-bt.html: Added.
  • fast/multicol/pagination-h-horizontal-tb.html: Added.
  • fast/multicol/pagination-h-vertical-lr.html: Added.
  • fast/multicol/pagination-h-vertical-rl.html: Added.
  • fast/multicol/pagination-v-horizontal-bt.html: Added.
  • fast/multicol/pagination-v-horizontal-tb.html: Added.
  • fast/multicol/pagination-v-vertical-lr.html: Added.
  • fast/multicol/pagination-v-vertical-rl.html: Added.
  • platform/mac/fast/multicol/pagination-h-horizontal-bt-expected.png: Added.
  • platform/mac/fast/multicol/pagination-h-horizontal-bt-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-h-horizontal-tb-expected.png: Added.
  • platform/mac/fast/multicol/pagination-h-horizontal-tb-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-h-vertical-lr-expected.png: Added.
  • platform/mac/fast/multicol/pagination-h-vertical-lr-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-h-vertical-rl-expected.png: Added.
  • platform/mac/fast/multicol/pagination-h-vertical-rl-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-v-horizontal-bt-expected.png: Added.
  • platform/mac/fast/multicol/pagination-v-horizontal-bt-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-v-horizontal-tb-expected.png: Added.
  • platform/mac/fast/multicol/pagination-v-horizontal-tb-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-v-vertical-lr-expected.png: Added.
  • platform/mac/fast/multicol/pagination-v-vertical-lr-expected.txt: Added.
  • platform/mac/fast/multicol/pagination-v-vertical-rl-expected.png: Added.
  • platform/mac/fast/multicol/pagination-v-vertical-rl-expected.txt: Added.
Location:
trunk
Files:
24 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r99612 r99613  
     12011-11-08  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10262225> Allow RenderView to have columns
     4        https://bugs.webkit.org/show_bug.cgi?id=71840
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/multicol/pagination-h-horizontal-bt.html: Added.
     9        * fast/multicol/pagination-h-horizontal-tb.html: Added.
     10        * fast/multicol/pagination-h-vertical-lr.html: Added.
     11        * fast/multicol/pagination-h-vertical-rl.html: Added.
     12        * fast/multicol/pagination-v-horizontal-bt.html: Added.
     13        * fast/multicol/pagination-v-horizontal-tb.html: Added.
     14        * fast/multicol/pagination-v-vertical-lr.html: Added.
     15        * fast/multicol/pagination-v-vertical-rl.html: Added.
     16        * platform/mac/fast/multicol/pagination-h-horizontal-bt-expected.png: Added.
     17        * platform/mac/fast/multicol/pagination-h-horizontal-bt-expected.txt: Added.
     18        * platform/mac/fast/multicol/pagination-h-horizontal-tb-expected.png: Added.
     19        * platform/mac/fast/multicol/pagination-h-horizontal-tb-expected.txt: Added.
     20        * platform/mac/fast/multicol/pagination-h-vertical-lr-expected.png: Added.
     21        * platform/mac/fast/multicol/pagination-h-vertical-lr-expected.txt: Added.
     22        * platform/mac/fast/multicol/pagination-h-vertical-rl-expected.png: Added.
     23        * platform/mac/fast/multicol/pagination-h-vertical-rl-expected.txt: Added.
     24        * platform/mac/fast/multicol/pagination-v-horizontal-bt-expected.png: Added.
     25        * platform/mac/fast/multicol/pagination-v-horizontal-bt-expected.txt: Added.
     26        * platform/mac/fast/multicol/pagination-v-horizontal-tb-expected.png: Added.
     27        * platform/mac/fast/multicol/pagination-v-horizontal-tb-expected.txt: Added.
     28        * platform/mac/fast/multicol/pagination-v-vertical-lr-expected.png: Added.
     29        * platform/mac/fast/multicol/pagination-v-vertical-lr-expected.txt: Added.
     30        * platform/mac/fast/multicol/pagination-v-vertical-rl-expected.png: Added.
     31        * platform/mac/fast/multicol/pagination-v-vertical-rl-expected.txt: Added.
     32
    1332011-11-08  Vineet Chaudhary  <vineet.chaudhary@motorola.com>
    234
  • trunk/Source/WebCore/ChangeLog

    r99612 r99613  
     12011-11-08  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10262225> Allow RenderView to have columns
     4        https://bugs.webkit.org/show_bug.cgi?id=71840
     5
     6        Reviewed by Simon Fraser.
     7
     8        Tests: fast/multicol/pagination-h-horizontal-bt.html
     9               fast/multicol/pagination-h-horizontal-tb.html
     10               fast/multicol/pagination-h-vertical-lr.html
     11               fast/multicol/pagination-h-vertical-rl.html
     12               fast/multicol/pagination-v-horizontal-bt.html
     13               fast/multicol/pagination-v-horizontal-tb.html
     14               fast/multicol/pagination-v-vertical-lr.html
     15               fast/multicol/pagination-v-vertical-rl.html
     16
     17        * WebCore.exp.in: Export Page::setPagination() for WebCoreTestSupport.
     18        * css/CSSStyleSelector.cpp:
     19        (WebCore::CSSStyleSelector::styleForDocument): Set the column axis and the column gap in the
     20        document style if the view is paginated.
     21        * page/Page.cpp:
     22        (WebCore::Page::setPagination): Added this setter.
     23        * page/Page.h:
     24        (WebCore::Page::Pagination::Pagination):
     25        (WebCore::Page::pagination): Added this getter.
     26        * rendering/RenderBlock.cpp:
     27        (WebCore::RenderBlock::requiresColumns): Added and moved some logic to here from...
     28        (WebCore::RenderBlock::setDesiredColumnCountAndWidth): ...here.
     29        * rendering/RenderBlock.h:
     30        * rendering/RenderBox.cpp:
     31        (WebCore::RenderBox::paintRootBoxFillLayers): Changed to use the new RenderView::backgroundRect()
     32        instead of unscaledDocumentRect().
     33        * rendering/RenderView.cpp:
     34        (WebCore::RenderView::requiresColumns): Added this override that always returns true if the view
     35        is paginated.
     36        (WebCore::RenderView::backgroundRect): Added. In the paginated case, returns a rectangle stretching
     37        across all columns.
     38        * rendering/RenderView.h:
     39        * testing/Internals.cpp:
     40        (WebCore::Internals::reset): Also reset pagination.
     41        (WebCore::Internals::setPagination): Added this setter for testing.
     42        * testing/Internals.h:
     43        * testing/Internals.idl:
     44
    1452011-11-08  Vineet Chaudhary  <vineet.chaudhary@motorola.com>
    246
  • trunk/Source/WebCore/WebCore.exp.in

    r99509 r99613  
    743743__ZN7WebCore4Page12setGroupNameERKN3WTF6StringE
    744744__ZN7WebCore4Page13rangeOfStringERKN3WTF6StringEPNS_5RangeEj
     745__ZN7WebCore4Page13setPaginationERKNS0_10PaginationE
    745746__ZN7WebCore4Page14setMediaVolumeEf
    746747__ZN7WebCore4Page15addSchedulePairEN3WTF10PassRefPtrINS_12SchedulePairEEE
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r99450 r99613  
    11621162        else
    11631163            documentStyle->setDirection(docElementRenderer->style()->direction());
     1164    }
     1165
     1166    if (frame) {
     1167        if (Page* page = frame->page()) {
     1168            const Page::Pagination& pagination = page->pagination();
     1169            if (pagination.mode != Page::Pagination::Unpaginated) {
     1170                documentStyle->setColumnAxis(pagination.mode == Page::Pagination::HorizontallyPaginated ? HorizontalColumnAxis : VerticalColumnAxis);
     1171                documentStyle->setColumnGap(pagination.gap);
     1172            }
     1173        }
    11641174    }
    11651175
  • trunk/Source/WebCore/page/Page.cpp

    r98472 r99613  
    666666}
    667667
     668void Page::setPagination(const Pagination& pagination)
     669{
     670    if (m_pagination.mode == pagination.mode && m_pagination.gap == pagination.gap)
     671        return;
     672
     673    m_pagination = pagination;
     674
     675    setNeedsRecalcStyleInAllFrames();
     676    backForward()->markPagesForFullStyleRecalc();
     677}
     678
    668679void Page::didMoveOnscreen()
    669680{
  • trunk/Source/WebCore/page/Page.h

    r97640 r99613  
    252252        void setDeviceScaleFactor(float);
    253253
     254        struct Pagination {
     255            enum Mode { Unpaginated, HorizontallyPaginated, VerticallyPaginated };
     256
     257            Pagination()
     258                : mode(Unpaginated)
     259                , gap(0)
     260            {
     261            };
     262
     263            Mode mode;
     264            unsigned gap;
     265        };
     266
     267        const Pagination& pagination() const { return m_pagination; }
     268        void setPagination(const Pagination&);
     269
    254270        // Notifications when the Page starts and stops being presented via a native window.
    255271        void didMoveOnscreen();
     
    383399        float m_deviceScaleFactor;
    384400
     401        Pagination m_pagination;
     402
    385403        bool m_javaScriptURLsAreAllowed;
    386404
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r99024 r99613  
    45074507}
    45084508
     4509bool RenderBlock::requiresColumns(int desiredColumnCount) const
     4510{
     4511    return firstChild()
     4512        && (desiredColumnCount != 1 || !style()->hasAutoColumnWidth() || !style()->hasInlineColumnAxis())
     4513        && !firstChild()->isAnonymousColumnsBlock()
     4514        && !firstChild()->isAnonymousColumnSpanBlock();
     4515}
     4516
    45094517void RenderBlock::setDesiredColumnCountAndWidth(int count, LayoutUnit width)
    45104518{
    4511     bool destroyColumns = !firstChild()
    4512                           || (count == 1 && style()->hasAutoColumnWidth() && style()->hasInlineColumnAxis())
    4513                           || firstChild()->isAnonymousColumnsBlock()
    4514                           || firstChild()->isAnonymousColumnSpanBlock();
     4519    bool destroyColumns = !requiresColumns(count);
    45154520    if (destroyColumns) {
    45164521        if (hasColumns()) {
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r99024 r99613  
    907907
    908908    bool logicalWidthChangedInRegions() const;
    909    
     909
     910    virtual bool requiresColumns(int desiredColumnCount) const;
     911
    910912public:
    911913    LayoutUnit offsetFromLogicalTopOfFirstPage() const;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r99462 r99613  
    873873    }
    874874
    875     // The background of the box generated by the root element covers the entire canvas, so just use
    876     // the RenderView's unscaledDocumentRect accessor.
    877     paintFillLayers(paintInfo, bgColor, bgLayer, view()->unscaledDocumentRect(), BackgroundBleedNone, CompositeSourceOver, bodyObject);
     875    RenderView* view = this->view();
     876    LayoutRect backgroundRect = view->backgroundRect();
     877    flipForWritingMode(backgroundRect);
     878    paintFillLayers(paintInfo, bgColor, bgLayer, backgroundRect, BackgroundBleedNone, CompositeSourceOver, bodyObject);
    878879}
    879880
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r99099 r99613  
    2222#include "RenderView.h"
    2323
     24#include "ColumnInfo.h"
    2425#include "Document.h"
    2526#include "Element.h"
     
    172173        transformState.applyTransform(t);
    173174    }
     175}
     176
     177bool RenderView::requiresColumns(int desiredColumnCount) const
     178{
     179    if (m_frameView) {
     180        if (Frame* frame = m_frameView->frame()) {
     181            if (Page* page = frame->page())
     182                return frame == page->mainFrame() && page->pagination().mode != Page::Pagination::Unpaginated;
     183        }
     184    }
     185    return RenderBlock::requiresColumns(desiredColumnCount);
    174186}
    175187
     
    681693}
    682694
     695LayoutRect RenderView::backgroundRect() const
     696{
     697    if (!hasColumns())
     698        return unscaledDocumentRect();
     699
     700    ColumnInfo* columnInfo = this->columnInfo();
     701    LayoutRect backgroundRect(0, 0, columnInfo->desiredColumnWidth(), columnInfo->columnHeight() * columnInfo->columnCount());
     702    if (!isHorizontalWritingMode())
     703        backgroundRect = backgroundRect.transposedRect();
     704    return backgroundRect;
     705}
     706
    683707IntRect RenderView::documentRect() const
    684708{
  • trunk/Source/WebCore/rendering/RenderView.h

    r99099 r99613  
    168168
    169169    IntRect unscaledDocumentRect() const;
     170    LayoutRect backgroundRect() const;
    170171
    171172    IntRect documentRect() const;
     
    191192    virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const;
    192193    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
     194    virtual bool requiresColumns(int desiredColumnCount) const OVERRIDE;
    193195
    194196private:
  • trunk/Source/WebCore/testing/Internals.cpp

    r99485 r99613  
    377377}
    378378
     379void Internals::setPagination(Document* document, const String& mode, int gap, ExceptionCode& ec)
     380{
     381    if (!document || !document->page()) {
     382        ec = INVALID_ACCESS_ERR;
     383        return;
     384    }
     385
     386    Page::Pagination pagination;
     387    if (mode == "Unpaginated")
     388        pagination.mode = Page::Pagination::Unpaginated;
     389    else if (mode == "HorizontallyPaginated")
     390        pagination.mode = Page::Pagination::HorizontallyPaginated;
     391    else if (mode == "VerticallyPaginated")
     392        pagination.mode = Page::Pagination::VerticallyPaginated;
     393    else {
     394        ec = SYNTAX_ERR;
     395        return;
     396    }
     397
     398    pagination.gap = gap;
     399
     400    document->page()->setPagination(pagination);
     401}
     402
    379403void Internals::reset(Document* document)
    380404{
     
    391415        passwordEchoEnabledBackedUp = false;
    392416    }
     417
     418    if (Page* page = document->page())
     419        page->setPagination(Page::Pagination());
    393420}
    394421
  • trunk/Source/WebCore/testing/Internals.h

    r99485 r99613  
    9090    void setScrollViewPosition(Document*, long x, long y, ExceptionCode&);
    9191
     92    void setPagination(Document*, const String& mode, int gap, ExceptionCode&);
     93
    9294    bool wasLastChangeUserEdit(Element* textField, ExceptionCode&);
    9395    String suggestedValue(Element* inputElement, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r99485 r99613  
    6363        void setScrollViewPosition(in Document document, in long x, in long y) raises(DOMException);
    6464
     65        void setPagination(in Document document, in DOMString mode, in long gap) raises(DOMException);
     66
    6567        boolean wasLastChangeUserEdit(in Element textField) raises (DOMException);
    6668        DOMString suggestedValue(in Element inputElement) raises (DOMException);
  • trunk/Source/WebKit2/ChangeLog

    r99606 r99613  
     12011-11-08  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10262225> Allow RenderView to have columns
     4        https://bugs.webkit.org/show_bug.cgi?id=71840
     5
     6        * win/WebKit2.def: Export Page::setPagination() for WebCoreTestSupport.
     7
    182011-11-08  Jon Lee  <jonlee@apple.com>
    29
  • trunk/Source/WebKit2/win/WebKit2.def

    r98624 r99613  
    170170        ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
    171171        ?setDOMException@WebCore@@YAXPAVExecState@JSC@@H@Z
     172        ?setPagination@Page@WebCore@@QAEXABUPagination@12@@Z
    172173        ?setResourcesDataSizeLimitsFromInternals@InspectorController@WebCore@@QAEXHH@Z
    173174        ?setScrollbarsSuppressed@ScrollView@WebCore@@QAEX_N0@Z
Note: See TracChangeset for help on using the changeset viewer.