Changeset 130698 in webkit


Ignore:
Timestamp:
Oct 8, 2012 3:59:36 PM (12 years ago)
Author:
eric@webkit.org
Message:

Make no-column table-layout cases a little faster with inlining
https://bugs.webkit.org/show_bug.cgi?id=98566

Reviewed by Julien Chaffraix.

This change is almost not worth it at only a couple percent boost on
http://www.robohornet.org/tests/resizecol.html
However, I think the logicalWidthFromTableColumn split it kinda nice
so I've decided to post it anyway.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::slowColElement):

  • rendering/RenderTable.h:

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

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::logicalWidthFromTableColumn):

  • rendering/RenderTableCell.h:

(WebCore::RenderTableCell::styleOrColLogicalWidth):
(RenderTableCell):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130694 r130698  
     12012-10-08  Eric Seidel  <eric@webkit.org>
     2
     3        Make no-column table-layout cases a little faster with inlining
     4        https://bugs.webkit.org/show_bug.cgi?id=98566
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        This change is almost not worth it at only a couple percent boost on
     9        http://www.robohornet.org/tests/resizecol.html
     10        However, I think the logicalWidthFromTableColumn split it kinda nice
     11        so I've decided to post it anyway.
     12
     13        * rendering/RenderTable.cpp:
     14        (WebCore::RenderTable::slowColElement):
     15        * rendering/RenderTable.h:
     16        (WebCore::RenderTable::colElement):
     17        (RenderTable):
     18        * rendering/RenderTableCell.cpp:
     19        (WebCore::RenderTableCell::logicalWidthFromTableColumn):
     20        * rendering/RenderTableCell.h:
     21        (WebCore::RenderTableCell::styleOrColLogicalWidth):
     22        (RenderTableCell):
     23
    1242012-10-08  Arpita Bahuguna  <arpitabahuguna@gmail.com>
    225
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r129078 r130698  
    755755}
    756756
    757 RenderTableCol* RenderTable::colElement(unsigned col, bool* startEdge, bool* endEdge) const
    758 {
    759     if (!m_hasColElements)
    760         return 0;
     757RenderTableCol* RenderTable::slowColElement(unsigned col, bool* startEdge, bool* endEdge) const
     758{
     759    ASSERT(m_hasColElements);
    761760
    762761    unsigned columnCount = 0;
  • trunk/Source/WebCore/rendering/RenderTable.h

    r128906 r130698  
    199199    RenderTableCol* firstColumn() const;
    200200
    201     RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const;
     201    RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const
     202    {
     203        // The common case is to not have columns, make that case fast.
     204        if (!m_hasColElements)
     205            return 0;
     206        return slowColElement(col, startEdge, endEdge);
     207    }
    202208
    203209    bool needsSectionRecalc() const { return m_needsSectionRecalc; }
     
    267273    virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE;
    268274    virtual LayoutUnit lastLineBoxBaseline() const OVERRIDE;
     275
     276    RenderTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge) const;
    269277
    270278    virtual RenderBlock* firstLineBlock() const;
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r130548 r130698  
    145145}
    146146
    147 Length RenderTableCell::styleOrColLogicalWidth() const
    148 {
    149     Length w = style()->logicalWidth();
    150     if (!w.isAuto())
    151         return w;
    152 
    153     if (RenderTableCol* tableCol = table()->colElement(col())) {
    154         unsigned colSpanCount = colSpan();
    155 
    156         Length colWidthSum = Length(0, Fixed);
    157         for (unsigned i = 1; i <= colSpanCount; i++) {
    158             Length colWidth = tableCol->style()->logicalWidth();
    159 
    160             // Percentage value should be returned only for colSpan == 1.
    161             // Otherwise we return original width for the cell.
    162             if (!colWidth.isFixed()) {
    163                 if (colSpanCount > 1)
    164                     return w;
    165                 return colWidth;
    166             }
    167 
    168             colWidthSum = Length(colWidthSum.value() + colWidth.value(), Fixed);
    169 
    170             tableCol = tableCol->nextColumn();
    171             // If no next <col> tag found for the span we just return what we have for now.
    172             if (!tableCol)
    173                 break;
    174         }
    175 
    176         // Column widths specified on <col> apply to the border box of the cell.
    177         // Percentages don't need to be handled since they're always treated this way (even when specified on the cells).
    178         // See Bugzilla bug 8126 for details.
    179         if (colWidthSum.isFixed() && colWidthSum.value() > 0)
    180             colWidthSum = Length(max(0.0f, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
    181         return colWidthSum;
    182     }
    183 
    184     return w;
     147Length RenderTableCell::logicalWidthFromColumns(RenderTableCol* firstColForThisCell, Length widthFromStyle) const
     148{
     149    ASSERT(firstColForThisCell && firstColForThisCell == table()->colElement(col()));
     150    RenderTableCol* tableCol = firstColForThisCell;
     151
     152    unsigned colSpanCount = colSpan();
     153    int colWidthSum = 0;
     154    for (unsigned i = 1; i <= colSpanCount; i++) {
     155        Length colWidth = tableCol->style()->logicalWidth();
     156
     157        // Percentage value should be returned only for colSpan == 1.
     158        // Otherwise we return original width for the cell.
     159        if (!colWidth.isFixed()) {
     160            if (colSpanCount > 1)
     161                return widthFromStyle;
     162            return colWidth;
     163        }
     164
     165        colWidthSum += colWidth.value();
     166        tableCol = tableCol->nextColumn();
     167        // If no next <col> tag found for the span we just return what we have for now.
     168        if (!tableCol)
     169            break;
     170    }
     171
     172    // Column widths specified on <col> apply to the border box of the cell, see bug 8126.
     173    // FIXME: Why is border/padding ignored in the negative width case?
     174    if (colWidthSum > 0)
     175        return Length(max(0, colWidthSum - borderAndPaddingLogicalWidth().ceil()), Fixed);
     176    return Length(colWidthSum, Fixed);
    185177}
    186178
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r130548 r130698  
    8181    }
    8282
    83     Length styleOrColLogicalWidth() const;
     83    Length styleOrColLogicalWidth() const
     84    {
     85        Length styleWidth = style()->logicalWidth();
     86        if (!styleWidth.isAuto())
     87            return styleWidth;
     88        if (RenderTableCol* firstColumn = table()->colElement(col()))
     89            return logicalWidthFromColumns(firstColumn, styleWidth);
     90        return styleWidth;
     91    }
    8492
    8593    LayoutUnit logicalHeightForRowSizing() const;
     
    238246    CollapsedBorderValue computeCollapsedAfterBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
    239247
     248    Length logicalWidthFromColumns(RenderTableCol* firstColForThisCell, Length widthFromStyle) const;
     249
    240250    void updateColAndRowSpanFlags();
    241251
Note: See TracChangeset for help on using the changeset viewer.