Changeset 260726 in webkit
- Timestamp:
- Apr 26, 2020 9:34:24 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r260725 r260726 1 2020-04-26 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Compute and distribute extra vertical space for rows 4 https://bugs.webkit.org/show_bug.cgi?id=211046 5 6 Reviewed by Antti Koivisto. 7 8 When the table computed height is bigger than the sum of the row heigts, we need to distribute the extra vertical 9 space among the non-fixed height rows. The distribution is based on the preferred height of those non-fixed rows. 10 11 * layout/tableformatting/TableFormattingContext.cpp: 12 (WebCore::Layout::TableFormattingContext::computeAndDistributeExtraVerticalSpace): 13 1 14 2020-04-11 Darin Adler <darin@apple.com> 2 15 -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r260708 r260726 493 493 } 494 494 495 void TableFormattingContext::computeAndDistributeExtraVerticalSpace(LayoutUnit availableHorizontalSpace, Optional<LayoutUnit> )495 void TableFormattingContext::computeAndDistributeExtraVerticalSpace(LayoutUnit availableHorizontalSpace, Optional<LayoutUnit> verticalConstraint) 496 496 { 497 497 auto& grid = formattingState().tableGrid(); … … 499 499 auto& rows = grid.rows(); 500 500 501 Vector< LayoutUnit> rowsHeight;501 Vector<float> rowsHeight; 502 502 Vector<InlineLayoutUnit> rowsBaselineOffset; 503 Vector<bool> isFixedRowList(rows.size(), true); 504 float tableUsedHeight = 0; 505 size_t flexibleRowCount = 0; 503 506 // 1. Collect initial row heights. 507 float flexibleSpace = 0; 504 508 for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) { 505 509 auto maximumColumnAscent = InlineLayoutUnit { }; … … 519 523 } 520 524 // <tr style="height: 10px"> is considered as min height. 521 auto computedRowHeight = geometry().computedContentHeight(rows.list()[rowIndex].box(), { }).valueOr(LayoutUnit { }); 522 rowsHeight.append(std::max(computedRowHeight, LayoutUnit { maximumColumnAscent + maximumColumnDescent })); 525 auto maximumRowHeight = maximumColumnAscent + maximumColumnDescent; 526 if (auto computedRowHeight = geometry().computedContentHeight(rows.list()[rowIndex].box(), { })) 527 maximumRowHeight = std::max(computedRowHeight->toFloat(), maximumRowHeight); 528 else { 529 flexibleSpace += maximumRowHeight; 530 ++flexibleRowCount; 531 isFixedRowList[rowIndex] = false; 532 } 533 tableUsedHeight += maximumRowHeight; 534 rowsHeight.append(maximumRowHeight); 523 535 rowsBaselineOffset.append(maximumColumnAscent); 536 } 537 538 // Distribute extra space if the table is supposed to be taller than the sum of the row heights. 539 auto minimumTableHeight = verticalConstraint; 540 if (!minimumTableHeight) 541 minimumTableHeight = geometry().fixedValue(root().style().logicalHeight()); 542 543 if (minimumTableHeight && *minimumTableHeight > tableUsedHeight) { 544 float spaceToDistribute = std::max(0.0f, *minimumTableHeight - tableUsedHeight - ((rows.size() + 1) * grid.verticalSpacing())); 545 for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) { 546 if (isFixedRowList[rowIndex]) 547 continue; 548 rowsHeight[rowIndex] += spaceToDistribute / flexibleSpace * rowsHeight[rowIndex]; 549 } 524 550 } 525 551 … … 529 555 auto rowHeight = rowsHeight[rowIndex]; 530 556 531 row.setLogicalHeight( rowHeight);557 row.setLogicalHeight(LayoutUnit { rowHeight }); 532 558 row.setBaselineOffset(rowsBaselineOffset[rowIndex]); 533 559 row.setLogicalTop(rowLogicalTop);
Note: See TracChangeset
for help on using the changeset viewer.