Changeset 92992 in webkit


Ignore:
Timestamp:
Aug 12, 2011 2:01:45 PM (13 years ago)
Author:
leviw@chromium.org
Message:

Switch RenderTable* to new layout types
https://bugs.webkit.org/show_bug.cgi?id=66146

Reviewed by Eric Seidel.

Converting RenderTable* classes to new LayoutUnits from ints.

No new tests as no new functionality.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::firstLineBoxBaseline):
(WebCore::RenderTable::overflowClipRect):

  • rendering/RenderTable.h:

(WebCore::RenderTable::columnPositions):

  • rendering/RenderTableCol.cpp:

(WebCore::RenderTableCol::clippedOverflowRectForRepaint):

  • rendering/RenderTableRow.cpp:

(WebCore::RenderTableRow::clippedOverflowRectForRepaint):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::setCellLogicalWidths):
(WebCore::RenderTableSection::calcRowLogicalHeight):
(WebCore::RenderTableSection::layoutRows):
(WebCore::RenderTableSection::calcOuterBorderBefore):
(WebCore::RenderTableSection::calcOuterBorderAfter):
(WebCore::RenderTableSection::calcOuterBorderStart):
(WebCore::RenderTableSection::calcOuterBorderEnd):
(WebCore::RenderTableSection::firstLineBoxBaseline):
(WebCore::RenderTableSection::paintObject):
(WebCore::RenderTableSection::nodeAtPoint):

  • rendering/RenderTableSection.h:

(WebCore::RenderTableSection::outerBorderBefore):
(WebCore::RenderTableSection::outerBorderAfter):
(WebCore::RenderTableSection::outerBorderStart):
(WebCore::RenderTableSection::outerBorderEnd):
(WebCore::RenderTableSection::getBaseline):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92991 r92992  
     12011-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
    1392011-08-12  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    240
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r92340 r92992  
    11451145}
    11461146
    1147 int RenderTable::firstLineBoxBaseline() const
     1147LayoutUnit RenderTable::firstLineBoxBaseline() const
    11481148{
    11491149    if (isWritingModeRoot())
     
    11621162}
    11631163
    1164 IntRect RenderTable::overflowClipRect(const IntPoint& location, OverlayScrollbarSizeRelevancy relevancy)
    1165 {
    1166     IntRect rect = RenderBlock::overflowClipRect(location, relevancy);
     1164LayoutRect RenderTable::overflowClipRect(const LayoutPoint& location, OverlayScrollbarSizeRelevancy relevancy)
     1165{
     1166    LayoutRect rect = RenderBlock::overflowClipRect(location, relevancy);
    11671167   
    11681168    // If we have a caption, expand the clip to include the caption.
  • trunk/Source/WebCore/rendering/RenderTable.h

    r91417 r92992  
    140140
    141141    Vector<ColumnStruct>& columns() { return m_columns; }
    142     Vector<int>& columnPositions() { return m_columnPos; }
     142    Vector<LayoutUnit>& columnPositions() { return m_columnPos; }
    143143    RenderTableSection* header() const { return m_head; }
    144144    RenderTableSection* footer() const { return m_foot; }
     
    223223    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
    224224   
    225     virtual int firstLineBoxBaseline() const;
     225    virtual LayoutUnit firstLineBoxBaseline() const;
    226226
    227227    virtual RenderBlock* firstLineBlock() const;
     
    232232    virtual void computeLogicalWidth();
    233233
    234     virtual IntRect overflowClipRect(const IntPoint& location, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);
     234    virtual LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);
    235235
    236236    virtual void addOverflowFromChildren();
     
    242242    void adjustLogicalHeightForCaption();
    243243
    244     mutable Vector<int> m_columnPos;
     244    mutable Vector<LayoutUnit> m_columnPos;
    245245    mutable Vector<ColumnStruct> m_columns;
    246246
  • trunk/Source/WebCore/rendering/RenderTableCol.cpp

    r92252 r92992  
    7979    RenderTable* parentTable = table();
    8080    if (!parentTable)
    81         return IntRect();
     81        return LayoutRect();
    8282    return parentTable->clippedOverflowRectForRepaint(repaintContainer);
    8383}
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r90675 r92992  
    255255void RenderTableSection::setCellLogicalWidths()
    256256{
    257     Vector<int>& columnPos = table()->columnPositions();
     257    Vector<LayoutUnit>& columnPos = table()->columnPositions();
    258258
    259259    LayoutStateMaintainer statePusher(view());
     
    294294}
    295295
    296 int RenderTableSection::calcRowLogicalHeight()
     296LayoutUnit RenderTableSection::calcRowLogicalHeight()
    297297{
    298298#ifndef NDEBUG
     
    304304    RenderTableCell* cell;
    305305
    306     int spacing = table()->vBorderSpacing();
     306    LayoutUnit spacing = table()->vBorderSpacing();
    307307
    308308    LayoutStateMaintainer statePusher(view());
     
    314314        m_rowPos[r + 1] = 0;
    315315        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);
    320320
    321321        m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
     
    340340                    // Technically, we should also push state for the row, but since
    341341                    // rows don't push a coordinate transform, that's not necessary.
    342                     statePusher.push(this, IntSize(x(), y()));
     342                    statePusher.push(this, locationOffset());
    343343                }
    344344                cell->clearIntrinsicPadding();
     
    348348            }
    349349
    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());
    353353
    354354            // Explicit heights use the border box in quirks mode.  In strict mode do the right
     
    366366            EVerticalAlign va = cell->style()->verticalAlign();
    367367            if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
    368                 int b = cell->cellBaselinePosition();
     368                LayoutUnit b = cell->cellBaselinePosition();
    369369                if (b > cell->borderBefore() + cell->paddingBefore()) {
    370370                    baseline = max(baseline, b - cell->intrinsicPaddingBefore());
     
    410410}
    411411
    412 int RenderTableSection::layoutRows(int toAdd)
     412LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd)
    413413{
    414414#ifndef NDEBUG
     
    418418    ASSERT(!needsLayout());
    419419
    420     int rHeight;
     420    LayoutUnit rHeight;
    421421    int rindx;
    422422    int totalRows = m_gridRows;
     
    428428
    429429    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;
    433433        int totalPercent = 0;
    434434        int numAuto = 0;
     
    441441        if (totalPercent) {
    442442            // try to satisfy percent
    443             int add = 0;
     443            LayoutUnit add = 0;
    444444            totalPercent = min(totalPercent, 100);
    445445            int rh = m_rowPos[1] - m_rowPos[0];
    446446            for (int r = 0; r < totalRows; r++) {
    447447                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));
    449449                    // If toAdd is negative, then we don't want to shrink the row (this bug
    450450                    // affected Outlook Web Access).
    451                     toAdd = max(0, toAdd);
     451                    toAdd = max<LayoutUnit>(0, toAdd);
    452452                    add += toAdd;
    453453                    dh -= toAdd;
     
    461461        if (numAuto) {
    462462            // distribute over variable cols
    463             int add = 0;
     463            LayoutUnit add = 0;
    464464            for (int r = 0; r < totalRows; r++) {
    465465                if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) {
    466                     int toAdd = dh / numAuto;
     466                    LayoutUnit toAdd = dh / numAuto;
    467467                    add += toAdd;
    468468                    dh -= toAdd;
     
    474474        if (dh > 0 && m_rowPos[totalRows]) {
    475475            // 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];
    479479            for (int r = 0; r < totalRows; r++) {
    480480                // weight with the original height
     
    486486    }
    487487
    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());
    493493
    494494    for (int r = 0; r < totalRows; r++) {
    495495        // Set the row's x/y position and width/height.
    496496        if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) {
    497             rowRenderer->setLocation(IntPoint(0, m_rowPos[r]));
     497            rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r]));
    498498            rowRenderer->setLogicalWidth(logicalWidth());
    499499            rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspacing);
     
    569569                EVerticalAlign va = cell->style()->verticalAlign();
    570570                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);
    574574                }
    575575            }
    576576
    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;
    582582            switch (cell->style()->verticalAlign()) {
    583583                case SUB:
     
    586586                case TEXT_BOTTOM:
    587587                case BASELINE: {
    588                     int b = cell->cellBaselinePosition();
     588                    LayoutUnit b = cell->cellBaselinePosition();
    589589                    if (b > cell->borderBefore() + cell->paddingBefore())
    590590                        intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore);
     
    603603            }
    604604           
    605             int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
     605            LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
    606606            cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore);
    607607            cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter);
    608608
    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]);
    612612            if (!style()->isLeftToRightDirection())
    613613                cellLocation.setX(table()->columnPositions()[nEffCols] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + hspacing);
     
    615615                cellLocation.setX(table()->columnPositions()[c] + hspacing);
    616616            cell->setLogicalLocation(cellLocation);
    617             view()->addLayoutDelta(IntSize(oldCellRect.x() - cell->x(), oldCellRect.y() - cell->y()));
     617            view()->addLayoutDelta(oldCellRect.location() - cell->location());
    618618
    619619            if (intrinsicPaddingBefore != oldIntrinsicPaddingBefore || intrinsicPaddingAfter != oldIntrinsicPaddingAfter)
     
    629629                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.
    630630
    631             IntSize childOffset(cell->x() - oldCellRect.x(), cell->y() - oldCellRect.y());
     631            LayoutSize childOffset(cell->location() - oldCellRect.location());
    632632            if (childOffset.width() || childOffset.height()) {
    633633                view()->addLayoutDelta(childOffset);
     
    668668}
    669669
    670 int RenderTableSection::calcOuterBorderBefore() const
     670LayoutUnit RenderTableSection::calcOuterBorderBefore() const
    671671{
    672672    int totalCols = table()->numEffCols();
     
    719719}
    720720
    721 int RenderTableSection::calcOuterBorderAfter() const
     721LayoutUnit RenderTableSection::calcOuterBorderAfter() const
    722722{
    723723    int totalCols = table()->numEffCols();
     
    770770}
    771771
    772 int RenderTableSection::calcOuterBorderStart() const
     772LayoutUnit RenderTableSection::calcOuterBorderStart() const
    773773{
    774774    int totalCols = table()->numEffCols();
     
    814814}
    815815
    816 int RenderTableSection::calcOuterBorderEnd() const
     816LayoutUnit RenderTableSection::calcOuterBorderEnd() const
    817817{
    818818    int totalCols = table()->numEffCols();
     
    866866}
    867867
    868 int RenderTableSection::firstLineBoxBaseline() const
     868LayoutUnit RenderTableSection::firstLineBoxBaseline() const
    869869{
    870870    if (!m_gridRows)
    871871        return -1;
    872872
    873     int firstLineBaseline = m_grid[0].baseline;
     873    LayoutUnit firstLineBaseline = m_grid[0].baseline;
    874874    if (firstLineBaseline)
    875875        return firstLineBaseline + m_rowPos[0];
     
    997997    if (!m_hasOverflowingCell && style()->isLeftToRightDirection()) {
    998998        LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os;
    999         Vector<int>& columnPos = table()->columnPositions();
     999        Vector<LayoutUnit>& columnPos = table()->columnPositions();
    10001000        startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin();
    10011001        if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start)))
     
    11901190
    11911191    Vector<LayoutUnit>& columnPos = table()->columnPositions();
    1192     int offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();
     1192    LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();
    11931193    if (!style()->isLeftToRightDirection())
    11941194        offsetInRowDirection = columnPos[columnPos.size() - 1] - offsetInRowDirection;
  • trunk/Source/WebCore/rendering/RenderTableSection.h

    r90675 r92992  
    4444    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    4545
    46     virtual int firstLineBoxBaseline() const;
     46    virtual LayoutUnit firstLineBoxBaseline() const;
    4747
    4848    void addCell(RenderTableCell*, RenderTableRow* row);
    4949
    5050    void setCellLogicalWidths();
    51     int calcRowLogicalHeight();
    52     int layoutRows(int logicalHeight);
     51    LayoutUnit calcRowLogicalHeight();
     52    LayoutUnit layoutRows(LayoutUnit logicalHeight);
    5353
    5454    RenderTable* table() const { return toRenderTable(parent()); }
     
    7979        Row* row;
    8080        RenderTableRow* rowRenderer;
    81         int baseline;
     81        LayoutUnit baseline;
    8282        Length logicalHeight;
    8383    };
     
    9494    void splitColumn(int pos, int first);
    9595
    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;
    100100    void recalcOuterBorder();
    101101
    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; }
    106106
    107107    int numRows() const { return m_gridRows; }
     
    117117    void setNeedsCellRecalc();
    118118
    119     int getBaseline(int row) { return m_grid[row].baseline; }
     119    LayoutUnit getBaseline(int row) { return m_grid[row].baseline; }
    120120
    121121private:
     
    147147
    148148    Vector<RowStruct> m_grid;
    149     Vector<int> m_rowPos;
     149    Vector<LayoutUnit> m_rowPos;
    150150
    151151    int m_gridRows;
     
    155155    int m_cRow;
    156156
    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;
    161161
    162162    bool m_needsCellRecalc;
Note: See TracChangeset for help on using the changeset viewer.