Commit 21cc37a9 authored by hyatt@apple.com's avatar hyatt@apple.com

Reviewed by Dan

        http://bugs.webkit.org/show_bug.cgi?id=17485

        Refine our behavior for empty inlines so that they work more correctly with margins/borders/padding.
        Fixes a regression on huffingtonpost.com.

        New tests added to fast/inline

        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
        (WebCore::InlineFlowBox::placeBoxesVertically):
        (WebCore::InlineFlowBox::shrinkBoxesWithNoTextChildren):
        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::calcMargins):
        * rendering/RenderFlow.h:
        * rendering/RenderObject.h:
        (WebCore::RenderObject::hasHorizontalBordersPaddingOrMargin):
        (WebCore::RenderObject::hasHorizontalBordersOrPadding):
        * rendering/bidi.cpp:
        (WebCore::getBorderPaddingMargin):
        (WebCore::RenderBlock::layoutInlineChildren):
        (WebCore::inlineFlowRequiresLineBox):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7e518c5b
2008-02-26 David Hyatt <hyatt@apple.com>
Reviewed by Dan
http://bugs.webkit.org/show_bug.cgi?id=17485
Refine our behavior for empty inlines so that they work more correctly with margins/borders/padding.
Fixes a regression on huffingtonpost.com.
New tests added to fast/inline
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
(WebCore::InlineFlowBox::placeBoxesVertically):
(WebCore::InlineFlowBox::shrinkBoxesWithNoTextChildren):
* rendering/RenderFlow.cpp:
(WebCore::RenderFlow::calcMargins):
* rendering/RenderFlow.h:
* rendering/RenderObject.h:
(WebCore::RenderObject::hasHorizontalBordersPaddingOrMargin):
(WebCore::RenderObject::hasHorizontalBordersOrPadding):
* rendering/bidi.cpp:
(WebCore::getBorderPaddingMargin):
(WebCore::RenderBlock::layoutInlineChildren):
(WebCore::inlineFlowRequiresLineBox):
2008-02-26 Sam Weinig <sam@webkit.org>
Fix Windows build.
......@@ -456,7 +456,7 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi
if (maxPositionBottom < curr->height())
maxPositionBottom = curr->height();
}
else if (curr->hasTextChildren() || curr->object()->hasBordersPaddingOrMargin() || strictMode) {
else if (curr->hasTextChildren() || curr->object()->hasHorizontalBordersOrPadding() || strictMode) {
int ascent = curr->baseline() - curr->yPos();
int descent = curr->height() - ascent;
if (maxAscent < ascent)
......@@ -491,7 +491,7 @@ void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bo
else if (curr->yPos() == PositionBottom)
curr->setYPos(y + maxHeight - curr->height());
else {
if (!curr->hasTextChildren() && !curr->object()->hasBordersPaddingOrMargin() && !strictMode)
if (!curr->hasTextChildren() && !curr->object()->hasHorizontalBordersOrPadding() && !strictMode)
childAffectsTopBottomPos = false;
curr->setYPos(curr->yPos() + y + maxAscent - curr->baseline());
}
......@@ -565,7 +565,7 @@ void InlineFlowBox::shrinkBoxesWithNoTextChildren(int topPos, int bottomPos)
}
// See if we have text children. If not, then we need to shrink ourselves to fit on the line.
if (!hasTextChildren() && !object()->hasBordersPaddingOrMargin()) {
if (!hasTextChildren() && !object()->hasHorizontalBordersOrPadding()) {
if (yPos() < topPos)
setYPos(topPos);
if (yPos() + height() > bottomPos)
......
......@@ -861,6 +861,12 @@ void RenderFlow::paintOutlineForLine(GraphicsContext* graphicsContext, int tx, i
ow);
}
void RenderFlow::calcMargins(int containerWidth)
{
m_marginLeft = style()->marginLeft().calcMinValue(containerWidth);
m_marginRight = style()->marginRight().calcMinValue(containerWidth);
}
#ifndef NDEBUG
void RenderFlow::checkConsistency() const
......
......@@ -102,6 +102,8 @@ public:
virtual bool hasColumns() const { return m_hasColumns; }
void calcMargins(int containerWidth);
void checkConsistency() const;
private:
......
......@@ -322,10 +322,9 @@ public:
bool hasBoxDecorations() const { return m_paintBackground; }
bool mustRepaintBackgroundOrBorder() const;
bool hasBordersPaddingOrMargin() const { return borderLeft() != 0 || borderRight() != 0 || borderTop() != 0 || borderBottom() != 0 ||
paddingLeft() != 0 || paddingRight() != 0 || paddingTop() != 0 || paddingBottom() != 0 ||
marginLeft() != 0 || marginRight() != 0 || marginTop() != 0 || marginBottom() != 0; }
bool hasHorizontalBordersPaddingOrMargin() const { return hasHorizontalBordersOrPadding() || marginLeft() != 0 || marginRight() != 0; }
bool hasHorizontalBordersOrPadding() const { return borderLeft() != 0 || borderRight() != 0 || paddingLeft() != 0 || paddingRight() != 0; }
bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; }
bool selfNeedsLayout() const { return m_needsLayout; }
bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
......
......@@ -83,26 +83,12 @@ static bool betweenMidpoints;
static bool isLineEmpty = true;
static bool previousLineBrokeCleanly = true;
static int getBPMWidth(int childValue, Length cssUnit)
{
if (!cssUnit.isIntrinsicOrAuto())
return (cssUnit.isFixed() ? cssUnit.value() : childValue);
return 0;
}
static int getBorderPaddingMargin(RenderObject* child, bool endOfInline)
{
RenderStyle* cstyle = child->style();
int result = 0;
bool leftSide = (cstyle->direction() == LTR) ? !endOfInline : endOfInline;
result += getBPMWidth((leftSide ? child->marginLeft() : child->marginRight()),
(leftSide ? cstyle->marginLeft() :
cstyle->marginRight()));
result += getBPMWidth((leftSide ? child->paddingLeft() : child->paddingRight()),
(leftSide ? cstyle->paddingLeft() :
cstyle->paddingRight()));
result += leftSide ? child->borderLeft() : child->borderRight();
return result;
bool leftSide = (child->style()->direction() == LTR) ? !endOfInline : endOfInline;
if (leftSide)
return child->marginLeft() + child->paddingLeft() + child->borderLeft();
return child->marginRight() + child->paddingRight() + child->borderRight();
}
static int inlineWidth(RenderObject* child, bool start = true, bool end = true)
......@@ -834,6 +820,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
bool endOfInline = false;
RenderObject* o = bidiFirst(this, bidi, false);
bool hasFloat = false;
int containerWidth = max(0, containingBlockWidth());
while (o) {
o->invalidateVerticalPosition();
if (o->isReplaced() || o->isFloating() || o->isPositioned()) {
......@@ -857,6 +844,10 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
else if (o->isText() || (o->isInlineFlow() && !endOfInline)) {
if (fullLayout || o->selfNeedsLayout())
o->dirtyLineBoxes(fullLayout);
// Calculate margins of inline flows so that they can be used later by line layout.
if (o->isInlineFlow())
static_cast<RenderFlow*>(o)->calcMargins(containerWidth);
o->setNeedsLayout(false);
}
o = bidiNext(this, o, bidi, false, &endOfInline);
......@@ -1227,7 +1218,7 @@ static bool inlineFlowRequiresLineBox(RenderObject* flow)
// FIXME: Right now, we only allow line boxes for inlines that are truly empty.
// We need to fix this, though, because at the very least, inlines containing only
// ignorable whitespace should should also have line boxes.
return flow->isInlineFlow() && !flow->firstChild() && flow->hasBordersPaddingOrMargin();
return flow->isInlineFlow() && !flow->firstChild() && flow->hasHorizontalBordersPaddingOrMargin();
}
static inline bool requiresLineBox(BidiIterator& it)
......
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