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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp
index a9e1667..72e826d 100644
--- a/Source/WebCore/rendering/RenderTableSection.cpp
+++ b/Source/WebCore/rendering/RenderTableSection.cpp
@@ -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();