Changeset 156355 in webkit
- Timestamp:
- Sep 24, 2013, 1:47:01 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156352 r156355 1 2013-09-24 Antti Koivisto <antti@apple.com> 2 3 Tighten table rendering code 4 https://bugs.webkit.org/show_bug.cgi?id=121860 5 6 Reviewed by Andreas Kling. 7 8 Hide firstChild/lastChild/nextSibling/previousSibling in table renderers, 9 expose correctly typed firstRow/nextCell etc instead. 10 1 11 2013-09-24 Dean Jackson <dino@apple.com> 2 12 -
trunk/Source/WebCore/rendering/FixedTableLayout.cpp
r156285 r156355 137 137 unsigned currentColumn = 0; 138 138 139 RenderObject* firstRow = section->firstChild(); 140 for (RenderObject* child = firstRow->firstChildSlow(); child; child = child->nextSibling()) { 141 if (!child->isTableCell()) 142 continue; 143 144 RenderTableCell* cell = toRenderTableCell(child); 145 139 RenderTableRow* firstRow = section->firstRow(); 140 for (RenderTableCell* cell = firstRow->firstCell(); cell; cell = cell->nextCell()) { 146 141 Length logicalWidth = cell->styleOrColLogicalWidth(); 147 142 unsigned span = cell->colSpan(); -
trunk/Source/WebCore/rendering/RenderTable.cpp
r156312 r156355 187 187 RenderTableSection* section = toRenderTableSection(lastBox); 188 188 if (beforeChild == section) 189 beforeChild = section->first Child();189 beforeChild = section->firstRow(); 190 190 section->addChild(child, beforeChild); 191 191 return; … … 570 570 if (!section->isTableSection()) 571 571 continue; 572 for (RenderObject* row = toRenderTableSection(section)->firstChild(); row; row = row->nextSibling()) { 573 if (!row->isTableRow()) 574 continue; 575 for (RenderObject* cell = toRenderTableRow(row)->firstChild(); cell; cell = cell->nextSibling()) { 576 if (!cell->isTableCell()) 577 continue; 578 ASSERT(toRenderTableCell(cell)->table() == this); 579 toRenderTableCell(cell)->collectBorderValues(m_collapsedBorders); 572 for (RenderTableRow* row = toRenderTableSection(section)->firstRow(); row; row = row->nextRow()) { 573 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->nextCell()) { 574 ASSERT(cell->table() == this); 575 cell->collectBorderValues(m_collapsedBorders); 580 576 } 581 577 } -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r155908 r156355 740 740 prevRow = parent()->previousSibling(); 741 741 else 742 prevRow = prevCell->section()->last Child();742 prevRow = prevCell->section()->lastRow(); 743 743 744 744 if (prevRow) { -
trunk/Source/WebCore/rendering/RenderTableCell.h
r156166 r156355 71 71 } 72 72 73 RenderTableCell* nextCell() const; 74 RenderTableCell* previousCell() const; 75 73 76 RenderTableRow* row() const { return toRenderTableRow(parent()); } 74 77 RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); } … … 208 211 } 209 212 213 using RenderBlockFlow::nodeAtPoint; 214 210 215 #ifndef NDEBUG 211 216 bool isFirstOrLastCellInRow() const … … 279 284 unsigned parseRowSpanFromDOM() const; 280 285 unsigned parseColSpanFromDOM() const; 286 287 void nextSibling() const WTF_DELETED_FUNCTION; 288 void previousSibling() const WTF_DELETED_FUNCTION; 281 289 282 290 // Note MSVC will only pack members if they have identical types, hence we use unsigned instead of bool here. … … 304 312 void toRenderTableCell(const RenderTableCell*); 305 313 314 inline RenderTableCell* RenderTableCell::nextCell() const 315 { 316 return toRenderTableCell(RenderBlockFlow::nextSibling()); 317 } 318 319 inline RenderTableCell* RenderTableCell::previousCell() const 320 { 321 return toRenderTableCell(RenderBlockFlow::previousSibling()); 322 } 323 324 inline RenderTableCell* RenderTableRow::firstCell() const 325 { 326 return toRenderTableCell(RenderBox::firstChild()); 327 } 328 329 inline RenderTableCell* RenderTableRow::lastCell() const 330 { 331 return toRenderTableCell(RenderBox::lastChild()); 332 } 333 306 334 } // namespace WebCore 307 335 -
trunk/Source/WebCore/rendering/RenderTableRow.cpp
r156312 r156355 110 110 RenderObject* last = beforeChild; 111 111 if (!last) 112 last = lastC hild();112 last = lastCell(); 113 113 if (last && last->isAnonymous() && last->isTableCell() && !last->isBeforeOrAfterContent()) { 114 114 RenderTableCell* cell = toRenderTableCell(last); … … 151 151 RenderBox::addChild(cell, beforeChild); 152 152 153 if (beforeChild || next Sibling())153 if (beforeChild || nextRow()) 154 154 section()->setNeedsCellRecalc(); 155 155 } … … 165 165 bool paginated = view().layoutState()->isPaginated(); 166 166 167 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 168 if (child->isTableCell()) { 169 RenderTableCell* cell = toRenderTableCell(child); 170 if (!cell->needsLayout() && paginated && view().layoutState()->pageLogicalHeight() && view().layoutState()->pageLogicalOffset(cell, cell->logicalTop()) != cell->pageLogicalOffset()) 171 cell->setChildNeedsLayout(true, MarkOnlyThis); 172 173 if (child->needsLayout()) { 174 cell->computeAndSetBlockDirectionMargins(table()); 175 cell->layout(); 176 } 167 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) { 168 if (!cell->needsLayout() && paginated && view().layoutState()->pageLogicalHeight() && view().layoutState()->pageLogicalOffset(cell, cell->logicalTop()) != cell->pageLogicalOffset()) 169 cell->setChildNeedsLayout(true, MarkOnlyThis); 170 171 if (cell->needsLayout()) { 172 cell->computeAndSetBlockDirectionMargins(table()); 173 cell->layout(); 177 174 } 178 175 } … … 184 181 // parent table, and being mid-layout, that is invalid. Instead, we repaint our cells. 185 182 if (selfNeedsLayout() && checkForRepaintDuringLayout()) { 186 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 187 if (child->isTableCell()) 188 child->repaint(); 189 } 183 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) 184 cell->repaint(); 190 185 } 191 186 … … 217 212 // Table rows cannot ever be hit tested. Effectively they do not exist. 218 213 // Just forward to our children always. 219 for (Render Object* child = lastChild(); child; child = child->previousSibling()) {214 for (RenderTableCell* cell = lastCell(); cell; cell = cell->previousCell()) { 220 215 // FIXME: We have to skip over inline flows, since they can show up inside table rows 221 216 // at the moment (a demoted inline <form> for example). If we ever implement a 222 217 // table-specific hit-test method (which we should do for performance reasons anyway), 223 218 // then we can remove this check. 224 if (c hild->isTableCell() && !toRenderBox(child)->hasSelfPaintingLayer()) {225 LayoutPoint cellPoint = flipForWritingModeForChild( toRenderTableCell(child), accumulatedOffset);226 if (c hild->nodeAtPoint(request, result, locationInContainer, cellPoint, action)) {219 if (cell->hasSelfPaintingLayer()) { 220 LayoutPoint cellPoint = flipForWritingModeForChild(cell, accumulatedOffset); 221 if (cell->nodeAtPoint(request, result, locationInContainer, cellPoint, action)) { 227 222 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(cellPoint)); 228 223 return true; … … 247 242 248 243 paintOutlineForRowIfNeeded(paintInfo, paintOffset); 249 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 250 if (child->isTableCell()) { 251 // Paint the row background behind the cell. 252 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) { 253 RenderTableCell* cell = toRenderTableCell(child); 254 cell->paintBackgroundsBehindCell(paintInfo, paintOffset, this); 255 } 256 if (!toRenderBox(child)->hasSelfPaintingLayer()) 257 child->paint(paintInfo, paintOffset); 258 } 244 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) { 245 // Paint the row background behind the cell. 246 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) 247 cell->paintBackgroundsBehindCell(paintInfo, paintOffset, this); 248 if (!cell->hasSelfPaintingLayer()) 249 cell->paint(paintInfo, paintOffset); 259 250 } 260 251 } -
trunk/Source/WebCore/rendering/RenderTableRow.h
r156278 r156355 36 36 public: 37 37 explicit RenderTableRow(Element*); 38 39 RenderTableRow* nextRow() const; 40 RenderTableRow* previousRow() const; 41 42 RenderTableCell* firstCell() const; 43 RenderTableCell* lastCell() const; 38 44 39 45 RenderTableSection* section() const { return toRenderTableSection(parent()); } … … 85 91 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE; 86 92 93 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; 94 87 95 private: 88 96 virtual const char* renderName() const OVERRIDE { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow"; } … … 95 103 virtual void layout() OVERRIDE; 96 104 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE; 97 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;98 105 99 106 virtual bool requiresLayer() const OVERRIDE { return hasOverflowClip() || hasTransform() || hasHiddenBackface() || hasClipPath() || createsGroup(); } … … 104 111 105 112 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE; 113 114 void firstChild() const WTF_DELETED_FUNCTION; 115 void lastChild() const WTF_DELETED_FUNCTION; 116 void nextSibling() const WTF_DELETED_FUNCTION; 117 void previousSibling() const WTF_DELETED_FUNCTION; 106 118 107 119 unsigned m_rowIndex : 31; … … 123 135 void toRenderTableRow(const RenderTableRow*); 124 136 137 inline RenderTableRow* RenderTableSection::firstRow() const 138 { 139 return toRenderTableRow(RenderBox::firstChild()); 140 } 141 142 inline RenderTableRow* RenderTableSection::lastRow() const 143 { 144 return toRenderTableRow(RenderBox::lastChild()); 145 } 146 147 inline RenderTableRow* RenderTableRow::nextRow() const 148 { 149 return toRenderTableRow(RenderBox::nextSibling()); 150 } 151 152 inline RenderTableRow* RenderTableRow::previousRow() const 153 { 154 return toRenderTableRow(RenderBox::previousSibling()); 155 } 156 125 157 } // namespace WebCore 126 158 -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r156312 r156355 129 129 RenderObject* last = beforeChild; 130 130 if (!last) 131 last = last Child();131 last = lastRow(); 132 132 if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) { 133 133 RenderTableRow* row = toRenderTableRow(last); 134 134 if (beforeChild == row) 135 beforeChild = row->firstC hild();135 beforeChild = row->firstCell(); 136 136 row->addChild(child, beforeChild); 137 137 return; … … 720 720 borderWidth = sb.width(); 721 721 722 const BorderValue& rb = first Child()->style()->borderBefore();722 const BorderValue& rb = firstRow()->style()->borderBefore(); 723 723 if (rb.style() == BHIDDEN) 724 724 return -1; … … 771 771 borderWidth = sb.width(); 772 772 773 const BorderValue& rb = last Child()->style()->borderAfter();773 const BorderValue& rb = lastRow()->style()->borderAfter(); 774 774 if (rb.style() == BHIDDEN) 775 775 return -1; … … 1224 1224 m_grid.clear(); 1225 1225 1226 for (RenderObject* row = firstChild(); row; row = row->nextSibling()) { 1227 if (row->isTableRow()) { 1228 unsigned insertionRow = m_cRow; 1229 m_cRow++; 1230 m_cCol = 0; 1231 ensureRows(m_cRow); 1232 1233 RenderTableRow* tableRow = toRenderTableRow(row); 1234 m_grid[insertionRow].rowRenderer = tableRow; 1235 tableRow->setRowIndex(insertionRow); 1236 setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]); 1237 1238 for (RenderObject* cell = tableRow->firstChild(); cell; cell = cell->nextSibling()) { 1239 if (!cell->isTableCell()) 1240 continue; 1241 1242 RenderTableCell* tableCell = toRenderTableCell(cell); 1243 addCell(tableCell, tableRow); 1244 } 1245 } 1226 for (RenderTableRow* row = firstRow(); row; row = row->nextRow()) { 1227 unsigned insertionRow = m_cRow; 1228 m_cRow++; 1229 m_cCol = 0; 1230 ensureRows(m_cRow); 1231 1232 m_grid[insertionRow].rowRenderer = row; 1233 row->setRowIndex(insertionRow); 1234 setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]); 1235 1236 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->nextCell()) 1237 addCell(cell, row); 1246 1238 } 1247 1239 … … 1258 1250 setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[rowIndex]); 1259 1251 1260 for (RenderObject* cell = m_grid[rowIndex].rowRenderer->firstChild(); cell; cell = cell->nextSibling()) { 1261 if (!cell->isTableCell()) 1262 continue; 1263 1264 updateLogicalHeightForCell(m_grid[rowIndex], toRenderTableCell(cell)); 1265 } 1252 for (RenderTableCell* cell = m_grid[rowIndex].rowRenderer->firstCell(); cell; cell = cell->nextCell()) 1253 updateLogicalHeightForCell(m_grid[rowIndex], cell); 1266 1254 } 1267 1255 … … 1349 1337 { 1350 1338 // If we have no children then we have nothing to do. 1351 if (!first Child())1339 if (!firstRow()) 1352 1340 return false; 1353 1341 … … 1360 1348 1361 1349 if (hasOverflowingCell()) { 1362 for (Render Object* child = lastChild(); child; child = child->previousSibling()) {1350 for (RenderTableRow* row = lastRow(); row; row = row->previousRow()) { 1363 1351 // FIXME: We have to skip over inline flows, since they can show up inside table rows 1364 1352 // at the moment (a demoted inline <form> for example). If we ever implement a 1365 1353 // table-specific hit-test method (which we should do for performance reasons anyway), 1366 1354 // then we can remove this check. 1367 if ( child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer()) {1368 LayoutPoint childPoint = flipForWritingModeForChild( toRenderBox(child), adjustedLocation);1369 if ( child->nodeAtPoint(request, result, locationInContainer, childPoint, action)) {1355 if (row->hasSelfPaintingLayer()) { 1356 LayoutPoint childPoint = flipForWritingModeForChild(row, adjustedLocation); 1357 if (row->nodeAtPoint(request, result, locationInContainer, childPoint, action)) { 1370 1358 updateHitTestResult(result, toLayoutPoint(locationInContainer.point() - childPoint)); 1371 1359 return true; -
trunk/Source/WebCore/rendering/RenderTableSection.h
r156278 r156355 31 31 namespace WebCore { 32 32 33 class RenderTableRow; 34 33 35 enum CollapsedBorderSide { 34 36 CBSBefore, … … 66 68 virtual ~RenderTableSection(); 67 69 70 RenderTableRow* firstRow() const; 71 RenderTableRow* lastRow() const; 72 68 73 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE; 69 74 … … 239 244 void setLogicalPositionForCell(RenderTableCell*, unsigned effectiveColumn) const; 240 245 246 void firstChild() const WTF_DELETED_FUNCTION; 247 void lastChild() const WTF_DELETED_FUNCTION; 248 241 249 Vector<RowStruct> m_grid; 242 250 Vector<int> m_rowPos;
Note:
See TracChangeset
for help on using the changeset viewer.