⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283477 in webkit


Ignore:
Timestamp:
Oct 3, 2021, 12:32:52 PM (5 years ago)
Author:
Alan Bujtas
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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r283474 r283477  
     12021-10-03  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Line functions can compute the "extra horizontal space"
     4        https://bugs.webkit.org/show_bug.cgi?id=231127
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for making applyRunExpansion hanging whitespace aware.
     9
     10        * layout/formattingContexts/inline/InlineLine.cpp:
     11        (WebCore::Layout::Line::removeCollapsibleContent):
     12        (WebCore::Layout::Line::applyRunExpansion):
     13        (WebCore::Layout::Line::visuallyCollapseHangingOverflow):
     14        * layout/formattingContexts/inline/InlineLine.h:
     15        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
     16        (WebCore::Layout::LineBuilder::close):
     17
    1182021-10-03  Alan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r283474 r283477  
    6161}
    6262
    63 void Line::removeCollapsibleContent(InlineLayoutUnit extraHorizontalSpace)
     63void Line::removeCollapsibleContent(InlineLayoutUnit horizontalAvailableSpace)
    6464{
    6565    removeTrailingTrimmableContent();
    66     visuallyCollapseHangingOverflow(extraHorizontalSpace);
    67 }
    68 
    69 void Line::applyRunExpansion(InlineLayoutUnit extraHorizontalSpace)
     66    visuallyCollapseHangingOverflow(horizontalAvailableSpace);
     67}
     68
     69void Line::applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace)
    7070{
    7171    ASSERT(formattingContext().root().style().textAlign() == TextAlignMode::Justify);
     
    7676        return;
    7777    // Anything to distribute?
    78     if (!extraHorizontalSpace)
     78    auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth();
     79    if (spaceToDistribute <= 0)
    7980        return;
    8081
     
    126127        return;
    127128    // Distribute the extra space.
    128     auto expansionToDistribute = extraHorizontalSpace / lineExpansionOpportunities;
     129    auto expansionToDistribute = spaceToDistribute / lineExpansionOpportunities;
    129130    auto accumulatedExpansion = InlineLayoutUnit { };
    130131    for (size_t runIndex = 0; runIndex < m_runs.size(); ++runIndex) {
     
    164165}
    165166
    166 void Line::visuallyCollapseHangingOverflow(InlineLayoutUnit extraHorizontalSpace)
     167void Line::visuallyCollapseHangingOverflow(InlineLayoutUnit horizontalAvailableSpace)
    167168{
    168169    ASSERT(m_trimmableTrailingContent.isEmpty());
     
    170171    // ...
    171172    // It may also visually collapse the character advance widths of any that would otherwise overflow.
    172     auto overflowWidth = -extraHorizontalSpace;
     173    auto overflowWidth = contentLogicalWidth() - horizontalAvailableSpace;
    173174    if (overflowWidth <= 0)
    174175        return;
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h

    r283474 r283477  
    5959    void addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth);
    6060
    61     void removeCollapsibleContent(InlineLayoutUnit extraHorizontalSpace);
    62     void applyRunExpansion(InlineLayoutUnit extraHorizontalSpace);
     61    void removeCollapsibleContent(InlineLayoutUnit horizontalAvailableSpace);
     62    void applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace);
    6363
    6464    struct Run {
     
    155155
    156156    void removeTrailingTrimmableContent();
    157     void visuallyCollapseHangingOverflow(InlineLayoutUnit extraHorizontalSpace);
     157    void visuallyCollapseHangingOverflow(InlineLayoutUnit horizontalAvailableSpace);
    158158
    159159    const InlineFormattingContext& formattingContext() const;
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp

    r283474 r283477  
    373373        return lineRange;
    374374    }
    375     auto availableWidth = m_lineLogicalRect.width() - m_line.contentLogicalRight();
    376     m_line.removeCollapsibleContent(availableWidth);
     375    auto horizontalAvailableSpace = m_lineLogicalRect.width();
     376    m_line.removeCollapsibleContent(horizontalAvailableSpace);
    377377    auto horizontalAlignment = root().style().textAlign();
    378378    auto runsExpandHorizontally = horizontalAlignment == TextAlignMode::Justify && !isLastLineWithInlineContent(lineRange, needsLayoutRange.end, committedContent.partialTrailingContentLength);
    379379    if (runsExpandHorizontally)
    380         m_line.applyRunExpansion(m_lineLogicalRect.width() - m_line.contentLogicalRight());
     380        m_line.applyRunExpansion(horizontalAvailableSpace);
    381381    auto lineEndsWithHyphen = false;
    382382    if (!m_line.runs().isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.