Title: [261991] trunk
Revision
261991
Author
[email protected]
Date
2020-05-21 05:33:00 -0700 (Thu, 21 May 2020)

Log Message

[LFC][TFC] Collapse in-between cell borders
https://bugs.webkit.org/show_bug.cgi?id=212183

Reviewed by Antti Koivisto.

Source/WebCore:

This patch expands border collapsing to in-between cell borders.

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

* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::layoutCell):
* layout/tableformatting/TableFormattingContext.h:
* layout/tableformatting/TableFormattingContextGeometry.cpp:
(WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
(WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261990 => 261991)


--- trunk/LayoutTests/ChangeLog	2020-05-21 10:50:54 UTC (rev 261990)
+++ trunk/LayoutTests/ChangeLog	2020-05-21 12:33:00 UTC (rev 261991)
@@ -1,3 +1,13 @@
+2020-05-21  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Collapse in-between cell borders
+        https://bugs.webkit.org/show_bug.cgi?id=212183
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-simple-border-collapse3-expected.html: Added.
+        * fast/layoutformattingcontext/table-simple-border-collapse3.html: Added.
+
 2020-05-21  Diego Pino Garcia  <[email protected]>
 
         [WPE] Gardening, remove tests passing after 261987

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


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse3-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse3-expected.html	2020-05-21 12:33:00 UTC (rev 261991)
@@ -0,0 +1,15 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    height: 10px;
+    width: 10px;
+    border: 0px solid green;
+    position: absolute;
+}
+</style>
+<div style="border-width: 20px 5px 1px 20px; height: 14px;"></div>
+<div style="top: 8px; left: 43px; border-width: 20px 5px 5px 5px;"></div>
+<div style="top: 8px; left: 63px; border-width: 20px 20px 1px 5px; height: 14px;"></div>
+<div style="top: 43px; left: 8px; border-width: 1px 5px 20px 20px; height: 14px;"></div>
+<div style="top: 43px; left: 43px; border-width: 5px 5px 20px 5px;"></div>
+<div style="top: 43px; left: 63px; border-width: 1px 20px 20px 5px; height: 14px;"></div>

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


--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse3.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-border-collapse3.html	2020-05-21 12:33:00 UTC (rev 261991)
@@ -0,0 +1,19 @@
+<!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: 2px solid green;
+    padding: 0px;
+}
+</style>
+<table>
+<tr><td></td><td style="border-width: 10px"></td><td></td></tr>
+<tr><td></td><td style="border-width: 10px"></td><td></td></tr>
+</tbody>
+</table>

Modified: trunk/Source/WebCore/ChangeLog (261990 => 261991)


--- trunk/Source/WebCore/ChangeLog	2020-05-21 10:50:54 UTC (rev 261990)
+++ trunk/Source/WebCore/ChangeLog	2020-05-21 12:33:00 UTC (rev 261991)
@@ -1,3 +1,21 @@
+2020-05-21  Zalan Bujtas  <[email protected]>
+
+        [LFC][TFC] Collapse in-between cell borders
+        https://bugs.webkit.org/show_bug.cgi?id=212183
+
+        Reviewed by Antti Koivisto.
+
+        This patch expands border collapsing to in-between cell borders.
+
+        Test: fast/layoutformattingcontext/table-simple-border-collapse3.html
+
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::layoutCell):
+        * layout/tableformatting/TableFormattingContext.h:
+        * layout/tableformatting/TableFormattingContextGeometry.cpp:
+        (WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
+        (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
+
 2020-05-21  Enrique Ocaña González  <[email protected]>
 
         [GStreamer][GTK][WPE] Expose and honor the media content types requiring hardware support setting

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (261990 => 261991)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-21 10:50:54 UTC (rev 261990)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-05-21 12:33:00 UTC (rev 261991)
@@ -199,23 +199,7 @@
     auto& cellBox = cell.box();
     auto& cellDisplayBox = formattingState().displayBox(cellBox);
 
-    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.setBorder(geometry().computedCellBorder(cell));
     cellDisplayBox.setPadding(geometry().computedPadding(cellBox, availableHorizontalSpace));
     // Internal table elements do not have margins.
     cellDisplayBox.setHorizontalMargin({ });

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h (261990 => 261991)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2020-05-21 10:50:54 UTC (rev 261990)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2020-05-21 12:33:00 UTC (rev 261991)
@@ -66,6 +66,7 @@
     class Geometry : public FormattingContext::Geometry {
     public:
         LayoutUnit cellHeigh(const ContainerBox&) const;
+        Edges computedCellBorder(const TableGrid::Cell&) const;
         Optional<LayoutUnit> computedColumnWidth(const ContainerBox& columnBox) const;
         FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraintsForCell(const TableGrid::Cell&);
         InlineLayoutUnit usedBaselineForCell(const ContainerBox& cellBox);

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp (261990 => 261991)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2020-05-21 10:50:54 UTC (rev 261990)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2020-05-21 12:33:00 UTC (rev 261991)
@@ -46,6 +46,43 @@
     return contentHeightForFormattingContextRoot(cellBox);
 }
 
+Edges TableFormattingContext::Geometry::computedCellBorder(const TableGrid::Cell& cell) const
+{
+    auto& cellBox = cell.box();
+    auto border = computedBorder(cellBox);
+    auto collapsedBorder = m_grid.collapsedBorder();
+    if (!collapsedBorder)
+        return border;
+
+    // We might want to cache these collapsed borders on the grid.
+    auto cellPosition = cell.position();
+    if (!cellPosition.column)
+        border.horizontal.left = collapsedBorder->horizontal.left / 2;
+    else {
+        auto adjacentBorderRight = computedBorder(m_grid.slot({ cellPosition.column - 1, cellPosition.row })->cell().box()).horizontal.right;
+        border.horizontal.left = std::max(border.horizontal.left, adjacentBorderRight) / 2;
+    }
+    if (cellPosition.column == m_grid.columns().size() - 1)
+        border.horizontal.right = collapsedBorder->horizontal.right / 2;
+    else {
+        auto adjacentBorderLeft = computedBorder(m_grid.slot({ cellPosition.column + 1, cellPosition.row })->cell().box()).horizontal.left;
+        border.horizontal.right = std::max(border.horizontal.right, adjacentBorderLeft) / 2;
+    }
+    if (!cellPosition.row)
+        border.vertical.top = collapsedBorder->vertical.top / 2;
+    else {
+        auto adjacentBorderBottom = computedBorder(m_grid.slot({ cellPosition.column, cellPosition.row - 1 })->cell().box()).vertical.bottom;
+        border.vertical.top = std::max(border.vertical.top, adjacentBorderBottom) / 2;
+    }
+    if (cellPosition.row == m_grid.rows().size() - 1)
+        border.vertical.bottom = collapsedBorder->vertical.bottom / 2;
+    else {
+        auto adjacentBorderTop = computedBorder(m_grid.slot({ cellPosition.column, cellPosition.row + 1 })->cell().box()).vertical.top;
+        border.vertical.bottom = std::max(border.vertical.bottom, adjacentBorderTop) / 2;
+    }
+    return border;
+}
+
 Optional<LayoutUnit> TableFormattingContext::Geometry::computedColumnWidth(const ContainerBox& columnBox) const
 {
     // Check both style and <col>'s width attribute.
@@ -60,19 +97,6 @@
     auto& cellBox = cell.box();
     auto& style = cellBox.style();
 
-    auto computedHorizontalBorder = [&] {
-        auto leftBorderWidth = LayoutUnit { style.borderLeftWidth() };
-        auto rightBorderWidth = LayoutUnit { style.borderRightWidth() };
-        if (auto collapsedBorder = m_grid.collapsedBorder()) {
-            auto cellPosition = cell.position();
-            if (!cellPosition.column)
-                leftBorderWidth = collapsedBorder->horizontal.left / 2;
-            if (cellPosition.column == m_grid.columns().size() - 1)
-                rightBorderWidth = collapsedBorder->horizontal.right / 2;
-        }
-        return leftBorderWidth + rightBorderWidth;
-    };
-
     auto computedIntrinsicWidthConstraints = [&] {
         // Even fixed width cells expand to their minimum content width
         // <td style="width: 10px">test_content</td> will size to max(minimum content width, computed width).
@@ -79,7 +103,7 @@
         auto intrinsicWidthConstraints = FormattingContext::IntrinsicWidthConstraints { };
         if (cellBox.hasChild())
             intrinsicWidthConstraints = LayoutContext::createFormattingContext(cellBox, layoutState())->computedIntrinsicWidthConstraints();
-        if (auto width = fixedValue(cellBox.style().logicalWidth()))
+        if (auto width = fixedValue(style.logicalWidth()))
             return FormattingContext::IntrinsicWidthConstraints { std::max(intrinsicWidthConstraints.minimum, *width), *width };
         return intrinsicWidthConstraints;
     };
@@ -86,7 +110,7 @@
     // FIXME Check for box-sizing: border-box;
     auto intrinsicWidthConstraints = constrainByMinMaxWidth(cellBox, computedIntrinsicWidthConstraints());
     // Expand with border
-    intrinsicWidthConstraints.expand(computedHorizontalBorder());
+    intrinsicWidthConstraints.expand(computedCellBorder(cell).horizontal.width());
     // padding
     intrinsicWidthConstraints.expand(fixedValue(style.paddingLeft()).valueOr(0) + fixedValue(style.paddingRight()).valueOr(0));
     // and margin
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to