Changeset 266996 in webkit


Ignore:
Timestamp:
Sep 13, 2020 9:46:12 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][Tree building] Table rows may not have any children.
https://bugs.webkit.org/show_bug.cgi?id=216456

Reviewed by Antti Koivisto.

Cover the case when the table row has no children at all (call numberOfCellsPerRow.append() on evey row when needed).

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::TreeBuilder::buildTableStructure):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r266995 r266996  
     12020-09-13  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][Tree building] Table rows may not have any children.
     4        https://bugs.webkit.org/show_bug.cgi?id=216456
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Cover the case when the table row has no children at all (call numberOfCellsPerRow.append() on evey row when needed).
     9
     10        * layout/layouttree/LayoutTreeBuilder.cpp:
     11        (WebCore::Layout::TreeBuilder::buildTableStructure):
     12
    1132020-09-13  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r266994 r266996  
    338338        // Find the max number of columns and fill in the gaps.
    339339        size_t maximumColumns = 0;
     340        size_t currentRow = 0;
    340341        Vector<size_t> numberOfCellsPerRow;
    341         size_t currentRow = 0;
    342342        for (auto& rowBox : childrenOfType<ContainerBox>(tableBody)) {
     343            if (numberOfCellsPerRow.size() <= currentRow) {
     344                // Ensure we always have a vector entry for the current row -even when the row is empty.
     345                numberOfCellsPerRow.append({ });
     346            }
    343347            for (auto& cellBox : childrenOfType<ContainerBox>(rowBox)) {
     348                auto numberOfSpannedColumns = cellBox.columnSpan();
    344349                for (size_t rowSpan = 0; rowSpan < cellBox.rowSpan(); ++rowSpan) {
    345                     if (numberOfCellsPerRow.size() <= currentRow + rowSpan)
    346                         numberOfCellsPerRow.append(cellBox.columnSpan());
    347                     else
    348                         numberOfCellsPerRow[currentRow + rowSpan] += cellBox.columnSpan();
     350                    auto rowIndexWithSpan = currentRow + rowSpan;
     351                    if (numberOfCellsPerRow.size() <= rowIndexWithSpan) {
     352                        // This is where we advance from the current row by having a row spanner.
     353                        numberOfCellsPerRow.append(numberOfSpannedColumns);
     354                        continue;
     355                    }
     356                    numberOfCellsPerRow[rowIndexWithSpan] += numberOfSpannedColumns;
    349357                }
    350358            }
Note: See TracChangeset for help on using the changeset viewer.