Changeset 86632 in webkit


Ignore:
Timestamp:
May 16, 2011 4:33:51 PM (13 years ago)
Author:
eae@chromium.org
Message:

2011-05-16 Emil A Eklund <eae@chromium.org>

Reviewed by Eric Seidel.

Replace docTop/Right/Bottom/Left/Width/Height with documentRect
https://bugs.webkit.org/show_bug.cgi?id=60743

Change RenderView::documentRect to compute rect once rather than four times.
Replace all uses of docTop/Right/Bottom/Left/Width/Height with documentRect to
simplify the code and reduce complexity.

Covered by existing tests.

  • WebCore.exp.in:
  • page/FrameView.cpp: (WebCore::FrameView::adjustViewSize): (WebCore::FrameView::forceLayoutForPagination):
  • page/PrintContext.cpp: (WebCore::PrintContext::computePageRects):
  • rendering/RenderBox.cpp: (WebCore::RenderBox::paintRootBoxFillLayers):
  • rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::updateRootLayerPosition):
  • rendering/RenderView.cpp: (WebCore::RenderView::documentRect):
  • rendering/RenderView.h:

2011-05-16 Emil A Eklund <eae@chromium.org>

Reviewed by Eric Seidel.

Replace docTop/Right/Bottom/Left/Width/Height with documentRect
https://bugs.webkit.org/show_bug.cgi?id=60743

Replace uses of docWidth/Height with documentRect.

  • WebView/WebFrame.mm: (-[WebFrame _computePageRectsWithPrintScaleFactor:pageSize:]):
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86631 r86632  
     12011-05-16  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Replace docTop/Right/Bottom/Left/Width/Height with documentRect
     6        https://bugs.webkit.org/show_bug.cgi?id=60743
     7
     8        Change RenderView::documentRect to compute rect once rather than four times.
     9        Replace all uses of docTop/Right/Bottom/Left/Width/Height with documentRect to
     10        simplify the code and reduce complexity.
     11
     12        Covered by existing tests.
     13
     14        * WebCore.exp.in:
     15        * page/FrameView.cpp:
     16        (WebCore::FrameView::adjustViewSize):
     17        (WebCore::FrameView::forceLayoutForPagination):
     18        * page/PrintContext.cpp:
     19        (WebCore::PrintContext::computePageRects):
     20        * rendering/RenderBox.cpp:
     21        (WebCore::RenderBox::paintRootBoxFillLayers):
     22        * rendering/RenderLayerCompositor.cpp:
     23        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
     24        * rendering/RenderView.cpp:
     25        (WebCore::RenderView::documentRect):
     26        * rendering/RenderView.h:
     27
    1282011-05-16  Tony Chang  <tony@chromium.org>
    229
  • trunk/Source/WebCore/WebCore.exp.in

    r86451 r86632  
    10271027__ZNK7WebCore10RenderText9firstRunXEv
    10281028__ZNK7WebCore10RenderText9firstRunYEv
    1029 __ZNK7WebCore10RenderView6docTopEv
    1030 __ZNK7WebCore10RenderView7docLeftEv
    1031 __ZNK7WebCore10RenderView8docRightEv
    1032 __ZNK7WebCore10RenderView9docBottomEv
     1029__ZNK7WebCore10RenderView12documentRectEv
    10331030__ZNK7WebCore10ScrollView12contentsSizeEv
    10341031__ZNK7WebCore10ScrollView12documentViewEv
  • trunk/Source/WebCore/page/FrameView.cpp

    r86597 r86632  
    503503        return;
    504504
    505     IntSize size = IntSize(root->docWidth(), root->docHeight());
    506 
    507     ScrollView::setScrollOrigin(IntPoint(-root->docLeft(), -root->docTop()), !m_frame->document()->printing(), size == contentsSize());
     505    const IntRect& rect = root->documentRect();
     506    const IntSize& size = rect.size();
     507    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
    508508   
    509509    setContentsSize(size);
     
    25532553        // FIXME: We are assuming a shrink-to-fit printing implementation.  A cropping
    25542554        // implementation should not do this!
    2555         int docLogicalWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() : root->docHeight();
     2555        const IntRect& documentRect = root->documentRect();
     2556        bool horizontalWritingMode = root->style()->isHorizontalWritingMode();
     2557        int docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
    25562558        if (docLogicalWidth > pageLogicalWidth) {
    25572559            flooredPageLogicalWidth = std::min<int>(docLogicalWidth, pageLogicalWidth * maximumShrinkFactor);
     
    25612563            root->setNeedsLayoutAndPrefWidthsRecalc();
    25622564            forceLayout();
    2563             int docLogicalHeight = root->style()->isHorizontalWritingMode() ? root->docHeight() : root->docWidth();
    2564             int docLogicalTop = root->style()->isHorizontalWritingMode() ? root->docTop() : root->docLeft();
    2565             int docLogicalRight = root->style()->isHorizontalWritingMode() ? root->docRight() : root->docBottom();
     2565            int docLogicalHeight = horizontalWritingMode ? documentRect.height() : documentRect.width();
     2566            int docLogicalTop = horizontalWritingMode ? documentRect.y() : documentRect.x();
     2567            int docLogicalRight = horizontalWritingMode ? documentRect.maxX() : documentRect.maxY();
    25662568            int clippedLogicalLeft = 0;
    25672569            if (!root->style()->isLeftToRightDirection())
    25682570                clippedLogicalLeft = docLogicalRight - flooredPageLogicalWidth;
    25692571            IntRect overflow(clippedLogicalLeft, docLogicalTop, flooredPageLogicalWidth, docLogicalHeight);
    2570             if (!root->style()->isHorizontalWritingMode())
     2572            if (!horizontalWritingMode)
    25712573                overflow = overflow.transposedRect();
    25722574            root->clearLayoutOverflow();
  • trunk/Source/WebCore/page/PrintContext.cpp

    r86542 r86632  
    7575    float pageWidth;
    7676    float pageHeight;
     77    const IntRect& documentRect = view->documentRect();
    7778    if (isHorizontal) {
    7879        float ratio = printRect.height() / printRect.width();
    79         pageWidth = view->docWidth();
     80        pageWidth = documentRect.width();
    8081        pageHeight = floorf(pageWidth * ratio);
    8182    } else {
    8283        float ratio = printRect.width() / printRect.height();
    83         pageHeight = view->docHeight();
     84        pageHeight = documentRect.height();
    8485        pageWidth = floorf(pageHeight * ratio);
    8586    }
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r86448 r86632  
    799799
    800800    // The background of the box generated by the root element covers the entire canvas, so just use
    801     // the RenderView's docTop/Left/Width/Height accessors.
     801    // the RenderView's documentRect accessor.
    802802    paintFillLayers(paintInfo, bgColor, bgLayer, view()->documentRect(), BackgroundBleedNone, CompositeSourceOver, bodyObject);
    803803}
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r85094 r86632  
    11401140{
    11411141    if (m_rootPlatformLayer) {
    1142         m_rootPlatformLayer->setSize(FloatSize(m_renderView->docWidth(), m_renderView->docHeight()));
    1143         m_rootPlatformLayer->setPosition(FloatPoint(m_renderView->docLeft(), m_renderView->docTop()));
     1142        const IntRect& documentRect = m_renderView->documentRect();
     1143        m_rootPlatformLayer->setSize(documentRect.size());
     1144        m_rootPlatformLayer->setPosition(documentRect.location());
    11441145    }
    11451146    if (m_clipLayer) {
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r84815 r86632  
    654654}
    655655
    656 int RenderView::docTop() const
    657 {
    658     IntRect overflowRect(0, minYLayoutOverflow(), 0, maxYLayoutOverflow() - minYLayoutOverflow());
    659     flipForWritingMode(overflowRect);
    660     if (hasTransform())
    661         overflowRect = layer()->currentTransform().mapRect(overflowRect);
    662     return overflowRect.y();
    663 }
    664 
    665 int RenderView::docBottom() const
     656IntRect RenderView::documentRect() const
    666657{
    667658    IntRect overflowRect(layoutOverflowRect());
     
    669660    if (hasTransform())
    670661        overflowRect = layer()->currentTransform().mapRect(overflowRect);
    671     return overflowRect.maxY();
    672 }
    673 
    674 int RenderView::docLeft() const
    675 {
    676     IntRect overflowRect(layoutOverflowRect());
    677     flipForWritingMode(overflowRect);
    678     if (hasTransform())
    679         overflowRect = layer()->currentTransform().mapRect(overflowRect);
    680     return overflowRect.x();
    681 }
    682 
    683 int RenderView::docRight() const
    684 {
    685     IntRect overflowRect(layoutOverflowRect());
    686     flipForWritingMode(overflowRect);
    687     if (hasTransform())
    688         overflowRect = layer()->currentTransform().mapRect(overflowRect);
    689     return overflowRect.maxX();
     662    return overflowRect;
    690663}
    691664
  • trunk/Source/WebCore/rendering/RenderView.h

    r76248 r86632  
    169169#endif
    170170
    171     int docTop() const;
    172     int docBottom() const;
    173     int docHeight() const { return docBottom() - docTop(); }
    174     int docLeft() const;
    175     int docRight() const;
    176     int docWidth() const { return docRight() - docLeft(); }
    177     IntRect documentRect() const { return IntRect(docLeft(), docTop(), docWidth(), docHeight()); }
     171    IntRect documentRect() const;
    178172
    179173protected:
  • trunk/Source/WebKit/mac/ChangeLog

    r86601 r86632  
     12011-05-16  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Replace docTop/Right/Bottom/Left/Width/Height with documentRect
     6        https://bugs.webkit.org/show_bug.cgi?id=60743
     7
     8        Replace uses of docWidth/Height with documentRect.
     9
     10        * WebView/WebFrame.mm:
     11        (-[WebFrame _computePageRectsWithPrintScaleFactor:pageSize:]):
     12
    1132011-05-16  Yuzo Fujishima  <yuzo@google.com>
    214
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r86330 r86632  
    13441344        return [NSArray array];
    13451345
    1346     float printWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() / printScaleFactor : pageSize.width;
    1347     float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : root->docHeight() / printScaleFactor;
     1346    const IntRect& documentRect = root->documentRect();
     1347    float printWidth = root->style()->isHorizontalWritingMode() ? documentRect.width() / printScaleFactor : pageSize.width;
     1348    float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : documentRect.height() / printScaleFactor;
    13481349
    13491350    PrintContext printContext(_private->coreFrame);
Note: See TracChangeset for help on using the changeset viewer.