Title: [266515] trunk
Revision
266515
Author
[email protected]
Date
2020-09-03 07:51:51 -0700 (Thu, 03 Sep 2020)

Log Message

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

Reviewed by Antti Koivisto.

Source/WebCore:

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

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

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

LayoutTests:

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

Modified Paths

Added Paths

Diff

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


--- trunk/LayoutTests/ChangeLog	2020-09-03 14:40:06 UTC (rev 266514)
+++ trunk/LayoutTests/ChangeLog	2020-09-03 14:51:51 UTC (rev 266515)
@@ -1,3 +1,14 @@
+2020-09-03  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add support for vertical-align: text-top
+        https://bugs.webkit.org/show_bug.cgi?id=215545
+        <rdar://problem/67629969>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/vertical-align-top-nested-expected.html: Added.
+        * fast/layoutformattingcontext/vertical-align-top-nested.html: Added.
+
 2020-09-03  Aditya Keerthi  <[email protected]>
 
         [macOS] Add disabled and readonly behaviors to date inputs

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


--- trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-top-nested-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-top-nested-expected.html	2020-09-03 14:51:51 UTC (rev 266515)
@@ -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-top-nested.html (0 => 266515)


--- trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-top-nested.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/vertical-align-top-nested.html	2020-09-03 14:51:51 UTC (rev 266515)
@@ -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-top; font-size: 20px;">XXX</span>
+  </span>
+</div>

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


--- trunk/Source/WebCore/ChangeLog	2020-09-03 14:40:06 UTC (rev 266514)
+++ trunk/Source/WebCore/ChangeLog	2020-09-03 14:51:51 UTC (rev 266515)
@@ -1,3 +1,20 @@
+2020-09-03  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add support for vertical-align: text-top
+        https://bugs.webkit.org/show_bug.cgi?id=215545
+        <rdar://problem/67629969>
+
+        Reviewed by Antti Koivisto.
+
+        See https://www.w3.org/TR/css-inline-3/#propdef-alignment-baseline
+        (align with the baseline + ascent of the parent inline box)
+
+        Test: fast/layoutformattingcontext/vertical-align-top-nested.html
+
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::LineBox::computeInlineBoxesLogicalHeight):
+        (WebCore::Layout::LineBox::alignInlineBoxesVerticallyAndComputeLineBoxHeight):
+
 2020-09-03  Aditya Keerthi  <[email protected]>
 
         [macOS] Add disabled and readonly behaviors to date inputs

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


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-09-03 14:40:06 UTC (rev 266514)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-09-03 14:51:51 UTC (rev 266515)
@@ -255,6 +255,12 @@
         case VerticalAlign::Bottom:
             // top and bottom alignments only stretch the line box. They don't stretch any of the inline boxes, not even the root inline box.
             break;
+        case VerticalAlign::TextTop: {
+            auto& parentInlineBox = inlineBoxForLayoutBox(layoutBox.parent());
+            auto parentTextLogicalTop = parentInlineBox.baseline() - parentInlineBox.layoutBox().style().fontMetrics().ascent();
+            parentInlineBox.setLogicalHeight(std::max(parentInlineBox.logicalHeight(), parentTextLogicalTop + inlineBox->logicalHeight()));
+            break;
+        }
         case VerticalAlign::Baseline: {
             auto& parentInlineBox = inlineBoxForLayoutBox(layoutBox.parent());
             auto baselineOverflow = std::max(0.0f, inlineBox->baseline() - parentInlineBox.baseline());
@@ -327,6 +333,12 @@
             inlineBoxLogicalTop = parentInlineBox.logicalTop() + parentInlineBox.baseline() - inlineBox->baseline();
             break;
         }
+        case VerticalAlign::TextTop: {
+            auto& parentLayoutBox = layoutBox.parent();
+            auto& parentInlineBox = inlineBoxForLayoutBox(parentLayoutBox);
+            inlineBoxLogicalTop = parentInlineBox.logicalTop() + parentInlineBox.baseline() - parentLayoutBox.style().fontMetrics().ascent();
+            break;
+        }
         case VerticalAlign::Top:
             inlineBoxLogicalTop = InlineLayoutUnit { };
             break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to