Title: [285948] trunk/Source/WebCore
Revision
285948
Author
[email protected]
Date
2021-11-17 12:16:45 -0800 (Wed, 17 Nov 2021)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285947 => 285948)


--- trunk/Source/WebCore/ChangeLog	2021-11-17 20:15:57 UTC (rev 285947)
+++ trunk/Source/WebCore/ChangeLog	2021-11-17 20:16:45 UTC (rev 285948)
@@ -1,5 +1,20 @@
 2021-11-17  Alan Bujtas  <[email protected]>
 
+        [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):
+
+2021-11-17  Alan Bujtas  <[email protected]>
+
         Address post review comment after r285925.
 
         Reviewed by Darin Adler.

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-11-17 20:15:57 UTC (rev 285947)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-11-17 20:16:45 UTC (rev 285948)
@@ -32,7 +32,6 @@
 #include "InlineFormattingContext.h"
 #include "InlineSoftLineBreakItem.h"
 #include "LayoutBoxGeometry.h"
-#include "RuntimeEnabledFeatures.h"
 #include "TextFlags.h"
 #include "TextUtil.h"
 #include <wtf/IsoMallocInlines.h>
@@ -173,13 +172,12 @@
     m_contentLogicalWidth += accumulatedExpansion;
 }
 
-void Line::removeTrailingTrimmableContent()
+void Line::removeTrailingTrimmableContent(ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk shouldApplyTrailingWhiteSpaceFollowedByBRQuirk)
 {
     if (m_trimmableTrailingContent.isEmpty() || m_runs.isEmpty())
         return;
 
-    // Complex line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
-    if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
+    if (shouldApplyTrailingWhiteSpaceFollowedByBRQuirk == ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::Yes) {
         auto isTextAlignRight = [&] {
             auto textAlign = formattingContext().root().style().textAlign();
             return textAlign == TextAlignMode::Right
@@ -192,7 +190,6 @@
             return;
         }
     }
-
     m_contentLogicalWidth -= m_trimmableTrailingContent.remove();
 }
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-11-17 20:15:57 UTC (rev 285947)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-11-17 20:16:45 UTC (rev 285948)
@@ -63,7 +63,8 @@
     std::optional<InlineLayoutUnit> trailingSoftHyphenWidth() const { return m_trailingSoftHyphenWidth; }
     void addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth);
 
-    void removeTrailingTrimmableContent();
+    enum class ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk { No, Yes };
+    void removeTrailingTrimmableContent(ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk);
     void removeHangingGlyphs();
     void visuallyCollapseHangingOverflowingGlyphs(InlineLayoutUnit horizontalAvailableSpace);
     void applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace);

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-11-17 20:15:57 UTC (rev 285947)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-11-17 20:16:45 UTC (rev 285948)
@@ -34,6 +34,7 @@
 #include "LayoutBox.h"
 #include "LayoutBoxGeometry.h"
 #include "LayoutState.h"
+#include "RuntimeEnabledFeatures.h"
 #include "TextUtil.h"
 #include <wtf/unicode/CharacterNames.h>
 
@@ -457,8 +458,16 @@
         return lineRange;
     }
     auto horizontalAvailableSpace = m_lineLogicalRect.width();
-    m_line.removeTrailingTrimmableContent();
-    if (isInIntrinsicWidthMode()) {
+    auto isInIntrinsicWidthMode = this->isInIntrinsicWidthMode();
+    // Legacy line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
+    // This quirk however should not be applied when running intrinsic width computation.
+    // FIXME: webkit.org/b/233261
+    auto shouldApplyTrailingWhiteSpaceFollowedByBRQuirk = isInIntrinsicWidthMode || !RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
+        ? Line::ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::No
+        : Line::ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk::Yes;
+    m_line.removeTrailingTrimmableContent(shouldApplyTrailingWhiteSpaceFollowedByBRQuirk);
+
+    if (isInIntrinsicWidthMode) {
         // 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.
         // https://drafts.csswg.org/css-text/#hanging
         // FIXME: Add support for conditionally hanging glyphs.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to