Changeset 112752 in webkit


Ignore:
Timestamp:
Mar 30, 2012 5:13:20 PM (12 years ago)
Author:
eae@chromium.org
Message:

Fix usage of LayoutUnits in table code.
https://bugs.webkit.org/show_bug.cgi?id=82765

Reviewed by Eric Seidel.

Clean up usage of ints and LayoutUnits in table code in preparation for
turning on subpixel layout.

No new tests, no change in functionality.

  • rendering/AutoTableLayout.cpp:

(WebCore::AutoTableLayout::computePreferredLogicalWidths):
Cast maxWidth to int as all table layout is done on int bounds.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
Change borders to LayoutUnit as paddings can have subpixel precision.

  • rendering/RenderTable.h:

(WebCore::RenderTable::getColumnPos):
(WebCore::RenderTable::columnPositions):
Change getColumnPos and columnPositions to ints as the values are always
on pixel bounds.

(WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::styleOrColLogicalWidth):
Remove unnecessary cast.

(WebCore::RenderTableCell::clippedOverflowRectForRepaint):
Use LayoutPoint instead of left/top.

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::calcRowLogicalHeight):
(WebCore::RenderTableSection::layoutRows):

  • rendering/RenderTableSection.h:

Change baseline and baselineDescent to int to avoid unnecessary type
conversion.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112749 r112752  
     12012-03-30  Emil A Eklund  <eae@chromium.org>
     2
     3        Fix usage of LayoutUnits in table code.
     4        https://bugs.webkit.org/show_bug.cgi?id=82765
     5
     6        Reviewed by Eric Seidel.
     7
     8        Clean up usage of ints and LayoutUnits in table code in preparation for
     9        turning on subpixel layout.
     10
     11        No new tests, no change in functionality.
     12
     13        * rendering/AutoTableLayout.cpp:
     14        (WebCore::AutoTableLayout::computePreferredLogicalWidths):
     15        Cast maxWidth to int as all table layout is done on int bounds.
     16       
     17        * rendering/RenderTable.cpp:
     18        (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
     19        Change borders to LayoutUnit as paddings can have subpixel precision.
     20       
     21        * rendering/RenderTable.h:
     22        (WebCore::RenderTable::getColumnPos):
     23        (WebCore::RenderTable::columnPositions):
     24        Change getColumnPos and columnPositions to ints as the values are always
     25        on pixel bounds.
     26       
     27        (WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):
     28        * rendering/RenderTableCell.cpp:
     29        (WebCore::RenderTableCell::styleOrColLogicalWidth):
     30        Remove unnecessary cast.
     31       
     32        (WebCore::RenderTableCell::clippedOverflowRectForRepaint):
     33        Use LayoutPoint instead of left/top.
     34       
     35        * rendering/RenderTableSection.cpp:
     36        (WebCore::RenderTableSection::calcRowLogicalHeight):
     37        (WebCore::RenderTableSection::layoutRows):
     38        * rendering/RenderTableSection.h:
     39        Change baseline and baselineDescent to int to avoid unnecessary type
     40        conversion.
     41
    1422012-03-30  Joe Thomas  <joethomas@motorola.com>
    243
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r112198 r112752  
    252252    if (scaleColumns) {
    253253        maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon);
    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)));
     254        maxWidth = max<int>(maxWidth, static_cast<int>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
     255        maxWidth = max<int>(maxWidth, static_cast<int>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
    256256    }
    257257
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r112425 r112752  
    272272{
    273273    // HTML tables' width styles already include borders and paddings, but CSS tables' width styles do not.
    274     int borders = 0;
     274    LayoutUnit borders = 0;
    275275    bool isCSSTable = !node() || !node()->hasTagName(tableTag);
    276276    if (isCSSTable && styleLogicalWidth.isFixed() && styleLogicalWidth.isPositive()) {
    277277        recalcBordersInRowDirection();
    278         borders = borderStart() + borderEnd() + (collapseBorders() ? 0 : paddingStart() + paddingEnd());
     278        borders = borderStart() + borderEnd() + (collapseBorders() ? zeroLayoutUnit : paddingStart() + paddingEnd());
    279279    }
    280280    return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders;
  • trunk/Source/WebCore/rendering/RenderTable.h

    r111353 r112752  
    4646    virtual ~RenderTable();
    4747
    48     LayoutUnit getColumnPos(unsigned col) const { return m_columnPos[col]; }
     48    int getColumnPos(unsigned col) const { return m_columnPos[col]; }
    4949
    5050    int hBorderSpacing() const { return m_hSpacing; }
     
    137137
    138138    Vector<ColumnStruct>& columns() { return m_columns; }
    139     Vector<LayoutUnit>& columnPositions() { return m_columnPos; }
     139    Vector<int>& columnPositions() { return m_columnPos; }
    140140    RenderTableSection* header() const { return m_head; }
    141141    RenderTableSection* footer() const { return m_foot; }
     
    173173    {
    174174        return borderStart() + borderEnd() +
    175                (collapseBorders() ? zeroLayoutUnit : (paddingStart() + paddingEnd() + (numEffCols() + 1) * hBorderSpacing()));
     175               (collapseBorders() ? zeroLayoutUnit : (paddingStart() + paddingEnd() + static_cast<LayoutUnit>(numEffCols() + 1) * hBorderSpacing()));
    176176    }
    177177
     
    255255    void distributeExtraLogicalHeight(int extraLogicalHeight);
    256256
    257     mutable Vector<LayoutUnit> m_columnPos;
     257    mutable Vector<int> m_columnPos;
    258258    mutable Vector<ColumnStruct> m_columns;
    259259    mutable Vector<RenderTableCaption*> m_captions;
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r112301 r112752  
    144144        // See Bugzilla bug 8126 for details.
    145145        if (colWidthSum.isFixed() && colWidthSum.value() > 0)
    146             colWidthSum = Length(max<LayoutUnit>(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
     146            colWidthSum = Length(max(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
    147147        return colWidthSum;
    148148    }
     
    297297        }
    298298    }
    299     left = max(left, -minXVisualOverflow());
    300     top = max(top, -minYVisualOverflow());
    301     LayoutRect r(-left, - top, left + max(width() + right, maxXVisualOverflow()), top + max(height() + bottom, maxYVisualOverflow()));
     299    LayoutPoint location(max<LayoutUnit>(left, -minXVisualOverflow()), max<LayoutUnit>(top, -minYVisualOverflow()));
     300    LayoutRect r(-location.x(), -location.y(), location.x() + max(width() + right, maxXVisualOverflow()), location.y() + max(height() + bottom, maxYVisualOverflow()));
    302301
    303302    if (RenderView* v = view()) {
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r112425 r112752  
    337337    for (unsigned r = 0; r < m_grid.size(); r++) {
    338338        m_grid[r].baseline = 0;
    339         LayoutUnit baselineDescent = 0;
     339        int baselineDescent = 0;
    340340
    341341        // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
     
    621621                EVerticalAlign va = cell->style()->verticalAlign();
    622622                if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
    623                     LayoutUnit baseline = cell->cellBaselinePosition();
     623                    int baseline = cell->cellBaselinePosition();
    624624                    if (baseline > cell->borderBefore() + cell->paddingBefore())
    625625                        m_grid[r].baseline = max(m_grid[r].baseline, baseline);
  • trunk/Source/WebCore/rendering/RenderTableSection.h

    r111435 r112752  
    111111        Row row;
    112112        RenderTableRow* rowRenderer;
    113         LayoutUnit baseline;
     113        int baseline;
    114114        Length logicalHeight;
    115115    };
Note: See TracChangeset for help on using the changeset viewer.