Title: [266516] trunk
Revision
266516
Author
za...@apple.com
Date
2020-09-03 07:56:24 -0700 (Thu, 03 Sep 2020)

Log Message

[LFC][IFC] Add support for vertical-align: text-bottom
https://bugs.webkit.org/show_bug.cgi?id=215538
<rdar://problem/67613372>

Reviewed by Antti Koivisto.

Source/WebCore:

See https://www.w3.org/TR/css-inline-3/#propdef-alignment-baseline
(align with the baseline + descent of the parent inline box)

Test: fast/layoutformattingcontext/vertical-align-bottom-nested.html

* layout/inlineformatting/InlineLineBox.cpp:
(WebCore::Layout::LineBox::computeInlineBoxesLogicalHeight):
(WebCore::Layout::LineBox::alignInlineBoxesVerticallyAndComputeLineBoxHeight):

LayoutTests:

* fast/layoutformattingcontext/vertical-align-bottom-nested-expected.html: Added.
* fast/layoutformattingcontext/vertical-align-bottom-nested.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (266515 => 266516)


--- trunk/LayoutTests/ChangeLog	2020-09-03 14:51:51 UTC (rev 266515)
+++ trunk/LayoutTests/ChangeLog	2020-09-03 14:56:24 UTC (rev 266516)
@@ -1,5 +1,16 @@
 2020-09-03  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Add support for vertical-align: text-bottom
+        https://bugs.webkit.org/show_bug.cgi?id=215538
+        <rdar://problem/67613372>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/vertical-align-bottom-nested-expected.html: Added.
+        * fast/layoutformattingcontext/vertical-align-bottom-nested.html: Added.
+
+2020-09-03  Zalan Bujtas  <za...@apple.com>
+
         [LFC][IFC] Add support for vertical-align: text-top
         https://bugs.webkit.org/show_bug.cgi?id=215545
         <rdar://problem/67629969>

Added: trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested-expected.html (0 => 266516)


--- trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested-expected.html	2020-09-03 14:56:24 UTC (rev 266516)
@@ -0,0 +1,7 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    background-color: green;
+}
+</style>
+<div style="height: 100px;"></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested.html (0 => 266516)


--- trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-bottom-nested.html	2020-09-03 14:56:24 UTC (rev 266516)
@@ -0,0 +1,16 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.container {
+  background-color: green;
+  color: green;
+  font-family: Ahem;
+}
+</style>
+
+<div class=container>
+  <img src="" style="width: 2px; height: 100px; vertical-align: bottom">
+  <span style="vertical-align: top; font-size: 40px;">
+    XXX
+    <span style="vertical-align: text-bottom; font-size: 20px;">XXX</span>
+  </span>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (266515 => 266516)


--- trunk/Source/WebCore/ChangeLog	2020-09-03 14:51:51 UTC (rev 266515)
+++ trunk/Source/WebCore/ChangeLog	2020-09-03 14:56:24 UTC (rev 266516)
@@ -1,5 +1,22 @@
 2020-09-03  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Add support for vertical-align: text-bottom
+        https://bugs.webkit.org/show_bug.cgi?id=215538
+        <rdar://problem/67613372>
+
+        Reviewed by Antti Koivisto.
+
+        See https://www.w3.org/TR/css-inline-3/#propdef-alignment-baseline
+        (align with the baseline + descent of the parent inline box)
+
+        Test: fast/layoutformattingcontext/vertical-align-bottom-nested.html
+
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::LineBox::computeInlineBoxesLogicalHeight):
+        (WebCore::Layout::LineBox::alignInlineBoxesVerticallyAndComputeLineBoxHeight):
+
+2020-09-03  Zalan Bujtas  <za...@apple.com>
+
         [LFC][IFC] Add support for vertical-align: text-top
         https://bugs.webkit.org/show_bug.cgi?id=215545
         <rdar://problem/67629969>

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (266515 => 266516)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-09-03 14:51:51 UTC (rev 266515)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-09-03 14:56:24 UTC (rev 266516)
@@ -275,6 +275,17 @@
                 parentInlineBox.setLogicalHeight(parentInlineBox.logicalHeight() + belowBaselineOverflow);
             break;
         }
+        case VerticalAlign::TextBottom: {
+            auto& parentInlineBox = inlineBoxForLayoutBox(layoutBox.parent());
+            auto parentTextLogicalBottom = parentInlineBox.baseline() + parentInlineBox.descent().valueOr(InlineLayoutUnit { });
+            auto overflow = std::max(0.0f, inlineBox->logicalHeight() - parentTextLogicalBottom);
+            if (overflow) {
+                // TextBottom pushes the baseline downward the same way 'bottom' does.
+                parentInlineBox.setLogicalHeight(parentInlineBox.logicalHeight() + overflow);
+                parentInlineBox.setBaseline(parentInlineBox.baseline() + overflow);
+            }
+            break;
+        }
         case VerticalAlign::Middle: {
             auto& parentLayoutBox = layoutBox.parent();
             auto& parentInlineBox = inlineBoxForLayoutBox(parentLayoutBox);
@@ -339,6 +350,13 @@
             inlineBoxLogicalTop = parentInlineBox.logicalTop() + parentInlineBox.baseline() - parentLayoutBox.style().fontMetrics().ascent();
             break;
         }
+        case VerticalAlign::TextBottom: {
+            auto& parentLayoutBox = layoutBox.parent();
+            auto& parentInlineBox = inlineBoxForLayoutBox(parentLayoutBox);
+            auto parentTextLogicalBottom = parentInlineBox.logicalTop() + parentInlineBox.baseline() + parentLayoutBox.style().fontMetrics().descent();
+            inlineBoxLogicalTop = parentTextLogicalBottom - inlineBox->logicalHeight();
+            break;
+        }
         case VerticalAlign::Top:
             inlineBoxLogicalTop = InlineLayoutUnit { };
             break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to