- Revision
- 262097
- Author
- [email protected]
- Date
- 2020-05-23 06:34:47 -0700 (Sat, 23 May 2020)
Log Message
[LFC][TFC] Non-collapsing row border should not make the table wider/taller
https://bugs.webkit.org/show_bug.cgi?id=212263
Reviewed by Antti Koivisto.
Source/WebCore:
Non-collapsing row border eats into the content box but oddly it does not
constraint the cell boxes, so we can end up with smaller row content box than
the cell box it contains.
Test: fast/layoutformattingcontext/table-simple-row-border.html
* layout/LayoutUnits.h:
(WebCore::Layout::Edges::width const):
(WebCore::Layout::Edges::height const):
(WebCore::Layout::HorizontalEdges::width const): Deleted.
(WebCore::Layout::VerticalEdges::height const): Deleted.
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
* layout/tableformatting/TableFormattingContextGeometry.cpp:
(WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
LayoutTests:
* fast/layoutformattingcontext/table-simple-row-border-expected.html: Added.
* fast/layoutformattingcontext/table-simple-row-border.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (262096 => 262097)
--- trunk/LayoutTests/ChangeLog 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/LayoutTests/ChangeLog 2020-05-23 13:34:47 UTC (rev 262097)
@@ -1,3 +1,13 @@
+2020-05-23 Zalan Bujtas <[email protected]>
+
+ [LFC][TFC] Non-collapsing row border should not make the table wider/taller
+ https://bugs.webkit.org/show_bug.cgi?id=212263
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/table-simple-row-border-expected.html: Added.
+ * fast/layoutformattingcontext/table-simple-row-border.html: Added.
+
2020-05-22 Jack Lee <[email protected]>
ASSERTION FAILED: (!s_current || &m_view != &s_current->m_view) in RenderTreeBuilder::RenderTreeBuilder
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border-expected.html (0 => 262097)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border-expected.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border-expected.html 2020-05-23 13:34:47 UTC (rev 262097)
@@ -0,0 +1,13 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+ height: 10px;
+ width: 10px;
+ border: 1px solid green;
+ position: absolute;
+}
+</style>
+<div style="top: 10px; left: 10px;"></div>
+<div style="top: 10px; left: 24px;"></div>
+<div style="top: 24px; left: 10px;"></div>
+<div style="top: 24px; left: 24px;"></div>
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border.html (0 => 262097)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-simple-row-border.html 2020-05-23 13:34:47 UTC (rev 262097)
@@ -0,0 +1,18 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+td {
+ width: 10px;
+ height: 10px;
+ padding: 0px;
+ border: 1px solid green;
+}
+
+tr {
+ border: 50px solid red;
+}
+</style>
+<table>
+<tr><td></td><td></td></tr>
+<tr><td></td><td></td></tr>
+</tbody>
+</table>
Modified: trunk/Source/WebCore/ChangeLog (262096 => 262097)
--- trunk/Source/WebCore/ChangeLog 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/Source/WebCore/ChangeLog 2020-05-23 13:34:47 UTC (rev 262097)
@@ -1,3 +1,26 @@
+2020-05-23 Zalan Bujtas <[email protected]>
+
+ [LFC][TFC] Non-collapsing row border should not make the table wider/taller
+ https://bugs.webkit.org/show_bug.cgi?id=212263
+
+ Reviewed by Antti Koivisto.
+
+ Non-collapsing row border eats into the content box but oddly it does not
+ constraint the cell boxes, so we can end up with smaller row content box than
+ the cell box it contains.
+
+ Test: fast/layoutformattingcontext/table-simple-row-border.html
+
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::Edges::width const):
+ (WebCore::Layout::Edges::height const):
+ (WebCore::Layout::HorizontalEdges::width const): Deleted.
+ (WebCore::Layout::VerticalEdges::height const): Deleted.
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
+ * layout/tableformatting/TableFormattingContextGeometry.cpp:
+ (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
+
2020-05-22 Jack Lee <[email protected]>
ASSERTION FAILED: (!s_current || &m_view != &s_current->m_view) in RenderTreeBuilder::RenderTreeBuilder
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (262096 => 262097)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2020-05-23 13:34:47 UTC (rev 262097)
@@ -115,20 +115,19 @@
struct HorizontalEdges {
LayoutUnit left;
LayoutUnit right;
-
- LayoutUnit width() const { return left + right; }
};
struct VerticalEdges {
LayoutUnit top;
LayoutUnit bottom;
-
- LayoutUnit height() const { return top + bottom; }
};
struct Edges {
HorizontalEdges horizontal;
VerticalEdges vertical;
+
+ LayoutUnit width() const { return horizontal.left + horizontal.right; }
+ LayoutUnit height() const { return vertical.top + vertical.bottom; }
};
inline Edges operator/(const Edges& edge, size_t value)
Modified: trunk/Source/WebCore/layout/Verification.cpp (262096 => 262097)
--- trunk/Source/WebCore/layout/Verification.cpp 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/Source/WebCore/layout/Verification.cpp 2020-05-23 13:34:47 UTC (rev 262097)
@@ -274,12 +274,16 @@
return true;
}
- if (!areEssentiallyEqual(renderer.paddingBoxRect(), displayBox.paddingBox())) {
+ // When the table row border overflows the row, padding box becomes negative and content box is incorrect.
+ auto shouldCheckPaddingAndContentBox = !is<RenderTableRow>(renderer) || renderer.paddingBoxRect().width() >= 0;
+ if (shouldCheckPaddingAndContentBox && !areEssentiallyEqual(renderer.paddingBoxRect(), displayBox.paddingBox())) {
outputRect("paddingBox", renderer.paddingBoxRect(), displayBox.paddingBox());
return true;
}
auto shouldCheckContentBox = [&] {
+ if (!shouldCheckPaddingAndContentBox)
+ return false;
// FIXME: Figure out why trunk/rendering comes back with odd values for <tbody> and <td> content box.
if (is<RenderTableCell>(renderer) || is<RenderTableSection>(renderer))
return false;
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (262096 => 262097)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-05-23 13:34:47 UTC (rev 262097)
@@ -113,7 +113,6 @@
auto& grid = formattingState().tableGrid();
auto& rows = grid.rows().list();
- auto rowWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
auto rowLogicalTop = grid.verticalSpacing();
for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) {
auto& row = rows[rowIndex];
@@ -120,6 +119,13 @@
auto& rowBox = row.box();
auto& rowDisplayBox = formattingState().displayBox(rowBox);
+ rowDisplayBox.setPadding(geometry().computedPadding(rowBox, availableHorizontalSpace));
+ // Internal table elements do not have margins.
+ rowDisplayBox.setHorizontalMargin({ });
+ rowDisplayBox.setHorizontalComputedMargin({ });
+ rowDisplayBox.setVerticalMargin({ { }, { } });
+
+
auto computedRowBorder = [&] {
auto border = geometry().computedBorder(rowBox);
if (!grid.collapsedBorder())
@@ -132,15 +138,28 @@
border.vertical.bottom = { };
return border;
}();
+ if (computedRowBorder.height() > row.logicalHeight()) {
+ // FIXME: This is an odd quirk when the row border overflows the row.
+ // We don't paint row borders so it does not matter too much, but if we don't
+ // set this fake border value, than we either end up with a negative content box
+ // or with a wide frame box.
+ // If it happens to cause issues in the display tree, we could also consider
+ // a special frame box override, where padding box + border != frame box.
+ computedRowBorder.vertical.top = { };
+ computedRowBorder.vertical.bottom = { };
+ }
+ rowDisplayBox.setContentBoxHeight(row.logicalHeight() - computedRowBorder.height());
+
+ auto rowLogicalWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
+ if (computedRowBorder.width() > rowLogicalWidth) {
+ // See comment above.
+ computedRowBorder.horizontal.left = { };
+ computedRowBorder.horizontal.right = { };
+ }
+ rowDisplayBox.setContentBoxWidth(rowLogicalWidth - computedRowBorder.width());
+
rowDisplayBox.setBorder(computedRowBorder);
- rowDisplayBox.setPadding(geometry().computedPadding(rowBox, availableHorizontalSpace));
- // Internal table elements do not have margins.
- rowDisplayBox.setHorizontalMargin({ });
- rowDisplayBox.setHorizontalComputedMargin({ });
- rowDisplayBox.setVerticalMargin({ { }, { } });
- rowDisplayBox.setContentBoxHeight(row.logicalHeight());
- rowDisplayBox.setContentBoxWidth(rowWidth);
rowDisplayBox.setTop(rowLogicalTop);
rowDisplayBox.setLeft({ });
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp (262096 => 262097)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp 2020-05-23 05:55:53 UTC (rev 262096)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp 2020-05-23 13:34:47 UTC (rev 262097)
@@ -110,7 +110,7 @@
// FIXME Check for box-sizing: border-box;
auto intrinsicWidthConstraints = constrainByMinMaxWidth(cellBox, computedIntrinsicWidthConstraints());
// Expand with border
- intrinsicWidthConstraints.expand(computedCellBorder(cell).horizontal.width());
+ intrinsicWidthConstraints.expand(computedCellBorder(cell).width());
// padding
intrinsicWidthConstraints.expand(fixedValue(style.paddingLeft()).valueOr(0) + fixedValue(style.paddingRight()).valueOr(0));
// and margin