Changeset 248671 in webkit
- Timestamp:
- Aug 14, 2019 8:39:23 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248670 r248671 1 2019-08-14 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Implement TableFormattingContext::computePreferredWidthForColumns 4 https://bugs.webkit.org/show_bug.cgi?id=200701 5 <rdar://problem/54287828> 6 7 Reviewed by Antti Koivisto. 8 9 Compute cells' min/max width first. 10 11 * layout/tableformatting/TableFormattingContext.cpp: 12 (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns const): 13 * layout/tableformatting/TableGrid.cpp: 14 (WebCore::Layout::TableGrid::slot): 15 (WebCore::Layout::TableGrid::appendCell): 16 * layout/tableformatting/TableGrid.h: 17 (WebCore::Layout::TableGrid::cells): 18 1 19 2019-08-14 Youenn Fablet <youenn@apple.com> 2 20 -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r248596 r248671 86 86 void TableFormattingContext::computePreferredWidthForColumns() const 87 87 { 88 auto& formattingState = this->formattingState(); 89 auto& grid = formattingState.tableGrid(); 90 91 // 1. Calculate the minimum content width (MCW) of each cell: the formatted content may span any number of lines but may not overflow the cell box. 92 // If the specified 'width' (W) of the cell is greater than MCW, W is the minimum cell width. A value of 'auto' means that MCW is the minimum cell width. 93 // Also, calculate the "maximum" cell width of each cell: formatting the content without breaking lines other than where explicit line breaks occur. 94 for (auto& cell : grid.cells()) { 95 ASSERT(cell->tableCellBox.establishesFormattingContext()); 96 97 auto intrinsicWidth = layoutState().createFormattingContext(cell->tableCellBox)->computedIntrinsicWidthConstraints(); 98 intrinsicWidth = Geometry::constrainByMinMaxWidth(cell->tableCellBox, intrinsicWidth); 99 formattingState.setIntrinsicWidthConstraints(intrinsicWidth); 100 101 auto columnSpan = cell->size.width(); 102 auto slotIntrinsicWidth = FormattingContext::IntrinsicWidthConstraints { intrinsicWidth.minimum / columnSpan, intrinsicWidth.maximum / columnSpan }; 103 auto initialPosition = cell->position; 104 for (auto i = 0; i < columnSpan; ++i) 105 grid.slot({ initialPosition.x() + i, initialPosition.y() })->widthConstraints = slotIntrinsicWidth; 106 } 88 107 } 89 108 -
trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp
r248596 r248671 52 52 } 53 53 54 TableGrid::SlotInfo* TableGrid::slot(SlotPosition position) 55 { 56 return m_slotMap.get(position); 57 } 58 54 59 void TableGrid::appendCell(const Box& tableCellBox) 55 60 { … … 80 85 auto position = SlotPosition { initialSlotPosition.x() + row - 1, initialSlotPosition.y() + column - 1 }; 81 86 ASSERT(!m_slotMap.contains(position)); 82 m_slotMap.add(position, SlotInfo { *cellInfo });87 m_slotMap.add(position, std::make_unique<SlotInfo>(*cellInfo)); 83 88 } 84 89 } -
trunk/Source/WebCore/layout/tableformatting/TableGrid.h
r248596 r248671 47 47 void removeCell(const Box&); 48 48 49 private:50 49 using SlotPosition = IntPoint; 51 50 using CellSize = IntSize; 52 using SlotLogicalSize = LayoutSize;53 54 51 struct CellInfo : public CanMakeWeakPtr<CellInfo> { 55 52 CellInfo(const Box& tableCellBox, SlotPosition, CellSize); … … 59 56 CellSize size; 60 57 }; 58 using CellList = WTF::ListHashSet<std::unique_ptr<CellInfo>>; 59 CellList& cells() { return m_cellList; } 61 60 61 using SlotLogicalSize = LayoutSize; 62 62 struct SlotInfo { 63 63 SlotInfo() = default; … … 65 65 66 66 WeakPtr<CellInfo> cell; 67 FormattingContext::IntrinsicWidthConstraints widthConstraints; 67 68 SlotLogicalSize size; 68 69 }; 70 SlotInfo* slot(SlotPosition); 69 71 70 using CellList = WTF::ListHashSet<std::unique_ptr<CellInfo>>; 71 using SlotMap = WTF::HashMap<SlotPosition, SlotInfo>;72 private: 73 using SlotMap = WTF::HashMap<SlotPosition, std::unique_ptr<SlotInfo>>; 72 74 SlotMap m_slotMap; 73 75 CellList m_cellList;
Note: See TracChangeset
for help on using the changeset viewer.