Skip to content
Permalink
Browse files
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:]):

Canonical link: https://commits.webkit.org/76282@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eaenet committed May 16, 2011
1 parent 732c7f8 commit 12dad354d26059a4b51edaf03dce074f68119ca9
Showing 10 changed files with 63 additions and 55 deletions.
@@ -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.
@@ -1026,10 +1026,7 @@ __ZNK7WebCore10PluginData16supportsMimeTypeERKN3WTF6StringE
__ZNK7WebCore10RenderText16linesBoundingBoxEv
__ZNK7WebCore10RenderText9firstRunXEv
__ZNK7WebCore10RenderText9firstRunYEv
__ZNK7WebCore10RenderView6docTopEv
__ZNK7WebCore10RenderView7docLeftEv
__ZNK7WebCore10RenderView8docRightEv
__ZNK7WebCore10RenderView9docBottomEv
__ZNK7WebCore10RenderView12documentRectEv
__ZNK7WebCore10ScrollView12contentsSizeEv
__ZNK7WebCore10ScrollView12documentViewEv
__ZNK7WebCore10ScrollView14scrollbarModesERNS_13ScrollbarModeES2_
@@ -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,22 +2552,24 @@ 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)
root->setPageLogicalHeight(flooredPageLogicalWidth / pageSize.width() * pageSize.height());
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.
@@ -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);
}

@@ -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);
}

@@ -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();
@@ -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
@@ -168,13 +168,7 @@ class RenderView : public RenderBlock {
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;
@@ -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.
@@ -1343,8 +1343,9 @@ - (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageS
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);

0 comments on commit 12dad35

Please sign in to comment.