[LFC][TFC] Adjust baseline offset for continuation
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 02:32:54 +0000 (02:32 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2020 02:32:54 +0000 (02:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213732

Reviewed by Antti Koivisto.

Source/WebCore:

Skip empty IFC generated for the "pre" part of the continuation (e.g. <span><div>text content</div></span>).

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

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

LayoutTests:

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

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

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

index 459d588..2ada942 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-29  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][TFC] Adjust baseline offset for continuation
+        https://bugs.webkit.org/show_bug.cgi?id=213732
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-cell-baseline-offset-simple-expected.html: Added.
+        * fast/layoutformattingcontext/table-cell-baseline-offset-simple.html: Added.
+
 2020-06-29  Karl Rackler  <rackler@apple.com>
 
         Remove expectation for imported/w3c/web-platform-tests/css/css-ui/text-overflow-005.html as it is passing. 
diff --git a/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple-expected.html b/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple-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-simple.html b/LayoutTests/fast/layoutformattingcontext/table-cell-baseline-offset-simple.html
new file mode 100644 (file)
index 0000000..22a6810
--- /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><div>i</div></td></tr>
+</table>
index da71923..4b124f0 100644 (file)
@@ -1,3 +1,17 @@
+2020-06-29  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][TFC] Adjust baseline offset for continuation
+        https://bugs.webkit.org/show_bug.cgi?id=213732
+
+        Reviewed by Antti Koivisto.
+
+        Skip empty IFC generated for the "pre" part of the continuation (e.g. <span><div>text content</div></span>).
+
+        Test: fast/layoutformattingcontext/table-cell-baseline-offset-simple.html
+
+        * layout/tableformatting/TableFormattingContextGeometry.cpp:
+        (WebCore::Layout::TableFormattingContext::Geometry::usedBaselineForCell):
+
 2020-06-29  Guowei Yang  <guowei_yang@apple.com>
 
         Adding Experimental Feature Flags for CoreImage backed SVG/CSS Filters
index 5c64a0f..0d9dbd0 100644 (file)
@@ -132,8 +132,11 @@ InlineLayoutUnit TableFormattingContext::Geometry::usedBaselineForCell(const Con
     // 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.
     for (auto& cellDescendant : descendantsOfType<ContainerBox>(cellBox)) {
-        if (cellDescendant.establishesInlineFormattingContext())
-            return layoutState().establishedInlineFormattingState(cellDescendant).displayInlineContent()->lineBoxes[0].baselineOffset();
+        if (cellDescendant.establishesInlineFormattingContext()) {
+            auto* displayInlineContent = layoutState().establishedInlineFormattingState(cellDescendant).displayInlineContent();
+            if (!displayInlineContent->runs.isEmpty())
+                return displayInlineContent->lineBoxes[0].baselineOffset();
+        }
         if (cellDescendant.establishesTableFormattingContext())
             return layoutState().establishedTableFormattingState(cellDescendant).tableGrid().rows().list()[0].baselineOffset();
     }