Diff
Modified: trunk/LayoutTests/ChangeLog (262143 => 262144)
--- trunk/LayoutTests/ChangeLog 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/LayoutTests/ChangeLog 2020-05-26 15:54:06 UTC (rev 262144)
@@ -1,3 +1,13 @@
+2020-05-26 Zalan Bujtas <[email protected]>
+
+ [LFC][TFC] Add support for multiple sections
+ https://bugs.webkit.org/show_bug.cgi?id=212354
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/table-simple-multiple-sections-expected.html: Added.
+ * fast/layoutformattingcontext/table-simple-multiple-sections.html: Added.
+
2020-05-26 Jason Lawrence <[email protected]>
REGRESSION: [ Mac wk1 ] fast/events/form-onchange.html is flaky failing.
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-expected.html (0 => 262144)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-expected.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-expected.html 2020-05-26 15:54:06 UTC (rev 262144)
@@ -0,0 +1,14 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+body {
+ margin: 0px;
+}
+div {
+ height: 50px;
+ width: 40px;
+ border: 10px solid green;
+}
+</style>
+<div></div>
+<div style="height: 40px;"></div>
+<div></div>
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections.html (0 => 262144)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections.html 2020-05-26 15:54:06 UTC (rev 262144)
@@ -0,0 +1,50 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+body {
+ margin: 10px;
+}
+table {
+ border-spacing: 0px;
+}
+
+td {
+ width: 20px;
+ height: 20px;
+ padding: 0px;
+}
+
+th {
+ width: 20px;
+ height: 20px;
+ padding: 0px;
+}
+
+thead {
+ outline: 10px solid green;
+}
+
+tbody {
+ outline: 10px solid green;
+}
+
+tfoot {
+ outline: 10px solid green;
+}
+</style>
+<table>
+<thead>
+<tr><th></th><th></th></tr>
+<tr><th></th><th></th></tr>
+<tr><th></th><th></th></tr>
+</thead>
+<tbody>
+<tr><td></td><td></td></tr>
+<tr><td></td><td></td></tr>
+<tr><td></td><td></td></tr>
+</tbody>
+<tfoot>
+<tr><th></th><th></th></tr>
+<tr><th></th><th></th></tr>
+<tr><th></th><th></th></tr>
+</tfoot>
+</table>
Modified: trunk/Source/WebCore/ChangeLog (262143 => 262144)
--- trunk/Source/WebCore/ChangeLog 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/Source/WebCore/ChangeLog 2020-05-26 15:54:06 UTC (rev 262144)
@@ -1,3 +1,29 @@
+2020-05-26 Zalan Bujtas <[email protected]>
+
+ [LFC][TFC] Add support for multiple sections
+ https://bugs.webkit.org/show_bug.cgi?id=212354
+
+ Reviewed by Antti Koivisto.
+
+ Let's keep the grid about rows and columns and about distributing available space.
+ Use the layout tree to find sections.
+
+ Test: fast/layoutformattingcontext/table-simple-multiple-sections.html
+
+ * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+ (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
+ (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
+ (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
+ * layout/tableformatting/TableGrid.cpp:
+ (WebCore::Layout::TableGrid::appendCell):
+ (WebCore::Layout::TableGrid::Section::Section): Deleted.
+ * layout/tableformatting/TableGrid.h:
+ (WebCore::Layout::TableGrid::Section::box const): Deleted.
+ (WebCore::Layout::TableGrid::sections const): Deleted.
+ (WebCore::Layout::TableGrid::sections): Deleted.
+
2020-05-26 Carlos Garcia Campos <[email protected]>
[GTK4] Use screen font options as default
Modified: trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp (262143 => 262144)
--- trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-05-26 15:54:06 UTC (rev 262144)
@@ -111,14 +111,13 @@
bottomBorder = std::max(bottomBorder, geometry().computedBorder(boxInLastRow).vertical.bottom);
}
- auto& sections = grid.sections();
- topBorder = std::max(topBorder, geometry().computedBorder(sections.first().box()).vertical.top);
- for (auto& section : sections) {
- auto horiztonalBorder = geometry().computedBorder(section.box()).horizontal;
+ topBorder = std::max(topBorder, geometry().computedBorder(*tableBox.firstChild()).vertical.top);
+ for (auto& section : childrenOfType<ContainerBox>(tableBox)) {
+ auto horiztonalBorder = geometry().computedBorder(section).horizontal;
leftBorder = std::max(leftBorder, horiztonalBorder.left);
rightBorder = std::max(rightBorder, horiztonalBorder.right);
}
- bottomBorder = std::max(bottomBorder, geometry().computedBorder(sections.last().box()).vertical.bottom);
+ bottomBorder = std::max(bottomBorder, geometry().computedBorder(*tableBox.lastChild()).vertical.bottom);
auto& rows = grid.rows().list();
topBorder = std::max(topBorder, geometry().computedBorder(rows.first().box()).vertical.top);
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (262143 => 262144)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-05-26 15:54:06 UTC (rev 262144)
@@ -68,10 +68,18 @@
auto& columnList = grid.columns().list();
auto& rowList = grid.rows().list();
// Final table cell layout. At this point all percentage values can be resolved.
+ auto sectionOffset = LayoutUnit { };
+ auto* currentSection = &rowList.first().box().parent();
for (auto& cell : grid.cells()) {
auto& cellBox = cell->box();
auto& cellDisplayBox = formattingState().displayBox(cellBox);
- cellDisplayBox.setTop(rowList[cell->startRow()].logicalTop());
+ auto& section = rowList[cell->startRow()].box().parent();
+ if (§ion != currentSection) {
+ currentSection = §ion;
+ // While the grid is a continuous flow of rows, in the display tree they are relative to their sections.
+ sectionOffset = rowList[cell->startRow()].logicalTop();
+ }
+ cellDisplayBox.setTop(rowList[cell->startRow()].logicalTop() - sectionOffset);
cellDisplayBox.setLeft(columnList[cell->startColumn()].logicalLeft());
auto availableVerticalSpace = rowList[cell->startRow()].logicalHeight();
for (size_t rowIndex = cell->startRow() + 1; rowIndex < cell->endRow(); ++rowIndex)
@@ -78,7 +86,6 @@
availableVerticalSpace += rowList[rowIndex].logicalHeight();
availableVerticalSpace += (cell->rowSpan() - 1) * grid.verticalSpacing();
layoutCell(*cell, availableHorizontalSpace, availableVerticalSpace);
-
// FIXME: Find out if it is ok to use the regular padding here to align the content box inside a tall cell or we need to
// use some kind of intrinsic padding similar to RenderTableCell.
auto paddingTop = cellDisplayBox.paddingTop().valueOr(LayoutUnit { });
@@ -114,6 +121,7 @@
auto& rows = grid.rows().list();
auto rowLogicalTop = grid.verticalSpacing();
+ const ContainerBox* previousRow = nullptr;
for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) {
auto& row = rows[rowIndex];
auto& rowBox = row.box();
@@ -125,7 +133,6 @@
rowDisplayBox.setHorizontalComputedMargin({ });
rowDisplayBox.setVerticalMargin({ { }, { } });
-
auto computedRowBorder = [&] {
auto border = geometry().computedBorder(rowBox);
if (!grid.collapsedBorder())
@@ -157,14 +164,17 @@
computedRowBorder.horizontal.right = { };
}
rowDisplayBox.setContentBoxWidth(rowLogicalWidth - computedRowBorder.width());
-
rowDisplayBox.setBorder(computedRowBorder);
+ if (previousRow && &previousRow->parent() != &rowBox.parent()) {
+ // This row is in a different section.
+ rowLogicalTop = { };
+ }
rowDisplayBox.setTop(rowLogicalTop);
rowDisplayBox.setLeft({ });
- row.setLogicalTop(rowLogicalTop);
rowLogicalTop += row.logicalHeight() + grid.verticalSpacing();
+ previousRow = &rowBox;
}
auto& columns = grid.columns();
@@ -190,8 +200,7 @@
auto& grid = formattingState().tableGrid();
auto sectionWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
auto logicalTop = constraints.vertical.logicalTop;
- for (auto& section : grid.sections()) {
- auto& sectionBox = section.box();
+ for (auto& sectionBox : childrenOfType<ContainerBox>(root())) {
auto& sectionDisplayBox = formattingState().displayBox(sectionBox);
// Section borders are either collapsed or ignored.
sectionDisplayBox.setBorder({ });
@@ -202,8 +211,12 @@
sectionDisplayBox.setVerticalMargin({ { }, { } });
sectionDisplayBox.setContentBoxWidth(sectionWidth);
- sectionDisplayBox.setContentBoxHeight(grid.rows().list().last().logicalBottom() + grid.verticalSpacing());
-
+ auto sectionContentHeight = LayoutUnit { };
+ for (auto& rowBox : childrenOfType<ContainerBox>(sectionBox))
+ sectionContentHeight += geometryForBox(rowBox).height() + grid.verticalSpacing();
+ // FIXME: Let's try not add vertical spacing to the content box.
+ sectionContentHeight += grid.verticalSpacing();
+ sectionDisplayBox.setContentBoxHeight(sectionContentHeight);
sectionDisplayBox.setLeft(constraints.horizontal.logicalLeft);
sectionDisplayBox.setTop(logicalTop);
Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp (262143 => 262144)
--- trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp 2020-05-26 15:54:06 UTC (rev 262144)
@@ -35,11 +35,6 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(TableGrid);
-TableGrid::Section::Section(const ContainerBox& sectionBox)
- : m_layoutBox(makeWeakPtr(sectionBox))
-{
-}
-
TableGrid::Column::Column(const ContainerBox* columnBox)
: m_layoutBox(makeWeakPtr(columnBox))
{
@@ -183,14 +178,6 @@
if (isInNewRow)
m_rows.addRow(cellBox.parent());
- auto& lastRowBox = m_rows.list().last().box();
- auto needsNewSection = m_sections.isEmpty() || &lastRowBox.parent() != &m_sections.last().box();
- if (needsNewSection) {
- auto& tableSection = lastRowBox.parent();
- ASSERT(tableSection.isTableHeader() || tableSection.isTableBody() || tableSection.isTableFooter());
- m_sections.append({ tableSection });
- }
-
m_cells.add(WTFMove(cell));
}
Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (262143 => 262144)
--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h 2020-05-26 15:42:09 UTC (rev 262143)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h 2020-05-26 15:54:06 UTC (rev 262144)
@@ -61,16 +61,6 @@
void setWidthConstraints(FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraints) { m_intrinsicWidthConstraints = intrinsicWidthConstraints; }
Optional<FormattingContext::IntrinsicWidthConstraints> widthConstraints() const { return m_intrinsicWidthConstraints; }
- class Section {
- public:
- Section(const ContainerBox&);
-
- const ContainerBox& box() const { return *m_layoutBox.get(); }
-
- private:
- WeakPtr<const ContainerBox> m_layoutBox;
- };
-
// Column represents a vertical set of slots in the grid. A column has horizontal position and width.
class Column {
public:
@@ -217,10 +207,6 @@
FormattingContext::IntrinsicWidthConstraints m_widthConstraints;
};
- using Sections = Vector<Section>;
- const Sections& sections() const { return m_sections; }
- Sections& sections() { return m_sections; }
-
const Columns& columns() const { return m_columns; }
Columns& columns() { return m_columns; }
@@ -240,7 +226,6 @@
Columns m_columns;
Rows m_rows;
Cells m_cells;
- Sections m_sections;
SlotMap m_slotMap;
LayoutUnit m_horizontalSpacing;