Title: [131366] trunk/Source/WebCore
- Revision
- 131366
- Author
- [email protected]
- Date
- 2012-10-15 14:52:22 -0700 (Mon, 15 Oct 2012)
Log Message
Make RenderTable columns() and columnPositions() return a const reference
https://bugs.webkit.org/show_bug.cgi?id=99339
Reviewed by Abhishek Arya.
The 2 getters were returning a non-const reference. This means that callers
could have modified the Vector's where only FixedTableLayout and AutoTableLayout
were expected to (for columnPositions(), no one should modify columns()).
Refactoring covered by existing tests.
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::layout):
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::layout):
Updated those functions to use the new setter.
* rendering/RenderTable.h:
(WebCore::RenderTable::columns):
(WebCore::RenderTable::columnPositions):
Made the 2 functions return a const reference. They are also const now!
(WebCore::RenderTable::setColumnPosition):
Added this setter.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addCell):
(WebCore::RenderTableSection::setCellLogicalWidths):
(WebCore::RenderTableSection::dirtiedColumns):
Updated to use a const reference.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (131365 => 131366)
--- trunk/Source/WebCore/ChangeLog 2012-10-15 21:50:53 UTC (rev 131365)
+++ trunk/Source/WebCore/ChangeLog 2012-10-15 21:52:22 UTC (rev 131366)
@@ -1,3 +1,36 @@
+2012-10-15 Julien Chaffraix <[email protected]>
+
+ Make RenderTable columns() and columnPositions() return a const reference
+ https://bugs.webkit.org/show_bug.cgi?id=99339
+
+ Reviewed by Abhishek Arya.
+
+ The 2 getters were returning a non-const reference. This means that callers
+ could have modified the Vector's where only FixedTableLayout and AutoTableLayout
+ were expected to (for columnPositions(), no one should modify columns()).
+
+ Refactoring covered by existing tests.
+
+ * rendering/AutoTableLayout.cpp:
+ (WebCore::AutoTableLayout::layout):
+ * rendering/FixedTableLayout.cpp:
+ (WebCore::FixedTableLayout::layout):
+ Updated those functions to use the new setter.
+
+ * rendering/RenderTable.h:
+ (WebCore::RenderTable::columns):
+ (WebCore::RenderTable::columnPositions):
+ Made the 2 functions return a const reference. They are also const now!
+
+ (WebCore::RenderTable::setColumnPosition):
+ Added this setter.
+
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::addCell):
+ (WebCore::RenderTableSection::setCellLogicalWidths):
+ (WebCore::RenderTableSection::dirtiedColumns):
+ Updated to use a const reference.
+
2012-10-15 Dan Bernstein <[email protected]>
WebCore part of <rdar://problem/12470680> Font’s fast code path doesn’t support kerning and ligatures
Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (131365 => 131366)
--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp 2012-10-15 21:50:53 UTC (rev 131365)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp 2012-10-15 21:52:22 UTC (rev 131366)
@@ -771,10 +771,10 @@
int pos = 0;
for (size_t i = 0; i < nEffCols; ++i) {
- m_table->columnPositions()[i] = pos;
+ m_table->setColumnPosition(i, pos);
pos += m_layoutStruct[i].computedLogicalWidth + m_table->hBorderSpacing();
}
- m_table->columnPositions()[m_table->columnPositions().size() - 1] = pos;
+ m_table->setColumnPosition(m_table->columnPositions().size() - 1, pos);
}
}
Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (131365 => 131366)
--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp 2012-10-15 21:50:53 UTC (rev 131365)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp 2012-10-15 21:52:22 UTC (rev 131366)
@@ -309,12 +309,12 @@
int pos = 0;
for (unsigned i = 0; i < nEffCols; i++) {
- m_table->columnPositions()[i] = pos;
+ m_table->setColumnPosition(i, pos);
pos += calcWidth[i] + hspacing;
}
int colPositionsSize = m_table->columnPositions().size();
if (colPositionsSize > 0)
- m_table->columnPositions()[colPositionsSize - 1] = pos;
+ m_table->setColumnPosition(colPositionsSize - 1, pos);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderTable.h (131365 => 131366)
--- trunk/Source/WebCore/rendering/RenderTable.h 2012-10-15 21:50:53 UTC (rev 131365)
+++ trunk/Source/WebCore/rendering/RenderTable.h 2012-10-15 21:52:22 UTC (rev 131366)
@@ -143,8 +143,13 @@
recalcSections();
}
- Vector<ColumnStruct>& columns() { return m_columns; }
- Vector<int>& columnPositions() { return m_columnPos; }
+ const Vector<ColumnStruct>& columns() const { return m_columns; }
+ const Vector<int>& columnPositions() const { return m_columnPos; }
+ void setColumnPosition(unsigned index, int position)
+ {
+ m_columnPos[index] = position;
+ }
+
RenderTableSection* header() const { return m_head; }
RenderTableSection* footer() const { return m_foot; }
RenderTableSection* firstBody() const { return m_firstBody; }
Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (131365 => 131366)
--- trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-10-15 21:50:53 UTC (rev 131365)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-10-15 21:52:22 UTC (rev 131366)
@@ -212,7 +212,7 @@
unsigned rSpan = cell->rowSpan();
unsigned cSpan = cell->colSpan();
- Vector<RenderTable::ColumnStruct>& columns = table()->columns();
+ const Vector<RenderTable::ColumnStruct>& columns = table()->columns();
unsigned nCols = columns.size();
unsigned insertionRow = row->rowIndex();
@@ -263,7 +263,7 @@
void RenderTableSection::setCellLogicalWidths()
{
- Vector<int>& columnPos = table()->columnPositions();
+ const Vector<int>& columnPos = table()->columnPositions();
LayoutStateMaintainer statePusher(view());
@@ -1034,7 +1034,7 @@
CellSpan coveredColumns = spannedColumns(damageRect);
- Vector<int>& columnPos = table()->columnPositions();
+ const Vector<int>& columnPos = table()->columnPositions();
// To repaint the border we might need to repaint first or last column even if they are not spanned themselves.
if (coveredColumns.start() >= columnPos.size() - 1 && columnPos[columnPos.size() - 1] + table()->outerBorderEnd() >= damageRect.x())
--coveredColumns.start();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes