[LFC][TFC] Adjust baseline when the table cell itself establishes an IFC
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 03:04:28 +0000 (03:04 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 03:04:28 +0000 (03:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213735

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html

* layout/tableformatting/TableFormattingContextGeometry.cpp:
(WebCore::Layout::TableFormattingContext::Geometry::usedBaselineForCell):

LayoutTests:

* fast/layoutformattingcontext/table-cell-baseline-offset-simple2-expected.html: Added.
* fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263720 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2-expected.html [new file with mode: 0644]
LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp

index 2ada942..05a0cb0 100644 (file)
@@ -1,5 +1,15 @@
 2020-06-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][TFC] Adjust baseline when the table cell itself establishes an IFC
+        https://bugs.webkit.org/show_bug.cgi?id=213735
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-cell-baseline-offset-simple2-expected.html: Added.
+        * fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html: Added.
+
+2020-06-29  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][TFC] Adjust baseline offset for continuation
         https://bugs.webkit.org/show_bug.cgi?id=213732
 
diff --git a/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2-expected.html b/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2-expected.html
new file mode 100644 (file)
index 0000000..5e67905
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    width: 150px;
+    height: 29px;
+    background-color: green;
+}
+
+.cell {
+    width: 72px;
+    height: 25px;
+    background-color: blue;
+    position: relative;
+}
+</style>
+<div></div>
+<div class=cell style="top: -27px; left: 2px"></div>
+<div class=cell style="top: -52px; left: 76px"></div>
diff --git a/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html b/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html
new file mode 100644 (file)
index 0000000..2455a92
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+table {
+    width: 150px;
+    font-size: 20px;
+    background-color: green;
+    color: blue;
+}
+
+td {
+    background-color: blue;
+}
+</style>
+<table>
+<tr><td><span><div>i</div></span></td><td>i</td></tr>
+</table>
index 4b124f0..0fecb6e 100644 (file)
@@ -1,5 +1,17 @@
 2020-06-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][TFC] Adjust baseline when the table cell itself establishes an IFC
+        https://bugs.webkit.org/show_bug.cgi?id=213735
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/layoutformattingcontext/table-cell-baseline-offset-simple2.html
+
+        * layout/tableformatting/TableFormattingContextGeometry.cpp:
+        (WebCore::Layout::TableFormattingContext::Geometry::usedBaselineForCell):
+
+2020-06-29  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][TFC] Adjust baseline offset for continuation
         https://bugs.webkit.org/show_bug.cgi?id=213732
 
index 0d9dbd0..1d52603 100644 (file)
@@ -131,6 +131,8 @@ InlineLayoutUnit TableFormattingContext::Geometry::usedBaselineForCell(const Con
     // The baseline of a cell is defined as the baseline of the first in-flow line box in the cell,
     // or the first in-flow table-row in the cell, whichever comes first.
     // If there is no such line box, the baseline is the bottom of content edge of the cell box.
+    if (cellBox.establishesInlineFormattingContext())
+        return layoutState().establishedInlineFormattingState(cellBox).displayInlineContent()->lineBoxes[0].baselineOffset();
     for (auto& cellDescendant : descendantsOfType<ContainerBox>(cellBox)) {
         if (cellDescendant.establishesInlineFormattingContext()) {
             auto* displayInlineContent = layoutState().establishedInlineFormattingState(cellDescendant).displayInlineContent();