2011-05-16 Emil A Eklund <eae@chromium.org>
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2011 23:33:51 +0000 (23:33 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2011 23:33:51 +0000 (23:33 +0000)
        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:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86632 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/PrintContext.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFrame.mm

index 43f4cdf..551ab4f 100644 (file)
@@ -1,3 +1,30 @@
+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  Tony Chang  <tony@chromium.org>
 
         Reviewed by Adam Barth.
index 63375da..bba2ea0 100644 (file)
@@ -1026,10 +1026,7 @@ __ZNK7WebCore10PluginData16supportsMimeTypeERKN3WTF6StringE
 __ZNK7WebCore10RenderText16linesBoundingBoxEv
 __ZNK7WebCore10RenderText9firstRunXEv
 __ZNK7WebCore10RenderText9firstRunYEv
-__ZNK7WebCore10RenderView6docTopEv
-__ZNK7WebCore10RenderView7docLeftEv
-__ZNK7WebCore10RenderView8docRightEv
-__ZNK7WebCore10RenderView9docBottomEv
+__ZNK7WebCore10RenderView12documentRectEv
 __ZNK7WebCore10ScrollView12contentsSizeEv
 __ZNK7WebCore10ScrollView12documentViewEv
 __ZNK7WebCore10ScrollView14scrollbarModesERNS_13ScrollbarModeES2_
index 0e87d6e..9a05681 100644 (file)
@@ -502,9 +502,9 @@ void FrameView::adjustViewSize()
     if (!root)
         return;
 
-    IntSize size = IntSize(root->docWidth(), root->docHeight());
-
-    ScrollView::setScrollOrigin(IntPoint(-root->docLeft(), -root->docTop()), !m_frame->document()->printing(), size == contentsSize());
+    const IntRect& rect = root->documentRect();
+    const IntSize& size = rect.size();
+    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
     
     setContentsSize(size);
 }
@@ -2552,7 +2552,9 @@ void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximu
         // page width when shrunk, we will lay out at maximum shrink and clip extra content.
         // FIXME: We are assuming a shrink-to-fit printing implementation.  A cropping
         // implementation should not do this!
-        int docLogicalWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() : root->docHeight();
+        const IntRect& documentRect = root->documentRect();
+        bool horizontalWritingMode = root->style()->isHorizontalWritingMode();
+        int docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
         if (docLogicalWidth > pageLogicalWidth) {
             flooredPageLogicalWidth = std::min<int>(docLogicalWidth, pageLogicalWidth * maximumShrinkFactor);
             if (pageLogicalHeight)
@@ -2560,14 +2562,14 @@ void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximu
             root->setLogicalWidth(flooredPageLogicalWidth);
             root->setNeedsLayoutAndPrefWidthsRecalc();
             forceLayout();
-            int docLogicalHeight = root->style()->isHorizontalWritingMode() ? root->docHeight() : root->docWidth();
-            int docLogicalTop = root->style()->isHorizontalWritingMode() ? root->docTop() : root->docLeft();
-            int docLogicalRight = root->style()->isHorizontalWritingMode() ? root->docRight() : root->docBottom();
+            int docLogicalHeight = horizontalWritingMode ? documentRect.height() : documentRect.width();
+            int docLogicalTop = horizontalWritingMode ? documentRect.y() : documentRect.x();
+            int docLogicalRight = horizontalWritingMode ? documentRect.maxX() : documentRect.maxY();
             int clippedLogicalLeft = 0;
             if (!root->style()->isLeftToRightDirection())
                 clippedLogicalLeft = docLogicalRight - flooredPageLogicalWidth;
             IntRect overflow(clippedLogicalLeft, docLogicalTop, flooredPageLogicalWidth, docLogicalHeight);
-            if (!root->style()->isHorizontalWritingMode())
+            if (!horizontalWritingMode)
                 overflow = overflow.transposedRect();
             root->clearLayoutOverflow();
             root->addLayoutOverflow(overflow); // This is how we clip in case we overflow again.
index 91ef3a3..1b08268 100644 (file)
@@ -74,13 +74,14 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
 
     float pageWidth;
     float pageHeight;
+    const IntRect& documentRect = view->documentRect();
     if (isHorizontal) {
         float ratio = printRect.height() / printRect.width();
-        pageWidth = view->docWidth();
+        pageWidth = documentRect.width();
         pageHeight = floorf(pageWidth * ratio);
     } else {
         float ratio = printRect.width() / printRect.height();
-        pageHeight = view->docHeight();
+        pageHeight = documentRect.height();
         pageWidth = floorf(pageHeight * ratio);
     }
 
index f1b6882..f2b278e 100644 (file)
@@ -798,7 +798,7 @@ void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)
     }
 
     // The background of the box generated by the root element covers the entire canvas, so just use
-    // the RenderView's docTop/Left/Width/Height accessors.
+    // the RenderView's documentRect accessor.
     paintFillLayers(paintInfo, bgColor, bgLayer, view()->documentRect(), BackgroundBleedNone, CompositeSourceOver, bodyObject);
 }
 
index 0eb12cc..591f607 100644 (file)
@@ -1139,8 +1139,9 @@ void RenderLayerCompositor::willMoveOffscreen()
 void RenderLayerCompositor::updateRootLayerPosition()
 {
     if (m_rootPlatformLayer) {
-        m_rootPlatformLayer->setSize(FloatSize(m_renderView->docWidth(), m_renderView->docHeight()));
-        m_rootPlatformLayer->setPosition(FloatPoint(m_renderView->docLeft(), m_renderView->docTop()));
+        const IntRect& documentRect = m_renderView->documentRect();
+        m_rootPlatformLayer->setSize(documentRect.size());
+        m_rootPlatformLayer->setPosition(documentRect.location());
     }
     if (m_clipLayer) {
         FrameView* frameView = m_renderView->frameView();
index 0cc0eed..a1d2377 100644 (file)
@@ -653,40 +653,13 @@ IntRect RenderView::viewRect() const
     return IntRect();
 }
 
-int RenderView::docTop() const
-{
-    IntRect overflowRect(0, minYLayoutOverflow(), 0, maxYLayoutOverflow() - minYLayoutOverflow());
-    flipForWritingMode(overflowRect);
-    if (hasTransform())
-        overflowRect = layer()->currentTransform().mapRect(overflowRect);
-    return overflowRect.y();
-}
-
-int RenderView::docBottom() const
-{
-    IntRect overflowRect(layoutOverflowRect());
-    flipForWritingMode(overflowRect);
-    if (hasTransform())
-        overflowRect = layer()->currentTransform().mapRect(overflowRect);
-    return overflowRect.maxY();
-}
-
-int RenderView::docLeft() const
-{
-    IntRect overflowRect(layoutOverflowRect());
-    flipForWritingMode(overflowRect);
-    if (hasTransform())
-        overflowRect = layer()->currentTransform().mapRect(overflowRect);
-    return overflowRect.x();
-}
-
-int RenderView::docRight() const
+IntRect RenderView::documentRect() const
 {
     IntRect overflowRect(layoutOverflowRect());
     flipForWritingMode(overflowRect);
     if (hasTransform())
         overflowRect = layer()->currentTransform().mapRect(overflowRect);
-    return overflowRect.maxX();
+    return overflowRect;
 }
 
 int RenderView::viewHeight() const
index 7e5b4e1..daa9d98 100644 (file)
@@ -168,13 +168,7 @@ public:
     bool usesCompositing() const;
 #endif
 
-    int docTop() const;
-    int docBottom() const;
-    int docHeight() const { return docBottom() - docTop(); }
-    int docLeft() const;
-    int docRight() const;
-    int docWidth() const { return docRight() - docLeft(); }
-    IntRect documentRect() const { return IntRect(docLeft(), docTop(), docWidth(), docHeight()); }
+    IntRect documentRect() const;
 
 protected:
     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
index 8177293..4971e1e 100644 (file)
@@ -1,3 +1,15 @@
+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:]):
+
 2011-05-16  Yuzo Fujishima  <yuzo@google.com>
 
         Reviewed by Antti Koivisto.
index 9f193c5..5f941a1 100644 (file)
@@ -1343,8 +1343,9 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     if (!root)
         return [NSArray array];
 
-    float printWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() / printScaleFactor : pageSize.width;
-    float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : root->docHeight() / printScaleFactor;
+    const IntRect& documentRect = root->documentRect();
+    float printWidth = root->style()->isHorizontalWritingMode() ? documentRect.width() / printScaleFactor : pageSize.width;
+    float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : documentRect.height() / printScaleFactor;
 
     PrintContext printContext(_private->coreFrame);
     printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true);