Title: [258473] trunk
Revision
258473
Author
[email protected]
Date
2020-03-14 15:04:00 -0700 (Sat, 14 Mar 2020)

Log Message

[LFC][TFC] Fill in the gaps with anonymous table cell boxes
https://bugs.webkit.org/show_bug.cgi?id=209114
<rdar://problem/60458806>

Reviewed by Antti Koivisto.

Source/WebCore:

17.5 Visual layout of table contents
A "missing cell" is a cell in the row/column grid that is not
occupied by an element or pseudo-element. Missing cells are rendered
as if an anonymous table-cell box occupied their position in the grid.
(https://www.w3.org/TR/CSS22/tables.html)

This helps to keep TableGrid an actual grid.

Test: fast/layoutformattingcontext/table-missing-cells-simple.html

* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::buildTableStructure):

LayoutTests:

* fast/layoutformattingcontext/table-missing-cells-simple-expected.html: Added.
* fast/layoutformattingcontext/table-missing-cells-simple.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (258472 => 258473)


--- trunk/LayoutTests/ChangeLog	2020-03-14 19:53:15 UTC (rev 258472)
+++ trunk/LayoutTests/ChangeLog	2020-03-14 22:04:00 UTC (rev 258473)
@@ -1,3 +1,14 @@
+2020-03-14  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Fill in the gaps with anonymous table cell boxes
+        https://bugs.webkit.org/show_bug.cgi?id=209114
+        <rdar://problem/60458806>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-missing-cells-simple-expected.html: Added.
+        * fast/layoutformattingcontext/table-missing-cells-simple.html: Added.
+
 2020-03-14  Peng Liu  <[email protected]>
 
         Cleanup RenderMediaControls.cpp and RenderMediaControlElements.cpp

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple-expected.html (0 => 258473)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple-expected.html	2020-03-14 22:04:00 UTC (rev 258473)
@@ -0,0 +1,32 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+body {
+    font-size: 10px;
+    padding: 3px;
+}
+span {
+    margin-right: 4px;
+}
+div {
+    margin-bottom: 4px;
+}
+.spacing {
+    margin-top: 6px;
+}
+</style>
+<div>1</div>
+<div><span>1</span><span>2</span></div>
+<div><span>1</span><span>2</span><span>3</span></div>
+<div><span>1</span><span>2</span><span>3</span><span>4</span></div>
+<div><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></div>
+<div class=spacing><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></div>
+<div><span>1</span><span>2</span><span>3</span><span>4</span></div>
+<div><span>1</span><span>2</span><span>3</span></div>
+<div><span>1</span><span>2</span></div>
+<div>1</div>
+<div class=spacing><span>1</span><span>2</span><span>3</span></div>
+<div>1</div>
+<div><span>1</span><span>2</span><span>3</span><span>4</span></div>
+<div><span>1</span><span>2</span></div>
+<div><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></div>
+

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple.html (0 => 258473)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-missing-cells-simple.html	2020-03-14 22:04:00 UTC (rev 258473)
@@ -0,0 +1,27 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+table {
+    font-size: 10px;
+}
+</style>
+<table>
+<tr><td>1</td></tr>
+<tr><td>1</td><td>2</td></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
+</table>
+<table>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+<tr><td>1</td><td>2</td></tr>
+<tr><td>1</td></tr>
+</table>
+<table>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+<tr><td>1</td></tr>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
+<tr><td>1</td><td>2</td></tr>
+<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
+</table>

Modified: trunk/Source/WebCore/ChangeLog (258472 => 258473)


--- trunk/Source/WebCore/ChangeLog	2020-03-14 19:53:15 UTC (rev 258472)
+++ trunk/Source/WebCore/ChangeLog	2020-03-14 22:04:00 UTC (rev 258473)
@@ -1,3 +1,24 @@
+2020-03-14  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Fill in the gaps with anonymous table cell boxes
+        https://bugs.webkit.org/show_bug.cgi?id=209114
+        <rdar://problem/60458806>
+
+        Reviewed by Antti Koivisto.
+
+        17.5 Visual layout of table contents
+        A "missing cell" is a cell in the row/column grid that is not
+        occupied by an element or pseudo-element. Missing cells are rendered
+        as if an anonymous table-cell box occupied their position in the grid.
+        (https://www.w3.org/TR/CSS22/tables.html)
+
+        This helps to keep TableGrid an actual grid.
+
+        Test: fast/layoutformattingcontext/table-missing-cells-simple.html
+
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::buildTableStructure):
+
 2020-03-14  Peng Liu  <[email protected]>
 
         Cleanup RenderMediaControls.cpp and RenderMediaControlElements.cpp

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (258472 => 258473)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-03-14 19:53:15 UTC (rev 258472)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-03-14 22:04:00 UTC (rev 258473)
@@ -304,6 +304,36 @@
         buildSubTree(downcast<RenderElement>(*sectionRenderer), sectionContainer);
         sectionRenderer = sectionRenderer->nextSibling();
     }
+    auto addMissingTableCells = [&] (auto& tableBody) {
+        // A "missing cell" is a cell in the row/column grid that is not occupied by an element or pseudo-element.
+        // Missing cells are rendered as if an anonymous table-cell box occupied their position in the grid.
+
+        // Find the max number of columns and fill in the gaps.
+        size_t maximumColumns = 0;
+        Vector<size_t> numberOfCellsPerRow;
+        for (auto& rowBox : childrenOfType<ContainerBox>(tableBody)) {
+            size_t numberOfCells = 0;
+            for (auto& cellBox : childrenOfType<ContainerBox>(rowBox))
+                numberOfCells += cellBox.columnSpan();
+            numberOfCellsPerRow.append(numberOfCells);
+            maximumColumns = std::max(maximumColumns, numberOfCells);
+        }
+        // Fill in the gaps.
+        size_t rowIndex = 0;
+        for (auto& rowBox : childrenOfType<ContainerBox>(tableBody)) {
+            ASSERT(maximumColumns >= numberOfCellsPerRow[rowIndex]);
+            auto numberOfMissingCells = maximumColumns - numberOfCellsPerRow[rowIndex++];
+            for (size_t i = 0; i < numberOfMissingCells; ++i)
+                appendChild(const_cast<ContainerBox&>(rowBox), createContainer({ }, RenderStyle::createAnonymousStyleWithDisplay(rowBox.style(), DisplayType::TableCell)));
+        }
+    };
+
+    for (auto& section : childrenOfType<ContainerBox>(tableBox)) {
+        // FIXME: Check if headers and footers need the same treatment.
+        if (!section.isTableBody())
+            continue;
+        addMissingTableCells(section);
+    }
 }
 
 void TreeBuilder::buildSubTree(const RenderElement& parentRenderer, ContainerBox& parentContainer)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to