Changeset 101574 in webkit


Ignore:
Timestamp:
Nov 30, 2011 5:14:25 PM (12 years ago)
Author:
mitz@apple.com
Message:

Source/WebCore: WebCore part of: Allow the length of a page along the pagination axis to differ from the length of the view
https://bugs.webkit.org/show_bug.cgi?id=73476

Reviewed by Anders Carlsson.

  • page/Page.cpp:

(WebCore::Page::setPagination): Changed to use Pagination::operator==.

  • page/Page.h:

(WebCore::Page::Pagination::Pagination): Added initializer for the new pageLength member variable.
(WebCore::Page::Pagination::operator==): Added.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::layoutColumns): Narrowed the scope of a local variable.

  • rendering/RenderBlock.h: Promoted setDesiredColumnCountAndWidth() from private to protected,

allowing its use from RenderView::calcColumnWidth(). Made calcColumnWidth() virtual.

  • rendering/RenderView.cpp:

(WebCore::RenderView::calcColumnWidth): Added. Uses the page length specified in the pagination
parameters to set the column width, if pages are to be laid out one next to the other.
(WebCore::RenderView::viewLogicalHeight): Added. Uses the page length specified in the pagination
parameters as the height, if pages are to be laid out one after the other.

  • rendering/RenderView.h:

Source/WebKit/mac: WebKit/mac part of: Allow the length of a page along the pagination axis to differ from the length of the view
https://bugs.webkit.org/show_bug.cgi?id=73476

Reviewed by Anders Carlsson.

  • WebView/WebView.mm:

(-[WebView _setPageLength:]): Added this accessor.
(-[WebView _pageLength]): Ditto.

  • WebView/WebViewPrivate.h:

Source/WebKit2: WebKit2 part of: Allow the length of a page along the pagination axis to differ from the length of the view
https://bugs.webkit.org/show_bug.cgi?id=73476

Reviewed by Anders Carlsson.

  • Shared/WebPageCreationParameters.cpp:

(WebKit::WebPageCreationParameters::encode): Encode pageLength.
(WebKit::WebPageCreationParameters::decode): Decode pageLength.

  • Shared/WebPageCreationParameters.h: Added pageLength.
  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageLength): Added this accessor.
(WKPageGetPageLength): Ditto.

  • UIProcess/API/C/WKPagePrivate.h:
  • UIProcess/API/mac/WKBrowsingContextController.mm:

(-[WKBrowsingContextController setPageLength:]): Ditto.
(-[WKBrowsingContextController pageLength]): Ditto.

  • UIProcess/API/mac/WKBrowsingContextControllerPrivate.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy): Added initializer for m_pageLength.
(WebKit::WebPageProxy::setPageLength): Added.
(WebKit::WebPageProxy::creationParameters): Initialize pageLength.

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::pageLength): Added.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage): Set the page length based on the creation parameters.
(WebKit::WebPage::setPageLength): Added.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in: Added SetPageLength.
Location:
trunk/Source
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101573 r101574  
     12011-11-30  Dan Bernstein  <mitz@apple.com>
     2
     3        WebCore part of: Allow the length of a page along the pagination axis to differ from the length of the view
     4        https://bugs.webkit.org/show_bug.cgi?id=73476
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * page/Page.cpp:
     9        (WebCore::Page::setPagination): Changed to use Pagination::operator==.
     10        * page/Page.h:
     11        (WebCore::Page::Pagination::Pagination): Added initializer for the new pageLength member variable.
     12        (WebCore::Page::Pagination::operator==): Added.
     13        * rendering/RenderBlock.cpp:
     14        (WebCore::RenderBlock::layoutColumns): Narrowed the scope of a local variable.
     15        * rendering/RenderBlock.h: Promoted setDesiredColumnCountAndWidth() from private to protected,
     16        allowing its use from RenderView::calcColumnWidth(). Made calcColumnWidth() virtual.
     17        * rendering/RenderView.cpp:
     18        (WebCore::RenderView::calcColumnWidth): Added. Uses the page length specified in the pagination
     19        parameters to set the column width, if pages are to be laid out one next to the other.
     20        (WebCore::RenderView::viewLogicalHeight): Added. Uses the page length specified in the pagination
     21        parameters as the height, if pages are to be laid out one after the other.
     22        * rendering/RenderView.h:
     23
    1242011-11-30  Chris Fleizach  <cfleizach@apple.com>
    225
  • trunk/Source/WebCore/page/Page.cpp

    r101345 r101574  
    678678void Page::setPagination(const Pagination& pagination)
    679679{
    680     if (m_pagination.mode == pagination.mode && m_pagination.gap == pagination.gap)
     680    if (m_pagination == pagination)
    681681        return;
    682682
  • trunk/Source/WebCore/page/Page.h

    r101307 r101574  
    262262            Pagination()
    263263                : mode(Unpaginated)
     264                , pageLength(0)
    264265                , gap(0)
    265266            {
    266267            };
    267268
     269            bool operator==(const Pagination& other) const
     270            {
     271                return mode == other.mode && pageLength == other.pageLength && gap == other.gap;
     272            }
     273
    268274            Mode mode;
     275            unsigned pageLength;
    269276            unsigned gap;
    270277        };
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r101411 r101574  
    46204620    // the distance between forced page breaks is so that we can avoid making the minimum column height too tall.
    46214621    ColumnInfo* colInfo = columnInfo();
    4622     int desiredColumnCount = colInfo->desiredColumnCount();
    46234622    if (!hasSpecifiedPageLogicalHeight) {
    46244623        LayoutUnit columnHeight = pageLogicalHeight;
    46254624        int minColumnCount = colInfo->forcedBreaks() + 1;
     4625        int desiredColumnCount = colInfo->desiredColumnCount();
    46264626        if (minColumnCount >= desiredColumnCount) {
    46274627            // The forced page breaks are in control of the balancing.  Just set the column height to the
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r99613 r101574  
    415415    void simplifiedNormalFlowLayout();
    416416
     417    void setDesiredColumnCountAndWidth(int, LayoutUnit);
     418
    417419    void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
    418420    virtual void addOverflowFromChildren();
     
    751753    LayoutUnit desiredColumnWidth() const;
    752754    unsigned desiredColumnCount() const;
    753     void setDesiredColumnCountAndWidth(int count, LayoutUnit width);
    754755
    755756    void paintContinuationOutlines(PaintInfo&, const LayoutPoint&);
     
    770771    void offsetForContents(LayoutPoint&) const;
    771772
    772     void calcColumnWidth();
     773    virtual void calcColumnWidth();
    773774    bool layoutColumns(bool hasSpecifiedPageLogicalHeight, LayoutUnit pageLogicalHeight, LayoutStateMaintainer&);
    774775    void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild);
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r99630 r101574  
    186186}
    187187
     188void RenderView::calcColumnWidth()
     189{
     190    int columnWidth = contentLogicalWidth();
     191    if (m_frameView && style()->hasInlineColumnAxis()) {
     192        if (Frame* frame = m_frameView->frame()) {
     193            if (Page* page = frame->page()) {
     194                if (int pageLength = page->pagination().pageLength)
     195                    columnWidth = pageLength;
     196            }
     197        }
     198    }
     199    setDesiredColumnCountAndWidth(1, columnWidth);
     200}
     201
    188202void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    189203{
     
    735749}
    736750
     751int RenderView::viewLogicalHeight() const
     752{
     753    int height = style()->isHorizontalWritingMode() ? viewHeight() : viewWidth();
     754
     755    if (hasColumns() && !style()->hasInlineColumnAxis()) {
     756        if (Frame* frame = m_frameView->frame()) {
     757            if (Page* page = frame->page()) {
     758                if (frame == page->mainFrame()) {
     759                    if (int pageLength = page->pagination().pageLength)
     760                        height = pageLength;
     761                }
     762            }
     763        }
     764    }
     765
     766    return height;
     767}
     768
    737769float RenderView::zoomFactor() const
    738770{
  • trunk/Source/WebCore/rendering/RenderView.h

    r99630 r101574  
    6262    int viewWidth() const;
    6363    int viewLogicalWidth() const { return style()->isHorizontalWritingMode() ? viewWidth() : viewHeight(); }
    64     int viewLogicalHeight() const { return style()->isHorizontalWritingMode() ? viewHeight() : viewWidth(); }
     64    int viewLogicalHeight() const;
    6565
    6666    float zoomFactor() const;
     
    195195
    196196private:
     197    virtual void calcColumnWidth() OVERRIDE;
     198
    197199    bool shouldRepaint(const IntRect& r) const;
    198200
  • trunk/Source/WebKit/mac/ChangeLog

    r101486 r101574  
     12011-11-30  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit/mac part of: Allow the length of a page along the pagination axis to differ from the length of the view
     4        https://bugs.webkit.org/show_bug.cgi?id=73476
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebView/WebView.mm:
     9        (-[WebView _setPageLength:]): Added this accessor.
     10        (-[WebView _pageLength]): Ditto.
     11        * WebView/WebViewPrivate.h:
     12
    1132011-11-30  Alexey Proskuryakov  <ap@apple.com>
    214
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r101413 r101574  
    27792779}
    27802780
     2781- (void)_setPageLength:(CGFloat)pageLength
     2782{
     2783    Page* page = core(self);
     2784    if (!page)
     2785        return;
     2786
     2787    Page::Pagination pagination = page->pagination();
     2788    pagination.pageLength = pageLength;
     2789
     2790    page->setPagination(pagination);
     2791}
     2792
     2793- (CGFloat)_pageLength
     2794{
     2795    Page* page = core(self);
     2796    if (!page)
     2797        return 1;
     2798
     2799    return page->pagination().pageLength;
     2800}
     2801
    27812802- (void)_setGapBetweenPages:(CGFloat)pageGap
    27822803{
  • trunk/Source/WebKit/mac/WebView/WebViewPrivate.h

    r100534 r101574  
    564564- (void)_setPaginationMode:(WebPaginationMode)paginationMode;
    565565- (WebPaginationMode)_paginationMode;
     566// Set to 0 to have the page length equal the view length.
     567- (void)_setPageLength:(CGFloat)pageLength;
     568- (CGFloat)_pageLength;
    566569- (void)_setGapBetweenPages:(CGFloat)pageGap;
    567570- (CGFloat)_gapBetweenPages;
  • trunk/Source/WebKit2/ChangeLog

    r101547 r101574  
     12011-11-30  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit2 part of: Allow the length of a page along the pagination axis to differ from the length of the view
     4        https://bugs.webkit.org/show_bug.cgi?id=73476
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/WebPageCreationParameters.cpp:
     9        (WebKit::WebPageCreationParameters::encode): Encode pageLength.
     10        (WebKit::WebPageCreationParameters::decode): Decode pageLength.
     11        * Shared/WebPageCreationParameters.h: Added pageLength.
     12        * UIProcess/API/C/WKPage.cpp:
     13        (WKPageSetPageLength): Added this accessor.
     14        (WKPageGetPageLength): Ditto.
     15        * UIProcess/API/C/WKPagePrivate.h:
     16        * UIProcess/API/mac/WKBrowsingContextController.mm:
     17        (-[WKBrowsingContextController setPageLength:]): Ditto.
     18        (-[WKBrowsingContextController pageLength]): Ditto.
     19        * UIProcess/API/mac/WKBrowsingContextControllerPrivate.h:
     20        * UIProcess/WebPageProxy.cpp:
     21        (WebKit::WebPageProxy::WebPageProxy): Added initializer for m_pageLength.
     22        (WebKit::WebPageProxy::setPageLength): Added.
     23        (WebKit::WebPageProxy::creationParameters): Initialize pageLength.
     24        * UIProcess/WebPageProxy.h:
     25        (WebKit::WebPageProxy::pageLength): Added.
     26        * WebProcess/WebPage/WebPage.cpp:
     27        (WebKit::WebPage::WebPage): Set the page length based on the creation parameters.
     28        (WebKit::WebPage::setPageLength): Added.
     29        * WebProcess/WebPage/WebPage.h:
     30        * WebProcess/WebPage/WebPage.messages.in: Added SetPageLength.
     31
    1322011-11-30  Alejandro G. Castro  <alex@igalia.com>
    233
  • trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp

    r100534 r101574  
    4848    encoder->encode(fixedLayoutSize);
    4949    encoder->encodeEnum(paginationMode);
     50    encoder->encode(pageLength);
    5051    encoder->encode(gapBetweenPages);
    5152    encoder->encode(userAgent);
     
    9596    if (!decoder->decodeEnum(parameters.paginationMode))
    9697        return false;
     98    if (!decoder->decode(parameters.pageLength))
     99        return false;
    97100    if (!decoder->decode(parameters.gapBetweenPages))
    98101        return false;
  • trunk/Source/WebKit2/Shared/WebPageCreationParameters.h

    r100534 r101574  
    6565
    6666    WebCore::Page::Pagination::Mode paginationMode;
     67    double pageLength;
    6768    double gapBetweenPages;
    6869
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r100534 r101574  
    380380}
    381381
     382void WKPageSetPageLength(WKPageRef pageRef, double pageLength)
     383{
     384    toImpl(pageRef)->setPageLength(pageLength);
     385}
     386
     387double WKPageGetPageLength(WKPageRef pageRef)
     388{
     389    return toImpl(pageRef)->pageLength();
     390}
     391
    382392void WKPageSetGapBetweenPages(WKPageRef pageRef, double gap)
    383393{
  • trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h

    r100534 r101574  
    6262WK_EXPORT void WKPageSetPaginationMode(WKPageRef page, WKPaginationMode paginationMode);
    6363WK_EXPORT WKPaginationMode WKPageGetPaginationMode(WKPageRef page);
     64WK_EXPORT void WKPageSetPageLength(WKPageRef page, double pagesPerView);
     65WK_EXPORT double WKPageGetPageLength(WKPageRef page);
    6466WK_EXPORT void WKPageSetGapBetweenPages(WKPageRef page, double gap);
    6567WK_EXPORT double WKPageGetGapBetweenPages(WKPageRef page);
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm

    r100534 r101574  
    235235}
    236236
     237- (void)setPageLength:(CGFloat)pageLength
     238{
     239    WKPageSetPageLength(self.pageRef, pageLength);
     240}
     241
     242- (CGFloat)pageLength
     243{
     244    return WKPageGetPageLength(self.pageRef);
     245}
     246
    237247- (void)setGapBetweenPages:(CGFloat)gapBetweenPages
    238248{
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerPrivate.h

    r100534 r101574  
    3636
    3737@property WKBrowsingContextPaginationMode paginationMode;
     38// Set to 0 to have the page length equal the view length.
     39@property CGFloat pageLength;
    3840@property CGFloat gapBetweenPages;
    3941
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r101290 r101574  
    162162    , m_useFixedLayout(false)
    163163    , m_paginationMode(Page::Pagination::Unpaginated)
     164    , m_pageLength(0)
    164165    , m_gapBetweenPages(0)
    165166    , m_isValid(true)
     
    12971298}
    12981299
     1300void WebPageProxy::setPageLength(double pageLength)
     1301{
     1302    if (pageLength == m_pageLength)
     1303        return;
     1304
     1305    m_pageLength = pageLength;
     1306
     1307    if (!isValid())
     1308        return;
     1309    process()->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
     1310}
     1311
    12991312void WebPageProxy::setGapBetweenPages(double gap)
    13001313{
     
    31923205    parameters.fixedLayoutSize = m_fixedLayoutSize;
    31933206    parameters.paginationMode = m_paginationMode;
     3207    parameters.pageLength = m_pageLength;
    31943208    parameters.gapBetweenPages = m_gapBetweenPages;
    31953209    parameters.userAgent = userAgent();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r101290 r101574  
    416416    void setPaginationMode(WebCore::Page::Pagination::Mode);
    417417    WebCore::Page::Pagination::Mode paginationMode() const { return m_paginationMode; }
     418    void setPageLength(double);
     419    double pageLength() const { return m_pageLength; }
    418420    void setGapBetweenPages(double);
    419421    double gapBetweenPages() const { return m_gapBetweenPages; }
     
    901903
    902904    WebCore::Page::Pagination::Mode m_paginationMode;
     905    double m_pageLength;
    903906    double m_gapBetweenPages;
    904907
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r101532 r101574  
    250250
    251251    setPaginationMode(parameters.paginationMode);
     252    setPageLength(parameters.pageLength);
    252253    setGapBetweenPages(parameters.gapBetweenPages);
    253254
     
    932933    Page::Pagination pagination = m_page->pagination();
    933934    pagination.mode = static_cast<Page::Pagination::Mode>(mode);
     935    m_page->setPagination(pagination);
     936}
     937
     938void WebPage::setPageLength(double pageLength)
     939{
     940    Page::Pagination pagination = m_page->pagination();
     941    pagination.pageLength = pageLength;
    934942    m_page->setPagination(pagination);
    935943}
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r101307 r101574  
    269269
    270270    void setPaginationMode(uint32_t /* WebCore::Page::Pagination::Mode */);
     271    void setPageLength(double);
    271272    void setGapBetweenPages(double);
    272273
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r100534 r101574  
    123123
    124124    SetPaginationMode(uint32_t mode);
     125    SetPageLength(double pageLength);
    125126    SetGapBetweenPages(double gap);
    126127
Note: See TracChangeset for help on using the changeset viewer.