[LFC][TFC] Add support for non-baseline aligned cell height
https://bugs.webkit.org/show_bug.cgi?id=213845
Reviewed by Antti Koivisto.
Source/WebCore:
Adjust max ascent/descent only when the cell is basline aligned.
Test: fast/layoutformattingcontext/table-cell-height-middle-align-simple.html
* layout/tableformatting/TableLayout.cpp:
(WebCore::Layout::TableFormattingContext::TableLayout::distributedVerticalSpace):
LayoutTests:
* fast/layoutformattingcontext/table-cell-height-middle-align-simple-expected.html: Added.
* fast/layoutformattingcontext/table-cell-height-middle-align-simple.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5772b22..a00a4b7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2020-07-01 Zalan Bujtas <zalan@apple.com>
+
+ [LFC][TFC] Add support for non-baseline aligned cell height
+ https://bugs.webkit.org/show_bug.cgi?id=213845
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/table-cell-height-middle-align-simple-expected.html: Added.
+ * fast/layoutformattingcontext/table-cell-height-middle-align-simple.html: Added.
+
2020-07-01 Antoine Quint <graouts@webkit.org>
pointerevents/ios/touch-action-none-on-iframe.html times out
diff --git a/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple-expected.html b/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple-expected.html
new file mode 100644
index 0000000..0169f63
--- /dev/null
+++ b/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple-expected.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.first {
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+}
+
+.second {
+ width: 50px;
+ height: 50px;
+ position: relative;
+ left: 50px;
+ top: -50px;
+ background-color: green;
+}
+</style>
+<div class=first></div>
+<div class=second></div>
\ No newline at end of file
diff --git a/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple.html b/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple.html
new file mode 100644
index 0000000..632ed94
--- /dev/null
+++ b/LayoutTests/fast/layoutformattingcontext/table-cell-height-middle-align-simple.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+table {
+ width: 100px;
+ font-size: 20px;
+ background-color: green;
+ border-spacing: 0px;
+ color: green;
+}
+
+td {
+ padding: 0px;
+}
+</style>
+<table>
+<tr>
+<td><div style="width: 50px; height: 50px; background-color: blue"></div></td>
+<td>XXX</td>
+</tr>
+</table>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6d8c56d..0e44ce2 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2020-07-01 Zalan Bujtas <zalan@apple.com>
+
+ [LFC][TFC] Add support for non-baseline aligned cell height
+ https://bugs.webkit.org/show_bug.cgi?id=213845
+
+ Reviewed by Antti Koivisto.
+
+ Adjust max ascent/descent only when the cell is basline aligned.
+
+ Test: fast/layoutformattingcontext/table-cell-height-middle-align-simple.html
+
+ * layout/tableformatting/TableLayout.cpp:
+ (WebCore::Layout::TableFormattingContext::TableLayout::distributedVerticalSpace):
+
2020-07-01 Antoine Quint <graouts@webkit.org>
[Media Controls] Tracks panel can show text tracks with mode "hidden" as selected
diff --git a/Source/WebCore/layout/tableformatting/TableLayout.cpp b/Source/WebCore/layout/tableformatting/TableLayout.cpp
index 1429e49..9d6e9a9 100644
--- a/Source/WebCore/layout/tableformatting/TableLayout.cpp
+++ b/Source/WebCore/layout/tableformatting/TableLayout.cpp
@@ -276,11 +276,15 @@
// The minimum height of a row (without spanning-related height distribution) is defined as the height of an hypothetical
// linebox containing the cells originating in the row.
auto& cell = slot.cell();
- maximumColumnAscent = std::max(maximumColumnAscent, cell.baselineOffset());
- maximumColumnDescent = std::max(maximumColumnDescent, formattingContext().geometryForBox(cell.box()).height() - cell.baselineOffset());
+ auto& cellBox = cell.box();
+ auto height = formattingContext().geometryForBox(cellBox).height();
+ if (cellBox.style().verticalAlign() == VerticalAlign::Baseline) {
+ maximumColumnAscent = std::max(maximumColumnAscent, cell.baselineOffset());
+ maximumColumnDescent = std::max(maximumColumnDescent, height - cell.baselineOffset());
+ rowHeight[rowIndex] = std::max(rowHeight[rowIndex], LayoutUnit { maximumColumnAscent + maximumColumnDescent });
+ } else
+ rowHeight[rowIndex] = std::max(rowHeight[rowIndex], height);
}
- // <tr style="height: 10px"> is considered as min height.
- rowHeight[rowIndex] = maximumColumnAscent + maximumColumnDescent;
tableUsedHeight += rowHeight[rowIndex];
}
// FIXME: Collect spanning row maximum heights.