Changeset 248596 in webkit
- Timestamp:
- Aug 13, 2019 10:05:20 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248594 r248596 1 2019-08-13 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Introduce TableGrid 4 https://bugs.webkit.org/show_bug.cgi?id=200656 5 <rdar://problem/54240833> 6 7 Reviewed by Antti Koivisto. 8 9 table grid: 10 A matrix containing as many rows and columns as needed to describe the position of all the table-rows 11 and table-cells of a table-root, as determined by the grid-dimensioning algorithm. 12 Each row of the grid might correspond to a table-row, and each column to a table-column. 13 14 slot of the table grid: 15 A slot (r,c) is an available space created by the intersection of a row r and a column c in the table grid. 16 17 https://www.w3.org/TR/css-tables-3/#terminology 18 19 * Sources.txt: 20 * WebCore.xcodeproj/project.pbxproj: 21 * layout/layouttree/LayoutBox.h: 22 (WebCore::Layout::Box::isTableHeader const): 23 (WebCore::Layout::Box::isTableBody const): 24 (WebCore::Layout::Box::isTableFooter const): 25 * layout/layouttree/LayoutTreeBuilder.cpp: 26 (WebCore::Layout::TreeBuilder::createLayoutBox): 27 * layout/tableformatting/TableFormattingContext.cpp: 28 (WebCore::Layout::TableFormattingContext::layout const): 29 (WebCore::Layout::TableFormattingContext::ensureTableGrid const): 30 (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns const): 31 (WebCore::Layout::TableFormattingContext::computeTableWidth const): 32 (WebCore::Layout::TableFormattingContext::distributeAvailabeWidth const): 33 (WebCore::Layout::TableFormattingContext::computeTableHeight const): 34 (WebCore::Layout::TableFormattingContext::distributeAvailableHeight const): 35 * layout/tableformatting/TableFormattingContext.h: 36 (WebCore::Layout::TableFormattingContext::formattingState const): 37 * layout/tableformatting/TableFormattingState.h: 38 (WebCore::Layout::TableFormattingState::tableGrid): 39 * layout/tableformatting/TableGrid.cpp: Added. 40 (WebCore::Layout::TableGrid::CellInfo::CellInfo): 41 (WebCore::Layout::TableGrid::SlotInfo::SlotInfo): 42 (WebCore::Layout::TableGrid::TableGrid): 43 (WebCore::Layout::TableGrid::appendCell): 44 (WebCore::Layout::TableGrid::insertCell): 45 (WebCore::Layout::TableGrid::removeCell): 46 * layout/tableformatting/TableGrid.h: Copied from Source/WebCore/layout/tableformatting/TableFormattingContext.h. 47 1 48 2019-08-13 Zalan Bujtas <zalan@apple.com> 2 49 -
trunk/Source/WebCore/Sources.txt
r248517 r248596 1419 1419 layout/tableformatting/TableFormattingContext.cpp 1420 1420 layout/tableformatting/TableFormattingState.cpp 1421 layout/tableformatting/TableGrid.cpp 1421 1422 layout/tableformatting/TableInvalidation.cpp 1422 1423 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r248517 r248596 9139 9139 6F3E1F612136141700A65A08 /* FloatBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; }; 9140 9140 6F4A5BD522F9F16B00A80F25 /* LayoutPhase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutPhase.cpp; sourceTree = "<group>"; }; 9141 6F5B7EAA2300A79E0067D9C3 /* TableGrid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableGrid.cpp; sourceTree = "<group>"; }; 9141 9142 6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; }; 9142 9143 6F7CA3C4208C2956002F29AB /* LayoutState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; }; … … 9173 9174 6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; }; 9174 9175 6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; }; 9176 6FB22E30230097E300C20866 /* TableGrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableGrid.h; sourceTree = "<group>"; }; 9175 9177 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBox.h; sourceTree = "<group>"; }; 9176 9178 6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; }; … … 17085 17087 C21BF72621CD89E300227979 /* WHLSLEnumerationMember.h */, 17086 17088 C21BF70221CD89C400227979 /* WHLSLEnumerationMemberLiteral.h */, 17089 522D07A322FBAB4300B905BE /* WHLSLExpression.cpp */, 17087 17090 C21BF70C21CD89CC00227979 /* WHLSLExpression.h */, 17088 522D07A322FBAB4300B905BE /* WHLSLExpression.cpp */,17089 17091 C21BF70021CD89C200227979 /* WHLSLFallthrough.h */, 17090 17092 C21BF73521CD89F200227979 /* WHLSLFloatLiteral.h */, … … 20447 20449 6FC5CA9222E3599300B13E11 /* TableFormattingState.cpp */, 20448 20450 6FC5CA9622E3599500B13E11 /* TableFormattingState.h */, 20451 6F5B7EAA2300A79E0067D9C3 /* TableGrid.cpp */, 20452 6FB22E30230097E300C20866 /* TableGrid.h */, 20449 20453 6FC5CA9722E3599500B13E11 /* TableInvalidation.cpp */, 20450 20454 6FC5CA9322E3599300B13E11 /* TableInvalidation.h */, -
trunk/Source/WebCore/layout/layouttree/LayoutBox.h
r248594 r248596 53 53 TableRowGroup, 54 54 TableHeaderGroup, 55 TableBodyGroup, 55 56 TableFooterGroup, 56 57 Image, … … 117 118 bool isTableBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableBox; } 118 119 bool isTableCaption() const { return style().display() == DisplayType::TableCaption; } 120 bool isTableHeader() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableHeaderGroup; } 121 bool isTableBody() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableBodyGroup; } 122 bool isTableFooter() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableFooterGroup; } 119 123 bool isTableRow() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableRow; } 120 124 bool isTableCell() const { return style().display() == DisplayType::TableCell;; } -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r248594 r248596 111 111 if (element->hasTagName(HTMLNames::theadTag)) 112 112 return Box::ElementAttributes { Box::ElementType::TableHeaderGroup }; 113 if (element->hasTagName(HTMLNames::t footTag))114 return Box::ElementAttributes { Box::ElementType::Table FooterGroup };113 if (element->hasTagName(HTMLNames::tbodyTag)) 114 return Box::ElementAttributes { Box::ElementType::TableBodyGroup }; 115 115 if (element->hasTagName(HTMLNames::tfootTag)) 116 116 return Box::ElementAttributes { Box::ElementType::TableFooterGroup }; -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r248262 r248596 45 45 void TableFormattingContext::layout() const 46 46 { 47 // https://www.w3.org/TR/css-tables-3/#table-layout-algorithm 48 // To layout a table, user agents must apply the following actions: 49 50 // 1. Ensure each cell slot is occupied by at least one cell. 51 ensureTableGrid(); 52 // 2. Compute the minimum width of each column. 53 computePreferredWidthForColumns(); 54 // 3. Compute the width of the table. 55 computeTableWidth(); 56 // 4. Distribute the width of the table among columns. 57 distributeAvailabeWidth(); 58 // 5. Compute the height of the table. 59 computeTableHeight(); 60 // 6. Distribute the height of the table among rows. 61 distributeAvailableHeight(); 47 62 } 48 63 … … 52 67 } 53 68 69 void TableFormattingContext::ensureTableGrid() const 70 { 71 auto& tableWrapperBox = downcast<Container>(root()); 72 auto& tableGrid = formattingState().tableGrid(); 73 74 for (auto* section = tableWrapperBox.firstChild(); section; section = section->nextSibling()) { 75 ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter()); 76 for (auto* row = downcast<Container>(*section).firstChild(); row; row = row->nextSibling()) { 77 ASSERT(row->isTableRow()); 78 for (auto* cell = downcast<Container>(*row).firstChild(); cell; cell = cell->nextSibling()) { 79 ASSERT(cell->isTableCell()); 80 tableGrid.appendCell(*cell); 81 } 82 } 83 } 84 } 85 86 void TableFormattingContext::computePreferredWidthForColumns() const 87 { 88 } 89 90 void TableFormattingContext::computeTableWidth() const 91 { 92 } 93 94 void TableFormattingContext::distributeAvailabeWidth() const 95 { 96 } 97 98 void TableFormattingContext::computeTableHeight() const 99 { 100 } 101 102 void TableFormattingContext::distributeAvailableHeight() const 103 { 104 } 105 54 106 } 55 107 } -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h
r248262 r248596 45 45 private: 46 46 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override; 47 48 void ensureTableGrid() const; 49 void computePreferredWidthForColumns() const; 50 void computeTableWidth() const; 51 void distributeAvailabeWidth() const; 52 void computeTableHeight() const; 53 void distributeAvailableHeight() const; 54 55 TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); } 47 56 }; 48 57 -
trunk/Source/WebCore/layout/tableformatting/TableFormattingState.h
r247669 r248596 29 29 30 30 #include "FormattingState.h" 31 #include "TableGrid.h" 31 32 #include <wtf/IsoMalloc.h> 32 33 … … 40 41 TableFormattingState(Ref<FloatingState>&&, LayoutState&); 41 42 virtual ~TableFormattingState(); 43 44 TableGrid& tableGrid() { return m_tableGrid; } 45 46 private: 47 TableGrid m_tableGrid; 42 48 }; 43 49 -
trunk/Source/WebCore/layout/tableformatting/TableGrid.h
r248595 r248596 28 28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 29 30 #include "FormattingContext.h" 31 #include "TableFormattingState.h" 30 #include "IntPointHash.h" 31 #include "LayoutBox.h" 32 #include <wtf/HashMap.h> 32 33 #include <wtf/IsoMalloc.h> 34 #include <wtf/ListHashSet.h> 35 #include <wtf/WeakPtr.h> 33 36 34 37 namespace WebCore { 35 38 namespace Layout { 36 39 37 // This class implements the layout logic for table formatting contexts. 38 // https://www.w3.org/TR/CSS22/tables.html 39 class TableFormattingContext : public FormattingContext { 40 WTF_MAKE_ISO_ALLOCATED(TableFormattingContext); 40 class TableGrid { 41 WTF_MAKE_ISO_ALLOCATED(TableGrid); 41 42 public: 42 TableFormattingContext(const Box& formattingContextRoot, TableFormattingState&); 43 void layout() const override; 43 TableGrid(); 44 45 void appendCell(const Box&); 46 void insertCell(const Box&, const Box& before); 47 void removeCell(const Box&); 44 48 45 49 private: 46 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override; 50 using SlotPosition = IntPoint; 51 using CellSize = IntSize; 52 using SlotLogicalSize = LayoutSize; 53 54 struct CellInfo : public CanMakeWeakPtr<CellInfo> { 55 CellInfo(const Box& tableCellBox, SlotPosition, CellSize); 56 57 const Box& tableCellBox; 58 SlotPosition position; 59 CellSize size; 60 }; 61 62 struct SlotInfo { 63 SlotInfo() = default; 64 SlotInfo(CellInfo&); 65 66 WeakPtr<CellInfo> cell; 67 SlotLogicalSize size; 68 }; 69 70 using CellList = WTF::ListHashSet<std::unique_ptr<CellInfo>>; 71 using SlotMap = WTF::HashMap<SlotPosition, SlotInfo>; 72 SlotMap m_slotMap; 73 CellList m_cellList; 47 74 }; 48 75
Note: See TracChangeset
for help on using the changeset viewer.