Title: [264107] trunk
Revision
264107
Author
[email protected]
Date
2020-07-08 09:45:47 -0700 (Wed, 08 Jul 2020)

Log Message

[LFC][IFC] Do not use the initial strut baseline values when the text content is inside an inline container
https://bugs.webkit.org/show_bug.cgi?id=214069

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html

* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::adjustBaselineAndLineHeight):
* layout/inlineformatting/InlineLineBuilder.h:

LayoutTests:

* fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container-expected.html: Added.
* fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (264106 => 264107)


--- trunk/LayoutTests/ChangeLog	2020-07-08 16:43:37 UTC (rev 264106)
+++ trunk/LayoutTests/ChangeLog	2020-07-08 16:45:47 UTC (rev 264107)
@@ -1,3 +1,13 @@
+2020-07-08  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Do not use the initial strut baseline values when the text content is inside an inline container
+        https://bugs.webkit.org/show_bug.cgi?id=214069
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container-expected.html: Added.
+        * fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html: Added.
+
 2020-07-08  Chris Dumez  <[email protected]>
 
         Skip a couple of WPT webaudio tests instead of marking them as crashing.

Added: trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container-expected.html (0 => 264107)


--- trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container-expected.html	2020-07-08 16:45:47 UTC (rev 264107)
@@ -0,0 +1,10 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    width: 120px;
+    height: 10px;
+    background-color: green;
+}
+
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html (0 => 264107)


--- trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html	2020-07-08 16:45:47 UTC (rev 264107)
@@ -0,0 +1,14 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    color: green;
+    background-color: green;
+    position: absolute;
+}
+
+span {
+    font-size: 10px;
+    font-family: Ahem;
+}
+</style>
+<div><span>text content</span></div>

Modified: trunk/Source/WebCore/ChangeLog (264106 => 264107)


--- trunk/Source/WebCore/ChangeLog	2020-07-08 16:43:37 UTC (rev 264106)
+++ trunk/Source/WebCore/ChangeLog	2020-07-08 16:45:47 UTC (rev 264107)
@@ -1,5 +1,19 @@
 2020-07-08  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Do not use the initial strut baseline values when the text content is inside an inline container
+        https://bugs.webkit.org/show_bug.cgi?id=214069
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/layoutformattingcontext/line-heigt-when-text-is-inside-inline-container.html
+
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::close):
+        (WebCore::Layout::LineBuilder::adjustBaselineAndLineHeight):
+        * layout/inlineformatting/InlineLineBuilder.h:
+
+2020-07-08  Zalan Bujtas  <[email protected]>
+
         [LFC][TFC] Table width is computed as if box-sizing was border-box
         https://bugs.webkit.org/show_bug.cgi?id=214070
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (264106 => 264107)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-07-08 16:43:37 UTC (rev 264106)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-07-08 16:45:47 UTC (rev 264107)
@@ -118,9 +118,25 @@
     auto hangingContent = collectHangingContent(isLastLineWithInlineContent);
 
     if (!m_isIntrinsicSizing) {
+        unsigned inlineContainerNestingLevel = 0;
+        auto hasSeenTextOrLineBreak = false;
         for (auto& run : m_runs) {
-            adjustBaselineAndLineHeight(run);
             run.setLogicalHeight(runContentHeight(run));
+            inlineContainerNestingLevel = run.isContainerStart() ? inlineContainerNestingLevel + 1 : run.isContainerEnd() ? inlineContainerNestingLevel - 1 : inlineContainerNestingLevel;
+            auto runIsTextOrLineBreak = run.isText() || run.isLineBreak();
+            if (runIsTextOrLineBreak) {
+                // For text content we set the baseline either through the initial strut (set by the formatting context root) or
+                // through the inline container (start). Normally the text content itself does not stretch the line.
+                if (hasSeenTextOrLineBreak)
+                    continue;
+                hasSeenTextOrLineBreak = true;
+                if (!m_initialStrut)
+                    continue;
+                if (inlineContainerNestingLevel)
+                    continue;
+            }
+            auto& usedBaseline = runIsTextOrLineBreak ? *m_initialStrut : m_lineBox.baseline();
+            adjustBaselineAndLineHeight(run, usedBaseline);
         }
         if (isVisuallyEmpty()) {
             m_lineBox.resetBaseline();
@@ -553,18 +569,12 @@
     m_runs.append({ downcast<InlineSoftLineBreakItem>(inlineItem), contentLogicalWidth() });
 }
 
-void LineBuilder::adjustBaselineAndLineHeight(const Run& run)
+void LineBuilder::adjustBaselineAndLineHeight(const Run& run, const LineBoxBuilder::Baseline& usedBaseline)
 {
-    auto& baseline = m_lineBox.baseline();
     if (run.isText() || run.isLineBreak()) {
-        // For text content we set the baseline either through the initial strut (set by the formatting context root) or
-        // through the inline container (start) -see above. Normally the text content itself does not stretch the line.
-        if (!m_initialStrut)
-            return;
-        m_lineBox.setAscentIfGreater(m_initialStrut->ascent());
-        m_lineBox.setDescentIfGreater(m_initialStrut->descent());
-        m_lineBox.setLogicalHeightIfGreater(baseline.height());
-        m_initialStrut = { };
+        m_lineBox.setAscentIfGreater(usedBaseline.ascent());
+        m_lineBox.setDescentIfGreater(usedBaseline.descent());
+        m_lineBox.setLogicalHeightIfGreater(usedBaseline.height());
         return;
     }
 
@@ -581,7 +591,7 @@
                 m_lineBox.setDescentIfGreater(halfLeading.descent());
             if (halfLeading.ascent() > 0)
                 m_lineBox.setAscentIfGreater(halfLeading.ascent());
-            m_lineBox.setLogicalHeightIfGreater(baseline.height());
+            m_lineBox.setLogicalHeightIfGreater(usedBaseline.height());
         } else
             m_lineBox.setLogicalHeightIfGreater(fontMetrics.height());
         return;
@@ -614,7 +624,7 @@
                 // Non inline-block boxes sit on the baseline (including their bottom margin).
                 m_lineBox.setAscentIfGreater(marginBoxHeight);
                 // Ignore negative descent (yes, negative descent is a thing).
-                m_lineBox.setLogicalHeightIfGreater(marginBoxHeight + std::max<InlineLayoutUnit>(0, baseline.descent()));
+                m_lineBox.setLogicalHeightIfGreater(marginBoxHeight + std::max<InlineLayoutUnit>(0, usedBaseline.descent()));
             }
             break;
         }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (264106 => 264107)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-07-08 16:43:37 UTC (rev 264106)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-07-08 16:45:47 UTC (rev 264107)
@@ -183,7 +183,7 @@
     void alignHorizontally(const HangingContent&, IsLastLineWithInlineContent);
     void alignContentVertically();
 
-    void adjustBaselineAndLineHeight(const Run&);
+    void adjustBaselineAndLineHeight(const Run&, const LineBoxBuilder::Baseline&);
     InlineLayoutUnit runContentHeight(const Run&) const;
 
     void justifyRuns(InlineLayoutUnit availableWidth);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to