Commit be9be86e authored by eae@chromium.org's avatar eae@chromium.org

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

        Reviewed by Darin Adler.

        Convert RenderBox::setLocation, setLogicalLocation and setLogicalSize to IntPoint/IntSize
        https://bugs.webkit.org/show_bug.cgi?id=60585

        Refactoring, covered by existing tests.

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::positionLineBox):
        * rendering/RenderBox.h:
        (WebCore::RenderBox::setLogicalLocation):
        (WebCore::RenderBox::setLogicalSize):
        (WebCore::RenderBox::setLocation):
        * rendering/RenderFrameSet.cpp:
        (WebCore::RenderFrameSet::positionFrames):
        (WebCore::RenderFrameSet::positionFramesWithFlattening):
        * rendering/RenderMedia.cpp:
        (WebCore::RenderMedia::layout):
        * rendering/RenderScrollbarPart.cpp:
        (WebCore::RenderScrollbarPart::paintIntoRect):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::adjustLogicalHeightForCaption):
        (WebCore::RenderTable::layout):
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::layoutRows):
        * rendering/RenderTextControlSingleLine.cpp:
        (WebCore::RenderTextControlSingleLine::layout):
        * rendering/svg/SVGRootInlineBox.cpp:
        (WebCore::SVGRootInlineBox::layoutRootBox):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86395 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 56d3618d
2011-05-12 Emil A Eklund <eae@chromium.org>
Reviewed by Darin Adler.
Convert RenderBox::setLocation, setLogicalLocation and setLogicalSize to IntPoint/IntSize
https://bugs.webkit.org/show_bug.cgi?id=60585
Refactoring, covered by existing tests.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::positionLineBox):
* rendering/RenderBox.h:
(WebCore::RenderBox::setLogicalLocation):
(WebCore::RenderBox::setLogicalSize):
(WebCore::RenderBox::setLocation):
* rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::positionFrames):
(WebCore::RenderFrameSet::positionFramesWithFlattening):
* rendering/RenderMedia.cpp:
(WebCore::RenderMedia::layout):
* rendering/RenderScrollbarPart.cpp:
(WebCore::RenderScrollbarPart::paintIntoRect):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::adjustLogicalHeightForCaption):
(WebCore::RenderTable::layout):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::layoutRows):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::layout):
* rendering/svg/SVGRootInlineBox.cpp:
(WebCore::SVGRootInlineBox::layoutRootBox):
2011-05-12 Adrienne Walker <enne@google.com>
Reviewed by James Robinson.
......@@ -1369,7 +1369,7 @@ void RenderBox::positionLineBox(InlineBox* box)
box->remove();
box->destroy(renderArena());
} else if (isReplaced()) {
setLocation(lroundf(box->x()), lroundf(box->y()));
setLocation(roundedIntPoint(FloatPoint(box->x(), box->y())));
m_inlineBoxWrapper = box;
}
}
......
......@@ -75,6 +75,13 @@ public:
else
setX(top);
}
void setLogicalLocation(const IntPoint& location)
{
if (style()->isHorizontalWritingMode())
setLocation(location);
else
setLocation(location.transposedPoint());
}
void setLogicalWidth(int size)
{
if (style()->isHorizontalWritingMode())
......@@ -89,12 +96,12 @@ public:
else
setWidth(size);
}
void setLogicalLocation(int left, int top)
void setLogicalSize(const IntSize& size)
{
if (style()->isHorizontalWritingMode())
setLocation(left, top);
setSize(size);
else
setLocation(top, left);
setSize(size.transposedSize());
}
IntPoint location() const { return m_frameRect.location(); }
......@@ -102,7 +109,6 @@ public:
IntSize size() const { return m_frameRect.size(); }
void setLocation(const IntPoint& location) { m_frameRect.setLocation(location); }
void setLocation(int x, int y) { setLocation(IntPoint(x, y)); }
void setSize(const IntSize& size) { m_frameRect.setSize(size); }
void move(int dx, int dy) { m_frameRect.move(dx, dy); }
......
......@@ -518,7 +518,7 @@ void RenderFrameSet::positionFrames()
int xPos = 0;
int height = m_rows.m_sizes[r];
for (int c = 0; c < cols; c++) {
child->setLocation(xPos, yPos);
child->setLocation(IntPoint(xPos, yPos));
int width = m_cols.m_sizes[c];
// has to be resized and itself resize its contents
......@@ -615,7 +615,7 @@ void RenderFrameSet::positionFramesWithFlattening()
// ensure the rows and columns are filled
IntRect oldRect = child->frameRect();
child->setLocation(xPos, yPos);
child->setLocation(IntPoint(xPos, yPos));
child->setHeight(m_rows.m_sizes[r]);
child->setWidth(m_cols.m_sizes[c]);
......
......@@ -74,7 +74,7 @@ void RenderMedia::layout()
// and this method will be called many times per second during playback, use a LayoutStateMaintainer:
LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
controlsRenderer->setLocation(borderLeft() + paddingLeft(), borderTop() + paddingTop());
controlsRenderer->setLocation(IntPoint(borderLeft(), borderTop()) + IntSize(paddingLeft(), paddingTop()));
controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed));
controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed));
controlsRenderer->setNeedsLayout(true, false);
......
......@@ -162,7 +162,7 @@ void RenderScrollbarPart::imageChanged(WrappedImagePtr image, const IntRect* rec
void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, int tx, int ty, const IntRect& rect)
{
// Make sure our dimensions match the rect.
setLocation(rect.x() - tx, rect.y() - ty);
setLocation(rect.location() - IntSize(tx, ty));
setWidth(rect.width());
setHeight(rect.height());
......
......@@ -257,7 +257,7 @@ void RenderTable::adjustLogicalHeightForCaption()
ASSERT(m_caption);
IntRect captionRect(m_caption->x(), m_caption->y(), m_caption->width(), m_caption->height());
m_caption->setLogicalLocation(m_caption->marginStart(), logicalHeight());
m_caption->setLogicalLocation(IntPoint(m_caption->marginStart(), logicalHeight()));
if (!selfNeedsLayout() && m_caption->checkForRepaintDuringLayout())
m_caption->repaintDuringLayoutIfMoved(captionRect);
......@@ -374,7 +374,7 @@ void RenderTable::layout()
sectionMoved = true;
movedSectionLogicalTop = min(logicalHeight(), section->logicalTop()) + (style()->isHorizontalWritingMode() ? section->minYVisualOverflow() : section->minXVisualOverflow());
}
section->setLogicalLocation(sectionLogicalLeft, logicalHeight());
section->setLogicalLocation(IntPoint(sectionLogicalLeft, logicalHeight()));
setLogicalHeight(logicalHeight() + section->logicalHeight());
section = sectionBelow(section);
......
......@@ -493,7 +493,7 @@ int RenderTableSection::layoutRows(int toAdd)
for (int r = 0; r < totalRows; r++) {
// Set the row's x/y position and width/height.
if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) {
rowRenderer->setLocation(0, m_rowPos[r]);
rowRenderer->setLocation(IntPoint(0, m_rowPos[r]));
rowRenderer->setLogicalWidth(logicalWidth());
rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspacing);
rowRenderer->updateLayerTransform();
......@@ -607,10 +607,12 @@ int RenderTableSection::layoutRows(int toAdd)
IntRect oldCellRect(cell->x(), cell->y() , cell->width(), cell->height());
IntPoint cellLocation(0, m_rowPos[rindx]);
if (!style()->isLeftToRightDirection())
cell->setLogicalLocation(table()->columnPositions()[nEffCols] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + hspacing, m_rowPos[rindx]);
cellLocation.setX(table()->columnPositions()[nEffCols] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + hspacing);
else
cell->setLogicalLocation(table()->columnPositions()[c] + hspacing, m_rowPos[rindx]);
cellLocation.setX(table()->columnPositions()[c] + hspacing);
cell->setLogicalLocation(cellLocation);
view()->addLayoutDelta(IntSize(oldCellRect.x() - cell->x(), oldCellRect.y() - cell->y()));
if (intrinsicPaddingBefore != oldIntrinsicPaddingBefore || intrinsicPaddingAfter != oldIntrinsicPaddingAfter)
......
......@@ -291,7 +291,7 @@ void RenderTextControlSingleLine::layout()
// Ignores the paddings for the inner spin button.
if (RenderBox* spinBox = m_innerSpinButton ? m_innerSpinButton->renderBox() : 0) {
spinBox->setLocation(spinBox->x() + paddingRight(), borderTop());
spinBox->setLocation(IntPoint(spinBox->x() + paddingRight(), borderTop()));
spinBox->setHeight(height() - borderTop() - borderBottom());
}
......@@ -302,7 +302,7 @@ void RenderTextControlSingleLine::layout()
// of the inner block and laid out at the far right.
int x = width() - borderAndPaddingWidth() - button->width() - button->borderAndPaddingWidth();
int y = (height() - button->height()) / 2;
button->setLocation(x, y);
button->setLocation(IntPoint(x, y));
} else {
int x = width() - borderRight() - paddingRight() - button->width();
if (m_outerSpinButton && m_outerSpinButton->renderBox())
......@@ -314,7 +314,7 @@ void RenderTextControlSingleLine::layout()
else
innerTextRenderer->setX(paddingLeft() + borderLeft() + (spinBox ? spinBox->width() : 0));
int y = (height() - button->height()) / 2;
button->setLocation(x, y);
button->setLocation(IntPoint(x, y));
}
}
#endif
......@@ -328,7 +328,7 @@ void RenderTextControlSingleLine::layout()
// shadow at the bottom.
int y = (diff / 2) + (diff % 2);
int x = width() - borderRight() - paddingRight() - spinBox->width();
spinBox->setLocation(x, y);
spinBox->setLocation(IntPoint(x, y));
}
}
......
......@@ -176,22 +176,19 @@ void SVGRootInlineBox::layoutRootBox()
childRect.unite(child->calculateBoundaries());
}
int xBlock = childRect.x();
int yBlock = childRect.y();
int widthBlock = childRect.width();
int heightBlock = childRect.height();
// Finally, assign the root block position, now that all content is laid out.
parentBlock->setLocation(xBlock, yBlock);
parentBlock->setWidth(widthBlock);
parentBlock->setHeight(heightBlock);
parentBlock->setLocation(childRect.location());
parentBlock->setSize(childRect.size());
// Position all children relative to the parent block.
for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
// Skip generated content.
if (!child->renderer()->node())
continue;
child->adjustPosition(-xBlock, -yBlock);
child->adjustPosition(-childRect.x(), -childRect.y());
}
// Position ourselves.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment