Changeset 278279 in webkit
- Timestamp:
- May 31, 2021, 8:47:28 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
layout/formattingContexts/table/TableFormattingContext.cpp (modified) (1 diff)
-
layout/formattingContexts/table/TableFormattingContext.h (modified) (1 diff)
-
layout/formattingContexts/table/TableFormattingState.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278277 r278279 1 2021-05-31 Alan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Move ensureTableGrid to TableFormattingState 4 https://bugs.webkit.org/show_bug.cgi?id=226424 5 6 Reviewed by Antti Koivisto. 7 8 We can certainly have this much logic in a formatting state class. 9 10 * layout/formattingContexts/table/TableFormattingContext.cpp: 11 (WebCore::Layout::TableFormattingContext::ensureTableGrid): Deleted. 12 * layout/formattingContexts/table/TableFormattingContext.h: 13 * layout/formattingContexts/table/TableFormattingState.cpp: 14 (WebCore::Layout::ensureTableGrid): 15 (WebCore::Layout::TableFormattingState::TableFormattingState): 16 1 17 2021-05-31 Antti Koivisto <antti@apple.com> 2 18 -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp
r278253 r278279 340 340 } 341 341 342 UniqueRef<TableGrid> TableFormattingContext::ensureTableGrid(const ContainerBox& tableBox)343 {344 auto tableGrid = makeUniqueRef<TableGrid>();345 auto& tableStyle = tableBox.style();346 auto shouldApplyBorderSpacing = tableStyle.borderCollapse() == BorderCollapse::Separate;347 tableGrid->setHorizontalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.horizontalBorderSpacing() : 0 });348 tableGrid->setVerticalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.verticalBorderSpacing() : 0 });349 350 auto* firstChild = tableBox.firstChild();351 if (!firstChild) {352 // The rare case of empty table.353 return tableGrid;354 }355 356 const Box* tableCaption = nullptr;357 const Box* colgroup = nullptr;358 // Table caption is an optional element; if used, it is always the first child of a <table>.359 if (firstChild->isTableCaption())360 tableCaption = firstChild;361 // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element.362 auto* colgroupCandidate = firstChild;363 if (tableCaption)364 colgroupCandidate = tableCaption->nextSibling();365 if (colgroupCandidate->isTableColumnGroup())366 colgroup = colgroupCandidate;367 368 if (colgroup) {369 auto& columns = tableGrid->columns();370 for (auto* column = downcast<ContainerBox>(*colgroup).firstChild(); column; column = column->nextSibling()) {371 ASSERT(column->isTableColumn());372 auto columnSpanCount = column->columnSpan();373 ASSERT(columnSpanCount > 0);374 while (columnSpanCount--)375 columns.addColumn(downcast<ContainerBox>(*column));376 }377 }378 379 auto* firstSection = colgroup ? colgroup->nextSibling() : tableCaption ? tableCaption->nextSibling() : firstChild;380 for (auto* section = firstSection; section; section = section->nextSibling()) {381 ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter());382 for (auto* row = downcast<ContainerBox>(*section).firstChild(); row; row = row->nextSibling()) {383 ASSERT(row->isTableRow());384 for (auto* cell = downcast<ContainerBox>(*row).firstChild(); cell; cell = cell->nextSibling()) {385 ASSERT(cell->isTableCell());386 tableGrid->appendCell(downcast<ContainerBox>(*cell));387 }388 }389 }390 return tableGrid;391 }392 393 342 IntrinsicWidthConstraints TableFormattingContext::computedPreferredWidthForColumns() 394 343 { -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h
r278253 r278279 52 52 const TableFormattingGeometry& formattingGeometry() const final { return m_tableFormattingGeometry; } 53 53 const TableFormattingQuirks& formattingQuirks() const final { return m_tableFormattingQuirks; } 54 55 static UniqueRef<TableGrid> ensureTableGrid(const ContainerBox& tableBox);56 57 54 const TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); } 58 55 -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingState.cpp
r276886 r278279 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(TableFormattingState); 38 38 39 static UniqueRef<TableGrid> ensureTableGrid(const ContainerBox& tableBox) 40 { 41 auto tableGrid = makeUniqueRef<TableGrid>(); 42 auto& tableStyle = tableBox.style(); 43 auto shouldApplyBorderSpacing = tableStyle.borderCollapse() == BorderCollapse::Separate; 44 tableGrid->setHorizontalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.horizontalBorderSpacing() : 0 }); 45 tableGrid->setVerticalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.verticalBorderSpacing() : 0 }); 46 47 auto* firstChild = tableBox.firstChild(); 48 if (!firstChild) { 49 // The rare case of empty table. 50 return tableGrid; 51 } 52 53 const Box* tableCaption = nullptr; 54 const Box* colgroup = nullptr; 55 // Table caption is an optional element; if used, it is always the first child of a <table>. 56 if (firstChild->isTableCaption()) 57 tableCaption = firstChild; 58 // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element. 59 auto* colgroupCandidate = firstChild; 60 if (tableCaption) 61 colgroupCandidate = tableCaption->nextSibling(); 62 if (colgroupCandidate->isTableColumnGroup()) 63 colgroup = colgroupCandidate; 64 65 if (colgroup) { 66 auto& columns = tableGrid->columns(); 67 for (auto* column = downcast<ContainerBox>(*colgroup).firstChild(); column; column = column->nextSibling()) { 68 ASSERT(column->isTableColumn()); 69 auto columnSpanCount = column->columnSpan(); 70 ASSERT(columnSpanCount > 0); 71 while (columnSpanCount--) 72 columns.addColumn(downcast<ContainerBox>(*column)); 73 } 74 } 75 76 auto* firstSection = colgroup ? colgroup->nextSibling() : tableCaption ? tableCaption->nextSibling() : firstChild; 77 for (auto* section = firstSection; section; section = section->nextSibling()) { 78 ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter()); 79 for (auto* row = downcast<ContainerBox>(*section).firstChild(); row; row = row->nextSibling()) { 80 ASSERT(row->isTableRow()); 81 for (auto* cell = downcast<ContainerBox>(*row).firstChild(); cell; cell = cell->nextSibling()) { 82 ASSERT(cell->isTableCell()); 83 tableGrid->appendCell(downcast<ContainerBox>(*cell)); 84 } 85 } 86 } 87 return tableGrid; 88 } 89 90 39 91 TableFormattingState::TableFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState, const ContainerBox& tableBox) 40 92 : FormattingState(WTFMove(floatingState), Type::Table, layoutState) 41 , m_tableGrid( TableFormattingContext::ensureTableGrid(tableBox))93 , m_tableGrid(ensureTableGrid(tableBox)) 42 94 { 43 95 }
Note:
See TracChangeset
for help on using the changeset viewer.