Title: [261919] trunk
Revision
261919
Author
[email protected]
Date
2020-05-20 08:34:24 -0700 (Wed, 20 May 2020)

Log Message

[LFC][TFC] Internal table boxes should take collapsed border into account
https://bugs.webkit.org/show_bug.cgi?id=212135

Source/WebCore:

Reviewed by Antti Koivisto.

Use the collapsed border value to compute the borders for sections, rows and cells.
The collapsed border is propagated to the table box and the adjacent cell boxes.

Test: fast/layoutformattingcontext/table-simple-border-collapse.html

* layout/LayoutUnits.h:
(WebCore::Layout::operator/):
* layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
(WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
(WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
(WebCore::Layout::TableFormattingContext::layoutCell):
* layout/tableformatting/TableGrid.h:
(WebCore::Layout::TableGrid::setCollapsedBorder):
(WebCore::Layout::TableGrid::collapsedBorder const):

LayoutTests:

Reviewed by Antti Koivisto.

* fast/layoutformattingcontext/table-simple-border-collapse-expected.html: Added.
* fast/layoutformattingcontext/table-simple-border-collapse.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261918 => 261919)


--- trunk/LayoutTests/ChangeLog	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/LayoutTests/ChangeLog	2020-05-20 15:34:24 UTC (rev 261919)
@@ -1,3 +1,13 @@
+2020-05-20  Alan Kinsley  <[email protected]>
+
+        [LFC][TFC] Internal table boxes should take collapsed border into account
+        https://bugs.webkit.org/show_bug.cgi?id=212135
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-simple-border-collapse-expected.html: Added.
+        * fast/layoutformattingcontext/table-simple-border-collapse.html: Added.
+
 2020-05-20  Zan Dobersek  <[email protected]>
 
         Unreviewed WPE gardening. Enabling the remaining unskippable CSS3 tests

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse-expected.html (0 => 261919)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse-expected.html	2020-05-20 15:34:24 UTC (rev 261919)
@@ -0,0 +1,9 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    height: 10px;
+    width: 10px;
+    border: 20px solid green;
+}
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse.html (0 => 261919)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse.html	2020-05-20 15:34:24 UTC (rev 261919)
@@ -0,0 +1,15 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+table {
+    border-collapse: collapse;
+    border: 20px solid green;
+}
+
+td {
+    width: 10px;
+    height: 10px;
+    border: 10px solid green;
+    padding: 0px;
+}
+</style>
+<table><tr><td></td></tr></tbody></table>

Modified: trunk/Source/WebCore/ChangeLog (261918 => 261919)


--- trunk/Source/WebCore/ChangeLog	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/Source/WebCore/ChangeLog	2020-05-20 15:34:24 UTC (rev 261919)
@@ -1,3 +1,27 @@
+2020-05-20  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Internal table boxes should take collapsed border into account
+        https://bugs.webkit.org/show_bug.cgi?id=212135
+
+        Reviewed by Antti Koivisto.
+
+        Use the collapsed border value to compute the borders for sections, rows and cells.
+        The collapsed border is propagated to the table box and the adjacent cell boxes.  
+
+        Test: fast/layoutformattingcontext/table-simple-border-collapse.html
+
+        * layout/LayoutUnits.h:
+        (WebCore::Layout::operator/):
+        * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+        (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
+        (WebCore::Layout::TableFormattingContext::layoutCell):
+        * layout/tableformatting/TableGrid.h:
+        (WebCore::Layout::TableGrid::setCollapsedBorder):
+        (WebCore::Layout::TableGrid::collapsedBorder const):
+
 2020-05-20  Youenn Fablet  <[email protected]>
 
         [Mac] Use preferedPixelBufferFormat for AVVideoCaptureSource

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (261918 => 261919)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2020-05-20 15:34:24 UTC (rev 261919)
@@ -131,6 +131,11 @@
     VerticalEdges vertical;
 };
 
+inline Edges operator/(const Edges& edge, size_t value)
+{
+    return { { edge.horizontal.left / value, edge.horizontal.right / value }, { edge.vertical.top / value, edge.vertical.bottom / value } };
+}
+
 struct ContentWidthAndMargin {
     LayoutUnit contentWidth;
     UsedHorizontalMargin usedMargin;

Modified: trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp (261918 => 261919)


--- trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp	2020-05-20 15:34:24 UTC (rev 261919)
@@ -110,10 +110,11 @@
             topBorder = std::max(topBorder, geometry().computedBorder(boxInFirstRox).vertical.top);
             bottomBorder = std::max(bottomBorder, geometry().computedBorder(boxInLastRow).vertical.bottom);
         }
-        auto collapsedBorder = Edges { { leftBorder / 2, rightBorder / 2 }, { topBorder / 2, bottomBorder / 2 } };
+        auto collapsedBorder = Edges { { leftBorder, rightBorder }, { topBorder, bottomBorder } };
+        grid.setCollapsedBorder(collapsedBorder);
 
         auto& displayBox = formattingState().displayBox(tableBox);
-        displayBox.setBorder(collapsedBorder);
+        displayBox.setBorder(collapsedBorder / 2);
         displayBox.setPadding(geometry().computedPadding(tableBox, horizontalConstraints.logicalWidth));
         return;
     }

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (261918 => 261919)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-20 15:34:24 UTC (rev 261919)
@@ -115,10 +115,25 @@
 
     auto rowWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
     auto rowLogicalTop = grid.verticalSpacing();
-    for (auto& row : rows) {
+    for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) {
+        auto& row = rows[rowIndex];
         auto& rowBox = row.box();
         auto& rowDisplayBox = formattingState().displayBox(rowBox);
-        computeBorderAndPadding(rowBox, HorizontalConstraints { { }, availableHorizontalSpace });
+
+        auto computedRowBorder = [&] {
+            auto border = geometry().computedBorder(rowBox);
+            if (!grid.collapsedBorder())
+                return border;
+            // Border collapsing delegates borders to table/cells.
+            border.horizontal = { };
+            if (!rowIndex)
+                border.vertical.top = { };
+            if (rowIndex == rows.size() - 1)
+                border.vertical.bottom = { };
+            return border;
+        }();
+        rowDisplayBox.setBorder(computedRowBorder);
+        rowDisplayBox.setPadding(geometry().computedPadding(rowBox, availableHorizontalSpace));
         // Internal table elements do not have margins.
         rowDisplayBox.setHorizontalMargin({ });
         rowDisplayBox.setHorizontalComputedMargin({ });
@@ -158,7 +173,9 @@
     auto logicalTop = constraints.vertical.logicalTop;
     for (auto& section : childrenOfType<ContainerBox>(root())) {
         auto& sectionDisplayBox = formattingState().displayBox(section);
-        computeBorderAndPadding(section, HorizontalConstraints { { }, constraints.horizontal.logicalWidth });
+        // FIXME: Multiple sections can have their own borders.
+        sectionDisplayBox.setBorder(grid.collapsedBorder() ? Edges(): geometry().computedBorder(section));
+        sectionDisplayBox.setPadding(geometry().computedPadding(section, constraints.horizontal.logicalWidth));
         // Internal table elements do not have margins.
         sectionDisplayBox.setHorizontalMargin({ });
         sectionDisplayBox.setHorizontalComputedMargin({ });
@@ -178,10 +195,28 @@
 {
     ASSERT(cell.box().establishesBlockFormattingContext());
 
+    auto& grid = formattingState().tableGrid();
     auto& cellBox = cell.box();
     auto& cellDisplayBox = formattingState().displayBox(cellBox);
 
-    computeBorderAndPadding(cellBox, HorizontalConstraints { { }, availableHorizontalSpace });
+    auto computedCellBorder = [&] {
+        auto border = geometry().computedBorder(cellBox);
+        auto collapsedBorder = grid.collapsedBorder();
+        if (!collapsedBorder)
+            return border;
+        auto cellPosition = cell.position();
+        if (!cellPosition.column)
+            border.horizontal.left = collapsedBorder->horizontal.left / 2;
+        if (cellPosition.column == grid.columns().size() - 1)
+            border.horizontal.right = collapsedBorder->horizontal.right / 2;
+        if (!cellPosition.row)
+            border.vertical.top = collapsedBorder->vertical.top / 2;
+        if (cellPosition.row == grid.rows().size() - 1)
+            border.vertical.bottom = collapsedBorder->vertical.bottom / 2;
+        return border;
+    }();
+    cellDisplayBox.setBorder(computedCellBorder);
+    cellDisplayBox.setPadding(geometry().computedPadding(cellBox, availableHorizontalSpace));
     // Internal table elements do not have margins.
     cellDisplayBox.setHorizontalMargin({ });
     cellDisplayBox.setHorizontalComputedMargin({ });
@@ -188,7 +223,6 @@
     cellDisplayBox.setVerticalMargin({ { }, { } });
 
     auto availableSpaceForContent = [&] {
-        auto& grid = formattingState().tableGrid();
         auto& columnList = grid.columns().list();
         auto logicalWidth = LayoutUnit { };
         for (auto columnIndex = cell.startColumn(); columnIndex < cell.endColumn(); ++columnIndex)

Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (261918 => 261919)


--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2020-05-20 15:20:10 UTC (rev 261918)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2020-05-20 15:34:24 UTC (rev 261919)
@@ -55,6 +55,9 @@
     void setVerticalSpacing(LayoutUnit verticalSpacing) { m_verticalSpacing = verticalSpacing; }
     LayoutUnit verticalSpacing() const { return m_verticalSpacing; }
 
+    void setCollapsedBorder(const Edges& collapsedBorder) { m_collapsedBorder = collapsedBorder; }
+    Optional<Edges> collapsedBorder() const { return m_collapsedBorder; }
+
     void setWidthConstraints(FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraints) { m_intrinsicWidthConstraints = intrinsicWidthConstraints; }
     Optional<FormattingContext::IntrinsicWidthConstraints> widthConstraints() const { return m_intrinsicWidthConstraints; }
 
@@ -228,6 +231,7 @@
     LayoutUnit m_horizontalSpacing;
     LayoutUnit m_verticalSpacing;
     Optional<FormattingContext::IntrinsicWidthConstraints> m_intrinsicWidthConstraints;
+    Optional<Edges> m_collapsedBorder;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to