Changeset 117988 in webkit
- Timestamp:
- May 22, 2012 9:43:48 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117986 r117988 1 2012-05-22 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Centralize and clean-up table column iteration 4 https://bugs.webkit.org/show_bug.cgi?id=87051 5 6 Reviewed by Eric Seidel. 7 8 Those tests just validate and enforce what we were already doing that were 9 not covered by any existing tests. 10 11 * fast/table/caption-between-column-and-column-group-expected.html: Added. 12 * fast/table/caption-between-column-and-column-group.html: Added. 13 * fast/table/caption-between-column-group-and-column-expected.html: Added. 14 * fast/table/caption-between-column-group-and-column.html: Added. 15 * fast/table/caption-between-columns-expected.html: Added. 16 * fast/table/caption-between-columns.html: Added. 17 1 18 2012-05-22 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r117987 r117988 1 2012-05-22 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Centralize and clean-up table column iteration 4 https://bugs.webkit.org/show_bug.cgi?id=87051 5 6 Reviewed by Eric Seidel. 7 8 Tests: fast/table/caption-between-column-and-column-group.html 9 fast/table/caption-between-column-group-and-column.html 10 fast/table/caption-between-columns.html 11 12 The existing code had duplications between different classes and some 13 of the iterating functions could use a better place. That's what this 14 change solves, along with several renamings. 15 16 * rendering/RenderTableCol.h: 17 (WebCore::RenderTableCol::isTableColumnGroupWithColumnChildren): 18 Renamed isTableColGroup to this to better reflect what it checks. 19 Also added a new function: nextColumn. 20 21 * rendering/FixedTableLayout.cpp: 22 (WebCore::FixedTableLayout::calcWidthArray): 23 Updated after isTableColGroup renaming. 24 25 * rendering/RenderTable.cpp: 26 (WebCore::RenderTable::firstColumn): 27 Added this new function to get the first column (or column group). 28 29 (WebCore::RenderTable::colElement): 30 Cleaned up this function: switched the loop to a 'for' now that the 31 helper functions make it easy. Cleaned up the ordering and the naming. 32 33 * rendering/RenderTable.h: 34 Added firstColumn. 35 36 * rendering/RenderTableCell.cpp: 37 (WebCore::RenderTableCell::styleOrColLogicalWidth): 38 Updated to use nextColumn(). 39 40 * rendering/RenderTableCol.cpp: 41 (WebCore::RenderTableCol::nextColumn): 42 Added this new helper function to centralize the code to iterate over columns. 43 1 44 2012-05-22 Hao Zheng <zhenghao@chromium.org> 2 45 -
trunk/Source/WebCore/rendering/FixedTableLayout.cpp
r111742 r117988 78 78 } 79 79 80 static RenderObject* nextCol(RenderObject* child)81 {82 // If child is a colgroup, the next col is the colgroup's first child col.83 if (RenderObject* next = child->firstChild())84 return next;85 // Otherwise it's the next col along.86 if (RenderObject* next = child->nextSibling())87 return next;88 // Failing that, the child is the last col in a colgroup, so the next col is the next col/colgroup after its colgroup.89 if (child->parent()->isTableCol())90 return child->parent()->nextSibling();91 return 0;92 }93 94 80 int FixedTableLayout::calcWidthArray(int) 95 81 { … … 102 88 103 89 unsigned currentEffectiveColumn = 0; 104 for (RenderObject* child = m_table->firstChild();child && child->isTableCol(); child = nextCol(child)) { 105 106 // Width specified by column-groups does not affect column width in fixed layout tables 107 RenderTableCol* col = toRenderTableCol(child); 90 for (RenderTableCol* col = m_table->firstColumn(); col; col = col->nextColumn()) { 108 91 col->computePreferredLogicalWidths(); 109 92 110 if (col->isTableColGroup()) 93 // Width specified by column-groups that have column child does not affect column width in fixed layout tables 94 if (col->isTableColumnGroupWithColumnChildren()) 111 95 continue; 112 96 -
trunk/Source/WebCore/rendering/RenderTable.cpp
r117697 r117988 727 727 } 728 728 729 RenderTableCol* RenderTable::nextColElement(RenderTableCol* current) const 730 { 731 RenderObject* next = current->firstChild(); 732 if (!next) 733 next = current->nextSibling(); 734 if (!next && current->parent()->isTableCol()) 735 next = current->parent()->nextSibling(); 736 737 while (next) { 738 if (next->isTableCol()) 739 return toRenderTableCol(next); 740 if (!m_captions.contains(next)) 729 RenderTableCol* RenderTable::firstColumn() const 730 { 731 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 732 if (child->isTableCol()) 733 return toRenderTableCol(child); 734 735 // We allow only table-captions before columns or column-groups. 736 if (!child->isTableCaption()) 741 737 return 0; 742 next = next->nextSibling(); 743 } 744 738 } 739 745 740 return 0; 746 741 } … … 750 745 if (!m_hasColElements) 751 746 return 0; 752 RenderObject* child = firstChild(); 753 unsigned cCol = 0; 754 755 while (child) { 756 if (child->isTableCol()) 757 break; 758 if (!m_captions.contains(child)) 759 return 0; 760 child = child->nextSibling(); 761 } 762 if (!child) 763 return 0; 764 765 RenderTableCol* colElem = toRenderTableCol(child); 766 while (colElem) { 767 unsigned span = colElem->span(); 768 if (!colElem->firstChild()) { 769 unsigned startCol = cCol; 770 ASSERT(span >= 1); 771 unsigned endCol = cCol + span - 1; 772 cCol += span; 773 if (cCol > col) { 774 if (startEdge) 775 *startEdge = startCol == col; 776 if (endEdge) 777 *endEdge = endCol == col; 778 return colElem; 779 } 780 } 781 colElem = nextColElement(colElem); 747 748 unsigned columnCount = 0; 749 for (RenderTableCol* columnRenderer = firstColumn(); columnRenderer; columnRenderer = columnRenderer->nextColumn()) { 750 if (columnRenderer->isTableColumnGroupWithColumnChildren()) 751 continue; 752 753 unsigned span = columnRenderer->span(); 754 unsigned startCol = columnCount; 755 ASSERT(span >= 1); 756 unsigned endCol = columnCount + span - 1; 757 columnCount += span; 758 if (columnCount > col) { 759 if (startEdge) 760 *startEdge = startCol == col; 761 if (endEdge) 762 *endEdge = endCol == col; 763 return columnRenderer; 764 } 782 765 } 783 766 -
trunk/Source/WebCore/rendering/RenderTable.h
r117339 r117988 176 176 } 177 177 178 // Return the first column or column-group. 179 RenderTableCol* firstColumn() const; 180 178 181 RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const; 179 RenderTableCol* nextColElement(RenderTableCol* current) const;180 182 181 183 bool needsSectionRecalc() const { return m_needsSectionRecalc; } -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r117697 r117988 133 133 colWidthSum = Length(colWidthSum.value() + colWidth.value(), Fixed); 134 134 135 tableCol = table ()->nextColElement(tableCol);135 tableCol = tableCol->nextColumn(); 136 136 // If no next <col> tag found for the span we just return what we have for now. 137 137 if (!tableCol) -
trunk/Source/WebCore/rendering/RenderTableCol.cpp
r100386 r117988 117 117 } 118 118 119 RenderTableCol* RenderTableCol::nextColumn() const 120 { 121 // If |this| is a column-group, the next column is the colgroup's first child column. 122 if (RenderObject* firstChild = this->firstChild()) 123 return toRenderTableCol(firstChild); 124 125 // Otherwise it's the next column along. 126 RenderObject* next = nextSibling(); 127 128 // Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group. 129 if (!next && parent()->isTableCol()) 130 next = parent()->nextSibling(); 131 132 for (; next && !next->isTableCol(); next = next->nextSibling()) { 133 // We allow captions mixed with columns and column-groups. 134 if (next->isTableCaption()) 135 continue; 136 137 return 0; 138 } 139 140 return toRenderTableCol(next); 119 141 } 142 143 } -
trunk/Source/WebCore/rendering/RenderTableCol.h
r111118 r117988 44 44 unsigned span() const { return m_span; } 45 45 void setSpan(unsigned span) { m_span = span; } 46 bool isTableColGroup() { return firstChild() ? true : false; } 46 47 bool isTableColumnGroupWithColumnChildren() { return firstChild(); } 48 49 // Returns the next column or column-group. 50 RenderTableCol* nextColumn() const; 51 47 52 private: 48 53 virtual RenderObjectChildList* virtualChildren() { return children(); }
Note: See TracChangeset
for help on using the changeset viewer.