Title: [262148] trunk
Revision
262148
Author
[email protected]
Date
2020-05-26 09:53:11 -0700 (Tue, 26 May 2020)

Log Message

[LFC][TFC] Use padding to space out sections
https://bugs.webkit.org/show_bug.cgi?id=212377

Reviewed by Antti Koivisto.

Source/WebCore:

Use fake padding before/after to space out sections.

Test: fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html

* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):

LayoutTests:

* fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse-expected.html: Added.
* fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (262147 => 262148)


--- trunk/LayoutTests/ChangeLog	2020-05-26 16:17:44 UTC (rev 262147)
+++ trunk/LayoutTests/ChangeLog	2020-05-26 16:53:11 UTC (rev 262148)
@@ -1,3 +1,13 @@
+2020-05-26  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Use padding to space out sections
+        https://bugs.webkit.org/show_bug.cgi?id=212377
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse-expected.html: Added.
+        * fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html: Added.
+
 2020-05-26  Chris Dumez  <[email protected]>
 
         Unskip fast/events/form-onchange.html after r262145.

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse-expected.html (0 => 262148)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse-expected.html	2020-05-26 16:53:11 UTC (rev 262148)
@@ -0,0 +1,8 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    border: 10px solid green;
+}
+</style>
+<div style="height: 70px; width: 70px;"></div>
+<div style="height: 40px; width: 40px;"></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html (0 => 262148)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html	2020-05-26 16:53:11 UTC (rev 262148)
@@ -0,0 +1,36 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+table {
+    border-spacing: 10px;
+    border: 10px solid green;
+}
+
+td {
+    width: 20px;
+    height: 20px;
+    padding: 0px;
+}
+
+th {
+    width: 20px;
+    height: 20px;
+    padding: 0px;
+}
+</style>
+<table>
+<thead>
+<tr><th></th><th></th></tr>
+</thead>
+<tbody>
+<tr><td></td><td></td></tr>
+</tbody>
+</table>
+
+<table style="border-collapse: collapse;">
+<thead>
+<tr><th></th><th></th></tr>
+</thead>
+<tbody>
+<tr><td></td><td></td></tr>
+</tbody>
+</table>

Modified: trunk/Source/WebCore/ChangeLog (262147 => 262148)


--- trunk/Source/WebCore/ChangeLog	2020-05-26 16:17:44 UTC (rev 262147)
+++ trunk/Source/WebCore/ChangeLog	2020-05-26 16:53:11 UTC (rev 262148)
@@ -1,3 +1,17 @@
+2020-05-26  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Use padding to space out sections
+        https://bugs.webkit.org/show_bug.cgi?id=212377
+
+        Reviewed by Antti Koivisto.
+
+        Use fake padding before/after to space out sections.
+
+        Test: fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html
+
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
+
 2020-05-26  Keith Rollin  <[email protected]>
 
         Enable the use of XCBuild by default in Apple builds

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (262147 => 262148)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-26 16:17:44 UTC (rev 262147)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-26 16:53:11 UTC (rev 262148)
@@ -198,13 +198,19 @@
 void TableFormattingContext::setUsedGeometryForSections(const ConstraintsForInFlowContent& constraints)
 {
     auto& grid = formattingState().tableGrid();
+    auto& tableBox = root();
     auto sectionWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
     auto logicalTop = constraints.vertical.logicalTop;
-    for (auto& sectionBox : childrenOfType<ContainerBox>(root())) {
+    auto verticalSpacing = grid.verticalSpacing();
+    auto paddingBefore = Optional<LayoutUnit> { verticalSpacing };
+    auto paddingAfter = verticalSpacing;
+    for (auto& sectionBox : childrenOfType<ContainerBox>(tableBox)) {
         auto& sectionDisplayBox = formattingState().displayBox(sectionBox);
         // Section borders are either collapsed or ignored.
         sectionDisplayBox.setBorder({ });
-        sectionDisplayBox.setPadding(geometry().computedPadding(sectionBox, constraints.horizontal.logicalWidth));
+        // Use fake vertical padding to space out the sections.
+        sectionDisplayBox.setPadding(Edges { { }, { paddingBefore.valueOr(0_lu), paddingAfter } });
+        paddingBefore = WTF::nullopt;
         // Internal table elements do not have margins.
         sectionDisplayBox.setHorizontalMargin({ });
         sectionDisplayBox.setHorizontalComputedMargin({ });
@@ -212,10 +218,12 @@
 
         sectionDisplayBox.setContentBoxWidth(sectionWidth);
         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();
+        size_t rowCount = 0;
+        for (auto& rowBox : childrenOfType<ContainerBox>(sectionBox)) {
+            sectionContentHeight += geometryForBox(rowBox).height();
+            ++rowCount;
+        }
+        sectionContentHeight += verticalSpacing * (rowCount - 1);
         sectionDisplayBox.setContentBoxHeight(sectionContentHeight);
         sectionDisplayBox.setLeft(constraints.horizontal.logicalLeft);
         sectionDisplayBox.setTop(logicalTop);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to