Title: [284063] trunk
Revision
284063
Author
za...@apple.com
Date
2021-10-12 17:01:51 -0700 (Tue, 12 Oct 2021)

Log Message

[LFC][IFC] Do not collapse whitespace with zero-width space separator in-between
https://bugs.webkit.org/show_bug.cgi?id=231595

Reviewed by Antti Koivisto.

Source/WebCore:

Zero-width space characters separate individual sequence of whitespace (and non-whitepsace) content so we
should no collapse the before/after whitespace.

Test: fast/text/whitespace-with-zero-width-space-in-between.html

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::appendTextContent):
* layout/formattingContexts/inline/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::isZeroWidthSpaceSeparator const):
(WebCore::Layout::InlineTextItem::isEmptyContent const): Deleted.
* layout/formattingContexts/inline/InlineTextItem.h:
(WebCore::Layout::InlineTextItem::width const):

LayoutTests:

* fast/text/whitespace-with-zero-width-space-in-between-expected.html: Added.
* fast/text/whitespace-with-zero-width-space-in-between.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284062 => 284063)


--- trunk/LayoutTests/ChangeLog	2021-10-12 23:51:11 UTC (rev 284062)
+++ trunk/LayoutTests/ChangeLog	2021-10-13 00:01:51 UTC (rev 284063)
@@ -1,3 +1,13 @@
+2021-10-12  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Do not collapse whitespace with zero-width space separator in-between
+        https://bugs.webkit.org/show_bug.cgi?id=231595
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/whitespace-with-zero-width-space-in-between-expected.html: Added.
+        * fast/text/whitespace-with-zero-width-space-in-between.html: Added.
+
 2021-10-12  Ayumi Kojima  <ayumi_koj...@apple.com>
 
         [ macOS wk1 ] imported/w3c/web-platform-tests/css/selectors/focus-visible-009.html is a flaky failure.

Added: trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between-expected.html (0 => 284063)


--- trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between-expected.html	2021-10-13 00:01:51 UTC (rev 284063)
@@ -0,0 +1,13 @@
+<style>
+div {
+  font-size: 20px;
+  font-family: Monospace;
+  white-space: pre;
+}
+</style>
+<div>XX</div>
+<div>X  X</div>
+<div>X   X</div>
+<div>X    X</div>
+<div>X X</div>
+<div>X   X</div>

Added: trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between.html (0 => 284063)


--- trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace-with-zero-width-space-in-between.html	2021-10-13 00:01:51 UTC (rev 284063)
@@ -0,0 +1,13 @@
+<style>
+div {
+  font-size: 20px;
+  font-family: Monospace;
+}
+</style>
+<!-- Do not collapse whitespace across zero-width space content -->
+<div>X&#x200B;X</div>
+<div>X &#x200B; X</div>
+<div>X &#x200B; &#x200B; X</div>
+<div>X &#x200B; &#x200B; &#x200B; X</div>
+<div>X&#x200B;  &#x200B;X</div>
+<div>X  &#x200B;  &#x200B;  X</div>

Modified: trunk/Source/WebCore/ChangeLog (284062 => 284063)


--- trunk/Source/WebCore/ChangeLog	2021-10-12 23:51:11 UTC (rev 284062)
+++ trunk/Source/WebCore/ChangeLog	2021-10-13 00:01:51 UTC (rev 284063)
@@ -1,5 +1,25 @@
 2021-10-12  Alan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Do not collapse whitespace with zero-width space separator in-between
+        https://bugs.webkit.org/show_bug.cgi?id=231595
+
+        Reviewed by Antti Koivisto.
+
+        Zero-width space characters separate individual sequence of whitespace (and non-whitepsace) content so we
+        should no collapse the before/after whitespace.
+
+        Test: fast/text/whitespace-with-zero-width-space-in-between.html
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::appendTextContent):
+        * layout/formattingContexts/inline/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::isZeroWidthSpaceSeparator const):
+        (WebCore::Layout::InlineTextItem::isEmptyContent const): Deleted.
+        * layout/formattingContexts/inline/InlineTextItem.h:
+        (WebCore::Layout::InlineTextItem::width const):
+
+2021-10-12  Alan Bujtas  <za...@apple.com>
+
         [LFC][IFC] LazyLineBreakIterator should be correctly setup for the prior context case
         https://bugs.webkit.org/show_bug.cgi?id=231608
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-12 23:51:11 UTC (rev 284062)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-13 00:01:51 UTC (rev 284063)
@@ -267,13 +267,11 @@
 void Line::appendTextContent(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
 {
     auto willCollapseCompletely = [&] {
-        if (inlineTextItem.isEmptyContent())
-            return true;
         if (!inlineTextItem.isWhitespace())
             return false;
         if (InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem))
             return false;
-        // Check if the last item is collapsed as well.
+        // This content is collapsible. Let's check if the last item is collapsed.
         for (auto& run : WTF::makeReversedRange(m_runs)) {
             if (run.isBox())
                 return false;
@@ -280,8 +278,6 @@
             // https://drafts.csswg.org/css-text-3/#white-space-phase-1
             // Any collapsible space immediately following another collapsible space—even one outside the boundary of the inline containing that space,
             // provided both spaces are within the same inline formatting context—is collapsed to have zero advance width.
-            // : "<span>  </span> " <- the trailing whitespace collapses completely.
-            // Not that when the inline box has preserve whitespace style, "<span style="white-space: pre">  </span> " <- this whitespace stays around.
             if (run.isText())
                 return run.hasCollapsibleTrailingWhitespace();
             ASSERT(run.isInlineBoxStart() || run.isInlineBoxEnd() || run.isWordBreakOpportunity());
@@ -305,6 +301,8 @@
             return true;
         if (inlineTextItem.isWordSeparator() && style.fontCascade().wordSpacing())
             return true;
+        if (inlineTextItem.isZeroWidthSpaceSeparator())
+            return true;
         return false;
     }();
     auto oldContentLogicalWidth = contentLogicalWidth();

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.cpp (284062 => 284063)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.cpp	2021-10-12 23:51:11 UTC (rev 284062)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.cpp	2021-10-13 00:01:51 UTC (rev 284063)
@@ -150,7 +150,7 @@
     }
 }
 
-bool InlineTextItem::isEmptyContent() const
+bool InlineTextItem::isZeroWidthSpaceSeparator() const
 {
     // FIXME: We should check for more zero width content and not just U+200B.
     return !m_length || (m_length == 1 && inlineTextBox().content()[start()] == zeroWidthSpace); 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.h (284062 => 284063)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.h	2021-10-12 23:51:11 UTC (rev 284062)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.h	2021-10-13 00:01:51 UTC (rev 284063)
@@ -45,9 +45,9 @@
 
     bool isWhitespace() const { return m_textItemType == TextItemType::Whitespace; }
     bool isWordSeparator() const { return m_isWordSeparator; }
+    bool isZeroWidthSpaceSeparator() const;
     bool hasTrailingSoftHyphen() const { return m_hasTrailingSoftHyphen; }
     std::optional<InlineLayoutUnit> width() const { return m_hasWidth ? std::make_optional(m_width) : std::optional<InlineLayoutUnit> { }; }
-    bool isEmptyContent() const;
 
     const InlineTextBox& inlineTextBox() const { return downcast<InlineTextBox>(layoutBox()); }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to