Title: [285826] trunk/Source/WebCore
Revision
285826
Author
[email protected]
Date
2021-11-15 12:47:49 -0800 (Mon, 15 Nov 2021)

Log Message

[LFC][IFC] Fix fast/text/letter-spacing-negative-opacity.html
https://bugs.webkit.org/show_bug.cgi?id=233132

Reviewed by Antti Koivisto.

Special case the negative letter spacing content when computing the content logical width.

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::appendTextContent):
1. Negative letter space value could produce negative content width
2. Subsequent text content (e.g. "this text has whitepspace content") may go from positive to negative content width as parts of the content may produce positive width even with negative letter spacing.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285825 => 285826)


--- trunk/Source/WebCore/ChangeLog	2021-11-15 20:39:16 UTC (rev 285825)
+++ trunk/Source/WebCore/ChangeLog	2021-11-15 20:47:49 UTC (rev 285826)
@@ -1,3 +1,17 @@
+2021-11-15  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Fix fast/text/letter-spacing-negative-opacity.html
+        https://bugs.webkit.org/show_bug.cgi?id=233132
+
+        Reviewed by Antti Koivisto.
+
+        Special case the negative letter spacing content when computing the content logical width.
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::appendTextContent):
+        1. Negative letter space value could produce negative content width
+        2. Subsequent text content (e.g. "this text has whitepspace content") may go from positive to negative content width as parts of the content may produce positive width even with negative letter spacing.
+
 2021-11-15  Chris Dumez  <[email protected]>
 
         `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (285825 => 285826)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-11-15 20:39:16 UTC (rev 285825)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-11-15 20:47:49 UTC (rev 285826)
@@ -342,10 +342,18 @@
         // Note that the _content_ logical right may be larger than the _run_ logical right.
         auto contentLogicalRight = runLogicalLeft + logicalWidth + m_clonedEndDecorationWidthForInlineBoxRuns;
         m_contentLogicalWidth = std::max(oldContentLogicalWidth, contentLogicalRight);
+    } else if (style.letterSpacing() >= 0) {
+        m_runs.last().expand(inlineTextItem, logicalWidth);
+        m_contentLogicalWidth += logicalWidth;
     } else {
-        m_runs.last().expand(inlineTextItem, logicalWidth);
-        // Do not let negative letter spacing make the content shorter than it already is.
-        m_contentLogicalWidth += std::max(0.0f, logicalWidth);
+        auto& lastRun = m_runs.last();
+        ASSERT(lastRun.isText());
+        // Negative letter spacing should only shorten the content to the boundary of the previous run.
+        // FIXME: We may need to traverse all the way to the previous non-text run (or even across inline boxes).
+        auto lastRunLogicalWidth = lastRun.logicalWidth();
+        auto contentWidthWithoutLastTextRun = m_contentLogicalWidth - std::max(0.f, lastRunLogicalWidth);
+        lastRun.expand(inlineTextItem, logicalWidth);
+        m_contentLogicalWidth = std::max(contentWidthWithoutLastTextRun, lastRunLogicalWidth + logicalWidth);
     }
 
     // Handle trailing content, specifically whitespace and letter spacing.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to