Changeset 108914 in webkit
- Timestamp:
- Feb 25, 2012 4:19:22 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r108907 r108914 1 2012-02-25 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 Nikolas Zimmermann. 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-25 Benjamin Poulain <benjamin@webkit.org> 2 27 -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r108892 r108914 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
r108892 r108914 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
r108892 r108914 335 335 336 336 for (unsigned r = 0; r < m_grid.size(); r++) { 337 m_rowPos[r + 1] = 0;338 337 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); 338 LayoutUnit baselineDescent = 0; 339 340 // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells). 341 m_rowPos[r + 1] = max(m_rowPos[r] + m_grid[r].logicalHeight.calcMinValue(0), 0); 345 342 346 343 Row& row = m_grid[r].row; … … 354 351 continue; 355 352 356 if ((cell->row() + cell->rowSpan() - 1) > r) 353 // FIXME: We are always adding the height of a rowspan to the last rows which doesn't match 354 // other browsers. See webkit.org/b/52185 for example. 355 if ((cell->row() + cell->rowSpan() - 1) != r) 357 356 continue; 358 357 359 unsigned indx = max(r - cell->rowSpan() + 1, 0u); 358 // For row spanning cells, |r| is the last row in the span. 359 unsigned cellStartRow = cell->row(); 360 360 361 361 if (cell->hasOverrideHeight()) { … … 371 371 } 372 372 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); 373 int cellLogicalHeight = cell->logicalHeightForRowSizing(); 374 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[cellStartRow] + cellLogicalHeight); 391 375 392 376 // find out the baseline 393 377 EVerticalAlign va = cell->style()->verticalAlign(); 394 378 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()));379 int baselinePosition = cell->cellBaselinePosition(); 380 if (baselinePosition > cell->borderBefore() + cell->paddingBefore()) { 381 m_grid[r].baseline = max(m_grid[r].baseline, baselinePosition - cell->intrinsicPaddingBefore()); 382 baselineDescent = max(baselineDescent, m_rowPos[cellStartRow] + cellLogicalHeight - (baselinePosition - cell->intrinsicPaddingBefore())); 399 383 } 400 384 } … … 402 386 403 387 // do we have baseline aligned elements? 404 if ( baseline) {388 if (m_grid[r].baseline) 405 389 // 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 390 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_grid[r].baseline + baselineDescent); 391 392 // Add the border-spacing to our final position. 393 m_rowPos[r + 1] += m_grid[r].rowRenderer ? spacing : 0; 410 394 m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[r]); 411 395 }
Note: See TracChangeset
for help on using the changeset viewer.