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

Changeset 285948 in webkit


Ignore:
Timestamp:
Nov 17, 2021, 12:16:45 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Do not apply the "do not trim whitespace followed by br" legacy line layout quirk when computing the intrinsic widths
https://bugs.webkit.org/show_bug.cgi?id=233262

Reviewed by Antti Koivisto.

While legacy line layout applies this quirk at line layout, the preferred width computation (totally different) codepath omits this quirk.

  • layout/formattingContexts/inline/InlineLine.cpp:

(WebCore::Layout::Line::removeTrailingTrimmableContent):

  • 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

    r285946 r285948  
     12021-11-17  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not apply the "do not trim whitespace followed by br" legacy line layout quirk when computing the intrinsic widths
     4        https://bugs.webkit.org/show_bug.cgi?id=233262
     5
     6        Reviewed by Antti Koivisto.
     7
     8        While legacy line layout applies this quirk at line layout, the preferred width computation (totally different) codepath omits this quirk.
     9
     10        * layout/formattingContexts/inline/InlineLine.cpp:
     11        (WebCore::Layout::Line::removeTrailingTrimmableContent):
     12        * layout/formattingContexts/inline/InlineLine.h:
     13        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
     14        (WebCore::Layout::LineBuilder::close):
     15
    1162021-11-17  Alan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r285931 r285948  
    3333#include "InlineSoftLineBreakItem.h"
    3434#include "LayoutBoxGeometry.h"
    35 #include "RuntimeEnabledFeatures.h"
    3635#include "TextFlags.h"
    3736#include "TextUtil.h"
     
    174173}
    175174
    176 void Line::removeTrailingTrimmableContent()
     175void Line::removeTrailingTrimmableContent(ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk shouldApplyTrailingWhiteSpaceFollowedByBRQuirk)
    177176{
    178177    if (m_trimmableTrailingContent.isEmpty() || m_runs.isEmpty())
    179178        return;
    180179
    181     // Complex line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
    182     if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
     180    if (shouldApplyTrailingWhiteSpaceFollowedByBRQuirk == ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::Yes) {
    183181        auto isTextAlignRight = [&] {
    184182            auto textAlign = formattingContext().root().style().textAlign();
     
    193191        }
    194192    }
    195 
    196193    m_contentLogicalWidth -= m_trimmableTrailingContent.remove();
    197194}
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h

    r285931 r285948  
    6464    void addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth);
    6565
    66     void removeTrailingTrimmableContent();
     66    enum class ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk { No, Yes };
     67    void removeTrailingTrimmableContent(ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk);
    6768    void removeHangingGlyphs();
    6869    void visuallyCollapseHangingOverflowingGlyphs(InlineLayoutUnit horizontalAvailableSpace);
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp

    r285931 r285948  
    3535#include "LayoutBoxGeometry.h"
    3636#include "LayoutState.h"
     37#include "RuntimeEnabledFeatures.h"
    3738#include "TextUtil.h"
    3839#include <wtf/unicode/CharacterNames.h>
     
    458459    }
    459460    auto horizontalAvailableSpace = m_lineLogicalRect.width();
    460     m_line.removeTrailingTrimmableContent();
    461     if (isInIntrinsicWidthMode()) {
     461    auto isInIntrinsicWidthMode = this->isInIntrinsicWidthMode();
     462    // Legacy line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
     463    // This quirk however should not be applied when running intrinsic width computation.
     464    // FIXME: webkit.org/b/233261
     465    auto shouldApplyTrailingWhiteSpaceFollowedByBRQuirk = isInIntrinsicWidthMode || !RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
     466        ? Line::ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::No
     467        : Line::ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::Yes;
     468    m_line.removeTrailingTrimmableContent(shouldApplyTrailingWhiteSpaceFollowedByBRQuirk);
     469
     470    if (isInIntrinsicWidthMode) {
    462471        // When a glyph at the start or end edge of a line hangs, it is not considered when measuring the line’s contents for fit.
    463472        // https://drafts.csswg.org/css-text/#hanging
Note: See TracChangeset for help on using the changeset viewer.