Changeset 108557 in webkit
- Timestamp:
- Feb 22, 2012 3:10:53 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r108556 r108557 1 2012-02-22 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Clean-up RenderTableSection::calcRowLogicalHeight 4 https://bugs.webkit.org/show_bug.cgi?id=77705 5 6 Reviewed by Eric Seidel. 7 8 Refactoring / simplication of the code. 9 10 This change removes some variables that were unneeded and were 11 hiding what the code was really doing. Also some of the code was 12 split and moved down to RenderTableCell. 13 14 * rendering/RenderTableCell.cpp: 15 (WebCore::RenderTableCell::logicalHeightForRowSizing): 16 * rendering/RenderTableCell.h: 17 (RenderTableCell): 18 Added the previous helper function to calculate the cell's 19 adjusted logical height. 20 21 * rendering/RenderTableSection.cpp: 22 (WebCore::RenderTableSection::calcRowLogicalHeight): 23 Removed some variables, simplified the rowspan logic to be clearer 24 (and added a comment about how we handle rowspans). 25 1 26 2012-02-22 Adam Barth <abarth@webkit.org> 2 27 -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r107874 r108557 92 92 } 93 93 94 LayoutUnit RenderTableCell::logicalHeightForRowSizing() const 95 { 96 LayoutUnit adjustedLogicalHeight = logicalHeight() - (intrinsicPaddingBefore() + intrinsicPaddingAfter()); 97 98 LayoutUnit styleLogicalHeight = style()->logicalHeight().calcValue(0); 99 if (document()->inQuirksMode() || style()->boxSizing() == BORDER_BOX) { 100 // Explicit heights use the border box in quirks mode. 101 // Don't adjust height. 102 } else { 103 // In strict mode, box-sizing: content-box do the right 104 // thing and actually add in the border and padding. 105 LayoutUnit adjustedPaddingBefore = paddingBefore() - intrinsicPaddingBefore(); 106 LayoutUnit adjustedPaddingAfter = paddingAfter() - intrinsicPaddingAfter(); 107 styleLogicalHeight += adjustedPaddingBefore + adjustedPaddingAfter + borderBefore() + borderAfter(); 108 } 109 110 return max(styleLogicalHeight, adjustedLogicalHeight); 111 } 112 94 113 Length RenderTableCell::styleOrColLogicalWidth() const 95 114 { -
trunk/Source/WebCore/rendering/RenderTableCell.h
r107874 r108557 86 86 Length styleOrColLogicalWidth() const; 87 87 88 LayoutUnit logicalHeightForRowSizing() const; 89 88 90 virtual void computePreferredLogicalWidths(); 89 91 -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r108372 r108557 335 335 336 336 for (unsigned r = 0; r < m_grid.size(); r++) { 337 m_rowPos[r + 1] = 0; 338 m_grid[r].baseline = 0; 339 LayoutUnit baseline = 0; 340 int bdesc = 0; 341 int ch = m_grid[r].logicalHeight.calcMinValue(0); 342 int pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0); 343 344 m_rowPos[r + 1] = max(m_rowPos[r + 1], pos); 337 LayoutUnit baselineDescent = 0; 338 339 // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells). 340 m_rowPos[r + 1] = max(m_rowPos[r] + m_grid[r].logicalHeight.calcMinValue(0), 0); 345 341 346 342 Row& row = m_grid[r].row; … … 354 350 continue; 355 351 356 if ((cell->row() + cell->rowSpan() - 1) > r) 352 // FIXME: We are always adding the height of a rowspan to the last rows which doesn't match 353 // other browsers. See webkit.org/b/52185 for example. 354 if ((cell->row() + cell->rowSpan() - 1) != r) 357 355 continue; 358 356 359 unsigned indx = max(r - cell->rowSpan() + 1, 0u); 357 // For row spanning cells, |r| is the last row in the span. 358 unsigned cellStartRow = cell->row(); 360 359 361 360 if (cell->hasOverrideHeight()) { … … 371 370 } 372 371 373 int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter()); 374 375 ch = cell->style()->logicalHeight().calcValue(0); 376 if (document()->inQuirksMode() || cell->style()->boxSizing() == BORDER_BOX) { 377 // Explicit heights use the border box in quirks mode. 378 // Don't adjust height. 379 } else { 380 // In strict mode, box-sizing: content-box do the right 381 // thing and actually add in the border and padding. 382 int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore(); 383 int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter(); 384 ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter(); 385 } 386 ch = max(ch, adjustedLogicalHeight); 387 388 pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : 0); 389 390 m_rowPos[r + 1] = max(m_rowPos[r + 1], pos); 372 int cellLogicalHeight = cell->logicalHeightForRowSizing(); 373 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[cellStartRow] + cellLogicalHeight); 391 374 392 375 // find out the baseline 393 376 EVerticalAlign va = cell->style()->verticalAlign(); 394 377 if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) { 395 int b = cell->cellBaselinePosition();396 if (b > cell->borderBefore() + cell->paddingBefore()) {397 baseline = max<LayoutUnit>(baseline, b- cell->intrinsicPaddingBefore());398 b desc = max(bdesc, m_rowPos[indx] + ch - (b- cell->intrinsicPaddingBefore()));378 int baselinePosition = cell->cellBaselinePosition(); 379 if (baselinePosition > cell->borderBefore() + cell->paddingBefore()) { 380 m_grid[r].baseline = max(m_grid[r].baseline, baselinePosition - cell->intrinsicPaddingBefore()); 381 baselineDescent = max(baselineDescent, m_rowPos[cellStartRow] + cellLogicalHeight - (baselinePosition - cell->intrinsicPaddingBefore())); 399 382 } 400 383 } … … 402 385 403 386 // do we have baseline aligned elements? 404 if ( baseline) {387 if (m_grid[r].baseline) 405 388 // increase rowheight if baseline requires 406 m_rowPos[r + 1] = max(m_rowPos[r + 1], baseline + bdesc + (m_grid[r].rowRenderer ? spacing : 0));407 m_grid[r].baseline = baseline; 408 }409 389 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_grid[r].baseline + baselineDescent); 390 391 // Add the border-spacing to our final position. 392 m_rowPos[r + 1] += m_grid[r].rowRenderer ? spacing : 0; 410 393 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[r]); 411 394 }
Note: See TracChangeset
for help on using the changeset viewer.