Title: [251642] trunk/Source/WebCore
Revision
251642
Author
[email protected]
Date
2019-10-27 10:18:58 -0700 (Sun, 27 Oct 2019)

Log Message

[LFC][IFC] Do not expand runs with collapsed trailing whitespace
https://bugs.webkit.org/show_bug.cgi?id=203468
<rdar://problem/56653689>

Reviewed by Antti Koivisto.

Runs are supposed to be a continuous chunk of content. Runs with trailing
collapsed whitespace can't accommodate additional trailing content.

* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::close):
(WebCore::Layout::Line::Run::isWhitespace const): Deleted.
(WebCore::Layout::Line::Run::canBeExtended const): Deleted.
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::expand):
(WebCore::Layout::Line::Run::isWhitespace const):
(WebCore::Layout::Line::Run::setIsCollapsed):
(WebCore::Layout::Line::Run::canBeExtended const):
(WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (251641 => 251642)


--- trunk/Source/WebCore/ChangeLog	2019-10-27 16:52:32 UTC (rev 251641)
+++ trunk/Source/WebCore/ChangeLog	2019-10-27 17:18:58 UTC (rev 251642)
@@ -1,5 +1,27 @@
 2019-10-27  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Do not expand runs with collapsed trailing whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=203468
+        <rdar://problem/56653689>
+
+        Reviewed by Antti Koivisto.
+
+        Runs are supposed to be a continuous chunk of content. Runs with trailing
+        collapsed whitespace can't accommodate additional trailing content.
+
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::close):
+        (WebCore::Layout::Line::Run::isWhitespace const): Deleted.
+        (WebCore::Layout::Line::Run::canBeExtended const): Deleted.
+        * layout/inlineformatting/InlineLine.h:
+        (WebCore::Layout::Line::Run::expand):
+        (WebCore::Layout::Line::Run::isWhitespace const):
+        (WebCore::Layout::Line::Run::setIsCollapsed):
+        (WebCore::Layout::Line::Run::canBeExtended const):
+        (WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth):
+
+2019-10-27  Zalan Bujtas  <[email protected]>
+
         [LFC][Painting] Use the dirty rect to decide what to paint
         https://bugs.webkit.org/show_bug.cgi?id=203467
         <rdar://problem/56653229>

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (251641 => 251642)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-10-27 16:52:32 UTC (rev 251641)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-10-27 17:18:58 UTC (rev 251642)
@@ -43,23 +43,6 @@
 {
 }
 
-bool Line::Run::isWhitespace() const
-{
-    if (!isText())
-        return false;
-    return downcast<InlineTextItem>(m_inlineItem).isWhitespace();
-}
-
-bool Line::Run::canBeExtended() const
-{
-    if (!isText())
-        return false;
-    // Non-collapsed text runs can be merged into one continuous run.
-    if (isCollapsedToZeroAdvanceWidth())
-        return false;
-    return !isCollapsed();
-}
-
 Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, Optional<TextAlignMode> horizontalAlignment, SkipAlignment skipAlignment)
     : m_inlineFormattingContext(inlineFormattingContext)
     , m_initialStrut(initialConstraints.heightAndBaseline ? initialConstraints.heightAndBaseline->strut : WTF::nullopt)
@@ -138,10 +121,11 @@
             continue;
         }
         auto& currentRun = m_runList[index];
-        if (!currentRun->isText() || &currentRun->layoutBox() != &previousRun->layoutBox()) {
-            // Do not merge runs from different boxes (<span>foo</span><span>bar</span>)
-            // or within the same layout box but with preserved \n
-            // (<span>text\n<span <- both the "text" and "\" belong to the same layout box)
+        // Do not merge runs from different boxes (<span>foo</span><span>bar</span>)
+        // or within the same layout box but with preserved \n
+        // (<span>text\n<span <- both the "text" and "\" belong to the same layout box)
+        auto canAppendToPreviousRun = currentRun->isText() && &currentRun->layoutBox() ==  &previousRun->layoutBox();
+        if (!canAppendToPreviousRun) {
             ++index;
             continue;
         }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (251641 => 251642)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-10-27 16:52:32 UTC (rev 251641)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-10-27 17:18:58 UTC (rev 251642)
@@ -90,7 +90,7 @@
 
         void expand(const Run&);
 
-        void setIsCollapsed() { m_isCollapsed = true; }
+        void setIsCollapsed();
         void setCollapsesToZeroAdvanceWidth();
 
         bool isWhitespace() const;
@@ -100,6 +100,7 @@
         Display::Run m_displayRun;
         bool m_isCollapsed { false };
         bool m_collapsedToZeroAdvanceWidth { false };
+        bool m_hasTrailingCollapsedContent { false };
     };
     using RunList = Vector<std::unique_ptr<Run>>;
     RunList close();
@@ -155,12 +156,31 @@
     ASSERT(isText());
     ASSERT(other.isText());
     ASSERT(!isCollapsedToZeroAdvanceWidth());
+    ASSERT(!m_hasTrailingCollapsedContent);
 
     auto& otherDisplayRun = other.displayRun();
     m_displayRun.expandHorizontally(otherDisplayRun.logicalWidth());
     m_displayRun.textContext()->expand(*otherDisplayRun.textContext());
+    m_hasTrailingCollapsedContent = other.isCollapsed();
 }
 
+inline bool Line::Run::isWhitespace() const
+{
+    return isText() && downcast<InlineTextItem>(m_inlineItem).isWhitespace();
+}
+
+inline void Line::Run::setIsCollapsed()
+{
+    ASSERT(isWhitespace());
+    m_isCollapsed = true;
+    m_hasTrailingCollapsedContent = true;
+}
+
+inline bool Line::Run::canBeExtended() const
+{
+    return isText() && !m_hasTrailingCollapsedContent;
+}
+
 inline bool Line::Run::isCollapsedToZeroAdvanceWidth() const
 {
     ASSERT(!m_collapsedToZeroAdvanceWidth || !m_displayRun.logicalWidth());
@@ -169,8 +189,8 @@
 
 inline void Line::Run::setCollapsesToZeroAdvanceWidth()
 {
+    setIsCollapsed();
     m_collapsedToZeroAdvanceWidth = true;
-    m_isCollapsed = true;
     m_displayRun.setLogicalWidth({ });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to