Commit 0bf6c84c authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-22 David Hyatt <hyatt@apple.com>

        Fix for https://bugs.webkit.org/show_bug.cgi?id=23487.

        This patch completely reworks vertical alignment of table cells.  The current system uses methods called borderTopExtra() and borderBottomExtra() to
        add extra space above and below the content of a cell.  This system was not confined to the table code and spilled out into all the other RenderObjects.
        The y-position of the table cell box was set to the outer edge of the cell, but the y() method of RenderBox lied and added in borderTopExtra().  height()
        also excluded the extra space, so did not accurately reflect the true size of the cell.
        
        With the new system, the table cell box is completely accurate.  The extra space becomes part of the padding of the cell.  Padding has been reworked so that
        additional intrinsic padding can be added on to the specified padding from style.  Only the table code has to deal with the extra cell padding.

        localToAbsoluteForContent has now been removed, since there no longer has to be a special hacked content box.

        A number of table layout tests progress with this change, since the new layout system actually fixes existing bugs in baseline alignment of cells.

        Reviewed by Oliver Hunt

        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        Make CSSComputedStyleDeclaration ask for padding values that exclude the built-in intrinsic padding.  This ensures that getComputedStyle continues
        to give the right answer.
    
        * dom/ContainerNode.cpp:
        (WebCore::ContainerNode::getLowerRightCorner):
        * editing/visible_units.cpp:
        (WebCore::previousLinePosition):
        (WebCore::nextLinePosition):
        * rendering/LayoutState.cpp:
        (WebCore::LayoutState::LayoutState):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
        
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::overflowRect):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
        
        (WebCore::RenderBlock::layoutBlock):
        (WebCore::RenderBlock::expandsToEncloseOverhangingFloats):
        The expandsToEncloseOverhangingFloats logic has been reworked.  Table cells and fieldsets did not properly handle floats that spilled into the bottom padding.  The
        resulting box needed to not only expand to encompass the float, but also needed to place the full bottom padding after the float.  The switch to make the extra table cell
        space into padding exposed this issue.  No extra layout test is required, since an existing table layout test exposes this issue and progresses to match Firefox with
        this change.
    
        (WebCore::RenderBlock::selectionGapRects):
        (WebCore::RenderBlock::paintSelection):
        (WebCore::RenderBlock::fillSelectionGaps):
        (WebCore::RenderBlock::nodeAtPoint):
        (WebCore::RenderBlock::positionForCoordinates):
        (WebCore::RenderBlock::offsetForContents):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
    
        * rendering/RenderBlock.h:
        Add the new simplified method for expanding to encompass overhanging floats.  The method has been devirtualized and made to include all of the cases (and not just a subset).

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::absoluteRects):
        (WebCore::RenderBox::absoluteQuads):
        (WebCore::RenderBox::absoluteContentBox):
        (WebCore::RenderBox::paintBoxDecorations):
        (WebCore::RenderBox::paintMask):
        (WebCore::RenderBox::getOverflowClipRect):
        (WebCore::RenderBox::localToAbsolute):
        (WebCore::RenderBox::absoluteToLocal):
        (WebCore::RenderBox::localToAbsoluteQuad):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
        
        * rendering/RenderBox.h:
        (WebCore::RenderBox::y):
        (WebCore::RenderBox::location):
        (WebCore::RenderBox::borderBoxRect):
        (WebCore::RenderBox::offsetHeight):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.

        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::addLineBoxRects):
        * rendering/RenderFieldset.cpp:
        (WebCore::RenderFieldset::paintBoxDecorations):
        (WebCore::RenderFieldset::paintMask):
        * rendering/RenderFieldset.h:
        (WebCore::RenderFieldset::avoidsFloats):
        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::localCaretRect):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::updateLayerPosition):
        (WebCore::RenderLayer::paintLayer):
        (WebCore::RenderLayer::hitTestLayer):
        (WebCore::RenderLayer::boundingBox):
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::isPointInOverflowControl):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::localToAbsolute):
        (WebCore::RenderObject::absoluteToLocal):
        (WebCore::RenderObject::localToAbsoluteQuad):
        (WebCore::RenderObject::offsetFromContainer):
        (WebCore::RenderObject::paddingTop):
        (WebCore::RenderObject::paddingBottom):
        (WebCore::RenderObject::paddingLeft):
        (WebCore::RenderObject::paddingRight):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::hasOverhangingFloats):
        * rendering/RenderReplaced.cpp:
        (WebCore::RenderReplaced::selectionRect):
        (WebCore::RenderReplaced::localSelectionRect):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.  Also modifed paddingLeft/Top/Right/Bottom to take an argument indicating
        whether or not the intrinsic padding of an object should be included (by default it is).  getComputedStyle needs to exclude it, which is why this argument is
        necessary.

        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::RenderTableCell):
        (WebCore::RenderTableCell::paddingTop):
        (WebCore::RenderTableCell::paddingBottom):
        The new paddingTop() and paddingBottom() methods on table cells include the extra intrinsic padding.
    
        (WebCore::RenderTableCell::setOverrideSize):
        When a table's override size gets altered, the intrinsic padding needs to be cleared.
        
        (WebCore::RenderTableCell::absoluteClippedOverflowRect):
        (WebCore::RenderTableCell::computeAbsoluteRepaintRect):
        (WebCore::RenderTableCell::baselinePosition):
        (WebCore::RenderTableCell::paint):
        (WebCore::RenderTableCell::paintBackgroundsBehindCell):
        (WebCore::RenderTableCell::paintBoxDecorations):
        (WebCore::RenderTableCell::paintMask):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
        
        * rendering/RenderTableCell.h:
        (WebCore::RenderTableCell::setIntrinsicPaddingTop):
        (WebCore::RenderTableCell::setIntrinsicPaddingBottom):
        (WebCore::RenderTableCell::setIntrinsicPadding):
        (WebCore::RenderTableCell::clearIntrinsicPadding):
        (WebCore::RenderTableCell::intrinsicPaddingTop):
        (WebCore::RenderTableCell::intrinsicPaddingBottom):
        Add new helper methods for getting/setting a cell's intrinsic padding.
    
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::calcRowHeight):
        calcRowHeight has been modified to exclude the intrinsic padding when calculating the base height of rows prior to flexing.  Because a cell now includes that
        extra space, it has to be subtracted out in this method.
        
        (WebCore::RenderTableSection::layoutRows):
        Modify the code that sets up the intrinsic padding so that it does a relayout if the intrinsic padding changes.   There was also an error where the baseline
        position mismatched leading to negative intrinsic padding being added in (this error exists in ToT).  The code now properly ignores cells that don't establish
        a baseline.  A number of tests progress with this change.
        
        * rendering/RenderText.cpp:
        (WebCore::RenderText::addLineBoxRects):
        Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
        
        * rendering/RenderTreeAsText.cpp:
        (WebCore::operator<<):
        (WebCore::writeTextRun):
        Modify the render tree dumping code to continue to produce the same results as before.  This is really a hack, since we're now capable of indicating the correct
        position for the descendants of cells with intrinsic padding (and also indicating what the correct cell box is).  A future patch can remove these hacks so that the
        layout test results can all be regenerated.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40142 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 803a749f
2009-01-22 David Hyatt <hyatt@apple.com>
Fix for https://bugs.webkit.org/show_bug.cgi?id=23487.
This patch completely reworks vertical alignment of table cells. The current system uses methods called borderTopExtra() and borderBottomExtra() to
add extra space above and below the content of a cell. This system was not confined to the table code and spilled out into all the other RenderObjects.
The y-position of the table cell box was set to the outer edge of the cell, but the y() method of RenderBox lied and added in borderTopExtra(). height()
also excluded the extra space, so did not accurately reflect the true size of the cell.
With the new system, the table cell box is completely accurate. The extra space becomes part of the padding of the cell. Padding has been reworked so that
additional intrinsic padding can be added on to the specified padding from style. Only the table code has to deal with the extra cell padding.
localToAbsoluteForContent has now been removed, since there no longer has to be a special hacked content box.
A number of table layout tests progress with this change, since the new layout system actually fixes existing bugs in baseline alignment of cells.
Reviewed by Oliver Hunt
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
Make CSSComputedStyleDeclaration ask for padding values that exclude the built-in intrinsic padding. This ensures that getComputedStyle continues
to give the right answer.
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::getLowerRightCorner):
* editing/visible_units.cpp:
(WebCore::previousLinePosition):
(WebCore::nextLinePosition):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::overflowRect):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
(WebCore::RenderBlock::layoutBlock):
(WebCore::RenderBlock::expandsToEncloseOverhangingFloats):
The expandsToEncloseOverhangingFloats logic has been reworked. Table cells and fieldsets did not properly handle floats that spilled into the bottom padding. The
resulting box needed to not only expand to encompass the float, but also needed to place the full bottom padding after the float. The switch to make the extra table cell
space into padding exposed this issue. No extra layout test is required, since an existing table layout test exposes this issue and progresses to match Firefox with
this change.
(WebCore::RenderBlock::selectionGapRects):
(WebCore::RenderBlock::paintSelection):
(WebCore::RenderBlock::fillSelectionGaps):
(WebCore::RenderBlock::nodeAtPoint):
(WebCore::RenderBlock::positionForCoordinates):
(WebCore::RenderBlock::offsetForContents):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderBlock.h:
Add the new simplified method for expanding to encompass overhanging floats. The method has been devirtualized and made to include all of the cases (and not just a subset).
* rendering/RenderBox.cpp:
(WebCore::RenderBox::absoluteRects):
(WebCore::RenderBox::absoluteQuads):
(WebCore::RenderBox::absoluteContentBox):
(WebCore::RenderBox::paintBoxDecorations):
(WebCore::RenderBox::paintMask):
(WebCore::RenderBox::getOverflowClipRect):
(WebCore::RenderBox::localToAbsolute):
(WebCore::RenderBox::absoluteToLocal):
(WebCore::RenderBox::localToAbsoluteQuad):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderBox.h:
(WebCore::RenderBox::y):
(WebCore::RenderBox::location):
(WebCore::RenderBox::borderBoxRect):
(WebCore::RenderBox::offsetHeight):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderContainer.cpp:
(WebCore::RenderContainer::addLineBoxRects):
* rendering/RenderFieldset.cpp:
(WebCore::RenderFieldset::paintBoxDecorations):
(WebCore::RenderFieldset::paintMask):
* rendering/RenderFieldset.h:
(WebCore::RenderFieldset::avoidsFloats):
* rendering/RenderFlow.cpp:
(WebCore::RenderFlow::localCaretRect):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
(WebCore::RenderLayer::paintLayer):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::boundingBox):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::isPointInOverflowControl):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::localToAbsolute):
(WebCore::RenderObject::absoluteToLocal):
(WebCore::RenderObject::localToAbsoluteQuad):
(WebCore::RenderObject::offsetFromContainer):
(WebCore::RenderObject::paddingTop):
(WebCore::RenderObject::paddingBottom):
(WebCore::RenderObject::paddingLeft):
(WebCore::RenderObject::paddingRight):
* rendering/RenderObject.h:
(WebCore::RenderObject::hasOverhangingFloats):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::selectionRect):
(WebCore::RenderReplaced::localSelectionRect):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. Also modifed paddingLeft/Top/Right/Bottom to take an argument indicating
whether or not the intrinsic padding of an object should be included (by default it is). getComputedStyle needs to exclude it, which is why this argument is
necessary.
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::RenderTableCell):
(WebCore::RenderTableCell::paddingTop):
(WebCore::RenderTableCell::paddingBottom):
The new paddingTop() and paddingBottom() methods on table cells include the extra intrinsic padding.
(WebCore::RenderTableCell::setOverrideSize):
When a table's override size gets altered, the intrinsic padding needs to be cleared.
(WebCore::RenderTableCell::absoluteClippedOverflowRect):
(WebCore::RenderTableCell::computeAbsoluteRepaintRect):
(WebCore::RenderTableCell::baselinePosition):
(WebCore::RenderTableCell::paint):
(WebCore::RenderTableCell::paintBackgroundsBehindCell):
(WebCore::RenderTableCell::paintBoxDecorations):
(WebCore::RenderTableCell::paintMask):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::setIntrinsicPaddingTop):
(WebCore::RenderTableCell::setIntrinsicPaddingBottom):
(WebCore::RenderTableCell::setIntrinsicPadding):
(WebCore::RenderTableCell::clearIntrinsicPadding):
(WebCore::RenderTableCell::intrinsicPaddingTop):
(WebCore::RenderTableCell::intrinsicPaddingBottom):
Add new helper methods for getting/setting a cell's intrinsic padding.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowHeight):
calcRowHeight has been modified to exclude the intrinsic padding when calculating the base height of rows prior to flexing. Because a cell now includes that
extra space, it has to be subtracted out in this method.
(WebCore::RenderTableSection::layoutRows):
Modify the code that sets up the intrinsic padding so that it does a relayout if the intrinsic padding changes. There was also an error where the baseline
position mismatched leading to negative intrinsic padding being added in (this error exists in ToT). The code now properly ignores cells that don't establish
a baseline. A number of tests progress with this change.
* rendering/RenderText.cpp:
(WebCore::RenderText::addLineBoxRects):
Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls.
* rendering/RenderTreeAsText.cpp:
(WebCore::operator<<):
(WebCore::writeTextRun):
Modify the render tree dumping code to continue to produce the same results as before. This is really a hack, since we're now capable of indicating the correct
position for the descendants of cells with intrinsic padding (and also indicating what the correct cell box is). A future patch can remove these hacks so that the
layout test results can all be regenerated.
2009-01-22 Eric Seidel <eric@webkit.org>
Reviewed by Justin Garcia.
......@@ -863,19 +863,19 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
return CSSPrimitiveValue::create(style->overflowY());
case CSSPropertyPaddingTop:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(renderer->paddingTop(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingTop());
case CSSPropertyPaddingRight:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(renderer->paddingRight(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingRight());
case CSSPropertyPaddingBottom:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(renderer->paddingBottom(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingBottom());
case CSSPropertyPaddingLeft:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(renderer->paddingLeft(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingLeft());
case CSSPropertyPageBreakAfter:
return CSSPrimitiveValue::create(style->pageBreakAfter());
......
......@@ -722,8 +722,7 @@ bool ContainerNode::getLowerRightCorner(FloatPoint& point) const
{
RenderBox* box = RenderBox::toRenderBox(o);
point = o->localToAbsolute();
point.move(box->width(),
box->height() + box->borderTopExtra() + box->borderBottomExtra());
point.move(box->width(), box->height());
return true;
}
......
......@@ -494,7 +494,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
if (root) {
// FIXME: Can be wrong for multi-column layout and with transforms.
FloatPoint absPos = containingBlock->localToAbsoluteForContent(FloatPoint());
FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint());
if (containingBlock->hasOverflowClip())
absPos -= containingBlock->layer()->scrolledContentOffset();
RenderObject *renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->object();
......@@ -595,7 +595,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int x)
if (root) {
// FIXME: Can be wrong for multi-column layout and with transforms.
FloatPoint absPos = containingBlock->localToAbsoluteForContent(FloatPoint());
FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint());
if (containingBlock->hasOverflowClip())
absPos -= containingBlock->layer()->scrolledContentOffset();
RenderObject *renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->object();
......
......@@ -88,7 +88,7 @@ LayoutState::LayoutState(RenderObject* root)
#endif
{
RenderObject* container = root->container();
FloatPoint absContentPoint = container->localToAbsoluteForContent(FloatPoint(), false, true);
FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), false, true);
m_offset = IntSize(absContentPoint.x(), absContentPoint.y());
}
......
......@@ -510,8 +510,8 @@ IntRect RenderBlock::overflowRect(bool includeInterior) const
if (!includeInterior && hasOverflowClip())
return borderBoxRect();
int l = overflowLeft(includeInterior);
int t = min(overflowTop(includeInterior), -borderTopExtra());
return IntRect(l, t, overflowWidth(includeInterior) - l, max(overflowHeight(includeInterior), height() + borderBottomExtra()) - t);
int t = overflowTop(includeInterior);
return IntRect(l, t, overflowWidth(includeInterior) - l, max(overflowHeight(includeInterior), height()) - t);
}
bool RenderBlock::isSelfCollapsingBlock() const
......@@ -659,8 +659,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
// Expand our intrinsic height to encompass floats.
int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight();
if (floatBottom() > (height() - toAdd) && (isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() ||
(parent() && parent()->isFlexibleBox() || m_hasColumns)))
if (floatBottom() > (height() - toAdd) && expandsToEncloseOverhangingFloats())
setHeight(floatBottom() + toAdd);
// Now lay out our columns within this intrinsic height, since they can slightly affect the intrinsic height as
......@@ -693,11 +692,6 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
if (previousHeight != height())
relayoutChildren = true;
// Some classes of objects (floats and fieldsets with no specified heights and table cells) expand to encompass
// overhanging floats.
if (hasOverhangingFloats() && expandsToEncloseOverhangingFloats())
setHeight(floatBottom() + borderBottom() + paddingBottom());
if ((isCell || isInline() || isFloatingOrPositioned() || isRoot()) && !hasOverflowClip() && !hasControlClip())
addVisualOverflow(floatRect());
......@@ -764,6 +758,11 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
setNeedsLayout(false);
}
bool RenderBlock::expandsToEncloseOverhangingFloats() const
{
return isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBox()) || m_hasColumns || isTableCell() || isFieldset();
}
void RenderBlock::adjustPositionedBlock(RenderObject* child, const MarginInfo& marginInfo)
{
if (child->hasStaticX()) {
......@@ -1896,11 +1895,11 @@ GapRects RenderBlock::selectionGapRects()
return GapRects();
// FIXME: this is broken with transforms
FloatPoint absContentPoint = localToAbsoluteForContent(FloatPoint());
FloatPoint absContentPoint = localToAbsolute(FloatPoint());
if (hasOverflowClip())
absContentPoint -= layer()->scrolledContentOffset();
int lastTop = -borderTopExtra();
int lastTop = 0;
int lastLeft = leftSelectionOffset(this, lastTop);
int lastRight = rightSelectionOffset(this, lastTop);
......@@ -1910,7 +1909,7 @@ GapRects RenderBlock::selectionGapRects()
void RenderBlock::paintSelection(PaintInfo& paintInfo, int tx, int ty)
{
if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) {
int lastTop = -borderTopExtra();
int lastTop = 0;
int lastLeft = leftSelectionOffset(this, lastTop);
int lastRight = rightSelectionOffset(this, lastTop);
paintInfo.context->save();
......@@ -1973,7 +1972,7 @@ GapRects RenderBlock::fillSelectionGaps(RenderBlock* rootBlock, int blockX, int
// Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block.
if (rootBlock == this && (m_selectionState != SelectionBoth && m_selectionState != SelectionEnd))
result.uniteCenter(fillVerticalSelectionGap(lastTop, lastLeft, lastRight, ty + height() + borderBottomExtra(),
result.uniteCenter(fillVerticalSelectionGap(lastTop, lastLeft, lastRight, ty + height(),
rootBlock, blockX, blockY, paintInfo));
return result;
}
......@@ -3164,10 +3163,9 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
// Now hit test our background
if (!inlineFlow && (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground)) {
int topExtra = borderTopExtra();
IntRect boundsRect(tx, ty - topExtra, width(), height() + topExtra + borderBottomExtra());
IntRect boundsRect(tx, ty, width(), height());
if (visibleToHitTesting() && boundsRect.contains(_x, _y)) {
updateHitTestResult(result, IntPoint(_x - tx, _y - ty + topExtra));
updateHitTestResult(result, IntPoint(_x - tx, _y - ty));
return true;
}
}
......@@ -3275,7 +3273,7 @@ VisiblePosition RenderBlock::positionForCoordinates(int x, int y)
return RenderFlow::positionForCoordinates(x, y);
int top = borderTop();
int bottom = top + borderTopExtra() + paddingTop() + contentHeight() + paddingBottom() + borderBottomExtra();
int bottom = top + paddingTop() + contentHeight() + paddingBottom();
int left = borderLeft();
int right = left + paddingLeft() + contentWidth() + paddingRight();
......@@ -3386,8 +3384,6 @@ VisiblePosition RenderBlock::positionForCoordinates(int x, int y)
void RenderBlock::offsetForContents(int& tx, int& ty) const
{
ty -= borderTopExtra();
if (hasOverflowClip())
m_layer->addScrolledContentOffset(tx, ty);
......
......@@ -331,6 +331,8 @@ private:
void calcColumnWidth();
int layoutColumns(int endOfContent = -1);
bool expandsToEncloseOverhangingFloats() const;
protected:
struct FloatingObject {
enum Type {
......
......@@ -356,7 +356,7 @@ void RenderBox::absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool topLe
tx - x() + continuation->containingBlock()->x(),
ty - y() + continuation->containingBlock()->y(), topLevel);
} else
rects.append(IntRect(tx, ty, width(), height() + borderTopExtra() + borderBottomExtra()));
rects.append(IntRect(tx, ty, width(), height()));
}
void RenderBox::absoluteQuads(Vector<FloatQuad>& quads, bool topLevel)
......@@ -371,13 +371,13 @@ void RenderBox::absoluteQuads(Vector<FloatQuad>& quads, bool topLevel)
quads.append(localToAbsoluteQuad(localRect));
continuation->absoluteQuads(quads, topLevel);
} else
quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height() + borderTopExtra() + borderBottomExtra())));
quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height())));
}
IntRect RenderBox::absoluteContentBox() const
{
IntRect rect = contentBoxRect();
FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
FloatPoint absPos = localToAbsolute(FloatPoint());
rect.move(absPos.x(), absPos.y());
return rect;
}
......@@ -651,8 +651,7 @@ void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
}
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
ty -= borderTopExtra();
int h = height();
// border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat
// balloon layout is an example of this).
......@@ -693,8 +692,7 @@ void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
return;
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
ty -= borderTopExtra();
int h = height();
// border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat
// balloon layout is an example of this).
......@@ -1158,7 +1156,7 @@ IntRect RenderBox::getOverflowClipRect(int tx, int ty)
int clipX = tx + bLeft;
int clipY = ty + bTop;
int clipWidth = width() - bLeft - borderRight();
int clipHeight = height() - bTop - borderBottom() + borderTopExtra() + borderBottomExtra();
int clipHeight = height() - bTop - borderBottom();
// Subtract out scrollbars if we have them.
if (m_layer) {
......@@ -1270,7 +1268,7 @@ FloatPoint RenderBox::localToAbsolute(FloatPoint localPoint, bool fixed, bool us
localPoint += offsetFromContainer(o);
return o->localToAbsoluteForContent(localPoint, fixed, useTransforms);
return o->localToAbsolute(localPoint, fixed, useTransforms);
}
return FloatPoint();
......@@ -1290,16 +1288,9 @@ FloatPoint RenderBox::absoluteToLocal(FloatPoint containerPoint, bool fixed, boo
RenderObject* o = container();
if (o) {
FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms);
// Take into account space above a vertically aligned table cell
// (see localToAbsoluteForContent())
localPoint.move(0.0f, -static_cast<float>(borderTopExtra()));
localPoint -= offsetFromContainer(o);
if (useTransforms && m_layer && m_layer->transform())
localPoint = m_layer->transform()->inverse().mapPoint(localPoint);
return localPoint;
}
......@@ -1318,13 +1309,7 @@ FloatQuad RenderBox::localToAbsoluteQuad(const FloatQuad& localQuad, bool fixed)
fixed = false; // Elements with transforms act as a containing block for fixed position descendants
quad = m_layer->transform()->mapQuad(quad);
}
quad += offsetFromContainer(o);
// Take into account space above a vertically aligned table cell
// (see localToAbsoluteForContent())
quad.move(0.0f, static_cast<float>(o->borderTopExtra()));
return o->localToAbsoluteQuad(quad, fixed);
}
......
......@@ -40,7 +40,7 @@ public:
static const RenderBox* toConstRenderBox(const RenderObject* o) { ASSERT(!o || o->isBox()); return static_cast<const RenderBox*>(o);}
int x() const { return m_frameRect.x(); }
int y() const { return m_frameRect.y() + borderTopExtra(); } // FIXME: Need to deal with the borderTopExtra() lie in a sane way.
int y() const { return m_frameRect.y(); }
int width() const { return m_frameRect.width(); }
int height() const { return m_frameRect.height(); }
......@@ -49,7 +49,7 @@ public:
void setWidth(int width) { m_frameRect.setWidth(width); }
void setHeight(int height) { m_frameRect.setHeight(height); }
IntPoint location() const { return m_frameRect.location(); } // FIXME: Be aware that this is not equivalent to x(), y() because of y()'s borderTopExtra() lie!
IntPoint location() const { return m_frameRect.location(); }
IntSize size() const { return m_frameRect.size(); }
void setLocation(const IntPoint& location) { m_frameRect.setLocation(location); }
......@@ -61,7 +61,7 @@ public:
IntRect frameRect() const { return m_frameRect; }
void setFrameRect(const IntRect& rect) { m_frameRect = rect; }
IntRect borderBoxRect() const { return IntRect(0, -borderTopExtra(), width(), height() + borderTopExtra() + borderBottomExtra()); }
IntRect borderBoxRect() const { return IntRect(0, 0, width(), height()); }
// The content area of the box (excludes padding and border).
IntRect contentBoxRect() const { return IntRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
......@@ -96,7 +96,7 @@ public:
// IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
// to return the remaining width on a given line (and the height of a single line).
virtual int offsetWidth() const { return width(); }
virtual int offsetHeight() const { return height() + borderTopExtra() + borderBottomExtra(); }
virtual int offsetHeight() const { return height(); }
virtual int offsetLeft() const;
virtual int offsetTop() const;
virtual RenderBox* offsetParent() const;
......
......@@ -671,7 +671,7 @@ VisiblePosition RenderContainer::positionForCoordinates(int xPos, int yPos)
void RenderContainer::addLineBoxRects(Vector<IntRect>& rects, unsigned start, unsigned end, bool)
{
if (!m_firstChild && (isInline() || isAnonymousBlock())) {
FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
FloatPoint absPos = localToAbsolute(FloatPoint());
absoluteRects(rects, absPos.x(), absPos.y());
return;
}
......@@ -682,7 +682,7 @@ void RenderContainer::addLineBoxRects(Vector<IntRect>& rects, unsigned start, un
unsigned offset = start;
for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) {
if (child->isText() || child->isInline() || child->isAnonymousBlock()) {
FloatPoint absPos = child->localToAbsoluteForContent(FloatPoint());
FloatPoint absPos = child->localToAbsolute(FloatPoint());
child->absoluteRects(rects, absPos.x(), absPos.y());
}
}
......
......@@ -121,7 +121,7 @@ RenderBox* RenderFieldset::findLegend() const
void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
{
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
int h = height();
RenderBox* legend = findLegend();
if (!legend)
return RenderBlock::paintBoxDecorations(paintInfo, tx, ty);
......@@ -129,7 +129,7 @@ void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
int legendBottom = ty + legend->y() + legend->height();
h -= yOff;
ty += yOff - borderTopExtra();
ty += yOff;
int my = max(ty, paintInfo.rect.y());
int end = min(paintInfo.rect.bottom(), ty + h);
......@@ -167,14 +167,14 @@ void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)
return;
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
int h = height();
RenderBox* legend = findLegend();
if (!legend)
return RenderBlock::paintMask(paintInfo, tx, ty);
int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
h -= yOff;
ty += yOff - borderTopExtra();
ty += yOff;
int my = max(ty, paintInfo.rect.y());
int end = min(paintInfo.rect.bottom(), ty + h);
......
......@@ -41,7 +41,6 @@ public:
virtual void calcPrefWidths();
virtual bool avoidsFloats() const { return true; }
virtual bool expandsToEncloseOverhangingFloats() const { return style()->height().isAuto(); }
virtual bool stretchesToMinIntrinsicWidth() const { return true; }
RenderBox* findLegend() const;
......
......@@ -686,10 +686,10 @@ IntRect RenderFlow::localCaretRect(InlineBox* inlineBox, int caretOffset, int* e
int myRight = x + caretWidth;
// FIXME: why call localToAbsoluteForContent() twice here, too?
FloatPoint absRightPoint = localToAbsoluteForContent(FloatPoint(myRight, 0));
FloatPoint absRightPoint = localToAbsolute(FloatPoint(myRight, 0));
int containerRight = containingBlock()->x() + containingBlockWidth();
FloatPoint absContainerPoint = localToAbsoluteForContent(FloatPoint(containerRight, 0));
FloatPoint absContainerPoint = localToAbsolute(FloatPoint(containerRight, 0));
*extraWidthToEndOfLine = absContainerPoint.x() - absRightPoint.x();
}
......
......@@ -378,7 +378,7 @@ void RenderLayer::updateLayerPosition()
clearClipRects();
int x = renderer()->x();
int y = renderer()->y() - renderer()->borderTopExtra();
int y = renderer()->y();
if (!renderer()->isPositioned() && renderer()->parent()) {
// We must adjust our position by walking up the render tree looking for the
......@@ -393,7 +393,6 @@ void RenderLayer::updateLayerPosition()
}
curr = curr->parentBox();
}
y += curr->borderTopExtra();
if (curr->isTableRow()) {
// Put ourselves into the row coordinate space.
x -= curr->x();
......@@ -433,7 +432,7 @@ void RenderLayer::updateLayerPosition()
setHeight(inlineFlow->boundingBoxHeight());
} else {
setWidth(renderer()->width());
setHeight(renderer()->height() + renderer()->borderTopExtra() + renderer()->borderBottomExtra());
setHeight(renderer()->height());
}
if (!renderer()->hasOverflowClip()) {
......@@ -1733,7 +1732,7 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
int x = layerBounds.x();
int y = layerBounds.y();
int tx = x - renderer()->x();
int ty = y - renderer()->y() + renderer()->borderTopExtra();
int ty = y - renderer()->y();
// Ensure our lists are up-to-date.
updateZOrderLists();
......@@ -1957,7 +1956,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, const HitTestRequ
if (fgRect.contains(hitTestPoint) &&
renderer()->hitTest(request, result, hitTestPoint,
layerBounds.x() - renderer()->x(),
layerBounds.y() - renderer()->y() + renderer()->borderTopExtra(),
layerBounds.y() - renderer()->y(),
HitTestDescendants)) {
// For positioned generated content, we might still not have a
// node by the time we get to the layer level, since none of
......@@ -1987,7 +1986,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, const HitTestRequ
if (bgRect.contains(hitTestPoint) &&
renderer()->hitTest(request, result, hitTestPoint,
layerBounds.x() - renderer()->x(),
layerBounds.y() - renderer()->y() + renderer()->borderTopExtra(),
layerBounds.y() - renderer()->y(),
HitTestSelf)) {
if (!result.innerNode() || !result.innerNonSharedNode()) {
Node* e = enclosingElement();
......@@ -2231,10 +2230,8 @@ IntRect RenderLayer::boundingBox(const RenderLayer* rootLayer) const
for (RenderObject* child = renderer()->firstChild(); child; child = child->nextSibling()) {
if (child->isTableCell()) {
IntRect bbox = RenderBox::toRenderBox(child)->borderBoxRect();
bbox.move(0, child->borderTopExtra());
result.unite(bbox);
IntRect overflowRect = renderer()->overflowRect(false);
overflowRect.move(0, child->borderTopExtra());
if (bbox != overflowRect)
result.unite(overflowRect);
}
......@@ -2252,11 +2249,7 @@ IntRect RenderLayer::boundingBox(const RenderLayer* rootLayer) const
}
// We have to adjust the x/y of this result so that it is in the coordinate space of the layer.
// We also have to add in intrinsicPaddingTop here, since borderBoxRect(), in order to play well with methods like
// floatRect that deal with child content, uses an origin of (0,0) that is at the child content box (so
// border box returns a y coord of -borderTopExtra(). The layer, however, uses the outer box. This is all
// really confusing.
result.move(m_x, m_y + renderer()->borderTopExtra());
result.move(m_x, m_y);
}
// Convert the bounding box to an absolute position. We can do this easily by looking at the delta
......
......@@ -370,9 +370,9 @@ bool RenderListBox::isPointInOverflowControl(HitTestResult& result, int _x, int
return false;
IntRect vertRect(_tx + width() - borderRight() - m_vBar->width(),
_ty + borderTop() -