Commit 6861fa52 authored by dgrogan's avatar dgrogan Committed by Commit bot

[css-tables] Don't use internal layout structure when iterating all rows

Instead use basic firstChild and nextSibling. This avoids a crash when
the internal layout structure is dirty.

Add DCHECK to discourage future mistakes.

BUG=627839

Review-Url: https://codereview.chromium.org/2146163005
Cr-Commit-Position: refs/heads/master@{#405555}
parent 7e921d98
There was a crash when a row was removed and the border of a section was changed without an intervening CellRecalc.
No crash == pass
<!doctype html>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
runAfterLayoutAndPaint(
function () {
theTbody.removeChild(row1);
theTbody.style.border = "solid 10px blue";
}, true /* autoNotifyDone */);
</script>
<table style="border-collapse: collapse">
<tbody id=theTbody>
<tr id=row1><td>Some text</td></tr>
</tbody>
</table>
<p>There was a crash when a row was removed and the border of a section was changed without an intervening CellRecalc.</p>
<p>No crash == pass</p>
...@@ -1227,10 +1227,7 @@ bool LayoutTableSection::recalcChildOverflowAfterStyleChange() ...@@ -1227,10 +1227,7 @@ bool LayoutTableSection::recalcChildOverflowAfterStyleChange()
void LayoutTableSection::markAllCellsWidthsDirtyAndOrNeedsLayout(WhatToMarkAllCells whatToMark) void LayoutTableSection::markAllCellsWidthsDirtyAndOrNeedsLayout(WhatToMarkAllCells whatToMark)
{ {
for (unsigned i = 0; i < numRows(); i++) { for (LayoutTableRow* row = firstRow(); row; row = row->nextRow()) {
LayoutTableRow* row = rowLayoutObjectAt(i);
if (!row)
continue;
for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->nextCell()) { for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->nextCell()) {
cell->setPreferredLogicalWidthsDirty(); cell->setPreferredLogicalWidthsDirty();
if (whatToMark == MarkDirtyAndNeedsLayout) if (whatToMark == MarkDirtyAndNeedsLayout)
......
...@@ -246,7 +246,11 @@ public: ...@@ -246,7 +246,11 @@ public:
int outerBorderStart() const { return m_outerBorderStart; } int outerBorderStart() const { return m_outerBorderStart; }
int outerBorderEnd() const { return m_outerBorderEnd; } int outerBorderEnd() const { return m_outerBorderEnd; }
unsigned numRows() const { return m_grid.size(); } unsigned numRows() const
{
DCHECK(!needsCellRecalc());
return m_grid.size();
}
unsigned numEffectiveColumns() const; unsigned numEffectiveColumns() const;
// recalcCells() is used when we are not sure about the section's structure // recalcCells() is used when we are not sure about the section's structure
......
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