Diff
Modified: trunk/Source/WebCore/ChangeLog (115704 => 115705)
--- trunk/Source/WebCore/ChangeLog 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/ChangeLog 2012-05-01 03:13:06 UTC (rev 115705)
@@ -1,3 +1,82 @@
+2012-04-30 Julien Chaffraix <[email protected]>
+
+ Move RenderTableCell's row index to RenderTableRow
+ https://bugs.webkit.org/show_bug.cgi?id=85229
+
+ Reviewed by Ojan Vafai.
+
+ Covered by the existing table tests.
+
+ Row index is a RenderTableRow concept and as such this change moves
+ the relevant logic into the class.
+
+ While touching the code, renamed row() -> rowIndex() as now RenderTableCell
+ can return its parent RenderTableRow and we were returning an index, not the row
+ itself.
+
+ * accessibility/AccessibilityTable.cpp:
+ (WebCore::AccessibilityTable::cellForColumnAndRow):
+ * accessibility/AccessibilityTableCell.cpp:
+ (WebCore::AccessibilityTableCell::rowIndexRange):
+ (WebCore::AccessibilityTableCell::titleUIElement):
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::cellAbove):
+ (WebCore::RenderTable::cellBelow):
+ (WebCore::RenderTable::cellBefore):
+ (WebCore::RenderTable::cellAfter):
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::RenderTreeAsText::writeRenderObject):
+ Updated after the renaming RenderTableCell::row() -> rowIndex().
+
+ * rendering/RenderTableCell.cpp:
+ (WebCore::RenderTableCell::RenderTableCell):
+ (WebCore::RenderTableCell::computeCollapsedBeforeBorder):
+ (WebCore::RenderTableCell::computeCollapsedAfterBorder):
+ Updated after m_rowIndex removal and row() -> rowIndex() renaming.
+
+ (WebCore::RenderTableCell::styleDidChange):
+ Switched the rowWasSet check to an ASSERT. The new logic guarantees that
+ row index was set straight when we insert the row. The previous logic was
+ opened to some race conditions as we could wait for a recalcCells call before
+ setting the index on the rows which made this check necessary.
+
+ * rendering/RenderTableCell.h:
+ (WebCore::RenderTableCell::row):
+ Added this RenderTableRow getter.
+
+ (WebCore::RenderTableCell::rowIndex):
+ Renamed from row().
+
+ * rendering/RenderTableRow.cpp:
+ (WebCore::RenderTableRow::RenderTableRow):
+ (WebCore::RenderTableRow::styleDidChange):
+ Updated after adding m_rowIndex / rowIndex().
+
+ * rendering/RenderTableRow.h:
+ (WebCore::RenderTableRow::setRowIndex):
+ (WebCore::RenderTableRow::rowIndex):
+ Added those getter / setter. Also kept m_rowIndex's smaller size
+ for future optimization and for symmetry with the column index on
+ RenderTableCell.
+
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::addChild):
+ (WebCore::RenderTableSection::recalcCells):
+ Made sure that whenever we insert or update our row index
+ we do call setRowIndex().
+
+ (WebCore::RenderTableSection::addCell):
+ This logic now doesn't need to query insertionRow as the cell's
+ should have the index of the row in which it is inserted.
+
+ (WebCore::RenderTableSection::calcRowLogicalHeight):
+ (WebCore::RenderTableSection::layoutRows):
+ (WebCore::compareCellPositionsWithOverflowingCells):
+ More updates after row() -> rowIndex() renaming.
+
+ * rendering/RenderTableSection.h:
+ Removed rowIndexForRenderer now that the row caches this informatin.
+
2012-04-30 Keishi Hattori <[email protected]>
datalist: Inconsistent behavior of HTMLInputElement::list
Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (115704 => 115705)
--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -501,7 +501,7 @@
cell = tableSection->primaryCellAt(testRow, column);
// cell overlapped. use this one
ASSERT(cell->rowSpan() >= 1);
- if (cell && ((cell->row() + (cell->rowSpan() - 1)) >= sectionSpecificRow))
+ if (cell && ((cell->rowIndex() + (cell->rowSpan() - 1)) >= sectionSpecificRow))
break;
cell = 0;
}
Modified: trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp (115704 => 115705)
--- trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -104,7 +104,7 @@
return;
RenderTableCell* renderCell = toRenderTableCell(m_renderer);
- rowRange.first = renderCell->row();
+ rowRange.first = renderCell->rowIndex();
rowRange.second = renderCell->rowSpan();
// since our table might have multiple sections, we have to offset our row appropriately
@@ -160,7 +160,7 @@
if (!col)
return 0;
- int row = renderCell->row();
+ int row = renderCell->rowIndex();
RenderTableSection* section = renderCell->section();
if (!section)
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -1134,7 +1134,7 @@
recalcSectionsIfNeeded();
// Find the section and row to look in
- unsigned r = cell->row();
+ unsigned r = cell->rowIndex();
RenderTableSection* section = 0;
unsigned rAbove = 0;
if (r > 0) {
@@ -1163,7 +1163,7 @@
recalcSectionsIfNeeded();
// Find the section and row to look in
- unsigned r = cell->row() + cell->rowSpan() - 1;
+ unsigned r = cell->rowIndex() + cell->rowSpan() - 1;
RenderTableSection* section = 0;
unsigned rBelow = 0;
if (r < cell->section()->numRows() - 1) {
@@ -1195,7 +1195,7 @@
return 0;
// If we hit a colspan back up to a real cell.
- RenderTableSection::CellStruct& prevCell = section->cellAt(cell->row(), effCol - 1);
+ RenderTableSection::CellStruct& prevCell = section->cellAt(cell->rowIndex(), effCol - 1);
return prevCell.primaryCell();
}
@@ -1206,7 +1206,7 @@
unsigned effCol = colToEffCol(cell->col() + cell->colSpan());
if (effCol >= numEffCols())
return 0;
- return cell->section()->primaryCellAt(cell->row(), effCol);
+ return cell->section()->primaryCellAt(cell->rowIndex(), effCol);
}
RenderBlock* RenderTable::firstLineBlock() const
Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -43,7 +43,6 @@
RenderTableCell::RenderTableCell(Node* node)
: RenderBlock(node)
- , m_row(unsetRowIndex)
, m_cellWidthChanged(false)
, m_column(unsetColumnIndex)
, m_hasAssociatedTableCellElement(node && (node->hasTagName(tdTag) || node->hasTagName(thTag)))
@@ -327,12 +326,13 @@
void RenderTableCell::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
ASSERT(style()->display() == TABLE_CELL);
+ ASSERT(!row() || row()->rowIndexWasSet());
RenderBlock::styleDidChange(diff, oldStyle);
setHasBoxDecorations(true);
- if (parent() && section() && oldStyle && style()->height() != oldStyle->height() && rowWasSet())
- section()->rowLogicalHeightChanged(row());
+ if (parent() && section() && oldStyle && style()->height() != oldStyle->height())
+ section()->rowLogicalHeightChanged(rowIndex());
// If border was changed, notify table.
if (parent()) {
@@ -597,7 +597,7 @@
// Now check row groups.
RenderTableSection* currSection = section();
- if (!row()) {
+ if (!rowIndex()) {
// (5) Our row group's before border.
result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderBefore(), includeColor ? currSection->style()->visitedDependentColor(beforeColorProperty) : Color(), BROWGROUP));
if (!result.exists())
@@ -675,7 +675,7 @@
// Now check row groups.
RenderTableSection* currSection = section();
- if (row() + rowSpan() >= currSection->numRows()) {
+ if (rowIndex() + rowSpan() >= currSection->numRows()) {
// (5) Our row group's after border.
result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderAfter(), includeColor ? currSection->style()->visitedDependentColor(afterColorProperty) : Color(), BROWGROUP));
if (!result.exists())
Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableCell.h 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h 2012-05-01 03:13:06 UTC (rev 115705)
@@ -25,6 +25,7 @@
#ifndef RenderTableCell_h
#define RenderTableCell_h
+#include "RenderTableRow.h"
#include "RenderTableSection.h"
namespace WebCore {
@@ -32,9 +33,6 @@
static const unsigned unsetColumnIndex = 0x7FFFFFFF;
static const unsigned maxColumnIndex = 0x7FFFFFFE; // 2,147,483,646
-static const unsigned unsetRowIndex = 0x7FFFFFFF;
-static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646
-
enum IncludeBorderColorOrNot { DoNotIncludeBorderColor, IncludeBorderColor };
class RenderTableCell : public RenderBlock {
@@ -65,24 +63,17 @@
return m_column;
}
- void setRow(unsigned row)
- {
- if (UNLIKELY(row > maxRowIndex))
- CRASH();
+ RenderTableRow* row() const { return toRenderTableRow(parent()); }
+ RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
+ RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
- m_row = row;
- }
-
- bool rowWasSet() const { return m_row != unsetRowIndex; }
- unsigned row() const
+ unsigned rowIndex() const
{
- ASSERT(rowWasSet());
- return m_row;
+ // This function shouldn't be called on a detached cell.
+ ASSERT(row());
+ return row()->rowIndex();
}
- RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
- RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
-
Length styleOrColLogicalWidth() const;
LayoutUnit logicalHeightForRowSizing() const;
@@ -190,7 +181,6 @@
CollapsedBorderValue computeCollapsedBeforeBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
CollapsedBorderValue computeCollapsedAfterBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
- unsigned m_row : 31;
bool m_cellWidthChanged : 1;
unsigned m_column : 31;
bool m_hasAssociatedTableCellElement : 1;
Modified: trunk/Source/WebCore/rendering/RenderTableRow.cpp (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableRow.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableRow.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -38,6 +38,7 @@
RenderTableRow::RenderTableRow(Node* node)
: RenderBox(node)
+ , m_rowIndex(unsetRowIndex)
{
// init RenderObject attributes
setInline(false); // our object is not Inline
@@ -72,7 +73,7 @@
updateBeforeAndAfterContent();
if (section() && oldStyle && style()->logicalHeight() != oldStyle->logicalHeight())
- section()->rowLogicalHeightChanged(section()->rowIndexForRenderer(this));
+ section()->rowLogicalHeightChanged(rowIndex());
// If border was changed, notify table.
if (parent()) {
Modified: trunk/Source/WebCore/rendering/RenderTableRow.h (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableRow.h 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableRow.h 2012-05-01 03:13:06 UTC (rev 115705)
@@ -29,6 +29,9 @@
namespace WebCore {
+static const unsigned unsetRowIndex = 0x7FFFFFFF;
+static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646
+
class RenderTableRow : public RenderBox {
public:
explicit RenderTableRow(Node*);
@@ -48,6 +51,21 @@
return createAnonymousWithParentRenderer(parent);
}
+ void setRowIndex(unsigned rowIndex)
+ {
+ if (UNLIKELY(rowIndex > maxRowIndex))
+ CRASH();
+
+ m_rowIndex = rowIndex;
+ }
+
+ bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; }
+ unsigned rowIndex() const
+ {
+ ASSERT(rowIndexWasSet());
+ return m_rowIndex;
+ }
+
private:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual const RenderObjectChildList* virtualChildren() const { return children(); }
@@ -73,6 +91,7 @@
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
RenderObjectChildList m_children;
+ unsigned m_rowIndex : 31;
};
inline RenderTableRow* toRenderTableRow(RenderObject* object)
Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -176,7 +176,9 @@
ensureRows(m_cRow);
- m_grid[insertionRow].rowRenderer = toRenderTableRow(child);
+ RenderTableRow* row = toRenderTableRow(child);
+ m_grid[insertionRow].rowRenderer = row;
+ row->setRowIndex(insertionRow);
if (!beforeChild)
setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]);
@@ -220,9 +222,7 @@
unsigned cSpan = cell->colSpan();
Vector<RenderTable::ColumnStruct>& columns = table()->columns();
unsigned nCols = columns.size();
- // addCell should be called only after m_cRow has been incremented.
- ASSERT(m_cRow);
- unsigned insertionRow = m_cRow - 1;
+ unsigned insertionRow = row->rowIndex();
// ### mozilla still seems to do the old HTML way, even for strict DTD
// (see the annotation on table cell layouting in the CSS specs and the testcase below:
@@ -266,7 +266,6 @@
cSpan -= currentSpan;
inColSpan = true;
}
- cell->setRow(insertionRow);
cell->setCol(table()->effColToCol(col));
}
@@ -348,11 +347,11 @@
// FIXME: We are always adding the height of a rowspan to the last rows which doesn't match
// other browsers. See webkit.org/b/52185 for example.
- if ((cell->row() + cell->rowSpan() - 1) != r)
+ if ((cell->rowIndex() + cell->rowSpan() - 1) != r)
continue;
// For row spanning cells, |r| is the last row in the span.
- unsigned cellStartRow = cell->row();
+ unsigned cellStartRow = cell->rowIndex();
if (cell->hasOverrideHeight()) {
if (!statePusher.didPush()) {
@@ -554,7 +553,7 @@
if (!cell || cs.inColSpan)
continue;
- rindx = cell->row();
+ rindx = cell->rowIndex();
rHeight = m_rowPos[rindx + cell->rowSpan()] - m_rowPos[rindx] - vspacing;
// Force percent height children to lay themselves out again.
@@ -989,15 +988,15 @@
static inline bool compareCellPositions(RenderTableCell* elem1, RenderTableCell* elem2)
{
- return elem1->row() < elem2->row();
+ return elem1->rowIndex() < elem2->rowIndex();
}
// This comparison is used only when we have overflowing cells as we have an unsorted array to sort. We thus need
// to sort both on rows and columns to properly repaint.
static inline bool compareCellPositionsWithOverflowingCells(RenderTableCell* elem1, RenderTableCell* elem2)
{
- if (elem1->row() != elem2->row())
- return elem1->row() < elem2->row();
+ if (elem1->rowIndex() != elem2->rowIndex())
+ return elem1->rowIndex() < elem2->rowIndex();
return elem1->col() < elem2->col();
}
@@ -1223,6 +1222,7 @@
RenderTableRow* tableRow = toRenderTableRow(row);
m_grid[insertionRow].rowRenderer = tableRow;
+ tableRow->setRowIndex(insertionRow);
setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]);
for (RenderObject* cell = row->firstChild(); cell; cell = cell->nextSibling()) {
@@ -1389,16 +1389,6 @@
}
-unsigned RenderTableSection::rowIndexForRenderer(const RenderTableRow* row) const
-{
- for (size_t i = 0; i < m_grid.size(); ++i) {
- if (m_grid[i].rowRenderer == row)
- return i;
- }
- ASSERT_NOT_REACHED();
- return 0;
-}
-
void RenderTableSection::removeCachedCollapsedBorders(const RenderTableCell* cell)
{
if (!table()->collapseBorders())
Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTableSection.h 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h 2012-05-01 03:13:06 UTC (rev 115705)
@@ -152,8 +152,6 @@
void rowLogicalHeightChanged(unsigned rowIndex);
- unsigned rowIndexForRenderer(const RenderTableRow*) const;
-
void removeCachedCollapsedBorders(const RenderTableCell*);
void setCachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide, CollapsedBorderValue);
CollapsedBorderValue& cachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide);
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (115704 => 115705)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -370,7 +370,7 @@
if (o.isTableCell()) {
const RenderTableCell& c = *toRenderTableCell(&o);
- ts << " [r=" << c.row() << " c=" << c.col() << " rs=" << c.rowSpan() << " cs=" << c.colSpan() << "]";
+ ts << " [r=" << c.rowIndex() << " c=" << c.col() << " rs=" << c.rowSpan() << " cs=" << c.colSpan() << "]";
}
#if ENABLE(DETAILS)
Modified: trunk/Source/WebKit/chromium/ChangeLog (115704 => 115705)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-01 03:13:06 UTC (rev 115705)
@@ -1,3 +1,13 @@
+2012-04-30 Julien Chaffraix <[email protected]>
+
+ Move RenderTableCell's row index to RenderTableRow
+ https://bugs.webkit.org/show_bug.cgi?id=85229
+
+ Reviewed by Ojan Vafai.
+
+ * tests/RenderTableCellTest.cpp:
+ Updated after the refactoring.
+
2012-04-30 Gavin Peters <[email protected]>
[Chromium] Add thunk headers for staging Prerendering API.
Modified: trunk/Source/WebKit/chromium/tests/RenderTableCellTest.cpp (115704 => 115705)
--- trunk/Source/WebKit/chromium/tests/RenderTableCellTest.cpp 2012-05-01 02:53:15 UTC (rev 115704)
+++ trunk/Source/WebKit/chromium/tests/RenderTableCellTest.cpp 2012-05-01 03:13:06 UTC (rev 115705)
@@ -94,8 +94,8 @@
TEST_F(RenderTableCellDeathTest, CanSetRow)
{
static const unsigned rowIndex = 10;
- m_cell->setRow(rowIndex);
- EXPECT_EQ(rowIndex, m_cell->row());
+ m_cell->row()->setRowIndex(rowIndex);
+ EXPECT_EQ(rowIndex, m_cell->rowIndex());
}
TEST_F(RenderTableCellDeathTest, CanSetColumnToMaxColumnIndex)
@@ -106,8 +106,8 @@
TEST_F(RenderTableCellDeathTest, CanSetRowToMaxRowIndex)
{
- m_cell->setRow(maxRowIndex);
- EXPECT_EQ(maxRowIndex, m_cell->row());
+ m_cell->row()->setRowIndex(maxRowIndex);
+ EXPECT_EQ(maxRowIndex, m_cell->rowIndex());
}
// FIXME: Re-enable these tests once ASSERT_DEATH is supported for Android.
@@ -121,7 +121,7 @@
TEST_F(RenderTableCellDeathTest, CrashIfRowOverflowOnSetting)
{
- ASSERT_DEATH(m_cell->setRow(maxRowIndex + 1), "");
+ ASSERT_DEATH(m_cell->row()->setRowIndex(maxRowIndex + 1), "");
}
TEST_F(RenderTableCellDeathTest, CrashIfSettingUnsetColumnIndex)
@@ -131,7 +131,7 @@
TEST_F(RenderTableCellDeathTest, CrashIfSettingUnsetRowIndex)
{
- ASSERT_DEATH(m_cell->setRow(unsetRowIndex), "");
+ ASSERT_DEATH(m_cell->row()->setRowIndex(unsetRowIndex), "");
}
#endif