summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderBox.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
commit6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (patch)
treed9c68d1cca0b3e352f1e438561f3e504e641a08f /Source/WebCore/rendering/RenderBox.cpp
parentd0424a769059c84ae20beb3c217812792ea6726b (diff)
downloadqtwebkit-6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2.tar.gz
Imported WebKit commit c7503cef7ecb236730d1309676ab9fc723fd061d (http://svn.webkit.org/repository/webkit/trunk@128886)
New snapshot with various build fixes
Diffstat (limited to 'Source/WebCore/rendering/RenderBox.cpp')
-rw-r--r--Source/WebCore/rendering/RenderBox.cpp69
1 files changed, 37 insertions, 32 deletions
diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp
index 2c3375da0..a1a3c9922 100644
--- a/Source/WebCore/rendering/RenderBox.cpp
+++ b/Source/WebCore/rendering/RenderBox.cpp
@@ -2119,21 +2119,23 @@ LayoutUnit RenderBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig
return -1;
}
+bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const
+{
+ // For quirks mode and anonymous blocks, we skip auto-height containingBlocks when computing percentages.
+ // For standards mode, we treat the percentage as auto if it has an auto-height containing block.
+ if (!document()->inQuirksMode() && !containingBlock->isAnonymousBlock())
+ return false;
+ return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPositioned() && containingBlock->style()->logicalHeight().isAuto() && isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode();
+}
+
LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
{
LayoutUnit availableHeight = -1;
- // In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
- // block that may have a specified height and then use it. In strict mode, this violates the
- // specification, which states that percentage heights just revert to auto if the containing
- // block has an auto height. We still skip anonymous containing blocks in both modes, though, and look
- // only at explicit containers.
bool skippedAutoHeightContainingBlock = false;
RenderBlock* cb = containingBlock();
LayoutUnit rootMarginBorderPaddingHeight = 0;
- while (!cb->isRenderView() && !cb->isTableCell() && !cb->isOutOfFlowPositioned() && cb->style()->logicalHeight().isAuto() && isHorizontalWritingMode() == cb->isHorizontalWritingMode()) {
- if (!document()->inQuirksMode() && !cb->isAnonymousBlock())
- break;
+ while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation(cb)) {
if (cb->isBody() || cb->isRoot())
rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfter() + cb->borderAndPaddingLogicalHeight();
skippedAutoHeightContainingBlock = true;
@@ -2153,29 +2155,26 @@ LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
if (isHorizontalWritingMode() != cb->isHorizontalWritingMode())
availableHeight = cb->contentLogicalWidth();
- else if (cb->isTableCell()) {
+ else if (cb->isTableCell() && !skippedAutoHeightContainingBlock) {
// Table cells violate what the CSS spec says to do with heights. Basically we
// don't care if the cell specified a height or not. We just always make ourselves
// be a percentage of the cell's current content height.
- if (!skippedAutoHeightContainingBlock) {
- if (!cb->hasOverrideHeight()) {
- // Normally we would let the cell size intrinsically, but scrolling overflow has to be
- // treated differently, since WinIE lets scrolled overflow regions shrink as needed.
- // While we can't get all cases right, we can at least detect when the cell has a specified
- // height or when the table has a specified height. In these cases we want to initially have
- // no size and allow the flexing of the table or the cell to its specified height to cause us
- // to grow to fill the space. This could end up being wrong in some cases, but it is
- // preferable to the alternative (sizing intrinsically and making the row end up too big).
- RenderTableCell* cell = toRenderTableCell(cb);
- if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAuto() || !cell->table()->style()->logicalHeight().isAuto()))
- return 0;
- return -1;
- }
- availableHeight = cb->overrideLogicalContentHeight();
- includeBorderPadding = true;
+ if (!cb->hasOverrideHeight()) {
+ // Normally we would let the cell size intrinsically, but scrolling overflow has to be
+ // treated differently, since WinIE lets scrolled overflow regions shrink as needed.
+ // While we can't get all cases right, we can at least detect when the cell has a specified
+ // height or when the table has a specified height. In these cases we want to initially have
+ // no size and allow the flexing of the table or the cell to its specified height to cause us
+ // to grow to fill the space. This could end up being wrong in some cases, but it is
+ // preferable to the alternative (sizing intrinsically and making the row end up too big).
+ RenderTableCell* cell = toRenderTableCell(cb);
+ if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAuto() || !cell->table()->style()->logicalHeight().isAuto()))
+ return 0;
+ return -1;
}
+ availableHeight = cb->overrideLogicalContentHeight();
+ includeBorderPadding = true;
} else if (cbstyle->logicalHeight().isFixed()) {
- // Otherwise we only use our percentage height if our containing block had a specified height.
LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
} else if (cbstyle->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) {
@@ -3727,16 +3726,22 @@ void RenderBox::clearLayoutOverflow()
m_overflow->setLayoutOverflow(borderBoxRect());
}
-static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
+inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
+{
+ return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containingBlock(), box->isOutOfFlowPositioned());
+}
+
+bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool isOutOfFlowPositioned)
{
// In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
// block that may have a specified height and then use it. In strict mode, this violates the
// specification, which states that percentage heights just revert to auto if the containing
// block has an auto height. We still skip anonymous containing blocks in both modes, though, and look
// only at explicit containers.
- const RenderBlock* cb = box->containingBlock();
+ const RenderBlock* cb = containingBlock;
+ bool inQuirksMode = cb->document()->inQuirksMode();
while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->isOutOfFlowPositioned() && cb->style()->logicalHeight().isAuto()) {
- if (!box->document()->inQuirksMode() && !cb->isAnonymousBlock())
+ if (!inQuirksMode && !cb->isAnonymousBlock())
break;
cb = cb->containingBlock();
}
@@ -3758,10 +3763,10 @@ static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
if (cb->style()->logicalHeight().isFixed())
return true;
if (cb->style()->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight)
- return percentageLogicalHeightIsResolvable(cb);
- if (cb->isRenderView() || (cb->isBody() && box->document()->inQuirksMode()) || isOutOfFlowPositionedWithSpecifiedHeight)
+ return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock(), cb->isOutOfFlowPositioned());
+ if (cb->isRenderView() || inQuirksMode || isOutOfFlowPositionedWithSpecifiedHeight)
return true;
- if (cb->isRoot() && box->isOutOfFlowPositioned()) {
+ if (cb->isRoot() && isOutOfFlowPositioned) {
// Match the positioned objects behavior, which is that positioned objects will fill their viewport
// always. Note we could only hit this case by recurring into computePercentageLogicalHeight on a positioned containing block.
return true;