Changeset 122282 in webkit


Ignore:
Timestamp:
Jul 10, 2012 5:41:48 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Re-factoring recalcColumn in AutoTableLayout.cpp for readability
https://bugs.webkit.org/show_bug.cgi?id=89636

Patch by Pravin D <pravind.2k4@gmail.com> on 2012-07-10
Reviewed by Julien Chaffraix.

No test case required. Code re-factoring.

  • rendering/AutoTableLayout.cpp:

Added a const integer place holder for 32760.

(WebCore::AutoTableLayout::recalcColumn):

Changes :
1) Moved the continue statement above the bool cellHasContent for an early return.
2) Replaced the constant 32760 by a placeholder.
3) Initialization of columnLayout max and min logical widths is made common for both cells having col span == 1 and span > 1.
4) Removed redundant check for cell logical width type.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122280 r122282  
     12012-07-10  Pravin D  <pravind.2k4@gmail.com>
     2
     3        Re-factoring recalcColumn in AutoTableLayout.cpp for readability
     4        https://bugs.webkit.org/show_bug.cgi?id=89636
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        No test case required. Code re-factoring.
     9
     10        * rendering/AutoTableLayout.cpp:
     11        Added a const integer place holder for 32760.
     12
     13        (WebCore::AutoTableLayout::recalcColumn):
     14         Changes :
     15         1) Moved the continue statement above the bool cellHasContent for an early return.
     16         2) Replaced the constant 32760 by a placeholder.
     17         3) Initialization of columnLayout max and min logical widths is made common for both cells having col span == 1 and span > 1.
     18         4) Removed redundant check for cell logical width type.
     19
    1202012-07-10  Adam Barth  <abarth@webkit.org>
    221
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r121279 r122282  
    6060                RenderTableCell* cell = current.primaryCell();
    6161               
    62                 bool cellHasContent = cell && !current.inColSpan && (cell->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding());
     62                if (current.inColSpan || !cell)
     63                    continue;
     64
     65                bool cellHasContent = cell->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding();
    6366                if (cellHasContent)
    6467                    columnLayout.emptyCellsOnly = false;
    65                    
    66                 if (current.inColSpan || !cell)
    67                     continue;
     68
     69                // A cell originates in this column. Ensure we have
     70                // a min/max width of at least 1px for this column now.
     71                columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
     72                columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
    6873
    6974                if (cell->colSpan() == 1) {
    70                     // A cell originates in this column.  Ensure we have
    71                     // a min/max width of at least 1px for this column now.
    72                     columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
    73                     columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
    7475                    if (cell->preferredLogicalWidthsDirty())
    7576                        cell->computePreferredLogicalWidths();
     
    8081                    }
    8182
     83                    // All browsers implement a size limit on the cell's max width.
     84                    // Our limit is based on KHTML's representation that used 16 bits widths.
     85                    // FIXME: Other browsers have a lower limit for the cell's max width.
     86                    const int cCellMaxWidth = 32760;
    8287                    Length cellLogicalWidth = cell->styleOrColLogicalWidth();
    83                     // FIXME: What is this arbitrary value?
    84                     if (cellLogicalWidth.value() > 32760)
    85                         cellLogicalWidth.setValue(32760);
     88                    if (cellLogicalWidth.value() > cCellMaxWidth)
     89                        cellLogicalWidth.setValue(cCellMaxWidth);
    8690                    if (cellLogicalWidth.isNegative())
    8791                        cellLogicalWidth.setValue(0);
     
    8993                    case Fixed:
    9094                        // ignore width=0
    91                         if (cellLogicalWidth.value() > 0 && columnLayout.logicalWidth.type() != Percent) {
     95                        if (cellLogicalWidth.isPositive() && !columnLayout.logicalWidth.isPercent()) {
    9296                            int logicalWidth = cell->computeBorderBoxLogicalWidth(cellLogicalWidth.value());
    9397                            if (columnLayout.logicalWidth.isFixed()) {
    9498                                // Nav/IE weirdness
    95                                 if ((logicalWidth > columnLayout.logicalWidth.value()) ||
    96                                     ((columnLayout.logicalWidth.value() == logicalWidth) && (maxContributor == cell))) {
    97                                     columnLayout.logicalWidth.setValue(logicalWidth);
     99                                if ((logicalWidth > columnLayout.logicalWidth.value())
     100                                    || ((columnLayout.logicalWidth.value() == logicalWidth) && (maxContributor == cell))) {
     101                                    columnLayout.logicalWidth.setValue(Fixed, logicalWidth);
    98102                                    fixedContributor = cell;
    99103                                }
     
    112116                        // FIXME: Need to understand this case and whether it makes sense to compare values
    113117                        // which are not necessarily of the same type.
    114                         if (cellLogicalWidth.isAuto() || (cellLogicalWidth.isRelative() && cellLogicalWidth.value() > columnLayout.logicalWidth.value()))
     118                        if (cellLogicalWidth.value() > columnLayout.logicalWidth.value())
    115119                            columnLayout.logicalWidth = cellLogicalWidth;
    116120                    default:
     
    118122                    }
    119123                } else if (!effCol || section->primaryCellAt(i, effCol - 1) != cell) {
    120                     // This spanning cell originates in this column.  Ensure we have
    121                     // a min/max width of at least 1px for this column now.
    122                     columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0);
    123                     columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
     124                    // This spanning cell originates in this column. Insert the cell into spanning cells list.
    124125                    insertSpanCell(cell);
    125126                }
Note: See TracChangeset for help on using the changeset viewer.