Title: [283477] trunk/Source/WebCore
Revision
283477
Author
[email protected]
Date
2021-10-03 12:32:52 -0700 (Sun, 03 Oct 2021)

Log Message

[LFC][IFC] Line functions can compute the "extra horizontal space"
https://bugs.webkit.org/show_bug.cgi?id=231127

Reviewed by Antti Koivisto.

This is in preparation for making applyRunExpansion hanging whitespace aware.

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::removeCollapsibleContent):
(WebCore::Layout::Line::applyRunExpansion):
(WebCore::Layout::Line::visuallyCollapseHangingOverflow):
* layout/formattingContexts/inline/InlineLine.h:
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283476 => 283477)


--- trunk/Source/WebCore/ChangeLog	2021-10-03 19:31:55 UTC (rev 283476)
+++ trunk/Source/WebCore/ChangeLog	2021-10-03 19:32:52 UTC (rev 283477)
@@ -1,5 +1,22 @@
 2021-10-03  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] Line functions can compute the "extra horizontal space"
+        https://bugs.webkit.org/show_bug.cgi?id=231127
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for making applyRunExpansion hanging whitespace aware.
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::removeCollapsibleContent):
+        (WebCore::Layout::Line::applyRunExpansion):
+        (WebCore::Layout::Line::visuallyCollapseHangingOverflow):
+        * layout/formattingContexts/inline/InlineLine.h:
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::close):
+
+2021-10-03  Alan Bujtas  <[email protected]>
+
         [LFC][IFC] Moving hanging whitespace sequence handling to Line
         https://bugs.webkit.org/show_bug.cgi?id=231126
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-03 19:31:55 UTC (rev 283476)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-03 19:32:52 UTC (rev 283477)
@@ -60,13 +60,13 @@
     m_trimmableTrailingContent.reset();
 }
 
-void Line::removeCollapsibleContent(InlineLayoutUnit extraHorizontalSpace)
+void Line::removeCollapsibleContent(InlineLayoutUnit horizontalAvailableSpace)
 {
     removeTrailingTrimmableContent();
-    visuallyCollapseHangingOverflow(extraHorizontalSpace);
+    visuallyCollapseHangingOverflow(horizontalAvailableSpace);
 }
 
-void Line::applyRunExpansion(InlineLayoutUnit extraHorizontalSpace)
+void Line::applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace)
 {
     ASSERT(formattingContext().root().style().textAlign() == TextAlignMode::Justify);
     // Text is justified according to the method specified by the text-justify property,
@@ -75,7 +75,8 @@
     if (m_runs.isEmpty() || m_runs.last().isLineBreak())
         return;
     // Anything to distribute?
-    if (!extraHorizontalSpace)
+    auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth();
+    if (spaceToDistribute <= 0)
         return;
 
     // Collect and distribute the expansion opportunities.
@@ -125,7 +126,7 @@
     if (!lineExpansionOpportunities)
         return;
     // Distribute the extra space.
-    auto expansionToDistribute = extraHorizontalSpace / lineExpansionOpportunities;
+    auto expansionToDistribute = spaceToDistribute / lineExpansionOpportunities;
     auto accumulatedExpansion = InlineLayoutUnit { };
     for (size_t runIndex = 0; runIndex < m_runs.size(); ++runIndex) {
         auto& run = m_runs[runIndex];
@@ -163,13 +164,13 @@
     m_contentLogicalWidth -= m_trimmableTrailingContent.remove();
 }
 
-void Line::visuallyCollapseHangingOverflow(InlineLayoutUnit extraHorizontalSpace)
+void Line::visuallyCollapseHangingOverflow(InlineLayoutUnit horizontalAvailableSpace)
 {
     ASSERT(m_trimmableTrailingContent.isEmpty());
     // If white-space is set to pre-wrap, the UA must
     // ...
     // It may also visually collapse the character advance widths of any that would otherwise overflow.
-    auto overflowWidth = -extraHorizontalSpace;
+    auto overflowWidth = contentLogicalWidth() - horizontalAvailableSpace;
     if (overflowWidth <= 0)
         return;
     // Let's just find the trailing pre-wrap whitespace content for now (e.g check if there are multiple trailing runs with

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (283476 => 283477)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-10-03 19:31:55 UTC (rev 283476)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-10-03 19:32:52 UTC (rev 283477)
@@ -58,8 +58,8 @@
     std::optional<InlineLayoutUnit> trailingSoftHyphenWidth() const { return m_trailingSoftHyphenWidth; }
     void addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth);
 
-    void removeCollapsibleContent(InlineLayoutUnit extraHorizontalSpace);
-    void applyRunExpansion(InlineLayoutUnit extraHorizontalSpace);
+    void removeCollapsibleContent(InlineLayoutUnit horizontalAvailableSpace);
+    void applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace);
 
     struct Run {
         bool isText() const { return m_type == InlineItem::Type::Text; }
@@ -154,7 +154,7 @@
     void appendWordBreakOpportunity(const InlineItem&);
 
     void removeTrailingTrimmableContent();
-    void visuallyCollapseHangingOverflow(InlineLayoutUnit extraHorizontalSpace);
+    void visuallyCollapseHangingOverflow(InlineLayoutUnit horizontalAvailableSpace);
 
     const InlineFormattingContext& formattingContext() const;
 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (283476 => 283477)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-10-03 19:31:55 UTC (rev 283476)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-10-03 19:32:52 UTC (rev 283477)
@@ -372,12 +372,12 @@
         // Line is empty, we only managed to place float boxes.
         return lineRange;
     }
-    auto availableWidth = m_lineLogicalRect.width() - m_line.contentLogicalRight();
-    m_line.removeCollapsibleContent(availableWidth);
+    auto horizontalAvailableSpace = m_lineLogicalRect.width();
+    m_line.removeCollapsibleContent(horizontalAvailableSpace);
     auto horizontalAlignment = root().style().textAlign();
     auto runsExpandHorizontally = horizontalAlignment == TextAlignMode::Justify && !isLastLineWithInlineContent(lineRange, needsLayoutRange.end, committedContent.partialTrailingContentLength);
     if (runsExpandHorizontally)
-        m_line.applyRunExpansion(m_lineLogicalRect.width() - m_line.contentLogicalRight());
+        m_line.applyRunExpansion(horizontalAvailableSpace);
     auto lineEndsWithHyphen = false;
     if (!m_line.runs().isEmpty()) {
         auto& lastTextContent = m_line.runs().last().textContent();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to