Changeset 143683 in webkit


Ignore:
Timestamp:
Feb 21, 2013, 7:12:04 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Clean up computePreferredLogicalWidths functions in TableLayout subclasses
https://bugs.webkit.org/show_bug.cgi?id=110515

Reviewed by Tony Chang.

No change in behavior. This is just a cleanup in preparation for other
refactoring to this code.

  • rendering/FixedTableLayout.cpp:

(WebCore::FixedTableLayout::calcWidthArray):
Move a FIXME here from computePreferredLogicalWidths. It makes more sense here.
(WebCore::FixedTableLayout::computePreferredLogicalWidths):
-Remove outdated or unhelpful comments.
-Isolate the fixed width codepath to make it a bit less convoluted.
(WebCore::FixedTableLayout::layout):

  • rendering/FixedTableLayout.h:

The argument to calcWidthArray is never used. Remove it.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143681 r143683  
     12013-02-21  Ojan Vafai  <ojan@chromium.org>
     2
     3        Clean up computePreferredLogicalWidths functions in TableLayout subclasses
     4        https://bugs.webkit.org/show_bug.cgi?id=110515
     5
     6        Reviewed by Tony Chang.
     7
     8        No change in behavior. This is just a cleanup in preparation for other
     9        refactoring to this code.
     10
     11        * rendering/FixedTableLayout.cpp:
     12        (WebCore::FixedTableLayout::calcWidthArray):
     13        Move a FIXME here from computePreferredLogicalWidths. It makes more sense here.
     14        (WebCore::FixedTableLayout::computePreferredLogicalWidths):
     15        -Remove outdated or unhelpful comments.
     16        -Isolate the fixed width codepath to make it a bit less convoluted.
     17        (WebCore::FixedTableLayout::layout):
     18        * rendering/FixedTableLayout.h:
     19        The argument to calcWidthArray is never used. Remove it.
     20
    1212013-02-21  Eric Seidel  <eric@webkit.org>
    222
  • trunk/Source/WebCore/rendering/FixedTableLayout.cpp

    r140047 r143683  
    7878}
    7979
    80 int FixedTableLayout::calcWidthArray(int)
     80int FixedTableLayout::calcWidthArray()
    8181{
     82    // FIXME: We might want to wait until we have all of the first row before computing for the first time.
    8283    int usedWidth = 0;
    8384
     
    178179void FixedTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
    179180{
    180     // FIXME: This entire calculation is incorrect for both minwidth and maxwidth.
    181    
    182     // we might want to wait until we have all of the first row before
    183     // layouting for the first time.
    184 
    185     // only need to calculate the minimum width as the sum of the
    186     // cols/cells with a fixed width.
    187     //
    188     // The maximum width is max(minWidth, tableWidth).
    189181    int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
    190 
    191     int tableLogicalWidth = m_table->style()->logicalWidth().isFixed() ? m_table->style()->logicalWidth().value() - bordersPaddingAndSpacing : 0;
    192     int mw = calcWidthArray(tableLogicalWidth) + bordersPaddingAndSpacing;
    193 
    194     minWidth = max(mw, tableLogicalWidth);
    195     maxWidth = minWidth;
    196 
    197     // This quirk is very similar to one that exists in RenderBlock::calcBlockPrefWidths().
    198     // Here's the example for this one:
     182    minWidth = maxWidth = calcWidthArray() + bordersPaddingAndSpacing;
     183
     184    Length tableLogicalWidth = m_table->style()->logicalWidth();
     185    if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive())
     186        minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - bordersPaddingAndSpacing);
     187
    199188    /*
    200189        <table style="width:100%; background-color:red"><tr><td>
     
    221210    // This means that our preferred logical widths were not recomputed as expected.
    222211    if (nEffCols != m_width.size()) {
    223         calcWidthArray(tableLogicalWidth);
     212        calcWidthArray();
    224213        // FIXME: Table layout shouldn't modify our table structure (but does due to columns and column-groups).
    225214        nEffCols = m_table->numEffCols();
  • trunk/Source/WebCore/rendering/FixedTableLayout.h

    r133779 r143683  
    3939
    4040private:
    41     int calcWidthArray(int tableWidth);
     41    int calcWidthArray();
    4242
    4343    Vector<Length> m_width;
Note: See TracChangeset for help on using the changeset viewer.