Changeset 108914 in webkit


Ignore:
Timestamp:
Feb 25, 2012 4:19:22 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

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

Reviewed by Nikolas Zimmermann.

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

    r108907 r108914  
     12012-02-25  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 Nikolas Zimmermann.
     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-25  Benjamin Poulain  <benjamin@webkit.org>
    227
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r108892 r108914  
    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

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

    r108892 r108914  
    335335
    336336    for (unsigned r = 0; r < m_grid.size(); r++) {
    337         m_rowPos[r + 1] = 0;
    338337        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);
     338        LayoutUnit baselineDescent = 0;
     339
     340        // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
     341        m_rowPos[r + 1] = max(m_rowPos[r] + m_grid[r].logicalHeight.calcMinValue(0), 0);
    345342
    346343        Row& row = m_grid[r].row;
     
    354351                continue;
    355352
    356             if ((cell->row() + cell->rowSpan() - 1) > r)
     353            // FIXME: We are always adding the height of a rowspan to the last rows which doesn't match
     354            // other browsers. See webkit.org/b/52185 for example.
     355            if ((cell->row() + cell->rowSpan() - 1) != r)
    357356                continue;
    358357
    359             unsigned indx = max(r - cell->rowSpan() + 1, 0u);
     358            // For row spanning cells, |r| is the last row in the span.
     359            unsigned cellStartRow = cell->row();
    360360
    361361            if (cell->hasOverrideHeight()) {
     
    371371            }
    372372
    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);
     373            int cellLogicalHeight = cell->logicalHeightForRowSizing();
     374            m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[cellStartRow] + cellLogicalHeight);
    391375
    392376            // find out the baseline
    393377            EVerticalAlign va = cell->style()->verticalAlign();
    394378            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()));
     379                int baselinePosition = cell->cellBaselinePosition();
     380                if (baselinePosition > cell->borderBefore() + cell->paddingBefore()) {
     381                    m_grid[r].baseline = max(m_grid[r].baseline, baselinePosition - cell->intrinsicPaddingBefore());
     382                    baselineDescent = max(baselineDescent, m_rowPos[cellStartRow] + cellLogicalHeight - (baselinePosition - cell->intrinsicPaddingBefore()));
    399383                }
    400384            }
     
    402386
    403387        // do we have baseline aligned elements?
    404         if (baseline) {
     388        if (m_grid[r].baseline)
    405389            // 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 
     390            m_rowPos[r + 1] = max(m_rowPos[r + 1], m_grid[r].baseline + baselineDescent);
     391
     392        // Add the border-spacing to our final position.
     393        m_rowPos[r + 1] += m_grid[r].rowRenderer ? spacing : 0;
    410394        m_rowPos[r + 1] = max(m_rowPos[r + 1], m_rowPos[r]);
    411395    }
Note: See TracChangeset for help on using the changeset viewer.