Changeset 99254 in webkit


Ignore:
Timestamp:
Nov 3, 2011 5:56:59 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Correct usage of LayoutUnits and integers in Table rendering classes
https://bugs.webkit.org/show_bug.cgi?id=71500

Reviewed by Darin Adler.

Fixing the Table layout classes to operate on integers -- sub-pixel table layout breaks
the spec. Meanwhile correcting the Table rendering classes themselves to still use
LayoutUnits.

No new tests -- no change in behavior.

  • rendering/AutoTableLayout.cpp: Reverting to operating on integers.

(WebCore::AutoTableLayout::recalcColumn):
(WebCore::AutoTableLayout::computePreferredLogicalWidths):
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
(WebCore::AutoTableLayout::layout):

  • rendering/AutoTableLayout.h: Reverting to operating on integers.
  • rendering/FixedTableLayout.cpp: Ditto.

(WebCore::FixedTableLayout::computePreferredLogicalWidths):
(WebCore::FixedTableLayout::layout):

  • rendering/RenderTable.h: Switching to LayoutUnits.

(WebCore::RenderTable::getColumnPos):
(WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):

  • rendering/RenderTableCell.cpp: Switching to LayoutUnits.

(WebCore::RenderTableCell::updateLogicalWidth):
(WebCore::RenderTableCell::setOverrideHeightFromRowHeight):
(WebCore::RenderTableCell::computeRectForRepaint):
(WebCore::RenderTableCell::cellBaselinePosition):
(WebCore::RenderTableCell::scrollbarsChanged):

  • rendering/RenderTableCell.h: Switching to LayoutUnits
  • rendering/RenderTableSection.cpp: Ditto.

(WebCore::RenderTableSection::setCellLogicalWidths):
(WebCore::RenderTableSection::layoutRows):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99253 r99254  
     12011-11-03  Levi Weintraub  <leviw@chromium.org>
     2
     3        Correct usage of LayoutUnits and integers in Table rendering classes
     4        https://bugs.webkit.org/show_bug.cgi?id=71500
     5
     6        Reviewed by Darin Adler.
     7
     8        Fixing the Table layout classes to operate on integers -- sub-pixel table layout breaks
     9        the spec. Meanwhile correcting the Table rendering classes themselves to still use
     10        LayoutUnits.
     11
     12        No new tests -- no change in behavior.
     13
     14        * rendering/AutoTableLayout.cpp: Reverting to operating on integers.
     15        (WebCore::AutoTableLayout::recalcColumn):
     16        (WebCore::AutoTableLayout::computePreferredLogicalWidths):
     17        (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
     18        (WebCore::AutoTableLayout::layout):
     19        * rendering/AutoTableLayout.h: Reverting to operating on integers.
     20        * rendering/FixedTableLayout.cpp: Ditto.
     21        (WebCore::FixedTableLayout::computePreferredLogicalWidths):
     22        (WebCore::FixedTableLayout::layout):
     23        * rendering/RenderTable.h: Switching to LayoutUnits.
     24        (WebCore::RenderTable::getColumnPos):
     25        (WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):
     26        * rendering/RenderTableCell.cpp: Switching to LayoutUnits.
     27        (WebCore::RenderTableCell::updateLogicalWidth):
     28        (WebCore::RenderTableCell::setOverrideHeightFromRowHeight):
     29        (WebCore::RenderTableCell::computeRectForRepaint):
     30        (WebCore::RenderTableCell::cellBaselinePosition):
     31        (WebCore::RenderTableCell::scrollbarsChanged):
     32        * rendering/RenderTableCell.h: Switching to LayoutUnits
     33        * rendering/RenderTableSection.cpp: Ditto.
     34        (WebCore::RenderTableSection::setCellLogicalWidths):
     35        (WebCore::RenderTableSection::layoutRows):
     36
    1372011-11-03  James Robinson  <jamesr@chromium.org>
    238
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r90955 r99254  
    7070                    // A cell originates in this column.  Ensure we have
    7171                    // a min/max width of at least 1px for this column now.
    72                     columnLayout.minLogicalWidth = max<LayoutUnit>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
    73                     columnLayout.maxLogicalWidth = max<LayoutUnit>(columnLayout.maxLogicalWidth, 1);
     72                    columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
     73                    columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
    7474                    if (cell->preferredLogicalWidthsDirty())
    7575                        cell->computePreferredLogicalWidths();
    76                     columnLayout.minLogicalWidth = max(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
     76                    columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
    7777                    if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) {
    7878                        columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth();
     
    120120                    // This spanning cell originates in this column.  Ensure we have
    121121                    // a min/max width of at least 1px for this column now.
    122                     columnLayout.minLogicalWidth = max<LayoutUnit>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
    123                     columnLayout.maxLogicalWidth = max<LayoutUnit>(columnLayout.maxLogicalWidth, 1);
     122                    columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
     123                    columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
    124124                    insertSpanCell(cell);
    125125                }
     
    224224    fullRecalc();
    225225
    226     LayoutUnit spanMaxLogicalWidth = calcEffectiveLogicalWidth();
     226    int spanMaxLogicalWidth = calcEffectiveLogicalWidth();
    227227    minWidth = 0;
    228228    maxWidth = 0;
     
    252252    if (scaleColumns) {
    253253        maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon);
    254         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    255         maxWidth = max<LayoutUnit>(maxWidth, static_cast<LayoutUnit>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
    256         maxWidth = max<LayoutUnit>(maxWidth, static_cast<LayoutUnit>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
    257     }
    258 
    259     maxWidth = max(maxWidth, spanMaxLogicalWidth);
    260 
    261     LayoutUnit bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
     254        maxWidth = max(maxWidth, static_cast<int>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
     255        maxWidth = max(maxWidth, static_cast<int>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
     256    }
     257
     258    maxWidth = max<int>(maxWidth, spanMaxLogicalWidth);
     259
     260    int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
    262261    minWidth += bordersPaddingAndSpacing;
    263262    maxWidth += bordersPaddingAndSpacing;
     
    265264    Length tableLogicalWidth = m_table->style()->logicalWidth();
    266265    if (tableLogicalWidth.isFixed() && tableLogicalWidth.value() > 0) {
    267         minWidth = max<LayoutUnit>(minWidth, tableLogicalWidth.value());
     266        minWidth = max<int>(minWidth, tableLogicalWidth.value());
    268267        maxWidth = minWidth;
    269268    } else if (!remainingPercent && maxNonPercent) {
     
    306305        float cellMaxLogicalWidth = cell->maxPreferredLogicalWidth() + spacingInRowDirection;
    307306        float totalPercent = 0;
    308         LayoutUnit spanMinLogicalWidth = 0;
     307        int spanMinLogicalWidth = 0;
    309308        float spanMaxLogicalWidth = 0;
    310309        bool allColsArePercent = true;
     
    312311        bool haveAuto = false;
    313312        bool spanHasEmptyCellsOnly = true;
    314         LayoutUnit fixedWidth = 0;
     313        int fixedWidth = 0;
    315314        while (lastCol < nEffCols && span > 0) {
    316315            Layout& columnLayout = m_layoutStruct[lastCol];
     
    391390            if (allColsAreFixed) {
    392391                for (unsigned pos = effCol; fixedWidth > 0 && pos < lastCol; ++pos) {
    393                     LayoutUnit cellLogicalWidth = max(m_layoutStruct[pos].effectiveMinLogicalWidth, cellMinLogicalWidth * m_layoutStruct[pos].logicalWidth.value() / fixedWidth);
     392                    int cellLogicalWidth = max(m_layoutStruct[pos].effectiveMinLogicalWidth, static_cast<int>(cellMinLogicalWidth * m_layoutStruct[pos].logicalWidth.value() / fixedWidth));
    394393                    fixedWidth -= m_layoutStruct[pos].logicalWidth.value();
    395394                    cellMinLogicalWidth -= cellLogicalWidth;
     
    398397            } else {
    399398                float remainingMaxLogicalWidth = spanMaxLogicalWidth;
    400                 LayoutUnit remainingMinLogicalWidth = spanMinLogicalWidth;
     399                int remainingMinLogicalWidth = spanMinLogicalWidth;
    401400               
    402401                // Give min to variable first, to fixed second, and to others third.
    403402                for (unsigned pos = effCol; remainingMaxLogicalWidth >= 0 && pos < lastCol; ++pos) {
    404403                    if (m_layoutStruct[pos].logicalWidth.isFixed() && haveAuto && fixedWidth <= cellMinLogicalWidth) {
    405                         int colMinLogicalWidth = max<LayoutUnit>(m_layoutStruct[pos].effectiveMinLogicalWidth, m_layoutStruct[pos].logicalWidth.value());
     404                        int colMinLogicalWidth = max<int>(m_layoutStruct[pos].effectiveMinLogicalWidth, m_layoutStruct[pos].logicalWidth.value());
    406405                        fixedWidth -= m_layoutStruct[pos].logicalWidth.value();
    407406                        remainingMinLogicalWidth -= m_layoutStruct[pos].effectiveMinLogicalWidth;
     
    414413                for (unsigned pos = effCol; remainingMaxLogicalWidth >= 0 && pos < lastCol && remainingMinLogicalWidth < cellMinLogicalWidth; ++pos) {
    415414                    if (!(m_layoutStruct[pos].logicalWidth.isFixed() && haveAuto && fixedWidth <= cellMinLogicalWidth)) {
    416                         int colMinLogicalWidth = max<LayoutUnit>(m_layoutStruct[pos].effectiveMinLogicalWidth, static_cast<int>(remainingMaxLogicalWidth ? cellMinLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / remainingMaxLogicalWidth : cellMinLogicalWidth));
    417                         colMinLogicalWidth = min<LayoutUnit>(m_layoutStruct[pos].effectiveMinLogicalWidth + (cellMinLogicalWidth - remainingMinLogicalWidth), colMinLogicalWidth);
     415                        int colMinLogicalWidth = max<int>(m_layoutStruct[pos].effectiveMinLogicalWidth, static_cast<int>(remainingMaxLogicalWidth ? cellMinLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / remainingMaxLogicalWidth : cellMinLogicalWidth));
     416                        colMinLogicalWidth = min<int>(m_layoutStruct[pos].effectiveMinLogicalWidth + (cellMinLogicalWidth - remainingMinLogicalWidth), colMinLogicalWidth);
    418417                        remainingMaxLogicalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth;
    419418                        remainingMinLogicalWidth -= m_layoutStruct[pos].effectiveMinLogicalWidth;
     
    427426            if (cellMaxLogicalWidth > spanMaxLogicalWidth) {
    428427                for (unsigned pos = effCol; spanMaxLogicalWidth >= 0 && pos < lastCol; ++pos) {
    429                     int colMaxLogicalWidth = max<LayoutUnit>(m_layoutStruct[pos].effectiveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogicalWidth : cellMaxLogicalWidth));
     428                    int colMaxLogicalWidth = max(m_layoutStruct[pos].effectiveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogicalWidth : cellMaxLogicalWidth));
    430429                    spanMaxLogicalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth;
    431430                    cellMaxLogicalWidth -= colMaxLogicalWidth;
     
    478477{
    479478    // table layout based on the values collected in the layout structure.
    480     LayoutUnit tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection();
    481     LayoutUnit available = tableLogicalWidth;
     479    int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection();
     480    int available = tableLogicalWidth;
    482481    size_t nEffCols = m_table->numEffCols();
    483482
     
    502501    // fill up every cell with its minWidth
    503502    for (size_t i = 0; i < nEffCols; ++i) {
    504         LayoutUnit cellLogicalWidth = m_layoutStruct[i].effectiveMinLogicalWidth;
     503        int cellLogicalWidth = m_layoutStruct[i].effectiveMinLogicalWidth;
    505504        m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth;
    506505        available -= cellLogicalWidth;
     
    538537            Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    539538            if (logicalWidth.isPercent()) {
    540                 LayoutUnit cellLogicalWidth = max<LayoutUnit>(m_layoutStruct[i].effectiveMinLogicalWidth, logicalWidth.calcMinValue(tableLogicalWidth));
     539                int cellLogicalWidth = max<int>(m_layoutStruct[i].effectiveMinLogicalWidth, logicalWidth.calcMinValue(tableLogicalWidth));
    541540                available += m_layoutStruct[i].computedLogicalWidth - cellLogicalWidth;
    542541                m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth;
     
    545544        if (totalPercent > 100) {
    546545            // remove overallocated space from the last columns
    547             LayoutUnit excess = tableLogicalWidth * (totalPercent - 100) / 100;
     546            int excess = tableLogicalWidth * (totalPercent - 100) / 100;
    548547            for (int i = nEffCols - 1; i >= 0; --i) {
    549548                if (m_layoutStruct[i].effectiveLogicalWidth.isPercent()) {
    550                     LayoutUnit cellLogicalWidth = m_layoutStruct[i].computedLogicalWidth;
    551                     LayoutUnit reduction = min(cellLogicalWidth,  excess);
     549                    int cellLogicalWidth = m_layoutStruct[i].computedLogicalWidth;
     550                    int reduction = min(cellLogicalWidth,  excess);
    552551                    // the lines below might look inconsistent, but that's the way it's handled in mozilla
    553552                    excess -= reduction;
    554                     LayoutUnit newLogicalWidth = max<LayoutUnit>(m_layoutStruct[i].effectiveMinLogicalWidth, cellLogicalWidth - reduction);
     553                    int newLogicalWidth = max<int>(m_layoutStruct[i].effectiveMinLogicalWidth, cellLogicalWidth - reduction);
    555554                    available += cellLogicalWidth - newLogicalWidth;
    556555                    m_layoutStruct[i].computedLogicalWidth = newLogicalWidth;
     
    577576            if (logicalWidth.isRelative() && logicalWidth.value() != 0) {
    578577                // width=0* gets effMinWidth.
    579                 LayoutUnit cellLogicalWidth = logicalWidth.value() * tableLogicalWidth / totalRelative;
     578                int cellLogicalWidth = logicalWidth.value() * tableLogicalWidth / totalRelative;
    580579                available += m_layoutStruct[i].computedLogicalWidth - cellLogicalWidth;
    581580                m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth;
     
    590589            Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    591590            if (logicalWidth.isAuto() && totalAuto && !m_layoutStruct[i].emptyCellsOnly) {
    592                 LayoutUnit cellLogicalWidth = max<LayoutUnit>(m_layoutStruct[i].computedLogicalWidth, static_cast<LayoutUnit>(available * static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) / totalAuto));
     591                int cellLogicalWidth = max<int>(m_layoutStruct[i].computedLogicalWidth, static_cast<int>(available * static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) / totalAuto));
    593592                available -= cellLogicalWidth;
    594593                totalAuto -= m_layoutStruct[i].effectiveMaxLogicalWidth;
     
    603602            Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    604603            if (logicalWidth.isFixed()) {
    605                 LayoutUnit cellLogicalWidth = static_cast<LayoutUnit>(available * static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) / totalFixed);
     604                int cellLogicalWidth = static_cast<int>(available * static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) / totalFixed);
    606605                available -= cellLogicalWidth;
    607606                totalFixed -= m_layoutStruct[i].effectiveMaxLogicalWidth;
     
    616615            Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    617616            if (logicalWidth.isPercent()) {
    618                 LayoutUnit cellLogicalWidth = available * logicalWidth.percent() / totalPercent;
     617                int cellLogicalWidth = available * logicalWidth.percent() / totalPercent;
    619618                available -= cellLogicalWidth;
    620619                totalPercent -= logicalWidth.percent();
     
    634633            if (m_layoutStruct[i].effectiveLogicalWidth.isAuto() && m_layoutStruct[i].emptyCellsOnly)
    635634                continue;
    636             LayoutUnit cellLogicalWidth = available / total;
     635            int cellLogicalWidth = available / total;
    637636            available -= cellLogicalWidth;
    638637            total--;
     
    651650        // This is basically the reverse of how we grew the cells.
    652651        if (available < 0) {
    653             LayoutUnit logicalWidthBeyondMin = 0;
     652            int logicalWidthBeyondMin = 0;
    654653            for (int i = nEffCols - 1; i >= 0; --i) {
    655654                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
     
    661660                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    662661                if (logicalWidth.isAuto()) {
    663                     LayoutUnit minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
    664                     LayoutUnit reduce = available * minMaxDiff / logicalWidthBeyondMin;
     662                    int minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
     663                    int reduce = available * minMaxDiff / logicalWidthBeyondMin;
    665664                    m_layoutStruct[i].computedLogicalWidth += reduce;
    666665                    available -= reduce;
     
    673672
    674673        if (available < 0) {
    675             LayoutUnit logicalWidthBeyondMin = 0;
     674            int logicalWidthBeyondMin = 0;
    676675            for (int i = nEffCols - 1; i >= 0; --i) {
    677676                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
     
    683682                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    684683                if (logicalWidth.isRelative()) {
    685                     LayoutUnit minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
    686                     LayoutUnit reduce = available * minMaxDiff / logicalWidthBeyondMin;
     684                    int minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
     685                    int reduce = available * minMaxDiff / logicalWidthBeyondMin;
    687686                    m_layoutStruct[i].computedLogicalWidth += reduce;
    688687                    available -= reduce;
     
    695694
    696695        if (available < 0) {
    697             LayoutUnit logicalWidthBeyondMin = 0;
     696            int logicalWidthBeyondMin = 0;
    698697            for (int i = nEffCols - 1; i >= 0; --i) {
    699698                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
     
    705704                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    706705                if (logicalWidth.isFixed()) {
    707                     LayoutUnit minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
    708                     LayoutUnit reduce = available * minMaxDiff / logicalWidthBeyondMin;
     706                    int minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
     707                    int reduce = available * minMaxDiff / logicalWidthBeyondMin;
    709708                    m_layoutStruct[i].computedLogicalWidth += reduce;
    710709                    available -= reduce;
     
    717716
    718717        if (available < 0) {
    719             LayoutUnit logicalWidthBeyondMin = 0;
     718            int logicalWidthBeyondMin = 0;
    720719            for (int i = nEffCols - 1; i >= 0; --i) {
    721720                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
     
    727726                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    728727                if (logicalWidth.isPercent()) {
    729                     LayoutUnit minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
    730                     LayoutUnit reduce = available * minMaxDiff / logicalWidthBeyondMin;
     728                    int minMaxDiff = m_layoutStruct[i].computedLogicalWidth - m_layoutStruct[i].effectiveMinLogicalWidth;
     729                    int reduce = available * minMaxDiff / logicalWidthBeyondMin;
    731730                    m_layoutStruct[i].computedLogicalWidth += reduce;
    732731                    available -= reduce;
     
    739738    }
    740739
    741     LayoutUnit pos = 0;
     740    int pos = 0;
    742741    for (size_t i = 0; i < nEffCols; ++i) {
    743742        m_table->columnPositions()[i] = pos;
  • trunk/Source/WebCore/rendering/AutoTableLayout.h

    r90955 r99254  
    6161        Length logicalWidth;
    6262        Length effectiveLogicalWidth;
    63         LayoutUnit minLogicalWidth;
    64         LayoutUnit maxLogicalWidth;
    65         LayoutUnit effectiveMinLogicalWidth;
    66         LayoutUnit effectiveMaxLogicalWidth;
    67         LayoutUnit computedLogicalWidth;
     63        int minLogicalWidth;
     64        int maxLogicalWidth;
     65        int effectiveMinLogicalWidth;
     66        int effectiveMaxLogicalWidth;
     67        int computedLogicalWidth;
    6868        bool emptyCellsOnly;
    6969    };
  • trunk/Source/WebCore/rendering/FixedTableLayout.cpp

    r94776 r99254  
    195195    //
    196196    // The maximum width is max(minWidth, tableWidth).
    197     LayoutUnit bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
    198 
    199     LayoutUnit tableLogicalWidth = m_table->style()->logicalWidth().isFixed() ? m_table->style()->logicalWidth().value() - bordersPaddingAndSpacing : 0;
    200     LayoutUnit mw = calcWidthArray(tableLogicalWidth) + bordersPaddingAndSpacing;
     197    int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
     198
     199    int tableLogicalWidth = m_table->style()->logicalWidth().isFixed() ? m_table->style()->logicalWidth().value() - bordersPaddingAndSpacing : 0;
     200    int mw = calcWidthArray(tableLogicalWidth) + bordersPaddingAndSpacing;
    201201
    202202    minWidth = max(mw, tableLogicalWidth);
     
    223223void FixedTableLayout::layout()
    224224{
    225     LayoutUnit tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection();
     225    int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection();
    226226    int nEffCols = m_table->numEffCols();
    227227    Vector<int> calcWidth(nEffCols, 0);
    228228
    229229    int numAuto = 0;
    230     LayoutUnit autoSpan = 0;
    231     LayoutUnit totalFixedWidth = 0;
    232     LayoutUnit totalPercentWidth = 0;
     230    int autoSpan = 0;
     231    int totalFixedWidth = 0;
     232    int totalPercentWidth = 0;
    233233    float totalPercent = 0;
    234234
     
    251251    }
    252252
    253     LayoutUnit hspacing = m_table->hBorderSpacing();
    254     LayoutUnit totalWidth = totalFixedWidth + totalPercentWidth;
     253    int hspacing = m_table->hBorderSpacing();
     254    int totalWidth = totalFixedWidth + totalPercentWidth;
    255255    if (!numAuto || totalWidth > tableLogicalWidth) {
    256256        // If there are no auto columns, or if the total is too wide, take
     
    280280    } else {
    281281        // Divide the remaining width among the auto columns.
    282         LayoutUnit remainingWidth = tableLogicalWidth - totalFixedWidth - totalPercentWidth - hspacing * (autoSpan - numAuto);
     282        int remainingWidth = tableLogicalWidth - totalFixedWidth - totalPercentWidth - hspacing * (autoSpan - numAuto);
    283283        int lastAuto = 0;
    284284        for (int i = 0; i < nEffCols; i++) {
    285285            if (m_width[i].isAuto()) {
    286                 LayoutUnit span = m_table->spanOfEffCol(i);
    287                 LayoutUnit w = remainingWidth * span / autoSpan;
     286                int span = m_table->spanOfEffCol(i);
     287                int w = remainingWidth * span / autoSpan;
    288288                calcWidth[i] = w + hspacing * (span - 1);
    289289                remainingWidth -= w;
     
    303303    if (totalWidth < tableLogicalWidth) {
    304304        // Spread extra space over columns.
    305         LayoutUnit remainingWidth = tableLogicalWidth - totalWidth;
     305        int remainingWidth = tableLogicalWidth - totalWidth;
    306306        int total = nEffCols;
    307307        while (total) {
    308             LayoutUnit w = remainingWidth / total;
     308            int w = remainingWidth / total;
    309309            remainingWidth -= w;
    310310            calcWidth[--total] += w;
     
    314314    }
    315315   
    316     LayoutUnit pos = 0;
     316    int pos = 0;
    317317    for (int i = 0; i < nEffCols; i++) {
    318318        m_table->columnPositions()[i] = pos;
    319319        pos += calcWidth[i] + hspacing;
    320320    }
    321     LayoutUnit colPositionsSize = m_table->columnPositions().size();
     321    int colPositionsSize = m_table->columnPositions().size();
    322322    if (colPositionsSize > 0)
    323323        m_table->columnPositions()[colPositionsSize - 1] = pos;
  • trunk/Source/WebCore/rendering/RenderTable.h

    r98676 r99254  
    4545    virtual ~RenderTable();
    4646
    47     int getColumnPos(int col) const { return m_columnPos[col]; }
     47    LayoutUnit getColumnPos(int col) const { return m_columnPos[col]; }
    4848
    4949    int hBorderSpacing() const { return m_hSpacing; }
     
    169169    }
    170170
    171     int bordersPaddingAndSpacingInRowDirection() const
     171    LayoutUnit bordersPaddingAndSpacingInRowDirection() const
    172172    {
    173173        return borderStart() + borderEnd() +
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r99212 r99254  
    156156}
    157157
    158 void RenderTableCell::updateLogicalWidth(int w)
     158void RenderTableCell::updateLogicalWidth(LayoutUnit w)
    159159{
    160160    if (w == logicalWidth())
     
    220220}
    221221
    222 void RenderTableCell::setOverrideHeightFromRowHeight(int rowHeight)
     222void RenderTableCell::setOverrideHeightFromRowHeight(LayoutUnit rowHeight)
    223223{
    224224    clearIntrinsicPadding();
     
    289289}
    290290
    291 void RenderTableCell::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& r, bool fixed) const
     291void RenderTableCell::computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect& r, bool fixed) const
    292292{
    293293    if (repaintContainer == this)
     
    300300}
    301301
    302 int RenderTableCell::cellBaselinePosition() const
     302LayoutUnit RenderTableCell::cellBaselinePosition() const
    303303{
    304304    // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: The baseline of a cell is the baseline of
    305305    // the first in-flow line box in the cell, or the first in-flow table-row in the cell, whichever comes first. If there
    306306    // is no such line box or table-row, the baseline is the bottom of content edge of the cell box.
    307     int firstLineBaseline = firstLineBoxBaseline();
     307    LayoutUnit firstLineBaseline = firstLineBoxBaseline();
    308308    if (firstLineBaseline != -1)
    309309        return firstLineBaseline;
     
    10371037void RenderTableCell::scrollbarsChanged(bool horizontalScrollbarChanged, bool verticalScrollbarChanged)
    10381038{
    1039     int scrollbarHeight = scrollbarLogicalHeight();
     1039    LayoutUnit scrollbarHeight = scrollbarLogicalHeight();
    10401040    if (!scrollbarHeight)
    10411041        return; // Not sure if we should be doing something when a scrollbar goes away or not.
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r99212 r99254  
    8585    virtual void computePreferredLogicalWidths();
    8686
    87     void updateLogicalWidth(int);
     87    void updateLogicalWidth(LayoutUnit);
    8888
    8989    virtual LayoutUnit borderLeft() const;
     
    125125    void paintBackgroundsBehindCell(PaintInfo&, const LayoutPoint&, RenderObject* backgroundObject);
    126126
    127     int cellBaselinePosition() const;
     127    LayoutUnit cellBaselinePosition() const;
    128128
    129129    void setIntrinsicPaddingBefore(int p) { m_intrinsicPaddingBefore = p; }
     
    146146    virtual LayoutUnit paddingAfter(bool includeIntrinsicPadding = true) const;
    147147
    148     void setOverrideHeightFromRowHeight(int);
     148    void setOverrideHeightFromRowHeight(LayoutUnit);
    149149
    150150    virtual void scrollbarsChanged(bool horizontalScrollbarChanged, bool verticalScrollbarChanged);
     
    170170    virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const;
    171171    virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
    172     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false) const;
     172    virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed = false) const;
    173173
    174174    void paintCollapsedBorder(GraphicsContext*, const LayoutRect&);
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r99212 r99254  
    290290                endCol++;
    291291            }
    292             int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
    293             int oldLogicalWidth = cell->logicalWidth();
     292            LayoutUnit w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
     293            LayoutUnit oldLogicalWidth = cell->logicalWidth();
    294294            if (w != oldLogicalWidth) {
    295295                cell->setNeedsLayout(true);
     
    298298                        // Technically, we should also push state for the row, but since
    299299                        // rows don't push a coordinate transform, that's not necessary.
    300                         statePusher.push(this, IntSize(x(), y()));
     300                        statePusher.push(this, LayoutSize(x(), y()));
    301301                    }
    302302                    cell->repaint();
     
    464464            LayoutUnit add = 0;
    465465            totalPercent = min(totalPercent, 100);
    466             int rh = m_rowPos[1] - m_rowPos[0];
     466            LayoutUnit rh = m_rowPos[1] - m_rowPos[0];
    467467            for (unsigned r = 0; r < totalRows; r++) {
    468468                if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) {
    469                     LayoutUnit toAdd = min(dh, static_cast<LayoutUnit>((totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh));
     469                    LayoutUnit toAdd = min<LayoutUnit>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh);
    470470                    // If toAdd is negative, then we don't want to shrink the row (this bug
    471471                    // affected Outlook Web Access).
Note: See TracChangeset for help on using the changeset viewer.