Changeset 140047 in webkit


Ignore:
Timestamp:
Jan 17, 2013 2:41:14 PM (11 years ago)
Author:
ojan@chromium.org
Message:

Table layout does not need to explicitly call computePreferredLogicalWidths
https://bugs.webkit.org/show_bug.cgi?id=106931

Reviewed by Julien Chaffraix.

Code shouldn't need to explicitly call computePreferredLogicalWidths.
It should only get called as a by-product of calling minPreferredLogicalWidth
or maxPreferredLogicalWidth.

Instead, make it clear that the calling code is just trying to clear
preferred width dirty bits.

  • rendering/AutoTableLayout.cpp:

(WebCore::AutoTableLayout::recalcColumn):
The computePreferredLogicalWidths call on the table cell is redundant
with the minPreferredLogicalWidth call on the next line.

  • rendering/FixedTableLayout.cpp:

(WebCore::FixedTableLayout::calcWidthArray):
We only need to clear the dirty bit here. Table cells don't use
their preferred widths in fixed table layout calculations.

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

(WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):

  • rendering/RenderTableCol.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140045 r140047  
     12013-01-17  Ojan Vafai  <ojan@chromium.org>
     2
     3        Table layout does not need to explicitly call computePreferredLogicalWidths
     4        https://bugs.webkit.org/show_bug.cgi?id=106931
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Code shouldn't need to explicitly call computePreferredLogicalWidths.
     9        It should only get called as a by-product of calling minPreferredLogicalWidth
     10        or maxPreferredLogicalWidth.
     11
     12        Instead, make it clear that the calling code is just trying to clear
     13        preferred width dirty bits.
     14
     15        * rendering/AutoTableLayout.cpp:
     16        (WebCore::AutoTableLayout::recalcColumn):
     17        The computePreferredLogicalWidths call on the table cell is redundant
     18        with the minPreferredLogicalWidth call on the next line.
     19
     20        * rendering/FixedTableLayout.cpp:
     21        (WebCore::FixedTableLayout::calcWidthArray):
     22        We only need to clear the dirty bit here. Table cells don't use
     23        their preferred widths in fixed table layout calculations.
     24
     25        * rendering/RenderTableCell.h:
     26        * rendering/RenderTableCol.cpp:
     27        (WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):
     28        * rendering/RenderTableCol.h:
     29
    1302013-01-17  Julien Chaffraix  <jchaffraix@webkit.org>
    231
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r133037 r140047  
    5151
    5252    for (RenderObject* child = m_table->children()->firstChild(); child; child = child->nextSibling()) {
    53         if (child->isRenderTableCol())
    54             toRenderTableCol(child)->computePreferredLogicalWidths();
    55         else if (child->isTableSection()) {
     53        if (child->isRenderTableCol()){
     54            // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
     55            // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
     56            // ancestors as dirty.
     57            toRenderTableCol(child)->clearPreferredLogicalWidthsDirtyBits();
     58        } else if (child->isTableSection()) {
    5659            RenderTableSection* section = toRenderTableSection(child);
    5760            unsigned numRows = section->numRows();
     
    7376
    7477                if (cell->colSpan() == 1) {
    75                     if (cell->preferredLogicalWidthsDirty())
    76                         cell->computePreferredLogicalWidths();
    7778                    columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
    7879                    if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) {
  • trunk/Source/WebCore/rendering/FixedTableLayout.cpp

    r134017 r140047  
    8989    unsigned currentEffectiveColumn = 0;
    9090    for (RenderTableCol* col = m_table->firstColumn(); col; col = col->nextColumn()) {
    91         col->computePreferredLogicalWidths();
     91        // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
     92        // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
     93        // ancestors as dirty.
     94        col->clearPreferredLogicalWidthsDirtyBits();
    9295
    9396        // Width specified by column-groups that have column child does not affect column width in fixed layout tables
     
    139142
    140143        RenderTableCell* cell = toRenderTableCell(child);
    141         if (cell->preferredLogicalWidthsDirty())
    142             cell->computePreferredLogicalWidths();
    143144
    144145        Length logicalWidth = cell->styleOrColLogicalWidth();
    145146        unsigned span = cell->colSpan();
    146147        int fixedBorderBoxLogicalWidth = 0;
     148        // FIXME: Support other length types. If the width is non-auto, it should probably just use
     149        // RenderBox::computeLogicalWidthInRegionUsing to compute the width.
    147150        if (logicalWidth.isFixed() && logicalWidth.isPositive()) {
    148151            fixedBorderBoxLogicalWidth = cell->adjustBorderBoxLogicalWidthForBoxSizing(logicalWidth.value());
     
    162165            ++currentColumn;
    163166        }
     167
     168        // FixedTableLayout doesn't use min/maxPreferredLogicalWidths, but we need to clear the
     169        // dirty bit on the cell so that we'll correctly mark its ancestors dirty
     170        // in case we later call setPreferredLogicalWidthsDirty(true) on it later.
     171        if (cell->preferredLogicalWidthsDirty())
     172            cell->setPreferredLogicalWidthsDirty(false);
    164173    }
    165174
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r140039 r140047  
    103103    }
    104104
    105     virtual void computePreferredLogicalWidths();
    106105
    107106    void setCellLogicalWidth(int constrainedLogicalWidth);
     
    208207protected:
    209208    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     209    virtual void computePreferredLogicalWidths();
    210210
    211211private:
  • trunk/Source/WebCore/rendering/RenderTableCol.cpp

    r140039 r140047  
    116116}
    117117
    118 void RenderTableCol::computePreferredLogicalWidths()
     118void RenderTableCol::clearPreferredLogicalWidthsDirtyBits()
    119119{
    120120    setPreferredLogicalWidthsDirty(false);
  • trunk/Source/WebCore/rendering/RenderTableCol.h

    r140039 r140047  
    4444    RenderObjectChildList* children() { return &m_children; }
    4545
    46     virtual void computePreferredLogicalWidths();
     46    void clearPreferredLogicalWidthsDirtyBits();
    4747
    4848    unsigned span() const { return m_span; }
     
    8686    virtual bool isRenderTableCol() const OVERRIDE { return true; }
    8787    virtual void updateFromElement();
     88    virtual void computePreferredLogicalWidths() OVERRIDE { ASSERT_NOT_REACHED(); }
    8889
    8990    virtual void insertedIntoTree() OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.