Changeset 92992 in webkit
- Timestamp:
- Aug 12, 2011 2:01:45 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92991 r92992 1 2011-08-12 Levi Weintraub <leviw@chromium.org> 2 3 Switch RenderTable* to new layout types 4 https://bugs.webkit.org/show_bug.cgi?id=66146 5 6 Reviewed by Eric Seidel. 7 8 Converting RenderTable* classes to new LayoutUnits from ints. 9 10 No new tests as no new functionality. 11 12 * rendering/RenderTable.cpp: 13 (WebCore::RenderTable::firstLineBoxBaseline): 14 (WebCore::RenderTable::overflowClipRect): 15 * rendering/RenderTable.h: 16 (WebCore::RenderTable::columnPositions): 17 * rendering/RenderTableCol.cpp: 18 (WebCore::RenderTableCol::clippedOverflowRectForRepaint): 19 * rendering/RenderTableRow.cpp: 20 (WebCore::RenderTableRow::clippedOverflowRectForRepaint): 21 * rendering/RenderTableSection.cpp: 22 (WebCore::RenderTableSection::setCellLogicalWidths): 23 (WebCore::RenderTableSection::calcRowLogicalHeight): 24 (WebCore::RenderTableSection::layoutRows): 25 (WebCore::RenderTableSection::calcOuterBorderBefore): 26 (WebCore::RenderTableSection::calcOuterBorderAfter): 27 (WebCore::RenderTableSection::calcOuterBorderStart): 28 (WebCore::RenderTableSection::calcOuterBorderEnd): 29 (WebCore::RenderTableSection::firstLineBoxBaseline): 30 (WebCore::RenderTableSection::paintObject): 31 (WebCore::RenderTableSection::nodeAtPoint): 32 * rendering/RenderTableSection.h: 33 (WebCore::RenderTableSection::outerBorderBefore): 34 (WebCore::RenderTableSection::outerBorderAfter): 35 (WebCore::RenderTableSection::outerBorderStart): 36 (WebCore::RenderTableSection::outerBorderEnd): 37 (WebCore::RenderTableSection::getBaseline): 38 1 39 2011-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 40 -
trunk/Source/WebCore/rendering/RenderTable.cpp
r92340 r92992 1145 1145 } 1146 1146 1147 int RenderTable::firstLineBoxBaseline() const1147 LayoutUnit RenderTable::firstLineBoxBaseline() const 1148 1148 { 1149 1149 if (isWritingModeRoot()) … … 1162 1162 } 1163 1163 1164 IntRect RenderTable::overflowClipRect(const IntPoint& location, OverlayScrollbarSizeRelevancy relevancy)1165 { 1166 IntRect rect = RenderBlock::overflowClipRect(location, relevancy);1164 LayoutRect RenderTable::overflowClipRect(const LayoutPoint& location, OverlayScrollbarSizeRelevancy relevancy) 1165 { 1166 LayoutRect rect = RenderBlock::overflowClipRect(location, relevancy); 1167 1167 1168 1168 // If we have a caption, expand the clip to include the caption. -
trunk/Source/WebCore/rendering/RenderTable.h
r91417 r92992 140 140 141 141 Vector<ColumnStruct>& columns() { return m_columns; } 142 Vector< int>& columnPositions() { return m_columnPos; }142 Vector<LayoutUnit>& columnPositions() { return m_columnPos; } 143 143 RenderTableSection* header() const { return m_head; } 144 144 RenderTableSection* footer() const { return m_foot; } … … 223 223 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction); 224 224 225 virtual int firstLineBoxBaseline() const;225 virtual LayoutUnit firstLineBoxBaseline() const; 226 226 227 227 virtual RenderBlock* firstLineBlock() const; … … 232 232 virtual void computeLogicalWidth(); 233 233 234 virtual IntRect overflowClipRect(const IntPoint& location, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);234 virtual LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize); 235 235 236 236 virtual void addOverflowFromChildren(); … … 242 242 void adjustLogicalHeightForCaption(); 243 243 244 mutable Vector< int> m_columnPos;244 mutable Vector<LayoutUnit> m_columnPos; 245 245 mutable Vector<ColumnStruct> m_columns; 246 246 -
trunk/Source/WebCore/rendering/RenderTableCol.cpp
r92252 r92992 79 79 RenderTable* parentTable = table(); 80 80 if (!parentTable) 81 return IntRect();81 return LayoutRect(); 82 82 return parentTable->clippedOverflowRectForRepaint(repaintContainer); 83 83 } -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r90675 r92992 255 255 void RenderTableSection::setCellLogicalWidths() 256 256 { 257 Vector< int>& columnPos = table()->columnPositions();257 Vector<LayoutUnit>& columnPos = table()->columnPositions(); 258 258 259 259 LayoutStateMaintainer statePusher(view()); … … 294 294 } 295 295 296 int RenderTableSection::calcRowLogicalHeight()296 LayoutUnit RenderTableSection::calcRowLogicalHeight() 297 297 { 298 298 #ifndef NDEBUG … … 304 304 RenderTableCell* cell; 305 305 306 int spacing = table()->vBorderSpacing();306 LayoutUnit spacing = table()->vBorderSpacing(); 307 307 308 308 LayoutStateMaintainer statePusher(view()); … … 314 314 m_rowPos[r + 1] = 0; 315 315 m_grid[r].baseline = 0; 316 int baseline = 0;317 int bdesc = 0;318 int ch = m_grid[r].logicalHeight.calcMinValue(0);319 int pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0);316 LayoutUnit baseline = 0; 317 LayoutUnit bdesc = 0; 318 LayoutUnit ch = m_grid[r].logicalHeight.calcMinValue(0); 319 LayoutUnit pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0); 320 320 321 321 m_rowPos[r + 1] = max(m_rowPos[r + 1], pos); … … 340 340 // Technically, we should also push state for the row, but since 341 341 // rows don't push a coordinate transform, that's not necessary. 342 statePusher.push(this, IntSize(x(), y()));342 statePusher.push(this, locationOffset()); 343 343 } 344 344 cell->clearIntrinsicPadding(); … … 348 348 } 349 349 350 int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();351 int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();352 int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());350 LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore(); 351 LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter(); 352 LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter()); 353 353 354 354 // Explicit heights use the border box in quirks mode. In strict mode do the right … … 366 366 EVerticalAlign va = cell->style()->verticalAlign(); 367 367 if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) { 368 int b = cell->cellBaselinePosition();368 LayoutUnit b = cell->cellBaselinePosition(); 369 369 if (b > cell->borderBefore() + cell->paddingBefore()) { 370 370 baseline = max(baseline, b - cell->intrinsicPaddingBefore()); … … 410 410 } 411 411 412 int RenderTableSection::layoutRows(int toAdd)412 LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) 413 413 { 414 414 #ifndef NDEBUG … … 418 418 ASSERT(!needsLayout()); 419 419 420 int rHeight;420 LayoutUnit rHeight; 421 421 int rindx; 422 422 int totalRows = m_gridRows; … … 428 428 429 429 if (toAdd && totalRows && (m_rowPos[totalRows] || !nextSibling())) { 430 int totalHeight = m_rowPos[totalRows] + toAdd;431 432 int dh = toAdd;430 LayoutUnit totalHeight = m_rowPos[totalRows] + toAdd; 431 432 LayoutUnit dh = toAdd; 433 433 int totalPercent = 0; 434 434 int numAuto = 0; … … 441 441 if (totalPercent) { 442 442 // try to satisfy percent 443 int add = 0;443 LayoutUnit add = 0; 444 444 totalPercent = min(totalPercent, 100); 445 445 int rh = m_rowPos[1] - m_rowPos[0]; 446 446 for (int r = 0; r < totalRows; r++) { 447 447 if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) { 448 int toAdd = min(dh, static_cast<int>((totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh));448 LayoutUnit toAdd = min(dh, static_cast<LayoutUnit>((totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh)); 449 449 // If toAdd is negative, then we don't want to shrink the row (this bug 450 450 // affected Outlook Web Access). 451 toAdd = max (0, toAdd);451 toAdd = max<LayoutUnit>(0, toAdd); 452 452 add += toAdd; 453 453 dh -= toAdd; … … 461 461 if (numAuto) { 462 462 // distribute over variable cols 463 int add = 0;463 LayoutUnit add = 0; 464 464 for (int r = 0; r < totalRows; r++) { 465 465 if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) { 466 int toAdd = dh / numAuto;466 LayoutUnit toAdd = dh / numAuto; 467 467 add += toAdd; 468 468 dh -= toAdd; … … 474 474 if (dh > 0 && m_rowPos[totalRows]) { 475 475 // if some left overs, distribute equally. 476 int tot = m_rowPos[totalRows];477 int add = 0;478 int prev = m_rowPos[0];476 LayoutUnit tot = m_rowPos[totalRows]; 477 LayoutUnit add = 0; 478 LayoutUnit prev = m_rowPos[0]; 479 479 for (int r = 0; r < totalRows; r++) { 480 480 // weight with the original height … … 486 486 } 487 487 488 int hspacing = table()->hBorderSpacing();489 int vspacing = table()->vBorderSpacing();490 int nEffCols = table()->numEffCols();491 492 LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), style()->isFlippedBlocksWritingMode());488 LayoutUnit hspacing = table()->hBorderSpacing(); 489 LayoutUnit vspacing = table()->vBorderSpacing(); 490 LayoutUnit nEffCols = table()->numEffCols(); 491 492 LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), style()->isFlippedBlocksWritingMode()); 493 493 494 494 for (int r = 0; r < totalRows; r++) { 495 495 // Set the row's x/y position and width/height. 496 496 if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) { 497 rowRenderer->setLocation( IntPoint(0, m_rowPos[r]));497 rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); 498 498 rowRenderer->setLogicalWidth(logicalWidth()); 499 499 rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspacing); … … 569 569 EVerticalAlign va = cell->style()->verticalAlign(); 570 570 if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) { 571 int b= cell->cellBaselinePosition();572 if (b > cell->borderBefore() + cell->paddingBefore())573 m_grid[r].baseline = max(m_grid[r].baseline, b );571 LayoutUnit baseline = cell->cellBaselinePosition(); 572 if (baseline > cell->borderBefore() + cell->paddingBefore()) 573 m_grid[r].baseline = max(m_grid[r].baseline, baseline); 574 574 } 575 575 } 576 576 577 int oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore();578 int oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter();579 int logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter;580 581 int intrinsicPaddingBefore = 0;577 LayoutUnit oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore(); 578 LayoutUnit oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter(); 579 LayoutUnit logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter; 580 581 LayoutUnit intrinsicPaddingBefore = 0; 582 582 switch (cell->style()->verticalAlign()) { 583 583 case SUB: … … 586 586 case TEXT_BOTTOM: 587 587 case BASELINE: { 588 int b = cell->cellBaselinePosition();588 LayoutUnit b = cell->cellBaselinePosition(); 589 589 if (b > cell->borderBefore() + cell->paddingBefore()) 590 590 intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore); … … 603 603 } 604 604 605 int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;605 LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; 606 606 cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore); 607 607 cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter); 608 608 609 IntRect oldCellRect(cell->x(), cell->y() , cell->width(), cell->height());610 611 IntPoint cellLocation(0, m_rowPos[rindx]);609 LayoutRect oldCellRect(cell->x(), cell->y() , cell->width(), cell->height()); 610 611 LayoutPoint cellLocation(0, m_rowPos[rindx]); 612 612 if (!style()->isLeftToRightDirection()) 613 613 cellLocation.setX(table()->columnPositions()[nEffCols] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + hspacing); … … 615 615 cellLocation.setX(table()->columnPositions()[c] + hspacing); 616 616 cell->setLogicalLocation(cellLocation); 617 view()->addLayoutDelta( IntSize(oldCellRect.x() - cell->x(), oldCellRect.y() - cell->y()));617 view()->addLayoutDelta(oldCellRect.location() - cell->location()); 618 618 619 619 if (intrinsicPaddingBefore != oldIntrinsicPaddingBefore || intrinsicPaddingAfter != oldIntrinsicPaddingAfter) … … 629 629 cell->setHeight(rHeight); // FIXME: Pagination might have made us change size. For now just shrink or grow the cell to fit without doing a relayout. 630 630 631 IntSize childOffset(cell->x() - oldCellRect.x(), cell->y() - oldCellRect.y());631 LayoutSize childOffset(cell->location() - oldCellRect.location()); 632 632 if (childOffset.width() || childOffset.height()) { 633 633 view()->addLayoutDelta(childOffset); … … 668 668 } 669 669 670 int RenderTableSection::calcOuterBorderBefore() const670 LayoutUnit RenderTableSection::calcOuterBorderBefore() const 671 671 { 672 672 int totalCols = table()->numEffCols(); … … 719 719 } 720 720 721 int RenderTableSection::calcOuterBorderAfter() const721 LayoutUnit RenderTableSection::calcOuterBorderAfter() const 722 722 { 723 723 int totalCols = table()->numEffCols(); … … 770 770 } 771 771 772 int RenderTableSection::calcOuterBorderStart() const772 LayoutUnit RenderTableSection::calcOuterBorderStart() const 773 773 { 774 774 int totalCols = table()->numEffCols(); … … 814 814 } 815 815 816 int RenderTableSection::calcOuterBorderEnd() const816 LayoutUnit RenderTableSection::calcOuterBorderEnd() const 817 817 { 818 818 int totalCols = table()->numEffCols(); … … 866 866 } 867 867 868 int RenderTableSection::firstLineBoxBaseline() const868 LayoutUnit RenderTableSection::firstLineBoxBaseline() const 869 869 { 870 870 if (!m_gridRows) 871 871 return -1; 872 872 873 int firstLineBaseline = m_grid[0].baseline;873 LayoutUnit firstLineBaseline = m_grid[0].baseline; 874 874 if (firstLineBaseline) 875 875 return firstLineBaseline + m_rowPos[0]; … … 997 997 if (!m_hasOverflowingCell && style()->isLeftToRightDirection()) { 998 998 LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os; 999 Vector< int>& columnPos = table()->columnPositions();999 Vector<LayoutUnit>& columnPos = table()->columnPositions(); 1000 1000 startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin(); 1001 1001 if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start))) … … 1190 1190 1191 1191 Vector<LayoutUnit>& columnPos = table()->columnPositions(); 1192 int offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();1192 LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y(); 1193 1193 if (!style()->isLeftToRightDirection()) 1194 1194 offsetInRowDirection = columnPos[columnPos.size() - 1] - offsetInRowDirection; -
trunk/Source/WebCore/rendering/RenderTableSection.h
r90675 r92992 44 44 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 45 45 46 virtual int firstLineBoxBaseline() const;46 virtual LayoutUnit firstLineBoxBaseline() const; 47 47 48 48 void addCell(RenderTableCell*, RenderTableRow* row); 49 49 50 50 void setCellLogicalWidths(); 51 int calcRowLogicalHeight();52 int layoutRows(int logicalHeight);51 LayoutUnit calcRowLogicalHeight(); 52 LayoutUnit layoutRows(LayoutUnit logicalHeight); 53 53 54 54 RenderTable* table() const { return toRenderTable(parent()); } … … 79 79 Row* row; 80 80 RenderTableRow* rowRenderer; 81 int baseline;81 LayoutUnit baseline; 82 82 Length logicalHeight; 83 83 }; … … 94 94 void splitColumn(int pos, int first); 95 95 96 int calcOuterBorderBefore() const;97 int calcOuterBorderAfter() const;98 int calcOuterBorderStart() const;99 int calcOuterBorderEnd() const;96 LayoutUnit calcOuterBorderBefore() const; 97 LayoutUnit calcOuterBorderAfter() const; 98 LayoutUnit calcOuterBorderStart() const; 99 LayoutUnit calcOuterBorderEnd() const; 100 100 void recalcOuterBorder(); 101 101 102 int outerBorderBefore() const { return m_outerBorderBefore; }103 int outerBorderAfter() const { return m_outerBorderAfter; }104 int outerBorderStart() const { return m_outerBorderStart; }105 int outerBorderEnd() const { return m_outerBorderEnd; }102 LayoutUnit outerBorderBefore() const { return m_outerBorderBefore; } 103 LayoutUnit outerBorderAfter() const { return m_outerBorderAfter; } 104 LayoutUnit outerBorderStart() const { return m_outerBorderStart; } 105 LayoutUnit outerBorderEnd() const { return m_outerBorderEnd; } 106 106 107 107 int numRows() const { return m_gridRows; } … … 117 117 void setNeedsCellRecalc(); 118 118 119 int getBaseline(int row) { return m_grid[row].baseline; }119 LayoutUnit getBaseline(int row) { return m_grid[row].baseline; } 120 120 121 121 private: … … 147 147 148 148 Vector<RowStruct> m_grid; 149 Vector< int> m_rowPos;149 Vector<LayoutUnit> m_rowPos; 150 150 151 151 int m_gridRows; … … 155 155 int m_cRow; 156 156 157 int m_outerBorderStart;158 int m_outerBorderEnd;159 int m_outerBorderBefore;160 int m_outerBorderAfter;157 LayoutUnit m_outerBorderStart; 158 LayoutUnit m_outerBorderEnd; 159 LayoutUnit m_outerBorderBefore; 160 LayoutUnit m_outerBorderAfter; 161 161 162 162 bool m_needsCellRecalc;
Note: See TracChangeset
for help on using the changeset viewer.