Title: [267920] trunk/Source/WebCore
Revision
267920
Author
[email protected]
Date
2020-10-03 06:22:26 -0700 (Sat, 03 Oct 2020)

Log Message

[LFC][IFC][Soft hyphen] Soft hyphen is always the trailing character
https://bugs.webkit.org/show_bug.cgi?id=217264

Reviewed by Antti Koivisto.

Soft hyphen is a word wrap opportunity. An InlineTextItem can only have one trailing soft hyphen.
e.g <span>before&shy;after</span> generates 2 separate InlineTextItems: [before-][after].

InlineTextItem should be able to tell if it ends with a soft hyphen.

* layout/inlineformatting/InlineItem.cpp:
* layout/inlineformatting/InlineItem.h:
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
* layout/inlineformatting/InlineTextItem.h:
(WebCore::Layout::InlineTextItem::hasTrailingSoftHyphen const):
(WebCore::Layout::InlineTextItem::createWhitespaceItem):
(WebCore::Layout::InlineTextItem::createNonWhitespaceItem):
(WebCore::Layout::InlineTextItem::InlineTextItem):
(WebCore::Layout::InlineTextItem::left const):
(WebCore::Layout::InlineTextItem::right const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267919 => 267920)


--- trunk/Source/WebCore/ChangeLog	2020-10-03 06:28:13 UTC (rev 267919)
+++ trunk/Source/WebCore/ChangeLog	2020-10-03 13:22:26 UTC (rev 267920)
@@ -1,3 +1,27 @@
+2020-10-03  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC][Soft hyphen] Soft hyphen is always the trailing character
+        https://bugs.webkit.org/show_bug.cgi?id=217264
+
+        Reviewed by Antti Koivisto.
+
+        Soft hyphen is a word wrap opportunity. An InlineTextItem can only have one trailing soft hyphen.
+        e.g <span>before&shy;after</span> generates 2 separate InlineTextItems: [before-][after].
+
+        InlineTextItem should be able to tell if it ends with a soft hyphen.
+
+        * layout/inlineformatting/InlineItem.cpp:
+        * layout/inlineformatting/InlineItem.h:
+        * layout/inlineformatting/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+        * layout/inlineformatting/InlineTextItem.h:
+        (WebCore::Layout::InlineTextItem::hasTrailingSoftHyphen const):
+        (WebCore::Layout::InlineTextItem::createWhitespaceItem):
+        (WebCore::Layout::InlineTextItem::createNonWhitespaceItem):
+        (WebCore::Layout::InlineTextItem::InlineTextItem):
+        (WebCore::Layout::InlineTextItem::left const):
+        (WebCore::Layout::InlineTextItem::right const):
+
 2020-10-02  Yusuke Suzuki  <[email protected]>
 
         std::once_flag must be allocated in static storage

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineItem.cpp (267919 => 267920)


--- trunk/Source/WebCore/layout/inlineformatting/InlineItem.cpp	2020-10-03 06:28:13 UTC (rev 267919)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineItem.cpp	2020-10-03 13:22:26 UTC (rev 267920)
@@ -38,6 +38,7 @@
     uint8_t enum1;
     uint8_t enum2;
     bool widthBool;
+    bool softHyphenBool;
     bool isCollapsible;
     InlineLayoutUnit width;
     unsigned start;

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineItem.h (267919 => 267920)


--- trunk/Source/WebCore/layout/inlineformatting/InlineItem.h	2020-10-03 06:28:13 UTC (rev 267919)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineItem.h	2020-10-03 13:22:26 UTC (rev 267920)
@@ -61,6 +61,7 @@
     enum class TextItemType  : uint8_t { Undefined, Whitespace, NonWhitespace };
     TextItemType m_textItemType { TextItemType::Undefined };
     bool m_hasWidth { false };
+    bool m_hasTrailingSoftHyphen { false };
     bool m_isCollapsible { false };
     InlineLayoutUnit m_width { };
     unsigned m_length { 0 };

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (267919 => 267920)


--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2020-10-03 06:28:13 UTC (rev 267919)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2020-10-03 13:22:26 UTC (rev 267920)
@@ -115,7 +115,9 @@
         }
 
         auto length = moveToNextBreakablePosition(currentPosition, lineBreakIterator, style);
-        inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineTextBox, currentPosition, length, inlineItemWidth(currentPosition, length)));
+        ASSERT(length);
+        auto hasTrailingSoftHyphen = text[currentPosition + length - 1] == softHyphen;
+        inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineTextBox, currentPosition, length, hasTrailingSoftHyphen, inlineItemWidth(currentPosition, length)));
         currentPosition += length;
     }
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h (267919 => 267920)


--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h	2020-10-03 06:28:13 UTC (rev 267919)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h	2020-10-03 13:22:26 UTC (rev 267920)
@@ -45,6 +45,7 @@
 
     bool isWhitespace() const { return m_textItemType == TextItemType::Whitespace; }
     bool isCollapsible() const { return m_isCollapsible; }
+    bool hasTrailingSoftHyphen() const { return m_hasTrailingSoftHyphen; }
     Optional<InlineLayoutUnit> width() const { return m_hasWidth ? makeOptional(m_width) : Optional<InlineLayoutUnit> { }; }
     bool isEmptyContent() const;
 
@@ -56,22 +57,22 @@
 private:
     using InlineItem::TextItemType;
 
-    InlineTextItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType);
+    InlineTextItem(const InlineTextBox&, unsigned start, unsigned length, bool hasTrailingSoftHyphen, Optional<InlineLayoutUnit> width, TextItemType);
     InlineTextItem(const InlineTextBox&);
 
     static InlineTextItem createWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
-    static InlineTextItem createNonWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
+    static InlineTextItem createNonWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, bool hasTrailingSoftHyphen, Optional<InlineLayoutUnit> width);
     static InlineTextItem createEmptyItem(const InlineTextBox&);
 };
 
 inline InlineTextItem InlineTextItem::createWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
 {
-    return { inlineTextBox, start, length, width, TextItemType::Whitespace };
+    return { inlineTextBox, start, length, false, width, TextItemType::Whitespace };
 }
 
-inline InlineTextItem InlineTextItem::createNonWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
+inline InlineTextItem InlineTextItem::createNonWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, bool hasTrailingSoftHyphen, Optional<InlineLayoutUnit> width)
 {
-    return { inlineTextBox, start, length, width, TextItemType::NonWhitespace };
+    return { inlineTextBox, start, length, hasTrailingSoftHyphen, width, TextItemType::NonWhitespace };
 }
 
 inline InlineTextItem InlineTextItem::createEmptyItem(const InlineTextBox& inlineTextBox)
@@ -79,12 +80,13 @@
     return { inlineTextBox };
 }
 
-inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType textItemType)
+inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, bool hasTrailingSoftHyphen, Optional<InlineLayoutUnit> width, TextItemType textItemType)
     : InlineItem(inlineTextBox, Type::Text)
 {
     m_startOrPosition = start;
     m_length = length;
     m_hasWidth = !!width;
+    m_hasTrailingSoftHyphen = hasTrailingSoftHyphen;
     m_isCollapsible = textItemType == TextItemType::Whitespace && inlineTextBox.style().collapseWhiteSpace();
     m_width = width.valueOr(0);
     m_textItemType = textItemType;
@@ -100,7 +102,7 @@
     RELEASE_ASSERT(length <= this->length());
     ASSERT(m_textItemType != TextItemType::Undefined);
     ASSERT(length);
-    return { inlineTextBox(), start(), length, WTF::nullopt, m_textItemType };
+    return { inlineTextBox(), start(), length, false, WTF::nullopt, m_textItemType };
 }
 
 inline InlineTextItem InlineTextItem::right(unsigned length) const
@@ -108,7 +110,7 @@
     RELEASE_ASSERT(length <= this->length());
     ASSERT(m_textItemType != TextItemType::Undefined);
     ASSERT(length);
-    return { inlineTextBox(), end() - length, length, WTF::nullopt, m_textItemType };
+    return { inlineTextBox(), end() - length, length, hasTrailingSoftHyphen(), WTF::nullopt, m_textItemType };
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to