Changeset 107038 in webkit
- Timestamp:
- Feb 7, 2012, 9:37:54 PM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
rendering/RenderTableSection.cpp (modified) (24 diffs)
-
rendering/RenderTableSection.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107036 r107038 1 2012-02-07 Emil A Eklund <eae@chromium.org> 2 3 Revert TableSection cell and border calculations to integers 4 https://bugs.webkit.org/show_bug.cgi?id=77918 5 6 Reviewed by Eric Seidel. 7 8 Change RenderTableSection cell width, row height and border calculations 9 back to use integers. Table layout is done on integer bounds to comply 10 with the specification and to ensure that columns given the same width, 11 including percentage widths, are rendered with identical widths. The same 12 applies to heights. 13 14 No new tests. 15 16 * rendering/RenderTableSection.cpp: 17 (WebCore::RenderTableSection::setCellLogicalWidths): 18 (WebCore::RenderTableSection::calcRowLogicalHeight): 19 (WebCore::RenderTableSection::layoutRows): 20 (WebCore::RenderTableSection::calcOuterBorderBefore): 21 (WebCore::RenderTableSection::calcOuterBorderAfter): 22 (WebCore::RenderTableSection::calcOuterBorderStart): 23 (WebCore::RenderTableSection::calcOuterBorderEnd): 24 (WebCore::RenderTableSection::paintObject): 25 (WebCore::RenderTableSection::nodeAtPoint): 26 * rendering/RenderTableSection.h: 27 (RenderTableSection): 28 (WebCore::RenderTableSection::RowStruct::RowStruct): 29 (WebCore::RenderTableSection::outerBorderBefore): 30 (WebCore::RenderTableSection::outerBorderAfter): 31 (WebCore::RenderTableSection::outerBorderStart): 32 (WebCore::RenderTableSection::outerBorderEnd): 33 1 34 2012-02-07 Robert Kroeger <rjkroege@chromium.org> 2 35 -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r105685 r107038 278 278 void RenderTableSection::setCellLogicalWidths() 279 279 { 280 Vector< LayoutUnit>& columnPos = table()->columnPositions();280 Vector<int>& columnPos = table()->columnPositions(); 281 281 282 282 LayoutStateMaintainer statePusher(view()); … … 297 297 endCol++; 298 298 } 299 LayoutUnit w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();300 LayoutUnit oldLogicalWidth = cell->logicalWidth();299 int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing(); 300 int oldLogicalWidth = cell->logicalWidth(); 301 301 if (w != oldLogicalWidth) { 302 302 cell->setNeedsLayout(true); … … 317 317 } 318 318 319 LayoutUnit RenderTableSection::calcRowLogicalHeight()319 int RenderTableSection::calcRowLogicalHeight() 320 320 { 321 321 #ifndef NDEBUG … … 327 327 RenderTableCell* cell; 328 328 329 LayoutUnit spacing = table()->vBorderSpacing();329 int spacing = table()->vBorderSpacing(); 330 330 331 331 LayoutStateMaintainer statePusher(view()); … … 338 338 m_grid[r].baseline = 0; 339 339 LayoutUnit baseline = 0; 340 LayoutUnit bdesc = 0;341 LayoutUnit ch = m_grid[r].logicalHeight.calcMinValue(0);342 LayoutUnit pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 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 343 344 344 m_rowPos[r + 1] = max(m_rowPos[r + 1], pos); … … 371 371 } 372 372 373 LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());373 int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter()); 374 374 375 375 ch = cell->style()->logicalHeight().calcValue(0); … … 380 380 // In strict mode, box-sizing: content-box do the right 381 381 // thing and actually add in the border and padding. 382 LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();383 LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();382 int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore(); 383 int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter(); 384 384 ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter(); 385 385 } … … 393 393 EVerticalAlign va = cell->style()->verticalAlign(); 394 394 if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) { 395 LayoutUnit b = cell->cellBaselinePosition();395 int b = cell->cellBaselinePosition(); 396 396 if (b > cell->borderBefore() + cell->paddingBefore()) { 397 baseline = max (baseline, b - cell->intrinsicPaddingBefore());397 baseline = max<LayoutUnit>(baseline, b - cell->intrinsicPaddingBefore()); 398 398 bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingBefore())); 399 399 } … … 437 437 } 438 438 439 LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd)439 int RenderTableSection::layoutRows(int toAdd) 440 440 { 441 441 #ifndef NDEBUG … … 445 445 ASSERT(!needsLayout()); 446 446 447 LayoutUnit rHeight;447 int rHeight; 448 448 unsigned rindx; 449 449 unsigned totalRows = m_grid.size(); … … 456 456 457 457 if (toAdd && totalRows && (m_rowPos[totalRows] || !nextSibling())) { 458 LayoutUnit totalHeight = m_rowPos[totalRows] + toAdd;459 460 LayoutUnit dh = toAdd;458 int totalHeight = m_rowPos[totalRows] + toAdd; 459 460 int dh = toAdd; 461 461 int totalPercent = 0; 462 462 int numAuto = 0; … … 469 469 if (totalPercent) { 470 470 // try to satisfy percent 471 LayoutUnit add = 0;471 int add = 0; 472 472 totalPercent = min(totalPercent, 100); 473 LayoutUnit rh = m_rowPos[1] - m_rowPos[0];473 int rh = m_rowPos[1] - m_rowPos[0]; 474 474 for (unsigned r = 0; r < totalRows; r++) { 475 475 if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) { 476 LayoutUnit toAdd = min<LayoutUnit>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh);476 int toAdd = min<int>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh); 477 477 // If toAdd is negative, then we don't want to shrink the row (this bug 478 478 // affected Outlook Web Access). 479 toAdd = max <LayoutUnit>(0, toAdd);479 toAdd = max(0, toAdd); 480 480 add += toAdd; 481 481 dh -= toAdd; … … 490 490 if (numAuto) { 491 491 // distribute over variable cols 492 LayoutUnit add = 0;492 int add = 0; 493 493 for (unsigned r = 0; r < totalRows; r++) { 494 494 if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) { 495 LayoutUnit toAdd = dh / numAuto;495 int toAdd = dh / numAuto; 496 496 add += toAdd; 497 497 dh -= toAdd; … … 503 503 if (dh > 0 && m_rowPos[totalRows]) { 504 504 // if some left overs, distribute equally. 505 LayoutUnit tot = m_rowPos[totalRows];506 LayoutUnit add = 0;507 LayoutUnit prev = m_rowPos[0];505 int tot = m_rowPos[totalRows]; 506 int add = 0; 507 int prev = m_rowPos[0]; 508 508 for (unsigned r = 0; r < totalRows; r++) { 509 509 // weight with the original height … … 515 515 } 516 516 517 LayoutUnit hspacing = table()->hBorderSpacing();518 LayoutUnit vspacing = table()->vBorderSpacing();517 int hspacing = table()->hBorderSpacing(); 518 int vspacing = table()->vBorderSpacing(); 519 519 unsigned nEffCols = table()->numEffCols(); 520 520 … … 604 604 } 605 605 606 LayoutUnit oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore();607 LayoutUnit oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter();608 LayoutUnit logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter;609 610 LayoutUnit intrinsicPaddingBefore = 0;606 int oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore(); 607 int oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter(); 608 int logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter; 609 610 int intrinsicPaddingBefore = 0; 611 611 switch (cell->style()->verticalAlign()) { 612 612 case SUB: … … 615 615 case TEXT_BOTTOM: 616 616 case BASELINE: { 617 LayoutUnit b = cell->cellBaselinePosition();617 int b = cell->cellBaselinePosition(); 618 618 if (b > cell->borderBefore() + cell->paddingBefore()) 619 619 intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore); … … 632 632 } 633 633 634 LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;634 int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; 635 635 cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore); 636 636 cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter); … … 716 716 } 717 717 718 LayoutUnit RenderTableSection::calcOuterBorderBefore() const718 int RenderTableSection::calcOuterBorderBefore() const 719 719 { 720 720 unsigned totalCols = table()->numEffCols(); … … 767 767 } 768 768 769 LayoutUnit RenderTableSection::calcOuterBorderAfter() const769 int RenderTableSection::calcOuterBorderAfter() const 770 770 { 771 771 unsigned totalCols = table()->numEffCols(); … … 818 818 } 819 819 820 LayoutUnit RenderTableSection::calcOuterBorderStart() const820 int RenderTableSection::calcOuterBorderStart() const 821 821 { 822 822 unsigned totalCols = table()->numEffCols(); … … 862 862 } 863 863 864 LayoutUnit RenderTableSection::calcOuterBorderEnd() const864 int RenderTableSection::calcOuterBorderEnd() const 865 865 { 866 866 unsigned totalCols = table()->numEffCols(); … … 1056 1056 if (!m_forceSlowPaintPathWithOverflowingCell && style()->isLeftToRightDirection()) { 1057 1057 LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os; 1058 Vector< LayoutUnit>& columnPos = table()->columnPositions();1058 Vector<int>& columnPos = table()->columnPositions(); 1059 1059 startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin(); 1060 1060 if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start))) … … 1314 1314 unsigned hitRow = nextRow > 0 ? nextRow - 1 : 0; 1315 1315 1316 Vector< LayoutUnit>& columnPos = table()->columnPositions();1316 Vector<int>& columnPos = table()->columnPositions(); 1317 1317 LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y(); 1318 1318 if (!style()->isLeftToRightDirection()) -
trunk/Source/WebCore/rendering/RenderTableSection.h
r105029 r107038 56 56 57 57 void setCellLogicalWidths(); 58 LayoutUnit calcRowLogicalHeight();59 LayoutUnit layoutRows(LayoutUnit logicalHeight);58 int calcRowLogicalHeight(); 59 int layoutRows(int logicalHeight); 60 60 61 61 RenderTable* table() const { return toRenderTable(parent()); } … … 88 88 RowStruct() 89 89 : rowRenderer(0) 90 , baseline( 0)90 , baseline() 91 91 { 92 92 } … … 109 109 void splitColumn(unsigned pos, unsigned first); 110 110 111 LayoutUnit calcOuterBorderBefore() const;112 LayoutUnit calcOuterBorderAfter() const;113 LayoutUnit calcOuterBorderStart() const;114 LayoutUnit calcOuterBorderEnd() const;111 int calcOuterBorderBefore() const; 112 int calcOuterBorderAfter() const; 113 int calcOuterBorderStart() const; 114 int calcOuterBorderEnd() const; 115 115 void recalcOuterBorder(); 116 116 117 LayoutUnit outerBorderBefore() const { return m_outerBorderBefore; }118 LayoutUnit outerBorderAfter() const { return m_outerBorderAfter; }119 LayoutUnit outerBorderStart() const { return m_outerBorderStart; }120 LayoutUnit outerBorderEnd() const { return m_outerBorderEnd; }117 int outerBorderBefore() const { return m_outerBorderBefore; } 118 int outerBorderAfter() const { return m_outerBorderAfter; } 119 int outerBorderStart() const { return m_outerBorderStart; } 120 int outerBorderEnd() const { return m_outerBorderEnd; } 121 121 122 122 unsigned numRows() const { return m_grid.size(); } … … 174 174 175 175 Vector<RowStruct> m_grid; 176 Vector< LayoutUnit> m_rowPos;176 Vector<int> m_rowPos; 177 177 178 178 // the current insertion position … … 180 180 unsigned m_cRow; 181 181 182 LayoutUnit m_outerBorderStart;183 LayoutUnit m_outerBorderEnd;184 LayoutUnit m_outerBorderBefore;185 LayoutUnit m_outerBorderAfter;182 int m_outerBorderStart; 183 int m_outerBorderEnd; 184 int m_outerBorderBefore; 185 int m_outerBorderAfter; 186 186 187 187 bool m_needsCellRecalc;
Note:
See TracChangeset
for help on using the changeset viewer.