Title: [276767] trunk
Revision
276767
Author
[email protected]
Date
2021-04-29 06:22:12 -0700 (Thu, 29 Apr 2021)

Log Message

[LFC][IFC] Incorrect middle alignment for inline boxes when line-height is present
https://bugs.webkit.org/show_bug.cgi?id=225166
<rdar://77272112>

Reviewed by Simon Fraser.

Source/WebCore:

Let's use the layout bounds instead of the baseline when computing the inline box's baseline offset from the root inline box's baseline.
The difference here is that the layout bounds (per spec) is adjusted with the line-height value.
These two values (layout bounds's ascent and the inline box's baseline) resolve to the same value as long as the line-height property is not set.

Tests: fast/inline/incorrect-middle-alignment-with-line-height.html
       fast/inline/incorrect-middle-baseline-alignment-with-line-height.html

* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::LineBoxBuilder::computeLineBoxHeightAndAlignInlineLevelBoxesVertically):

LayoutTests:

* fast/inline/incorrect-middle-alignment-with-line-height-expected.html: Added.
* fast/inline/incorrect-middle-alignment-with-line-height.html: Added.
* fast/inline/incorrect-middle-baseline-alignment-with-line-height-expected.html: Added.
* fast/inline/incorrect-middle-baseline-alignment-with-line-height.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276766 => 276767)


--- trunk/LayoutTests/ChangeLog	2021-04-29 12:28:12 UTC (rev 276766)
+++ trunk/LayoutTests/ChangeLog	2021-04-29 13:22:12 UTC (rev 276767)
@@ -1,3 +1,16 @@
+2021-04-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Incorrect middle alignment for inline boxes when line-height is present
+        https://bugs.webkit.org/show_bug.cgi?id=225166
+        <rdar://77272112>
+
+        Reviewed by Simon Fraser.
+
+        * fast/inline/incorrect-middle-alignment-with-line-height-expected.html: Added.
+        * fast/inline/incorrect-middle-alignment-with-line-height.html: Added.
+        * fast/inline/incorrect-middle-baseline-alignment-with-line-height-expected.html: Added.
+        * fast/inline/incorrect-middle-baseline-alignment-with-line-height.html: Added.
+
 2021-04-28  Wenson Hsieh  <[email protected]>
 
         [iOS] Coalesce adjacent selection geometries when rendering individual selection quads

Added: trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height-expected.html (0 => 276767)


--- trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height-expected.html	2021-04-29 13:22:12 UTC (rev 276767)
@@ -0,0 +1,14 @@
+<style>
+table {
+  font-family: Ahem;
+  font-size: 20px;
+  line-height: 10;
+  background-color: green;
+  border-spacing: 0px;
+}
+td {
+  padding-top: 50px;
+  vertical-align: baseline;
+}
+</style>
+<div><table><td style="height: 300px; width: 0px;"></td><td>middle align with line-height</td></table></div>

Added: trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height.html (0 => 276767)


--- trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/incorrect-middle-alignment-with-line-height.html	2021-04-29 13:22:12 UTC (rev 276767)
@@ -0,0 +1,14 @@
+<style>
+table {
+  font-family: Ahem;
+  font-size: 20px;
+  line-height: 10;
+  background-color: green;
+  border-spacing: 0px;
+}
+
+td {
+  vertical-align: middle;
+}
+</style>
+<div><table><td style="height: 300px; width: 0px;"></td><td>middle align with line-height</td></table></div>

Added: trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height-expected.html (0 => 276767)


--- trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height-expected.html	2021-04-29 13:22:12 UTC (rev 276767)
@@ -0,0 +1,10 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 20px;
+  background-color: green;
+  height: 112px;
+  padding-top: 90px; 
+}
+</style>
+<div>middle align with line-height</div>

Added: trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height.html (0 => 276767)


--- trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/incorrect-middle-baseline-alignment-with-line-height.html	2021-04-29 13:22:12 UTC (rev 276767)
@@ -0,0 +1,12 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 20px;
+  line-height: 10;
+  background-color: green; 
+}
+span {
+  vertical-align: middle;
+}
+</style>
+<div><span>middle align with line-height</span></div>

Modified: trunk/Source/WebCore/ChangeLog (276766 => 276767)


--- trunk/Source/WebCore/ChangeLog	2021-04-29 12:28:12 UTC (rev 276766)
+++ trunk/Source/WebCore/ChangeLog	2021-04-29 13:22:12 UTC (rev 276767)
@@ -1,3 +1,21 @@
+2021-04-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Incorrect middle alignment for inline boxes when line-height is present
+        https://bugs.webkit.org/show_bug.cgi?id=225166
+        <rdar://77272112>
+
+        Reviewed by Simon Fraser.
+
+        Let's use the layout bounds instead of the baseline when computing the inline box's baseline offset from the root inline box's baseline.
+        The difference here is that the layout bounds (per spec) is adjusted with the line-height value.
+        These two values (layout bounds's ascent and the inline box's baseline) resolve to the same value as long as the line-height property is not set.
+
+        Tests: fast/inline/incorrect-middle-alignment-with-line-height.html
+               fast/inline/incorrect-middle-baseline-alignment-with-line-height.html
+
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::computeLineBoxHeightAndAlignInlineLevelBoxesVertically):
+
 2021-04-29  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] REGRESSION(r272888): Don't assert the validity of the dataURL mimeType inside GPU Process

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (276766 => 276767)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-04-29 12:28:12 UTC (rev 276766)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-04-29 13:22:12 UTC (rev 276767)
@@ -503,12 +503,12 @@
                     break;
                 case VerticalAlign::Middle: {
                     auto logicalTopOffsetFromParentBaseline = (inlineLevelBox.layoutBounds().height() / 2 + parentInlineBox.style().fontMetrics().xHeight() / 2);
-                    baselineOffsetFromParentBaseline = logicalTopOffsetFromParentBaseline - inlineLevelBox.baseline();
+                    baselineOffsetFromParentBaseline = logicalTopOffsetFromParentBaseline - inlineLevelBox.layoutBounds().ascent;
                     break;
                 }
                 case VerticalAlign::BaselineMiddle: {
                     auto logicalTopOffsetFromParentBaseline = inlineLevelBox.layoutBounds().height() / 2;
-                    baselineOffsetFromParentBaseline = logicalTopOffsetFromParentBaseline - inlineLevelBox.baseline();
+                    baselineOffsetFromParentBaseline = logicalTopOffsetFromParentBaseline - inlineLevelBox.layoutBounds().ascent;
                     break;
                 }
                 case VerticalAlign::Length: {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to