Index: Source/core/rendering/RenderTableSection.cpp |
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
index a04afb2003167a18f7a1413a66a82d682dfd3f8a..656b5514fe13c482437ea97056ee9d13e7a07d12 100644 |
--- a/Source/core/rendering/RenderTableSection.cpp |
+++ b/Source/core/rendering/RenderTableSection.cpp |
@@ -1065,7 +1065,7 @@ void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n |
ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
} |
-int RenderTableSection::calcOuterBorderBefore() const |
+int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) const |
{ |
unsigned totalCols = table()->numEffCols(); |
if (!m_grid.size() || !totalCols) |
@@ -1073,13 +1073,13 @@ int RenderTableSection::calcOuterBorderBefore() const |
unsigned borderWidth = 0; |
- const BorderValue& sb = style()->borderBefore(); |
+ const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : style()->borderAfter(); |
if (sb.style() == BHIDDEN) |
return -1; |
if (sb.style() > BHIDDEN) |
borderWidth = sb.width(); |
- const BorderValue& rb = firstChild()->style()->borderBefore(); |
+ const BorderValue& rb = side == BorderBefore ? firstChild()->style()->borderBefore() : lastChild()->style()->borderAfter(); |
if (rb.style() == BHIDDEN) |
return -1; |
if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
@@ -1087,14 +1087,15 @@ int RenderTableSection::calcOuterBorderBefore() const |
bool allHidden = true; |
for (unsigned c = 0; c < totalCols; c++) { |
- const CellStruct& current = cellAt(0, c); |
+ const CellStruct& current = cellAt(side == BorderBefore ? 0 : m_grid.size() - 1, c); |
if (current.inColSpan || !current.hasCells()) |
continue; |
- const BorderValue& cb = current.primaryCell()->style()->borderBefore(); // FIXME: Make this work with perpendicular and flipped cells. |
+ const RenderStyle* primaryCellStyle = current.primaryCell()->style(); |
+ const BorderValue& cb = side == BorderBefore ? primaryCellStyle->borderBefore() : primaryCellStyle->borderAfter(); // FIXME: Make this work with perpendicular and flipped cells. |
// FIXME: Don't repeat for the same col group |
RenderTableCol* colGroup = table()->colElement(c); |
if (colGroup) { |
- const BorderValue& gb = colGroup->style()->borderBefore(); |
+ const BorderValue& gb = side == BorderBefore ? colGroup->style()->borderBefore() : colGroup->style()->borderAfter(); |
if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) |
continue; |
allHidden = false; |
@@ -1113,120 +1114,28 @@ int RenderTableSection::calcOuterBorderBefore() const |
if (allHidden) |
return -1; |
+ if (side == BorderAfter) |
+ borderWidth++; // Distribute rounding error |
return borderWidth / 2; |
} |
-int RenderTableSection::calcOuterBorderAfter() const |
+int RenderTableSection::calcInlineDirectionOuterBorder(InlineBorderSide side) const |
{ |
unsigned totalCols = table()->numEffCols(); |
if (!m_grid.size() || !totalCols) |
return 0; |
+ unsigned colIndex = side == BorderStart ? 0 : totalCols - 1; |
unsigned borderWidth = 0; |
- const BorderValue& sb = style()->borderAfter(); |
+ const BorderValue& sb = side == BorderStart ? style()->borderStart() : style()->borderEnd(); |
if (sb.style() == BHIDDEN) |
return -1; |
if (sb.style() > BHIDDEN) |
borderWidth = sb.width(); |
- const BorderValue& rb = lastChild()->style()->borderAfter(); |
- if (rb.style() == BHIDDEN) |
- return -1; |
- if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
- borderWidth = rb.width(); |
- |
- bool allHidden = true; |
- for (unsigned c = 0; c < totalCols; c++) { |
- const CellStruct& current = cellAt(m_grid.size() - 1, c); |
- if (current.inColSpan || !current.hasCells()) |
- continue; |
- const BorderValue& cb = current.primaryCell()->style()->borderAfter(); // FIXME: Make this work with perpendicular and flipped cells. |
- // FIXME: Don't repeat for the same col group |
- RenderTableCol* colGroup = table()->colElement(c); |
- if (colGroup) { |
- const BorderValue& gb = colGroup->style()->borderAfter(); |
- if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) |
- continue; |
- allHidden = false; |
- if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
- borderWidth = gb.width(); |
- if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
- borderWidth = cb.width(); |
- } else { |
- if (cb.style() == BHIDDEN) |
- continue; |
- allHidden = false; |
- if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
- borderWidth = cb.width(); |
- } |
- } |
- if (allHidden) |
- return -1; |
- |
- return (borderWidth + 1) / 2; |
-} |
- |
-int RenderTableSection::calcOuterBorderStart() const |
-{ |
- unsigned totalCols = table()->numEffCols(); |
- if (!m_grid.size() || !totalCols) |
- return 0; |
- |
- unsigned borderWidth = 0; |
- |
- const BorderValue& sb = style()->borderStart(); |
- if (sb.style() == BHIDDEN) |
- return -1; |
- if (sb.style() > BHIDDEN) |
- borderWidth = sb.width(); |
- |
- if (RenderTableCol* colGroup = table()->colElement(0)) { |
- const BorderValue& gb = colGroup->style()->borderStart(); |
- if (gb.style() == BHIDDEN) |
- return -1; |
- if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
- borderWidth = gb.width(); |
- } |
- |
- bool allHidden = true; |
- for (unsigned r = 0; r < m_grid.size(); r++) { |
- const CellStruct& current = cellAt(r, 0); |
- if (!current.hasCells()) |
- continue; |
- // FIXME: Don't repeat for the same cell |
- const BorderValue& cb = current.primaryCell()->style()->borderStart(); // FIXME: Make this work with perpendicular and flipped cells. |
- const BorderValue& rb = current.primaryCell()->parent()->style()->borderStart(); |
- if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) |
- continue; |
- allHidden = false; |
- if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
- borderWidth = cb.width(); |
- if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
- borderWidth = rb.width(); |
- } |
- if (allHidden) |
- return -1; |
- |
- return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2; |
-} |
- |
-int RenderTableSection::calcOuterBorderEnd() const |
-{ |
- unsigned totalCols = table()->numEffCols(); |
- if (!m_grid.size() || !totalCols) |
- return 0; |
- |
- unsigned borderWidth = 0; |
- |
- const BorderValue& sb = style()->borderEnd(); |
- if (sb.style() == BHIDDEN) |
- return -1; |
- if (sb.style() > BHIDDEN) |
- borderWidth = sb.width(); |
- |
- if (RenderTableCol* colGroup = table()->colElement(totalCols - 1)) { |
- const BorderValue& gb = colGroup->style()->borderEnd(); |
+ if (RenderTableCol* colGroup = table()->colElement(colIndex)) { |
+ const BorderValue& gb = side == BorderStart ? colGroup->style()->borderStart() : colGroup->style()->borderEnd(); |
if (gb.style() == BHIDDEN) |
return -1; |
if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
@@ -1235,12 +1144,14 @@ int RenderTableSection::calcOuterBorderEnd() const |
bool allHidden = true; |
for (unsigned r = 0; r < m_grid.size(); r++) { |
- const CellStruct& current = cellAt(r, totalCols - 1); |
+ const CellStruct& current = cellAt(r, colIndex); |
if (!current.hasCells()) |
continue; |
// FIXME: Don't repeat for the same cell |
- const BorderValue& cb = current.primaryCell()->style()->borderEnd(); // FIXME: Make this work with perpendicular and flipped cells. |
- const BorderValue& rb = current.primaryCell()->parent()->style()->borderEnd(); |
+ const RenderStyle* primaryCellStyle = current.primaryCell()->style(); |
+ const RenderStyle* primaryCellParentStyle = current.primaryCell()->parent()->style(); |
+ const BorderValue& cb = side == BorderStart ? primaryCellStyle->borderStart() : primaryCellStyle->borderEnd(); // FIXME: Make this work with perpendicular and flipped cells. |
+ const BorderValue& rb = side == BorderStart ? primaryCellParentStyle->borderStart() : primaryCellParentStyle->borderEnd(); |
if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) |
continue; |
allHidden = false; |
@@ -1252,15 +1163,17 @@ int RenderTableSection::calcOuterBorderEnd() const |
if (allHidden) |
return -1; |
- return (borderWidth + (table()->style()->isLeftToRightDirection() ? 1 : 0)) / 2; |
+ if ((side == BorderStart) != table()->style()->isLeftToRightDirection()) |
+ borderWidth++; // Distribute rounding error |
+ return borderWidth / 2; |
} |
void RenderTableSection::recalcOuterBorder() |
{ |
- m_outerBorderBefore = calcOuterBorderBefore(); |
- m_outerBorderAfter = calcOuterBorderAfter(); |
- m_outerBorderStart = calcOuterBorderStart(); |
- m_outerBorderEnd = calcOuterBorderEnd(); |
+ m_outerBorderBefore = calcBlockDirectionOuterBorder(BorderBefore); |
+ m_outerBorderAfter = calcBlockDirectionOuterBorder(BorderAfter); |
+ m_outerBorderStart = calcInlineDirectionOuterBorder(BorderStart); |
+ m_outerBorderEnd = calcInlineDirectionOuterBorder(BorderEnd); |
} |
int RenderTableSection::firstLineBoxBaseline() const |