Title: [283486] trunk
Revision
283486
Author
[email protected]
Date
2021-10-03 21:34:43 -0700 (Sun, 03 Oct 2021)

Log Message

[LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
https://bugs.webkit.org/show_bug.cgi?id=231132

Reviewed by Antti Koivisto.

Source/WebCore:

Ignore hanging whitespace for expansion opportunities.
This patch fixes imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::applyRunExpansion):

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283485 => 283486)


--- trunk/LayoutTests/ChangeLog	2021-10-04 01:07:25 UTC (rev 283485)
+++ trunk/LayoutTests/ChangeLog	2021-10-04 04:34:43 UTC (rev 283486)
@@ -1,5 +1,14 @@
 2021-10-03  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
+        https://bugs.webkit.org/show_bug.cgi?id=231132
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations:
+
+2021-10-03  Alan Bujtas  <[email protected]>
+
         Incorrect preferred width computation when trimmable leading whitespace is present
         https://bugs.webkit.org/show_bug.cgi?id=231139
 

Modified: trunk/LayoutTests/TestExpectations (283485 => 283486)


--- trunk/LayoutTests/TestExpectations	2021-10-04 01:07:25 UTC (rev 283485)
+++ trunk/LayoutTests/TestExpectations	2021-10-04 04:34:43 UTC (rev 283486)
@@ -4447,7 +4447,6 @@
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/seg-break-transformation-018.html [ ImageOnlyFailure ]
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/seg-break-transformation-019.html [ ImageOnlyFailure ]
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-012.html [ ImageOnlyFailure ]
-webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html [ ImageOnlyFailure ]
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-001.html [ ImageOnlyFailure ]
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-002.html [ ImageOnlyFailure ]
 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-003.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (283485 => 283486)


--- trunk/Source/WebCore/ChangeLog	2021-10-04 01:07:25 UTC (rev 283485)
+++ trunk/Source/WebCore/ChangeLog	2021-10-04 04:34:43 UTC (rev 283486)
@@ -1,5 +1,18 @@
 2021-10-03  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
+        https://bugs.webkit.org/show_bug.cgi?id=231132
+
+        Reviewed by Antti Koivisto.
+
+        Ignore hanging whitespace for expansion opportunities.
+        This patch fixes imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::applyRunExpansion):
+
+2021-10-03  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] HangingTrailingContent should cache width/length
         https://bugs.webkit.org/show_bug.cgi?id=231128
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-04 01:07:25 UTC (rev 283485)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-04 04:34:43 UTC (rev 283486)
@@ -79,11 +79,12 @@
     // the last line before a forced break or the end of the block is start-aligned.
     if (m_runs.isEmpty() || m_runs.last().isLineBreak())
         return;
-    // Anything to distribute?
-    auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth();
+    // A hanging glyph is still enclosed inside its parent inline box and still participates in text justification:
+    // its character advance is just not measured when determining how much content fits on the line, how much the line’s contents
+    // need to be expanded or compressed for justification, or how to position the content within the line box for text alignment.
+    auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth() + m_hangingTrailingContent.width();
     if (spaceToDistribute <= 0)
         return;
-
     // Collect and distribute the expansion opportunities.
     size_t lineExpansionOpportunities = 0;
     Vector<size_t> runsExpansionOpportunities(m_runs.size());
@@ -92,17 +93,24 @@
 
     // Line start behaves as if we had an expansion here (i.e. fist runs should not start with allowing left expansion).
     auto runIsAfterExpansion = true;
+    auto hangingTrailingContentLength = m_hangingTrailingContent.length();
     for (size_t runIndex = 0; runIndex < m_runs.size(); ++runIndex) {
         auto& run = m_runs[runIndex];
         int expansionBehavior = DefaultExpansion;
         size_t expansionOpportunitiesInRun = 0;
 
-        if (run.isText() && !TextUtil::shouldPreserveSpacesAndTabs(run.layoutBox())) {
+        // FIXME: Check why we don't apply expansion when whitespace is preserved.
+        if (run.isText() && (!TextUtil::shouldPreserveSpacesAndTabs(run.layoutBox()) || hangingTrailingContentLength)) {
             if (run.hasTextCombine())
                 expansionBehavior = ForbidLeftExpansion | ForbidRightExpansion;
             else {
                 expansionBehavior = (runIsAfterExpansion ? ForbidLeftExpansion : AllowLeftExpansion) | AllowRightExpansion;
-                std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(run.textContent()->start, run.textContent()->length), run.inlineDirection(), expansionBehavior);
+                auto& textContent = *run.textContent();
+                // Trailing hanging whitespace sequence is ignored when computing the expansion opportunities.
+                auto hangingTrailingContentInCurrentRun = std::min(textContent.length, hangingTrailingContentLength);
+                auto length = textContent.length - hangingTrailingContentInCurrentRun;
+                hangingTrailingContentLength -= hangingTrailingContentInCurrentRun;
+                std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(textContent.start, length), run.inlineDirection(), expansionBehavior);
             }
         } else if (run.isBox())
             runIsAfterExpansion = false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to