Index: Source/core/rendering/RenderTableSection.cpp |
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
index a04afb2003167a18f7a1413a66a82d682dfd3f8a..df67ea4a4bd84e8035e77e0b8d34364b4b6ee55c 100644 |
--- a/Source/core/rendering/RenderTableSection.cpp |
+++ b/Source/core/rendering/RenderTableSection.cpp |
@@ -1065,168 +1065,77 @@ void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n |
ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
} |
-int RenderTableSection::calcOuterBorderBefore() const |
+int RenderTableSection::calcOuterBorder(BorderSide side) const |
{ |
- unsigned totalCols = table()->numEffCols(); |
- if (!m_grid.size() || !totalCols) |
- return 0; |
- |
- unsigned borderWidth = 0; |
- |
- const BorderValue& sb = style()->borderBefore(); |
- if (sb.style() == BHIDDEN) |
- return -1; |
- if (sb.style() > BHIDDEN) |
- borderWidth = sb.width(); |
+ if (side == BorderBefore || side == BorderAfter) { |
ojan
2014/01/24 01:35:13
I'd use a separate function for before/after and s
|
+ unsigned totalCols = table()->numEffCols(); |
+ if (!m_grid.size() || !totalCols) |
+ return 0; |
- const BorderValue& rb = firstChild()->style()->borderBefore(); |
- if (rb.style() == BHIDDEN) |
- return -1; |
- if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
- borderWidth = rb.width(); |
+ unsigned borderWidth = 0; |
- bool allHidden = true; |
- for (unsigned c = 0; c < totalCols; c++) { |
- const CellStruct& current = cellAt(0, c); |
- if (current.inColSpan || !current.hasCells()) |
- continue; |
- const BorderValue& cb = current.primaryCell()->style()->borderBefore(); // 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(); |
- 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 / 2; |
-} |
- |
-int RenderTableSection::calcOuterBorderAfter() const |
-{ |
- unsigned totalCols = table()->numEffCols(); |
- if (!m_grid.size() || !totalCols) |
- return 0; |
- |
- unsigned borderWidth = 0; |
- |
- const BorderValue& sb = style()->borderAfter(); |
- if (sb.style() == BHIDDEN) |
- return -1; |
- if (sb.style() > BHIDDEN) |
- borderWidth = sb.width(); |
+ 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 = lastChild()->style()->borderAfter(); |
- if (rb.style() == BHIDDEN) |
- return -1; |
- if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
- borderWidth = rb.width(); |
+ const BorderValue& rb = side == BorderBefore ? firstChild()->style()->borderBefore() : 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) |
+ bool allHidden = true; |
+ for (unsigned c = 0; c < totalCols; c++) { |
+ const CellStruct& current = cellAt(side == BorderBefore ? 0 : m_grid.size() - 1, c); |
+ if (current.inColSpan || !current.hasCells()) |
continue; |
- allHidden = false; |
- if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
- borderWidth = cb.width(); |
+ 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 = side == BorderBefore ? colGroup->style()->borderBefore() : 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) |
+ if (allHidden) |
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 (side == BorderAfter) |
+ borderWidth++; // Distribute rounding error |
+ return borderWidth / 2; |
} |
- if (allHidden) |
- return -1; |
- |
- return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2; |
-} |
-int RenderTableSection::calcOuterBorderEnd() const |
-{ |
+ ASSERT(side == BorderStart || side == BorderEnd); |
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()->borderEnd(); |
+ const BorderValue& sb = side == BorderStart ? style()->borderStart() : 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 = calcOuterBorder(BorderBefore); |
+ m_outerBorderAfter = calcOuterBorder(BorderAfter); |
+ m_outerBorderStart = calcOuterBorder(BorderStart); |
+ m_outerBorderEnd = calcOuterBorder(BorderEnd); |
} |
int RenderTableSection::firstLineBoxBaseline() const |