Index: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
index 743943848cd72604487ddec936cfc8d786bab25c..603f7c357168986e2c4eabca8382c6b28a810c50 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
@@ -210,18 +210,6 @@ void LayoutTableSection::addChild(LayoutObject* child, |
LayoutTableBoxComponent::addChild(child, beforeChild); |
} |
-void LayoutTableSection::ensureRows(unsigned numRows) { |
- if (numRows <= m_grid.size()) |
- return; |
- |
- unsigned oldSize = m_grid.size(); |
- m_grid.grow(numRows); |
- |
- unsigned effectiveColumnCount = std::max(1u, table()->numEffectiveColumns()); |
- for (unsigned row = oldSize; row < m_grid.size(); ++row) |
- m_grid[row].row.grow(effectiveColumnCount); |
-} |
- |
static inline void checkThatVectorIsDOMOrdered( |
const Vector<LayoutTableCell*, 1>& cells) { |
#ifndef NDEBUG |
@@ -261,7 +249,6 @@ void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) { |
unsigned cSpan = cell->colSpan(); |
const Vector<LayoutTable::ColumnStruct>& columns = |
table()->effectiveColumns(); |
- unsigned nCols = columns.size(); |
unsigned insertionRow = row->rowIndex(); |
// ### mozilla still seems to do the old HTML way, even for strict DTD |
@@ -271,8 +258,9 @@ void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) { |
// <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4 |
// <TR><TD colspan="2">5 |
// </TABLE> |
- while (m_cCol < nCols && (cellAt(insertionRow, m_cCol).hasCells() || |
- cellAt(insertionRow, m_cCol).inColSpan)) |
+ while (m_cCol < numCols(insertionRow) && |
+ (cellAt(insertionRow, m_cCol).hasCells() || |
+ cellAt(insertionRow, m_cCol).inColSpan)) |
m_cCol++; |
updateLogicalHeightForCell(m_grid[insertionRow], cell); |
@@ -286,7 +274,7 @@ void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) { |
bool inColSpan = false; |
while (cSpan) { |
unsigned currentSpan; |
- if (m_cCol >= nCols) { |
+ if (m_cCol >= columns.size()) { |
table()->appendEffectiveColumn(cSpan); |
currentSpan = cSpan; |
} else { |
@@ -295,6 +283,7 @@ void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) { |
currentSpan = columns[m_cCol].span; |
} |
for (unsigned r = 0; r < rSpan; r++) { |
+ ensureCols(insertionRow + r, m_cCol + 1); |
CellStruct& c = cellAt(insertionRow + r, m_cCol); |
ASSERT(cell); |
c.cells.append(cell); |
@@ -1139,7 +1128,6 @@ void LayoutTableSection::layoutRows() { |
setLogicalWidth(table()->contentLogicalWidth()); |
int vspacing = table()->vBorderSpacing(); |
- unsigned nEffCols = table()->numEffectiveColumns(); |
LayoutState state(*this); |
// Set the rows' location and size. |
@@ -1164,7 +1152,7 @@ void LayoutTableSection::layoutRows() { |
for (unsigned r = 0; r < totalRows; r++) { |
LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; |
- for (unsigned c = 0; c < nEffCols; c++) { |
+ for (unsigned c = 0; c < numCols(r); c++) { |
CellStruct& cs = cellAt(r, c); |
LayoutTableCell* cell = cs.primaryCell(); |
@@ -1228,7 +1216,7 @@ void LayoutTableSection::layoutRows() { |
setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); |
- computeOverflowFromCells(totalRows, nEffCols); |
+ computeOverflowFromCells(totalRows, table()->numEffectiveColumns()); |
} |
int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row, |
@@ -1284,7 +1272,7 @@ void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, |
#endif |
// Now that our height has been determined, add in overflow from cells. |
for (unsigned r = 0; r < totalRows; r++) { |
- for (unsigned c = 0; c < nEffCols; c++) { |
+ for (unsigned c = 0; c < numCols(r); c++) { |
CellStruct& cs = cellAt(r, c); |
LayoutTableCell* cell = cs.primaryCell(); |
if (!cell || cs.inColSpan) |
@@ -1317,7 +1305,6 @@ bool LayoutTableSection::recalcChildOverflowAfterStyleChange() { |
ASSERT(childNeedsOverflowRecalcAfterStyleChange()); |
clearChildNeedsOverflowRecalcAfterStyleChange(); |
unsigned totalRows = m_grid.size(); |
- unsigned numEffCols = table()->numEffectiveColumns(); |
bool childrenOverflowChanged = false; |
for (unsigned r = 0; r < totalRows; r++) { |
LayoutTableRow* rowLayouter = rowLayoutObjectAt(r); |
@@ -1326,7 +1313,7 @@ bool LayoutTableSection::recalcChildOverflowAfterStyleChange() { |
continue; |
rowLayouter->clearChildNeedsOverflowRecalcAfterStyleChange(); |
bool rowChildrenOverflowChanged = false; |
- for (unsigned c = 0; c < numEffCols; c++) { |
+ for (unsigned c = 0; c < numCols(r); c++) { |
CellStruct& cs = cellAt(r, c); |
LayoutTableCell* cell = cs.primaryCell(); |
if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleChange()) |
@@ -1339,7 +1326,7 @@ bool LayoutTableSection::recalcChildOverflowAfterStyleChange() { |
} |
// TODO(crbug.com/604136): Add visual overflow from rows too. |
if (childrenOverflowChanged) |
- computeOverflowFromCells(totalRows, numEffCols); |
+ computeOverflowFromCells(totalRows, table()->numEffectiveColumns()); |
return childrenOverflowChanged; |
} |
@@ -1357,8 +1344,7 @@ void LayoutTableSection::markAllCellsWidthsDirtyAndOrNeedsLayout( |
int LayoutTableSection::calcBlockDirectionOuterBorder( |
BlockBorderSide side) const { |
- unsigned totalCols = table()->numEffectiveColumns(); |
- if (!m_grid.size() || !totalCols) |
+ if (!m_grid.size() || !table()->numEffectiveColumns()) |
return 0; |
int borderWidth = 0; |
@@ -1379,9 +1365,9 @@ int LayoutTableSection::calcBlockDirectionOuterBorder( |
borderWidth = rb.width(); |
bool allHidden = true; |
- for (unsigned c = 0; c < totalCols; c++) { |
- const CellStruct& current = |
- cellAt(side == BorderBefore ? 0 : m_grid.size() - 1, c); |
+ unsigned r = side == BorderBefore ? 0 : m_grid.size() - 1; |
+ for (unsigned c = 0; c < numCols(r); c++) { |
+ const CellStruct& current = cellAt(r, c); |
if (current.inColSpan || !current.hasCells()) |
continue; |
const ComputedStyle& primaryCellStyle = current.primaryCell()->styleRef(); |
@@ -1448,6 +1434,8 @@ int LayoutTableSection::calcInlineDirectionOuterBorder( |
bool allHidden = true; |
for (unsigned r = 0; r < m_grid.size(); r++) { |
+ if (colIndex >= numCols(r)) |
+ continue; |
const CellStruct& current = cellAt(r, colIndex); |
if (!current.hasCells()) |
continue; |
@@ -1699,7 +1687,7 @@ unsigned LayoutTableSection::numEffectiveColumns() const { |
unsigned result = 0; |
for (unsigned r = 0; r < m_grid.size(); ++r) { |
- for (unsigned c = result; c < table()->numEffectiveColumns(); ++c) { |
+ for (unsigned c = result; c < numCols(r); ++c) { |
const CellStruct& cell = cellAt(r, c); |
if (cell.hasCells() || cell.inColSpan) |
result = c; |
@@ -1727,14 +1715,14 @@ const LayoutTableCell* LayoutTableSection::firstRowCellAdjoiningTableStart() |
const { |
unsigned adjoiningStartCellColumnIndex = |
hasSameDirectionAs(table()) ? 0 : table()->lastEffectiveColumnIndex(); |
- return cellAt(0, adjoiningStartCellColumnIndex).primaryCell(); |
+ return primaryCellAt(0, adjoiningStartCellColumnIndex); |
} |
const LayoutTableCell* LayoutTableSection::firstRowCellAdjoiningTableEnd() |
const { |
unsigned adjoiningEndCellColumnIndex = |
hasSameDirectionAs(table()) ? table()->lastEffectiveColumnIndex() : 0; |
- return cellAt(0, adjoiningEndCellColumnIndex).primaryCell(); |
+ return primaryCellAt(0, adjoiningEndCellColumnIndex); |
} |
void LayoutTableSection::appendEffectiveColumn(unsigned pos) { |
@@ -1751,6 +1739,7 @@ void LayoutTableSection::splitEffectiveColumn(unsigned pos, unsigned first) { |
m_cCol++; |
for (unsigned row = 0; row < m_grid.size(); ++row) { |
Row& r = m_grid[row].row; |
+ ensureCols(row, pos + 2); |
r.insert(pos + 1, CellStruct()); |
if (r[pos].hasCells()) { |
r[pos + 1].cells.appendVector(r[pos].cells); |
@@ -1818,6 +1807,9 @@ bool LayoutTableSection::nodeAtPoint(HitTestResult& result, |
for (unsigned hitRow = rowSpan.start(); hitRow < rowSpan.end(); ++hitRow) { |
for (unsigned hitColumn = columnSpan.start(); hitColumn < columnSpan.end(); |
++hitColumn) { |
+ if (hitColumn >= numCols(hitRow)) |
+ break; |
+ |
CellStruct& current = cellAt(hitRow, hitColumn); |
// If the cell is empty, there's nothing to do |