Changeset 100386 in webkit


Ignore:
Timestamp:
Nov 15, 2011, 6:03:54 PM (14 years ago)
Author:
jchaffraix@webkit.org
Message:

Switch table indexing to unsigned
https://bugs.webkit.org/show_bug.cgi?id=72083

Reviewed by Darin Adler.

No expected change in behavior.

All of the code is now using unsigned for indexing!

  • rendering/FixedTableLayout.cpp:

(WebCore::FixedTableLayout::layout):

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::colElement):
(WebCore::RenderTable::cellAbove):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::splitColumn):
Added some ASSERTs to make sure we don't underflow. Looking at how
the different variables are populated, they should not be reached.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::colSpan):
(WebCore::RenderTableCell::rowSpan):
Those 2 functions promotes HTMLTableCellElement's int to unsigned
which should be fine as we make sure their are positive. Also HTML5
makes those 2 fields "unsigned long" which goes in the same direction.

  • rendering/AutoTableLayout.cpp:

(WebCore::AutoTableLayout::layout):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::nodeAtPoint):
Rewrote a couple of reverse iterating to be able to use unsigned
without overflowing.

  • rendering/AutoTableLayout.cpp:

(WebCore::AutoTableLayout::recalcColumn):
(WebCore::AutoTableLayout::fullRecalc):
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
(WebCore::AutoTableLayout::insertSpanCell):

  • rendering/AutoTableLayout.h:
  • rendering/FixedTableLayout.cpp:

(WebCore::FixedTableLayout::calcWidthArray):

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::splitColumn):
(WebCore::RenderTable::appendColumn):
(WebCore::RenderTable::recalcSections):

  • rendering/RenderTable.h:

(WebCore::RenderTable::getColumnPos):
(WebCore::RenderTable::spanOfEffCol):
(WebCore::RenderTable::effColToCol):

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::styleOrColLogicalWidth):
(WebCore::CollapsedBorders::nextBorder):

  • rendering/RenderTableCell.h:
  • rendering/RenderTableCol.cpp:

(WebCore::RenderTableCol::updateFromElement):

  • rendering/RenderTableCol.h:

(WebCore::RenderTableCol::span):
(WebCore::RenderTableCol::setSpan):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::addCell):
(WebCore::RenderTableSection::setCellLogicalWidths):
(WebCore::RenderTableSection::layoutRows):
(WebCore::RenderTableSection::calcOuterBorderBefore):
(WebCore::RenderTableSection::calcOuterBorderAfter):
(WebCore::RenderTableSection::calcOuterBorderStart):
(WebCore::RenderTableSection::calcOuterBorderEnd):
(WebCore::RenderTableSection::paintObject):
(WebCore::RenderTableSection::appendColumn):

  • rendering/RenderTableSection.h:

(WebCore::RenderTableSection::cellAt):
(WebCore::RenderTableSection::primaryCellAt):
(WebCore::RenderTableSection::getBaseline):
Mechanical change int -> unsigned.

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100384 r100386  
     12011-11-15  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Switch table indexing to unsigned
     4        https://bugs.webkit.org/show_bug.cgi?id=72083
     5
     6        Reviewed by Darin Adler.
     7
     8        No expected change in behavior.
     9
     10        All of the code is now using unsigned for indexing!
     11
     12        * rendering/FixedTableLayout.cpp:
     13        (WebCore::FixedTableLayout::layout):
     14        * rendering/RenderTable.cpp:
     15        (WebCore::RenderTable::colElement):
     16        (WebCore::RenderTable::cellAbove):
     17        * rendering/RenderTableSection.cpp:
     18        (WebCore::RenderTableSection::splitColumn):
     19        Added some ASSERTs to make sure we don't underflow. Looking at how
     20        the different variables are populated, they should not be reached.
     21
     22        * rendering/RenderTableCell.cpp:
     23        (WebCore::RenderTableCell::colSpan):
     24        (WebCore::RenderTableCell::rowSpan):
     25        Those 2 functions promotes HTMLTableCellElement's int to unsigned
     26        which should be fine as we make sure their are positive. Also HTML5
     27        makes those 2 fields "unsigned long" which goes in the same direction.
     28
     29        * rendering/AutoTableLayout.cpp:
     30        (WebCore::AutoTableLayout::layout):
     31        * rendering/RenderTableSection.cpp:
     32        (WebCore::RenderTableSection::nodeAtPoint):
     33        Rewrote a couple of reverse iterating to be able to use unsigned
     34        without overflowing.
     35
     36        * rendering/AutoTableLayout.cpp:
     37        (WebCore::AutoTableLayout::recalcColumn):
     38        (WebCore::AutoTableLayout::fullRecalc):
     39        (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
     40        (WebCore::AutoTableLayout::insertSpanCell):
     41        * rendering/AutoTableLayout.h:
     42        * rendering/FixedTableLayout.cpp:
     43        (WebCore::FixedTableLayout::calcWidthArray):
     44        * rendering/RenderTable.cpp:
     45        (WebCore::RenderTable::splitColumn):
     46        (WebCore::RenderTable::appendColumn):
     47        (WebCore::RenderTable::recalcSections):
     48        * rendering/RenderTable.h:
     49        (WebCore::RenderTable::getColumnPos):
     50        (WebCore::RenderTable::spanOfEffCol):
     51        (WebCore::RenderTable::effColToCol):
     52        * rendering/RenderTableCell.cpp:
     53        (WebCore::RenderTableCell::styleOrColLogicalWidth):
     54        (WebCore::CollapsedBorders::nextBorder):
     55        * rendering/RenderTableCell.h:
     56        * rendering/RenderTableCol.cpp:
     57        (WebCore::RenderTableCol::updateFromElement):
     58        * rendering/RenderTableCol.h:
     59        (WebCore::RenderTableCol::span):
     60        (WebCore::RenderTableCol::setSpan):
     61        * rendering/RenderTableSection.cpp:
     62        (WebCore::RenderTableSection::addCell):
     63        (WebCore::RenderTableSection::setCellLogicalWidths):
     64        (WebCore::RenderTableSection::layoutRows):
     65        (WebCore::RenderTableSection::calcOuterBorderBefore):
     66        (WebCore::RenderTableSection::calcOuterBorderAfter):
     67        (WebCore::RenderTableSection::calcOuterBorderStart):
     68        (WebCore::RenderTableSection::calcOuterBorderEnd):
     69        (WebCore::RenderTableSection::paintObject):
     70        (WebCore::RenderTableSection::appendColumn):
     71        * rendering/RenderTableSection.h:
     72        (WebCore::RenderTableSection::cellAt):
     73        (WebCore::RenderTableSection::primaryCellAt):
     74        (WebCore::RenderTableSection::getBaseline):
     75        Mechanical change int -> unsigned.
     76
    1772011-11-15  Andy Estes  <aestes@apple.com>
    278
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r99254 r100386  
    4343}
    4444
    45 void AutoTableLayout::recalcColumn(int effCol)
     45void AutoTableLayout::recalcColumn(unsigned effCol)
    4646{
    4747    Layout& columnLayout = m_layoutStruct[effCol];
     
    5555        else if (child->isTableSection()) {
    5656            RenderTableSection* section = toRenderTableSection(child);
    57             int numRows = section->numRows();
    58             for (int i = 0; i < numRows; i++) {
     57            unsigned numRows = section->numRows();
     58            for (unsigned i = 0; i < numRows; i++) {
    5959                RenderTableSection::CellStruct current = section->cellAt(i, effCol);
    6060                RenderTableCell* cell = current.primaryCell();
     
    144144    m_effectiveLogicalWidthDirty = true;
    145145
    146     int nEffCols = m_table->numEffCols();
     146    unsigned nEffCols = m_table->numEffCols();
    147147    m_layoutStruct.resize(nEffCols);
    148148    m_layoutStruct.fill(Layout());
     
    151151    RenderObject* child = m_table->firstChild();
    152152    Length groupLogicalWidth;
    153     int currentColumn = 0;
     153    unsigned currentColumn = 0;
    154154    while (child && child->isTableCol()) {
    155155        RenderTableCol* col = toRenderTableCol(child);
    156         int span = col->span();
     156        unsigned span = col->span();
    157157        if (col->firstChild())
    158158            groupLogicalWidth = col->style()->logicalWidth();
     
    163163            if ((colLogicalWidth.isFixed() || colLogicalWidth.isPercent()) && colLogicalWidth.isZero())
    164164                colLogicalWidth = Length();
    165             int effCol = m_table->colToEffCol(currentColumn);
     165            unsigned effCol = m_table->colToEffCol(currentColumn);
    166166            if (!colLogicalWidth.isAuto() && span == 1 && effCol < nEffCols && m_table->spanOfEffCol(effCol) == 1) {
    167167                m_layoutStruct[effCol].logicalWidth = colLogicalWidth;
     
    182182    }
    183183
    184     for (int i = 0; i < nEffCols; i++)
     184    for (unsigned i = 0; i < nEffCols; i++)
    185185        recalcColumn(i);
    186186}
     
    294294            break;
    295295
    296         int span = cell->colSpan();
     296        unsigned span = cell->colSpan();
    297297
    298298        Length cellLogicalWidth = cell->styleOrColLogicalWidth();
     
    300300            cellLogicalWidth = Length(); // make it Auto
    301301
    302         int effCol = m_table->colToEffCol(cell->col());
     302        unsigned effCol = m_table->colToEffCol(cell->col());
    303303        size_t lastCol = effCol;
    304304        int cellMinLogicalWidth = cell->minPreferredLogicalWidth() + spacingInRowDirection;
     
    456456        return;
    457457
    458     int size = m_spanCells.size();
     458    unsigned size = m_spanCells.size();
    459459    if (!size || m_spanCells[size-1] != 0) {
    460460        m_spanCells.grow(size + 10);
    461         for (int i = 0; i < 10; i++)
     461        for (unsigned i = 0; i < 10; i++)
    462462            m_spanCells[size+i] = 0;
    463463        size += 10;
     
    465465
    466466    // add them in sort. This is a slow algorithm, and a binary search or a fast sorting after collection would be better
    467     unsigned int pos = 0;
    468     int span = cell->colSpan();
     467    unsigned pos = 0;
     468    unsigned span = cell->colSpan();
    469469    while (pos < m_spanCells.size() && m_spanCells[pos] && span > m_spanCells[pos]->colSpan())
    470470        pos++;
     
    545545            // remove overallocated space from the last columns
    546546            int excess = tableLogicalWidth * (totalPercent - 100) / 100;
    547             for (int i = nEffCols - 1; i >= 0; --i) {
     547            for (unsigned i = nEffCols; i; ) {
     548                --i;
    548549                if (m_layoutStruct[i].effectiveLogicalWidth.isPercent()) {
    549550                    int cellLogicalWidth = m_layoutStruct[i].computedLogicalWidth;
     
    627628    // spread over the rest
    628629    if (available > 0 && nEffCols > numAutoEmptyCellsOnly) {
    629         int total = nEffCols - numAutoEmptyCellsOnly;
     630        unsigned total = nEffCols - numAutoEmptyCellsOnly;
    630631        // still have some width to spread
    631         for (int i = nEffCols - 1; i >= 0; --i) {
     632        for (unsigned i = nEffCols; i; ) {
     633            --i;
    632634            // variable columns with empty cells only don't get any width
    633635            if (m_layoutStruct[i].effectiveLogicalWidth.isAuto() && m_layoutStruct[i].emptyCellsOnly)
     
    651653        if (available < 0) {
    652654            int logicalWidthBeyondMin = 0;
    653             for (int i = nEffCols - 1; i >= 0; --i) {
     655            for (unsigned i = nEffCols; i; ) {
     656                --i;
    654657                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    655658                if (logicalWidth.isAuto())
     
    657660            }
    658661           
    659             for (int i = nEffCols - 1; i >= 0 && logicalWidthBeyondMin > 0; --i) {
     662            for (unsigned i = nEffCols; i && logicalWidthBeyondMin > 0; ) {
     663                --i;
    660664                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    661665                if (logicalWidth.isAuto()) {
     
    673677        if (available < 0) {
    674678            int logicalWidthBeyondMin = 0;
    675             for (int i = nEffCols - 1; i >= 0; --i) {
     679            for (unsigned i = nEffCols; i; ) {
     680                --i;
    676681                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    677682                if (logicalWidth.isRelative())
     
    679684            }
    680685           
    681             for (int i = nEffCols - 1; i >= 0 && logicalWidthBeyondMin > 0; --i) {
     686            for (unsigned i = nEffCols; i && logicalWidthBeyondMin > 0; ) {
     687                --i;
    682688                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    683689                if (logicalWidth.isRelative()) {
     
    695701        if (available < 0) {
    696702            int logicalWidthBeyondMin = 0;
    697             for (int i = nEffCols - 1; i >= 0; --i) {
     703            for (unsigned i = nEffCols; i; ) {
     704                --i;
    698705                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    699706                if (logicalWidth.isFixed())
     
    701708            }
    702709           
    703             for (int i = nEffCols - 1; i >= 0 && logicalWidthBeyondMin > 0; --i) {
     710            for (unsigned i = nEffCols; i && logicalWidthBeyondMin > 0; ) {
     711                --i;
    704712                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    705713                if (logicalWidth.isFixed()) {
     
    717725        if (available < 0) {
    718726            int logicalWidthBeyondMin = 0;
    719             for (int i = nEffCols - 1; i >= 0; --i) {
     727            for (unsigned i = nEffCols; i; ) {
     728                --i;
    720729                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    721730                if (logicalWidth.isPercent())
     
    723732            }
    724733           
    725             for (int i = nEffCols-1; i >= 0 && logicalWidthBeyondMin > 0; i--) {
     734            for (unsigned i = nEffCols; i && logicalWidthBeyondMin > 0; ) {
     735                --i;
    726736                Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth;
    727737                if (logicalWidth.isPercent()) {
  • trunk/Source/WebCore/rendering/AutoTableLayout.h

    r99254 r100386  
    4242private:
    4343    void fullRecalc();
    44     void recalcColumn(int effCol);
     44    void recalcColumn(unsigned effCol);
    4545
    4646    int calcEffectiveLogicalWidth();
  • trunk/Source/WebCore/rendering/FixedTableLayout.cpp

    r99254 r100386  
    8484    // iterate over all <col> elements
    8585    RenderObject* child = m_table->firstChild();
    86     int nEffCols = m_table->numEffCols();
     86    unsigned nEffCols = m_table->numEffCols();
    8787    m_width.resize(nEffCols);
    8888    m_width.fill(Length(Auto));
    8989
    90     int currentEffectiveColumn = 0;
     90    unsigned currentEffectiveColumn = 0;
    9191    Length grpWidth;
    9292    while (child && child->isTableCol()) {
     
    102102                effWidth = w.value();
    103103
    104             int span = col->span();
     104            unsigned span = col->span();
    105105            while (span) {
    106                 int spanInCurrentEffectiveColumn;
     106                unsigned spanInCurrentEffectiveColumn;
    107107                if (currentEffectiveColumn >= nEffCols) {
    108108                    m_table->appendColumn(span);
     
    142142    RenderTableSection* section = m_table->topNonEmptySection();
    143143    if (section) {
    144         int cCol = 0;
     144        unsigned cCol = 0;
    145145        RenderObject* firstRow = section->firstChild();
    146146        child = firstRow->firstChild();
     
    152152
    153153                Length w = cell->styleOrColLogicalWidth();
    154                 int span = cell->colSpan();
     154                unsigned span = cell->colSpan();
    155155                int effWidth = 0;
    156156                if (w.isFixed() && w.isPositive())
    157157                    effWidth = w.value();
    158158               
    159                 int usedSpan = 0;
    160                 int i = 0;
     159                unsigned usedSpan = 0;
     160                unsigned i = 0;
    161161                while (usedSpan < span && cCol + i < nEffCols) {
    162162                    float eSpan = m_table->spanOfEffCol(cCol + i);
     
    224224{
    225225    int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection();
    226     int nEffCols = m_table->numEffCols();
     226    unsigned nEffCols = m_table->numEffCols();
    227227    Vector<int> calcWidth(nEffCols, 0);
    228228
    229     int numAuto = 0;
    230     int autoSpan = 0;
     229    unsigned numAuto = 0;
     230    unsigned autoSpan = 0;
    231231    int totalFixedWidth = 0;
    232232    int totalPercentWidth = 0;
     
    237237    // for a table width of 100px with columns (40px, 10%), the 10% compute
    238238    // to 10px here, and will scale up to 20px in the final (80px, 20px).
    239     for (int i = 0; i < nEffCols; i++) {
     239    for (unsigned i = 0; i < nEffCols; i++) {
    240240        if (m_width[i].isFixed()) {
    241241            calcWidth[i] = m_width[i].value();
     
    260260            if (totalFixedWidth && totalWidth < tableLogicalWidth) {
    261261                totalFixedWidth = 0;
    262                 for (int i = 0; i < nEffCols; i++) {
     262                for (unsigned i = 0; i < nEffCols; i++) {
    263263                    if (m_width[i].isFixed()) {
    264264                        calcWidth[i] = calcWidth[i] * tableLogicalWidth / totalWidth;
     
    269269            if (totalPercent) {
    270270                totalPercentWidth = 0;
    271                 for (int i = 0; i < nEffCols; i++) {
     271                for (unsigned i = 0; i < nEffCols; i++) {
    272272                    if (m_width[i].isPercent()) {
    273273                        calcWidth[i] = m_width[i].percent() * (tableLogicalWidth - totalFixedWidth) / totalPercent;
     
    280280    } else {
    281281        // Divide the remaining width among the auto columns.
     282        ASSERT(autoSpan >= numAuto);
    282283        int remainingWidth = tableLogicalWidth - totalFixedWidth - totalPercentWidth - hspacing * (autoSpan - numAuto);
    283284        int lastAuto = 0;
    284         for (int i = 0; i < nEffCols; i++) {
     285        for (unsigned i = 0; i < nEffCols; i++) {
    285286            if (m_width[i].isAuto()) {
    286                 int span = m_table->spanOfEffCol(i);
     287                unsigned span = m_table->spanOfEffCol(i);
    287288                int w = remainingWidth * span / autoSpan;
    288289                calcWidth[i] = w + hspacing * (span - 1);
     
    292293                lastAuto = i;
    293294                numAuto--;
     295                ASSERT(autoSpan >= span);
    294296                autoSpan -= span;
    295297            }
     
    315317   
    316318    int pos = 0;
    317     for (int i = 0; i < nEffCols; i++) {
     319    for (unsigned i = 0; i < nEffCols; i++) {
    318320        m_table->columnPositions()[i] = pos;
    319321        pos += calcWidth[i] + hspacing;
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r100183 r100386  
    634634}
    635635
    636 void RenderTable::splitColumn(unsigned position, int firstSpan)
     636void RenderTable::splitColumn(unsigned position, unsigned firstSpan)
    637637{
    638638    // we need to add a new columnStruct
    639639    unsigned oldSize = m_columns.size();
    640640    m_columns.grow(oldSize + 1);
    641     int oldSpan = m_columns[position].span;
     641    unsigned oldSpan = m_columns[position].span;
    642642    ASSERT(oldSpan > firstSpan);
    643643    m_columns[position].span = firstSpan;
     
    662662}
    663663
    664 void RenderTable::appendColumn(int span)
     664void RenderTable::appendColumn(unsigned span)
    665665{
    666666    unsigned pos = m_columns.size();
     
    705705}
    706706
    707 RenderTableCol* RenderTable::colElement(int col, bool* startEdge, bool* endEdge) const
     707RenderTableCol* RenderTable::colElement(unsigned col, bool* startEdge, bool* endEdge) const
    708708{
    709709    if (!m_hasColElements)
    710710        return 0;
    711711    RenderObject* child = firstChild();
    712     int cCol = 0;
     712    unsigned cCol = 0;
    713713
    714714    while (child) {
     
    724724    RenderTableCol* colElem = toRenderTableCol(child);
    725725    while (colElem) {
    726         int span = colElem->span();
     726        unsigned span = colElem->span();
    727727        if (!colElem->firstChild()) {
    728             int startCol = cCol;
    729             int endCol = cCol + span - 1;
     728            unsigned startCol = cCol;
     729            ASSERT(span >= 1);
     730            unsigned endCol = cCol + span - 1;
    730731            cCol += span;
    731732            if (cCol > col) {
     
    793794
    794795    // repair column count (addChild can grow it too much, because it always adds elements to the last row of a section)
    795     int maxCols = 0;
     796    unsigned maxCols = 0;
    796797    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    797798        if (child->isTableSection()) {
    798799            RenderTableSection* section = toRenderTableSection(child);
    799             int sectionCols = section->numColumns();
     800            unsigned sectionCols = section->numColumns();
    800801            if (sectionCols > maxCols)
    801802                maxCols = sectionCols;
     
    10811082
    10821083    // Find the section and row to look in
    1083     int r = cell->row();
     1084    unsigned r = cell->row();
    10841085    RenderTableSection* section = 0;
    1085     int rAbove = 0;
     1086    unsigned rAbove = 0;
    10861087    if (r > 0) {
    10871088        // cell is not in the first row, so use the above row in its own section
     
    10901091    } else {
    10911092        section = sectionAbove(cell->section(), SkipEmptySections);
    1092         if (section)
     1093        if (section) {
     1094            ASSERT(section->numRows());
    10931095            rAbove = section->numRows() - 1;
     1096        }
    10941097    }
    10951098
  • trunk/Source/WebCore/rendering/RenderTable.h

    r100177 r100386  
    4545    virtual ~RenderTable();
    4646
    47     LayoutUnit getColumnPos(int col) const { return m_columnPos[col]; }
     47    LayoutUnit getColumnPos(unsigned col) const { return m_columnPos[col]; }
    4848
    4949    int hBorderSpacing() const { return m_hSpacing; }
     
    147147    RenderTableSection* topNonEmptySection() const;
    148148
    149     void splitColumn(unsigned position, int firstSpan);
    150     void appendColumn(int span);
     149    void splitColumn(unsigned position, unsigned firstSpan);
     150    void appendColumn(unsigned span);
    151151    unsigned numEffCols() const { return m_columns.size(); }
    152     int spanOfEffCol(int effCol) const { return m_columns[effCol].span; }
     152    unsigned spanOfEffCol(unsigned effCol) const { return m_columns[effCol].span; }
    153153   
    154154    unsigned colToEffCol(unsigned column) const
     
    161161    }
    162162   
    163     int effColToCol(int effCol) const
    164     {
    165         int c = 0;
    166         for (int i = 0; i < effCol; i++)
     163    unsigned effColToCol(unsigned effCol) const
     164    {
     165        unsigned c = 0;
     166        for (unsigned i = 0; i < effCol; i++)
    167167            c += m_columns[i].span;
    168168        return c;
     
    175175    }
    176176
    177     RenderTableCol* colElement(int col, bool* startEdge = 0, bool* endEdge = 0) const;
     177    RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const;
    178178    RenderTableCol* nextColElement(RenderTableCol* current) const;
    179179
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r100051 r100386  
    6363}
    6464
    65 int RenderTableCell::colSpan() const
     65unsigned RenderTableCell::colSpan() const
    6666{
    6767    if (UNLIKELY(!m_hasAssociatedTableCellElement))
     
    7171}
    7272
    73 int RenderTableCell::rowSpan() const
     73unsigned RenderTableCell::rowSpan() const
    7474{
    7575    if (UNLIKELY(!m_hasAssociatedTableCellElement))
     
    9797
    9898    if (RenderTableCol* tableCol = table()->colElement(col())) {
    99         int colSpanCount = colSpan();
     99        unsigned colSpanCount = colSpan();
    100100
    101101        Length colWidthSum = Length(0, Fixed);
    102         for (int i = 1; i <= colSpanCount; i++) {
     102        for (unsigned i = 1; i <= colSpanCount; i++) {
    103103            Length colWidth = tableCol->style()->logicalWidth();
    104104
     
    867867    CollapsedBorder* nextBorder()
    868868    {
    869         for (int i = 0; i < m_count; i++) {
     869        for (unsigned i = 0; i < m_count; i++) {
    870870            if (m_borders[i].borderValue.exists() && m_borders[i].shouldPaint) {
    871871                m_borders[i].shouldPaint = false;
     
    878878   
    879879    CollapsedBorder m_borders[4];
    880     int m_count;
     880    unsigned m_count;
    881881};
    882882
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r100051 r100386  
    4444    void setCellIndex(int) { }
    4545
    46     int colSpan() const;
    47     int rowSpan() const;
     46    unsigned colSpan() const;
     47    unsigned rowSpan() const;
    4848
    4949    // Called from HTMLTableCellElement.
  • trunk/Source/WebCore/rendering/RenderTableCol.cpp

    r98767 r100386  
    5959void RenderTableCol::updateFromElement()
    6060{
    61     int oldSpan = m_span;
     61    unsigned oldSpan = m_span;
    6262    Node* n = node();
    6363    if (n && (n->hasTagName(colTag) || n->hasTagName(colgroupTag))) {
  • trunk/Source/WebCore/rendering/RenderTableCol.h

    r98767 r100386  
    4242    virtual void computePreferredLogicalWidths();
    4343
    44     int span() const { return m_span; }
    45     void setSpan(int span) { m_span = span; }
     44    unsigned span() const { return m_span; }
     45    void setSpan(unsigned span) { m_span = span; }
    4646
    4747private:
     
    6565
    6666    RenderObjectChildList m_children;
    67     int m_span;
     67    unsigned m_span;
    6868};
    6969
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r100183 r100386  
    194194        return;
    195195
    196     int rSpan = cell->rowSpan();
    197     int cSpan = cell->colSpan();
     196    unsigned rSpan = cell->rowSpan();
     197    unsigned cSpan = cell->colSpan();
    198198    Vector<RenderTable::ColumnStruct>& columns = table()->columns();
    199199    unsigned nCols = columns.size();
     
    242242    bool inColSpan = false;
    243243    while (cSpan) {
    244         int currentSpan;
     244        unsigned currentSpan;
    245245        if (m_cCol >= nCols) {
    246246            table()->appendColumn(cSpan);
    247247            currentSpan = cSpan;
    248248        } else {
    249             if (cSpan < (int)columns[m_cCol].span)
     249            if (cSpan < columns[m_cCol].span)
    250250                table()->splitColumn(m_cCol, cSpan);
    251251            currentSpan = columns[m_cCol].span;
    252252        }
    253         for (int r = 0; r < rSpan; r++) {
     253        for (unsigned r = 0; r < rSpan; r++) {
    254254            CellStruct& c = cellAt(insertionRow + r, m_cCol);
    255255            ASSERT(cell);
     
    284284              continue;
    285285            unsigned endCol = j;
    286             int cspan = cell->colSpan();
     286            unsigned cspan = cell->colSpan();
    287287            while (cspan && endCol < cols) {
    288288                ASSERT(endCol < table()->columns().size());
     
    439439
    440440    LayoutUnit rHeight;
    441     int rindx;
     441    unsigned rindx;
    442442    unsigned totalRows = m_grid.size();
    443443
     
    510510    LayoutUnit hspacing = table()->hBorderSpacing();
    511511    LayoutUnit vspacing = table()->vBorderSpacing();
    512     LayoutUnit nEffCols = table()->numEffCols();
     512    unsigned nEffCols = table()->numEffCols();
    513513
    514514    LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), style()->isFlippedBlocksWritingMode());
     
    523523        }
    524524
    525         for (int c = 0; c < nEffCols; c++) {
     525        for (unsigned c = 0; c < nEffCols; c++) {
    526526            CellStruct& cs = cellAt(r, c);
    527527            RenderTableCell* cell = cs.primaryCell();
     
    680680    // Now that our height has been determined, add in overflow from cells.
    681681    for (unsigned r = 0; r < totalRows; r++) {
    682         for (int c = 0; c < nEffCols; c++) {
     682        for (unsigned c = 0; c < nEffCols; c++) {
    683683            CellStruct& cs = cellAt(r, c);
    684684            RenderTableCell* cell = cs.primaryCell();
     
    711711LayoutUnit RenderTableSection::calcOuterBorderBefore() const
    712712{
    713     int totalCols = table()->numEffCols();
     713    unsigned totalCols = table()->numEffCols();
    714714    if (!m_grid.size() || !totalCols)
    715715        return 0;
     
    730730
    731731    bool allHidden = true;
    732     for (int c = 0; c < totalCols; c++) {
     732    for (unsigned c = 0; c < totalCols; c++) {
    733733        const CellStruct& current = cellAt(0, c);
    734734        if (current.inColSpan || !current.hasCells())
     
    762762LayoutUnit RenderTableSection::calcOuterBorderAfter() const
    763763{
    764     int totalCols = table()->numEffCols();
     764    unsigned totalCols = table()->numEffCols();
    765765    if (!m_grid.size() || !totalCols)
    766766        return 0;
     
    781781
    782782    bool allHidden = true;
    783     for (int c = 0; c < totalCols; c++) {
     783    for (unsigned c = 0; c < totalCols; c++) {
    784784        const CellStruct& current = cellAt(m_grid.size() - 1, c);
    785785        if (current.inColSpan || !current.hasCells())
     
    813813LayoutUnit RenderTableSection::calcOuterBorderStart() const
    814814{
    815     int totalCols = table()->numEffCols();
     815    unsigned totalCols = table()->numEffCols();
    816816    if (!m_grid.size() || !totalCols)
    817817        return 0;
     
    857857LayoutUnit RenderTableSection::calcOuterBorderEnd() const
    858858{
    859     int totalCols = table()->numEffCols();
     859    unsigned totalCols = table()->numEffCols();
    860860    if (!m_grid.size() || !totalCols)
    861861        return 0;
     
    11071107                std::sort(cells.begin(), cells.end(), compareCellPositionsWithOverflowingCells);
    11081108
    1109             int size = cells.size();
    1110             // Paint the cells.
    1111             for (int i = 0; i < size; ++i)
     1109            for (unsigned i = 0; i < cells.size(); ++i)
    11121110                paintCell(cells[i], paintInfo, paintOffset);
    11131111        }
     
    11851183}
    11861184
    1187 void RenderTableSection::appendColumn(int pos)
     1185void RenderTableSection::appendColumn(unsigned pos)
    11881186{
    11891187    ASSERT(!m_needsCellRecalc);
     
    11931191}
    11941192
    1195 void RenderTableSection::splitColumn(unsigned pos, int first)
     1193void RenderTableSection::splitColumn(unsigned pos, unsigned first)
    11961194{
    11971195    ASSERT(!m_needsCellRecalc);
     
    12061204            RenderTableCell* cell = r[pos].primaryCell();
    12071205            ASSERT(cell);
    1208             int colleft = cell->colSpan() - r[pos].inColSpan;
     1206            ASSERT(cell->colSpan() >= (r[pos].inColSpan ? 1 : 0));
     1207            unsigned colleft = cell->colSpan() - r[pos].inColSpan;
    12091208            if (first > colleft)
    12101209              r[pos + 1].inColSpan = 0;
     
    12801279        return false;
    12811280
    1282     for (int i = current.cells.size() - 1; i >= 0; --i) {
     1281    for (unsigned i = current.cells.size() ; i; ) {
     1282        --i;
    12831283        RenderTableCell* cell = current.cells[i];
    12841284        LayoutPoint cellPoint = flipForWritingModeForChild(cell, adjustedLocation);
  • trunk/Source/WebCore/rendering/RenderTableSection.h

    r99919 r100386  
    9191    };
    9292
    93     CellStruct& cellAt(int row,  int col) { return m_grid[row].row[col]; }
    94     const CellStruct& cellAt(int row, int col) const { return m_grid[row].row[col]; }
    95     RenderTableCell* primaryCellAt(int row, int col)
     93    CellStruct& cellAt(unsigned row,  unsigned col) { return m_grid[row].row[col]; }
     94    const CellStruct& cellAt(unsigned row, unsigned col) const { return m_grid[row].row[col]; }
     95    RenderTableCell* primaryCellAt(unsigned row, unsigned col)
    9696    {
    9797        CellStruct& c = m_grid[row].row[col];
     
    9999    }
    100100
    101     void appendColumn(int pos);
    102     void splitColumn(unsigned pos, int first);
     101    void appendColumn(unsigned pos);
     102    void splitColumn(unsigned pos, unsigned first);
    103103
    104104    LayoutUnit calcOuterBorderBefore() const;
     
    125125    void setNeedsCellRecalc();
    126126
    127     LayoutUnit getBaseline(int row) { return m_grid[row].baseline; }
     127    LayoutUnit getBaseline(unsigned row) { return m_grid[row].baseline; }
    128128
    129129    void rowLogicalHeightChanged(unsigned rowIndex);
Note: See TracChangeset for help on using the changeset viewer.