Changeset 108557 in webkit


Ignore:
Timestamp:
Feb 22, 2012 3:10:53 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

Clean-up RenderTableSection::calcRowLogicalHeight
https://bugs.webkit.org/show_bug.cgi?id=77705

Reviewed by Eric Seidel.

Refactoring / simplication of the code.

This change removes some variables that were unneeded and were
hiding what the code was really doing. Also some of the code was
split and moved down to RenderTableCell.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::logicalHeightForRowSizing):

  • rendering/RenderTableCell.h:

(RenderTableCell):
Added the previous helper function to calculate the cell's
adjusted logical height.

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::calcRowLogicalHeight):
Removed some variables, simplified the rowspan logic to be clearer
(and added a comment about how we handle rowspans).

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108556 r108557  
     12012-02-22  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Clean-up RenderTableSection::calcRowLogicalHeight
     4        https://bugs.webkit.org/show_bug.cgi?id=77705
     5
     6        Reviewed by Eric Seidel.
     7
     8        Refactoring / simplication of the code.
     9
     10        This change removes some variables that were unneeded and were
     11        hiding what the code was really doing. Also some of the code was
     12        split and moved down to RenderTableCell.
     13
     14        * rendering/RenderTableCell.cpp:
     15        (WebCore::RenderTableCell::logicalHeightForRowSizing):
     16        * rendering/RenderTableCell.h:
     17        (RenderTableCell):
     18        Added the previous helper function to calculate the cell's
     19        adjusted logical height.
     20
     21        * rendering/RenderTableSection.cpp:
     22        (WebCore::RenderTableSection::calcRowLogicalHeight):
     23        Removed some variables, simplified the rowspan logic to be clearer
     24        (and added a comment about how we handle rowspans).
     25
    1262012-02-22  Adam Barth  <abarth@webkit.org>
    227
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r107874 r108557  
    9292}
    9393
     94LayoutUnit RenderTableCell::logicalHeightForRowSizing() const
     95{
     96    LayoutUnit adjustedLogicalHeight = logicalHeight() - (intrinsicPaddingBefore() + intrinsicPaddingAfter());
     97
     98    LayoutUnit styleLogicalHeight = style()->logicalHeight().calcValue(0);
     99    if (document()->inQuirksMode() || style()->boxSizing() == BORDER_BOX) {
     100        // Explicit heights use the border box in quirks mode.
     101        // Don't adjust height.
     102    } else {
     103        // In strict mode, box-sizing: content-box do the right
     104        // thing and actually add in the border and padding.
     105        LayoutUnit adjustedPaddingBefore = paddingBefore() - intrinsicPaddingBefore();
     106        LayoutUnit adjustedPaddingAfter = paddingAfter() - intrinsicPaddingAfter();
     107        styleLogicalHeight += adjustedPaddingBefore + adjustedPaddingAfter + borderBefore() + borderAfter();
     108    }
     109
     110    return max(styleLogicalHeight, adjustedLogicalHeight);
     111}
     112
    94113Length RenderTableCell::styleOrColLogicalWidth() const
    95114{
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r107874 r108557  
    8686    Length styleOrColLogicalWidth() const;
    8787
     88    LayoutUnit logicalHeightForRowSizing() const;
     89
    8890    virtual void computePreferredLogicalWidths();
    8991
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r108372 r108557  
    335335
    336336    for (unsigned r = 0; r < m_grid.size(); r++) {
    337         m_rowPos[r + 1] = 0;
    338         m_grid[r].baseline = 0;
    339         LayoutUnit baseline = 0;
    340         int bdesc = 0;
    341         int ch = m_grid[r].logicalHeight.calcMinValue(0);
    342         int pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0);
    343 
    344         m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
     337        LayoutUnit baselineDescent = 0;
     338
     339        // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
     340        m_rowPos[r + 1] = max(m_rowPos[r] + m_grid[r].logicalHeight.calcMinValue(0), 0);
    345341
    346342        Row& row = m_grid[r].row;
     
    354350                continue;
    355351
    356             if ((cell->row() + cell->rowSpan() - 1) > r)
     352            // FIXME: We are always adding the height of a rowspan to the last rows which doesn't match
     353            // other browsers. See webkit.org/b/52185 for example.
     354            if ((cell->row() + cell->rowSpan() - 1) != r)
    357355                continue;
    358356
    359             unsigned indx = max(r - cell->rowSpan() + 1, 0u);
     357            // For row spanning cells, |r| is the last row in the span.
     358            unsigned cellStartRow = cell->row();
    360359
    361360            if (cell->hasOverrideHeight()) {
     
    371370            }
    372371
    373             int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
    374 
    375             ch = cell->style()->logicalHeight().calcValue(0);
    376             if (document()->inQuirksMode() || cell->style()->boxSizing() == BORDER_BOX) {
    377                 // Explicit heights use the border box in quirks mode.
    378                 // Don't adjust height.
    379             } else {
    380                 // In strict mode, box-sizing: content-box do the right
    381                 // thing and actually add in the border and padding.
    382                 int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
    383                 int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
    384                 ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter();
    385             }
    386             ch = max(ch, adjustedLogicalHeight);
    387 
    388             pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : 0);
    389 
    390             m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
     372            int cellLogicalHeight = cell->logicalHeightForRowSizing();
     373            m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[cellStartRow] + cellLogicalHeight);
    391374
    392375            // find out the baseline
    393376            EVerticalAlign va = cell->style()->verticalAlign();
    394377            if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
    395                 int b = cell->cellBaselinePosition();
    396                 if (b > cell->borderBefore() + cell->paddingBefore()) {
    397                     baseline = max<LayoutUnit>(baseline, b - cell->intrinsicPaddingBefore());
    398                     bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingBefore()));
     378                int baselinePosition = cell->cellBaselinePosition();
     379                if (baselinePosition > cell->borderBefore() + cell->paddingBefore()) {
     380                    m_grid[r].baseline = max(m_grid[r].baseline, baselinePosition - cell->intrinsicPaddingBefore());
     381                    baselineDescent = max(baselineDescent, m_rowPos[cellStartRow] + cellLogicalHeight - (baselinePosition - cell->intrinsicPaddingBefore()));
    399382                }
    400383            }
     
    402385
    403386        // do we have baseline aligned elements?
    404         if (baseline) {
     387        if (m_grid[r].baseline)
    405388            // increase rowheight if baseline requires
    406             m_rowPos[r + 1] = max(m_rowPos[r + 1], baseline + bdesc + (m_grid[r].rowRenderer ? spacing : 0));
    407             m_grid[r].baseline = baseline;
    408         }
    409 
     389            m_rowPos[r + 1] = max(m_rowPos[r + 1], m_grid[r].baseline + baselineDescent);
     390
     391        // Add the border-spacing to our final position.
     392        m_rowPos[r + 1] += m_grid[r].rowRenderer ? spacing : 0;
    410393        m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[r]);
    411394    }
Note: See TracChangeset for help on using the changeset viewer.