⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 107038 in webkit


Ignore:
Timestamp:
Feb 7, 2012, 9:37:54 PM (15 years ago)
Author:
eae@chromium.org
Message:

Revert TableSection cell and border calculations to integers
https://bugs.webkit.org/show_bug.cgi?id=77918

Reviewed by Eric Seidel.

Change RenderTableSection cell width, row height and border calculations
back to use integers. Table layout is done on integer bounds to comply
with the specification and to ensure that columns given the same width,
including percentage widths, are rendered with identical widths. The same
applies to heights.

No new tests.

  • 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::paintObject):
(WebCore::RenderTableSection::nodeAtPoint):

  • rendering/RenderTableSection.h:

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

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107036 r107038  
     12012-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
    1342012-02-07  Robert Kroeger  <rjkroege@chromium.org>
    235
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r105685 r107038  
    278278void RenderTableSection::setCellLogicalWidths()
    279279{
    280     Vector<LayoutUnit>& columnPos = table()->columnPositions();
     280    Vector<int>& columnPos = table()->columnPositions();
    281281
    282282    LayoutStateMaintainer statePusher(view());
     
    297297                endCol++;
    298298            }
    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();
    301301            if (w != oldLogicalWidth) {
    302302                cell->setNeedsLayout(true);
     
    317317}
    318318
    319 LayoutUnit RenderTableSection::calcRowLogicalHeight()
     319int RenderTableSection::calcRowLogicalHeight()
    320320{
    321321#ifndef NDEBUG
     
    327327    RenderTableCell* cell;
    328328
    329     LayoutUnit spacing = table()->vBorderSpacing();
     329    int spacing = table()->vBorderSpacing();
    330330
    331331    LayoutStateMaintainer statePusher(view());
     
    338338        m_grid[r].baseline = 0;
    339339        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);
    343343
    344344        m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
     
    371371            }
    372372
    373             LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
     373            int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
    374374
    375375            ch = cell->style()->logicalHeight().calcValue(0);
     
    380380                // In strict mode, box-sizing: content-box do the right
    381381                // 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();
    384384                ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter();
    385385            }
     
    393393            EVerticalAlign va = cell->style()->verticalAlign();
    394394            if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
    395                 LayoutUnit b = cell->cellBaselinePosition();
     395                int b = cell->cellBaselinePosition();
    396396                if (b > cell->borderBefore() + cell->paddingBefore()) {
    397                     baseline = max(baseline, b - cell->intrinsicPaddingBefore());
     397                    baseline = max<LayoutUnit>(baseline, b - cell->intrinsicPaddingBefore());
    398398                    bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingBefore()));
    399399                }
     
    437437}
    438438
    439 LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd)
     439int RenderTableSection::layoutRows(int toAdd)
    440440{
    441441#ifndef NDEBUG
     
    445445    ASSERT(!needsLayout());
    446446
    447     LayoutUnit rHeight;
     447    int rHeight;
    448448    unsigned rindx;
    449449    unsigned totalRows = m_grid.size();
     
    456456
    457457    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;
    461461        int totalPercent = 0;
    462462        int numAuto = 0;
     
    469469        if (totalPercent) {
    470470            // try to satisfy percent
    471             LayoutUnit add = 0;
     471            int add = 0;
    472472            totalPercent = min(totalPercent, 100);
    473             LayoutUnit rh = m_rowPos[1] - m_rowPos[0];
     473            int rh = m_rowPos[1] - m_rowPos[0];
    474474            for (unsigned r = 0; r < totalRows; r++) {
    475475                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);
    477477                    // If toAdd is negative, then we don't want to shrink the row (this bug
    478478                    // affected Outlook Web Access).
    479                     toAdd = max<LayoutUnit>(0, toAdd);
     479                    toAdd = max(0, toAdd);
    480480                    add += toAdd;
    481481                    dh -= toAdd;
     
    490490        if (numAuto) {
    491491            // distribute over variable cols
    492             LayoutUnit add = 0;
     492            int add = 0;
    493493            for (unsigned r = 0; r < totalRows; r++) {
    494494                if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) {
    495                     LayoutUnit toAdd = dh / numAuto;
     495                    int toAdd = dh / numAuto;
    496496                    add += toAdd;
    497497                    dh -= toAdd;
     
    503503        if (dh > 0 && m_rowPos[totalRows]) {
    504504            // 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];
    508508            for (unsigned r = 0; r < totalRows; r++) {
    509509                // weight with the original height
     
    515515    }
    516516
    517     LayoutUnit hspacing = table()->hBorderSpacing();
    518     LayoutUnit vspacing = table()->vBorderSpacing();
     517    int hspacing = table()->hBorderSpacing();
     518    int vspacing = table()->vBorderSpacing();
    519519    unsigned nEffCols = table()->numEffCols();
    520520
     
    604604            }
    605605
    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;
    611611            switch (cell->style()->verticalAlign()) {
    612612                case SUB:
     
    615615                case TEXT_BOTTOM:
    616616                case BASELINE: {
    617                     LayoutUnit b = cell->cellBaselinePosition();
     617                    int b = cell->cellBaselinePosition();
    618618                    if (b > cell->borderBefore() + cell->paddingBefore())
    619619                        intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore);
     
    632632            }
    633633           
    634             LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
     634            int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
    635635            cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore);
    636636            cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter);
     
    716716}
    717717
    718 LayoutUnit RenderTableSection::calcOuterBorderBefore() const
     718int RenderTableSection::calcOuterBorderBefore() const
    719719{
    720720    unsigned totalCols = table()->numEffCols();
     
    767767}
    768768
    769 LayoutUnit RenderTableSection::calcOuterBorderAfter() const
     769int RenderTableSection::calcOuterBorderAfter() const
    770770{
    771771    unsigned totalCols = table()->numEffCols();
     
    818818}
    819819
    820 LayoutUnit RenderTableSection::calcOuterBorderStart() const
     820int RenderTableSection::calcOuterBorderStart() const
    821821{
    822822    unsigned totalCols = table()->numEffCols();
     
    862862}
    863863
    864 LayoutUnit RenderTableSection::calcOuterBorderEnd() const
     864int RenderTableSection::calcOuterBorderEnd() const
    865865{
    866866    unsigned totalCols = table()->numEffCols();
     
    10561056    if (!m_forceSlowPaintPathWithOverflowingCell && style()->isLeftToRightDirection()) {
    10571057        LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os;
    1058         Vector<LayoutUnit>& columnPos = table()->columnPositions();
     1058        Vector<int>& columnPos = table()->columnPositions();
    10591059        startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin();
    10601060        if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start)))
     
    13141314    unsigned hitRow = nextRow > 0 ? nextRow - 1 : 0;
    13151315
    1316     Vector<LayoutUnit>& columnPos = table()->columnPositions();
     1316    Vector<int>& columnPos = table()->columnPositions();
    13171317    LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();
    13181318    if (!style()->isLeftToRightDirection())
  • trunk/Source/WebCore/rendering/RenderTableSection.h

    r105029 r107038  
    5656
    5757    void setCellLogicalWidths();
    58     LayoutUnit calcRowLogicalHeight();
    59     LayoutUnit layoutRows(LayoutUnit logicalHeight);
     58    int calcRowLogicalHeight();
     59    int layoutRows(int logicalHeight);
    6060
    6161    RenderTable* table() const { return toRenderTable(parent()); }
     
    8888        RowStruct()
    8989            : rowRenderer(0)
    90             , baseline(0)
     90            , baseline()
    9191        {
    9292        }
     
    109109    void splitColumn(unsigned pos, unsigned first);
    110110
    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;
    115115    void recalcOuterBorder();
    116116
    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; }
    121121
    122122    unsigned numRows() const { return m_grid.size(); }
     
    174174
    175175    Vector<RowStruct> m_grid;
    176     Vector<LayoutUnit> m_rowPos;
     176    Vector<int> m_rowPos;
    177177
    178178    // the current insertion position
     
    180180    unsigned m_cRow;
    181181
    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;
    186186
    187187    bool m_needsCellRecalc;
Note: See TracChangeset for help on using the changeset viewer.