Title: [285076] trunk/Source/WebCore
Revision
285076
Author
[email protected]
Date
2021-10-29 22:25:59 -0700 (Fri, 29 Oct 2021)

Log Message

[LFC][IFC] Move InlineTextItem construction to InlineItemsBuilder
https://bugs.webkit.org/show_bug.cgi?id=232498

Reviewed by Antti Koivisto.

This is in preparation for adding bidi support.

* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::moveToNextNonWhitespacePosition):
(WebCore::Layout::moveToNextBreakablePosition):
(WebCore::Layout::InlineItemsBuilder::build):
(WebCore::Layout::InlineItemsBuilder::createAndAppendTextItems):
* layout/formattingContexts/inline/InlineItemsBuilder.h:
* layout/formattingContexts/inline/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::InlineTextItem):
(WebCore::Layout::InlineTextItem::left const):
(WebCore::Layout::InlineTextItem::right const):
(): Deleted.
(WebCore::Layout::moveToNextNonWhitespacePosition): Deleted.
(WebCore::Layout::moveToNextBreakablePosition): Deleted.
(WebCore::Layout::InlineTextItem::createAndAppendTextItems): Deleted.
* layout/formattingContexts/inline/InlineTextItem.h:
(WebCore::Layout::InlineTextItem::InlineTextItem): Deleted.
(WebCore::Layout::InlineTextItem::left const): Deleted.
(WebCore::Layout::InlineTextItem::right const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285075 => 285076)


--- trunk/Source/WebCore/ChangeLog	2021-10-30 05:11:58 UTC (rev 285075)
+++ trunk/Source/WebCore/ChangeLog	2021-10-30 05:25:59 UTC (rev 285076)
@@ -1,3 +1,31 @@
+2021-10-29  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Move InlineTextItem construction to InlineItemsBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=232498
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for adding bidi support.
+
+        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+        (WebCore::Layout::moveToNextNonWhitespacePosition):
+        (WebCore::Layout::moveToNextBreakablePosition):
+        (WebCore::Layout::InlineItemsBuilder::build):
+        (WebCore::Layout::InlineItemsBuilder::createAndAppendTextItems):
+        * layout/formattingContexts/inline/InlineItemsBuilder.h:
+        * layout/formattingContexts/inline/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::InlineTextItem):
+        (WebCore::Layout::InlineTextItem::left const):
+        (WebCore::Layout::InlineTextItem::right const):
+        (): Deleted.
+        (WebCore::Layout::moveToNextNonWhitespacePosition): Deleted.
+        (WebCore::Layout::moveToNextBreakablePosition): Deleted.
+        (WebCore::Layout::InlineTextItem::createAndAppendTextItems): Deleted.
+        * layout/formattingContexts/inline/InlineTextItem.h:
+        (WebCore::Layout::InlineTextItem::InlineTextItem): Deleted.
+        (WebCore::Layout::InlineTextItem::left const): Deleted.
+        (WebCore::Layout::InlineTextItem::right const): Deleted.
+
 2021-10-29  Myles C. Maxfield  <[email protected]>
 
         Rename ImageBuffer.logicalSize to ImageBuffer.truncatedLogicalSize

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (285075 => 285076)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-10-30 05:11:58 UTC (rev 285075)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-10-30 05:25:59 UTC (rev 285076)
@@ -28,9 +28,49 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
+#include "InlineSoftLineBreakItem.h"
+
 namespace WebCore {
 namespace Layout {
 
+struct WhitespaceContent {
+    size_t length { 0 };
+    bool isWordSeparator { true };
+};
+static std::optional<WhitespaceContent> moveToNextNonWhitespacePosition(StringView textContent, size_t startPosition, bool preserveNewline, bool preserveTab, bool treatNonBreakingSpaceAsRegularSpace, bool stopAtWordSeparatorBoundary)
+{
+    auto hasWordSeparatorCharacter = false;
+    auto isWordSeparatorCharacter = false;
+    auto isWhitespaceCharacter = [&](auto character) {
+        // white space processing in CSS affects only the document white space characters: spaces (U+0020), tabs (U+0009), and segment breaks.
+        auto isTreatedAsSpaceCharacter = character == space || (character == newlineCharacter && !preserveNewline) || (character == tabCharacter && !preserveTab) || (character == noBreakSpace && treatNonBreakingSpaceAsRegularSpace);
+        isWordSeparatorCharacter = isTreatedAsSpaceCharacter;
+        hasWordSeparatorCharacter = hasWordSeparatorCharacter || isWordSeparatorCharacter;
+        return isTreatedAsSpaceCharacter || character == tabCharacter;
+    };
+    auto nextNonWhiteSpacePosition = startPosition;
+    while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition])) {
+        if (UNLIKELY(stopAtWordSeparatorBoundary && hasWordSeparatorCharacter && !isWordSeparatorCharacter))
+            break;
+        ++nextNonWhiteSpacePosition;
+    }
+    return nextNonWhiteSpacePosition == startPosition ? std::nullopt : std::make_optional(WhitespaceContent { nextNonWhiteSpacePosition - startPosition, hasWordSeparatorCharacter });
+}
+
+static unsigned moveToNextBreakablePosition(unsigned startPosition, LazyLineBreakIterator& lineBreakIterator, const RenderStyle& style)
+{
+    auto textLength = lineBreakIterator.stringView().length();
+    auto startPositionForNextBreakablePosition = startPosition;
+    while (startPositionForNextBreakablePosition < textLength) {
+        auto nextBreakablePosition = TextUtil::findNextBreakablePosition(lineBreakIterator, startPositionForNextBreakablePosition, style);
+        // Oftentimes the next breakable position comes back as the start position (most notably hyphens).
+        if (nextBreakablePosition != startPosition)
+            return nextBreakablePosition - startPosition;
+        ++startPositionForNextBreakablePosition;
+    }
+    return textLength - startPosition;
+}
+
 InlineItemsBuilder::InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
     : m_root(formattingContextRoot)
     , m_formattingState(formattingState)
@@ -74,7 +114,7 @@
             else if (layoutBox.isAtomicInlineLevelBox())
                 formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
             else if (layoutBox.isInlineTextBox()) {
-                InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
+                createAndAppendTextItems(downcast<InlineTextBox>(layoutBox));
             } else if (layoutBox.isInlineBox())
                 formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxEnd });
             else
@@ -88,7 +128,89 @@
     }
 }
 
+void InlineItemsBuilder::createAndAppendTextItems(const InlineTextBox& inlineTextBox)
+{
+    auto& formattingState = this->formattingState();
+
+    auto text = inlineTextBox.content();
+    if (!text.length())
+        return formattingState.addInlineItem(InlineTextItem::createEmptyItem(inlineTextBox));
+
+    auto& style = inlineTextBox.style();
+    auto& fontCascade = style.fontCascade();
+    auto shouldPreserveSpacesAndTabs = TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
+    auto whitespaceContentIsTreatedAsSingleSpace = !shouldPreserveSpacesAndTabs;
+    auto shouldPreserveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
+    auto shouldTreatNonBreakingSpaceAsRegularSpace = style.nbspMode() == NBSPMode::Space;
+    auto lineBreakIterator = LazyLineBreakIterator { text, style.computedLocale(), TextUtil::lineBreakIteratorMode(style.lineBreak()) };
+    unsigned currentPosition = 0;
+
+    auto inlineItemWidth = [&](auto startPosition, auto length) -> std::optional<InlineLayoutUnit> {
+        if (!inlineTextBox.canUseSimplifiedContentMeasuring()
+            || !TextUtil::canUseSimplifiedTextMeasuringForFirstLine(inlineTextBox.style(), inlineTextBox.firstLineStyle()))
+            return { };
+        return TextUtil::width(inlineTextBox, fontCascade, startPosition, startPosition + length, { });
+    };
+
+    while (currentPosition < text.length()) {
+        auto isSegmentBreakCandidate = [](auto character) {
+            return character == '\n';
+        };
+
+        // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break.
+        if (isSegmentBreakCandidate(text[currentPosition]) && shouldPreserveNewline) {
+            formattingState.addInlineItem(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineTextBox, currentPosition));
+            ++currentPosition;
+            continue;
+        }
+
+        auto stopAtWordSeparatorBoundary = shouldPreserveSpacesAndTabs && fontCascade.wordSpacing();
+        if (auto whitespaceContent = moveToNextNonWhitespacePosition(text, currentPosition, shouldPreserveNewline, shouldPreserveSpacesAndTabs, shouldTreatNonBreakingSpaceAsRegularSpace, stopAtWordSeparatorBoundary)) {
+            ASSERT(whitespaceContent->length);
+            auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
+                auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);
+                auto width = simpleSingleWhitespaceContent ? std::make_optional(InlineLayoutUnit { fontCascade.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
+                formattingState.addInlineItem(InlineTextItem::createWhitespaceItem(inlineTextBox, startPosition, itemLength, whitespaceContent->isWordSeparator, width));
+            };
+            if (style.whiteSpace() == WhiteSpace::BreakSpaces) {
+                // https://www.w3.org/TR/css-text-3/#white-space-phase-1
+                // For break-spaces, a soft wrap opportunity exists after every space and every tab.
+                // FIXME: if this turns out to be a perf hit with too many individual whitespace inline items, we should transition this logic to line breaking.
+                for (size_t i = 0; i < whitespaceContent->length; ++i)
+                    appendWhitespaceItem(currentPosition + i, 1);
+            } else
+                appendWhitespaceItem(currentPosition, whitespaceContent->length);
+            currentPosition += whitespaceContent->length;
+            continue;
+        }
+
+        auto hasTrailingSoftHyphen = false;
+        auto initialNonWhitespacePosition = currentPosition;
+        auto isAtSoftHyphen = [&](auto position) {
+            return text[position] == softHyphen;
+        };
+        if (style.hyphens() == Hyphens::None) {
+            // Let's merge candidate InlineTextItems separated by soft hyphen when the style says so.
+            while (currentPosition < text.length()) {
+                auto nonWhiteSpaceLength = moveToNextBreakablePosition(currentPosition, lineBreakIterator, style);
+                ASSERT(nonWhiteSpaceLength);
+                currentPosition += nonWhiteSpaceLength;
+                if (!isAtSoftHyphen(currentPosition - 1))
+                    break;
+            }
+        } else {
+            auto nonWhiteSpaceLength = moveToNextBreakablePosition(initialNonWhitespacePosition, lineBreakIterator, style);
+            ASSERT(nonWhiteSpaceLength);
+            currentPosition += nonWhiteSpaceLength;
+            hasTrailingSoftHyphen = isAtSoftHyphen(currentPosition - 1);
+        }
+        ASSERT(initialNonWhitespacePosition < currentPosition);
+        ASSERT_IMPLIES(style.hyphens() == Hyphens::None, !hasTrailingSoftHyphen);
+        auto length = currentPosition - initialNonWhitespacePosition;
+        formattingState.addInlineItem(InlineTextItem::createNonWhitespaceItem(inlineTextBox, initialNonWhitespacePosition, length, hasTrailingSoftHyphen, inlineItemWidth(initialNonWhitespacePosition, length)));
+    }
 }
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (285075 => 285076)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h	2021-10-30 05:11:58 UTC (rev 285075)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h	2021-10-30 05:25:59 UTC (rev 285076)
@@ -32,6 +32,7 @@
 
 namespace WebCore {
 namespace Layout {
+class InlineTextBox;
 
 class InlineItemsBuilder {
 public:
@@ -39,6 +40,8 @@
     void build();
 
 private:
+    void createAndAppendTextItems(const InlineTextBox&);
+
     const ContainerBox& root() const { return m_root; }
     InlineFormattingState& formattingState() const { return m_formattingState; }
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.cpp	2021-10-30 05:11:58 UTC (rev 285075)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.cpp	2021-10-30 05:25:59 UTC (rev 285076)
@@ -38,123 +38,37 @@
 
 static_assert(sizeof(InlineItem) == sizeof(InlineTextItem), "");
 
-struct WhitespaceContent {
-    size_t length { 0 };
-    bool isWordSeparator { true };
-};
-static std::optional<WhitespaceContent> moveToNextNonWhitespacePosition(StringView textContent, size_t startPosition, bool preserveNewline, bool preserveTab, bool treatNonBreakingSpaceAsRegularSpace, bool stopAtWordSeparatorBoundary)
+InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, bool hasTrailingSoftHyphen, bool isWordSeparator, std::optional<InlineLayoutUnit> width, TextItemType textItemType)
+    : InlineItem(inlineTextBox, Type::Text)
 {
-    auto hasWordSeparatorCharacter = false;
-    auto isWordSeparatorCharacter = false;
-    auto isWhitespaceCharacter = [&](auto character) {
-        // white space processing in CSS affects only the document white space characters: spaces (U+0020), tabs (U+0009), and segment breaks.
-        auto isTreatedAsSpaceCharacter = character == space || (character == newlineCharacter && !preserveNewline) || (character == tabCharacter && !preserveTab) || (character == noBreakSpace && treatNonBreakingSpaceAsRegularSpace);
-        isWordSeparatorCharacter = isTreatedAsSpaceCharacter;
-        hasWordSeparatorCharacter = hasWordSeparatorCharacter || isWordSeparatorCharacter;
-        return isTreatedAsSpaceCharacter || character == tabCharacter;
-    };
-    auto nextNonWhiteSpacePosition = startPosition;
-    while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition])) {
-        if (UNLIKELY(stopAtWordSeparatorBoundary && hasWordSeparatorCharacter && !isWordSeparatorCharacter))
-            break;
-        ++nextNonWhiteSpacePosition;
-    }
-    return nextNonWhiteSpacePosition == startPosition ? std::nullopt : std::make_optional(WhitespaceContent { nextNonWhiteSpacePosition - startPosition, hasWordSeparatorCharacter });
+    m_startOrPosition = start;
+    m_length = length;
+    m_hasWidth = !!width;
+    m_hasTrailingSoftHyphen = hasTrailingSoftHyphen;
+    m_isWordSeparator = isWordSeparator;
+    m_width = width.value_or(0);
+    m_textItemType = textItemType;
 }
 
-static unsigned moveToNextBreakablePosition(unsigned startPosition, LazyLineBreakIterator& lineBreakIterator, const RenderStyle& style)
+InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox)
+    : InlineItem(inlineTextBox, Type::Text)
 {
-    auto textLength = lineBreakIterator.stringView().length();
-    auto startPositionForNextBreakablePosition = startPosition;
-    while (startPositionForNextBreakablePosition < textLength) {
-        auto nextBreakablePosition = TextUtil::findNextBreakablePosition(lineBreakIterator, startPositionForNextBreakablePosition, style);
-        // Oftentimes the next breakable position comes back as the start position (most notably hyphens).
-        if (nextBreakablePosition != startPosition)
-            return nextBreakablePosition - startPosition;
-        ++startPositionForNextBreakablePosition;
-    }
-    return textLength - startPosition;
 }
 
-void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const InlineTextBox& inlineTextBox)
+InlineTextItem InlineTextItem::left(unsigned length) const
 {
-    auto text = inlineTextBox.content();
-    if (!text.length())
-        return inlineContent.append(InlineTextItem::createEmptyItem(inlineTextBox));
+    RELEASE_ASSERT(length <= this->length());
+    ASSERT(m_textItemType != TextItemType::Undefined);
+    ASSERT(length);
+    return { inlineTextBox(), start(), length, false, isWordSeparator(), std::nullopt, m_textItemType };
+}
 
-    auto& style = inlineTextBox.style();
-    auto& fontCascade = style.fontCascade();
-    auto shouldPreserveSpacesAndTabs = TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
-    auto whitespaceContentIsTreatedAsSingleSpace = !shouldPreserveSpacesAndTabs;
-    auto shouldPreserveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
-    auto shouldTreatNonBreakingSpaceAsRegularSpace = style.nbspMode() == NBSPMode::Space;
-    auto lineBreakIterator = LazyLineBreakIterator { text, style.computedLocale(), TextUtil::lineBreakIteratorMode(style.lineBreak()) };
-    unsigned currentPosition = 0;
-
-    auto inlineItemWidth = [&](auto startPosition, auto length) -> std::optional<InlineLayoutUnit> {
-        if (!inlineTextBox.canUseSimplifiedContentMeasuring()
-            || !TextUtil::canUseSimplifiedTextMeasuringForFirstLine(inlineTextBox.style(), inlineTextBox.firstLineStyle()))
-            return { };
-        return TextUtil::width(inlineTextBox, fontCascade, startPosition, startPosition + length, { });
-    };
-
-    while (currentPosition < text.length()) {
-        auto isSegmentBreakCandidate = [](auto character) {
-            return character == '\n';
-        };
-
-        // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break.
-        if (isSegmentBreakCandidate(text[currentPosition]) && shouldPreserveNewline) {
-            inlineContent.append(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineTextBox, currentPosition));
-            ++currentPosition;
-            continue;
-        }
-
-        auto stopAtWordSeparatorBoundary = shouldPreserveSpacesAndTabs && fontCascade.wordSpacing();
-        if (auto whitespaceContent = moveToNextNonWhitespacePosition(text, currentPosition, shouldPreserveNewline, shouldPreserveSpacesAndTabs, shouldTreatNonBreakingSpaceAsRegularSpace, stopAtWordSeparatorBoundary)) {
-            ASSERT(whitespaceContent->length);
-            auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
-                auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);
-                auto width = simpleSingleWhitespaceContent ? std::make_optional(InlineLayoutUnit { fontCascade.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
-                inlineContent.append(InlineTextItem::createWhitespaceItem(inlineTextBox, startPosition, itemLength, whitespaceContent->isWordSeparator, width));
-            };
-            if (style.whiteSpace() == WhiteSpace::BreakSpaces) {
-                // https://www.w3.org/TR/css-text-3/#white-space-phase-1
-                // For break-spaces, a soft wrap opportunity exists after every space and every tab.
-                // FIXME: if this turns out to be a perf hit with too many individual whitespace inline items, we should transition this logic to line breaking.
-                for (size_t i = 0; i < whitespaceContent->length; ++i)
-                    appendWhitespaceItem(currentPosition + i, 1);
-            } else
-                appendWhitespaceItem(currentPosition, whitespaceContent->length);
-            currentPosition += whitespaceContent->length;
-            continue;
-        }
-
-        auto hasTrailingSoftHyphen = false;
-        auto initialNonWhitespacePosition = currentPosition;
-        auto isAtSoftHyphen = [&](auto position) {
-            return text[position] == softHyphen;
-        };
-        if (style.hyphens() == Hyphens::None) {
-            // Let's merge candidate InlineTextItems separated by soft hyphen when the style says so.
-            while (currentPosition < text.length()) {
-                auto nonWhiteSpaceLength = moveToNextBreakablePosition(currentPosition, lineBreakIterator, style);
-                ASSERT(nonWhiteSpaceLength);
-                currentPosition += nonWhiteSpaceLength;
-                if (!isAtSoftHyphen(currentPosition - 1))
-                    break;
-            }
-        } else {
-            auto nonWhiteSpaceLength = moveToNextBreakablePosition(initialNonWhitespacePosition, lineBreakIterator, style);
-            ASSERT(nonWhiteSpaceLength);
-            currentPosition += nonWhiteSpaceLength;
-            hasTrailingSoftHyphen = isAtSoftHyphen(currentPosition - 1);
-        }
-        ASSERT(initialNonWhitespacePosition < currentPosition);
-        ASSERT_IMPLIES(style.hyphens() == Hyphens::None, !hasTrailingSoftHyphen);
-        auto length = currentPosition - initialNonWhitespacePosition;
-        inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineTextBox, initialNonWhitespacePosition, length, hasTrailingSoftHyphen, inlineItemWidth(initialNonWhitespacePosition, length)));
-    }
+InlineTextItem InlineTextItem::right(unsigned length, std::optional<InlineLayoutUnit> width) const
+{
+    RELEASE_ASSERT(length <= this->length());
+    ASSERT(m_textItemType != TextItemType::Undefined);
+    ASSERT(length);
+    return { inlineTextBox(), end() - length, length, hasTrailingSoftHyphen(), isWordSeparator(), width, m_textItemType };
 }
 
 bool InlineTextItem::isZeroWidthSpaceSeparator() const

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.h	2021-10-30 05:11:58 UTC (rev 285075)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineTextItem.h	2021-10-30 05:25:59 UTC (rev 285076)
@@ -37,7 +37,9 @@
 
 class InlineTextItem : public InlineItem {
 public:
-    static void createAndAppendTextItems(InlineItems&, const InlineTextBox&);
+    static InlineTextItem createWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, bool isWordSeparator, std::optional<InlineLayoutUnit> width);
+    static InlineTextItem createNonWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, bool hasTrailingSoftHyphen, std::optional<InlineLayoutUnit> width);
+    static InlineTextItem createEmptyItem(const InlineTextBox&);
 
     unsigned start() const { return m_startOrPosition; }
     unsigned end() const { return start() + length(); }
@@ -61,10 +63,6 @@
 
     InlineTextItem(const InlineTextBox&, unsigned start, unsigned length, bool hasTrailingSoftHyphen, bool isWordSeparator, std::optional<InlineLayoutUnit> width, TextItemType);
     explicit InlineTextItem(const InlineTextBox&);
-
-    static InlineTextItem createWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, bool isWordSeparator, std::optional<InlineLayoutUnit> width);
-    static InlineTextItem createNonWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, bool hasTrailingSoftHyphen, std::optional<InlineLayoutUnit> width);
-    static InlineTextItem createEmptyItem(const InlineTextBox&);
 };
 
 inline InlineTextItem InlineTextItem::createWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, bool isWordSeparator, std::optional<InlineLayoutUnit> width)
@@ -83,42 +81,9 @@
     return InlineTextItem { inlineTextBox };
 }
 
-inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, bool hasTrailingSoftHyphen, bool isWordSeparator, std::optional<InlineLayoutUnit> width, TextItemType textItemType)
-    : InlineItem(inlineTextBox, Type::Text)
-{
-    m_startOrPosition = start;
-    m_length = length;
-    m_hasWidth = !!width;
-    m_hasTrailingSoftHyphen = hasTrailingSoftHyphen;
-    m_isWordSeparator = isWordSeparator;
-    m_width = width.value_or(0);
-    m_textItemType = textItemType;
 }
-
-inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox)
-    : InlineItem(inlineTextBox, Type::Text)
-{
 }
 
-inline InlineTextItem InlineTextItem::left(unsigned length) const
-{
-    RELEASE_ASSERT(length <= this->length());
-    ASSERT(m_textItemType != TextItemType::Undefined);
-    ASSERT(length);
-    return { inlineTextBox(), start(), length, false, isWordSeparator(), std::nullopt, m_textItemType };
-}
-
-inline InlineTextItem InlineTextItem::right(unsigned length, std::optional<InlineLayoutUnit> width) const
-{
-    RELEASE_ASSERT(length <= this->length());
-    ASSERT(m_textItemType != TextItemType::Undefined);
-    ASSERT(length);
-    return { inlineTextBox(), end() - length, length, hasTrailingSoftHyphen(), isWordSeparator(), width, m_textItemType };
-}
-
-}
-}
-
 SPECIALIZE_TYPE_TRAITS_INLINE_ITEM(InlineTextItem, isText())
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to