Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (252695 => 252696)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-11-20 18:53:27 UTC (rev 252695)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-11-20 18:57:00 UTC (rev 252696)
@@ -89,6 +89,13 @@
auto& style = inlineBox.style();
LazyLineBreakIterator lineBreakIterator(text);
unsigned currentPosition = 0;
+
+ auto inlineItemWidth = [&](auto startPosition, auto length) -> Optional<LayoutUnit> {
+ if (!inlineBox.textContext().canUseSimplifiedContentMeasuring)
+ return { };
+ return TextUtil::width(inlineBox, startPosition, startPosition + length);
+ };
+
while (currentPosition < text.length()) {
auto isSegmentBreakCandidate = [](auto character) {
return character == '\n';
@@ -101,32 +108,33 @@
++currentPosition;
continue;
}
+
if (isWhitespaceCharacter(text[currentPosition])) {
auto length = moveToNextNonWhitespacePosition(text, currentPosition);
- inlineContent.append(InlineTextItem::createWhitespaceItem(inlineBox, currentPosition, length));
+ inlineContent.append(InlineTextItem::createWhitespaceItem(inlineBox, currentPosition, length, inlineItemWidth(currentPosition, length)));
currentPosition += length;
continue;
}
auto length = moveToNextBreakablePosition(currentPosition, lineBreakIterator, style);
- inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineBox, currentPosition, length));
+ inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineBox, currentPosition, length, inlineItemWidth(currentPosition, length)));
currentPosition += length;
}
}
-std::unique_ptr<InlineTextItem> InlineTextItem::createWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length)
+std::unique_ptr<InlineTextItem> InlineTextItem::createWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length, Optional<LayoutUnit> width)
{
- return makeUnique<InlineTextItem>(inlineBox, start, length, TextItemType::Whitespace);
+ return makeUnique<InlineTextItem>(inlineBox, start, length, width, TextItemType::Whitespace);
}
-std::unique_ptr<InlineTextItem> InlineTextItem::createNonWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length)
+std::unique_ptr<InlineTextItem> InlineTextItem::createNonWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length, Optional<LayoutUnit> width)
{
- return makeUnique<InlineTextItem>(inlineBox, start, length, TextItemType::NonWhitespace);
+ return makeUnique<InlineTextItem>(inlineBox, start, length, width, TextItemType::NonWhitespace);
}
std::unique_ptr<InlineTextItem> InlineTextItem::createSegmentBreakItem(const Box& inlineBox, unsigned position)
{
- return makeUnique<InlineTextItem>(inlineBox, position, 1, TextItemType::SegmentBreak);
+ return makeUnique<InlineTextItem>(inlineBox, position, 1, WTF::nullopt, TextItemType::SegmentBreak);
}
std::unique_ptr<InlineTextItem> InlineTextItem::createEmptyItem(const Box& inlineBox)
@@ -134,10 +142,11 @@
return makeUnique<InlineTextItem>(inlineBox);
}
-InlineTextItem::InlineTextItem(const Box& inlineBox, unsigned start, unsigned length, TextItemType textItemType)
+InlineTextItem::InlineTextItem(const Box& inlineBox, unsigned start, unsigned length, Optional<LayoutUnit> width, TextItemType textItemType)
: InlineItem(inlineBox, Type::Text)
, m_start(start)
, m_length(length)
+ , m_width(width)
, m_textItemType(textItemType)
{
}
@@ -151,7 +160,7 @@
{
RELEASE_ASSERT(length <= this->length());
ASSERT(m_textItemType != TextItemType::Undefined);
- return makeUnique<InlineTextItem>(layoutBox(), start(), length, m_textItemType);
+ return makeUnique<InlineTextItem>(layoutBox(), start(), length, WTF::nullopt, m_textItemType);
}
std::unique_ptr<InlineTextItem> InlineTextItem::right(unsigned length) const
@@ -158,7 +167,7 @@
{
RELEASE_ASSERT(length <= this->length());
ASSERT(m_textItemType != TextItemType::Undefined);
- return makeUnique<InlineTextItem>(layoutBox(), end() - length, length, m_textItemType);
+ return makeUnique<InlineTextItem>(layoutBox(), end() - length, length, WTF::nullopt, m_textItemType);
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h (252695 => 252696)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2019-11-20 18:53:27 UTC (rev 252695)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2019-11-20 18:57:00 UTC (rev 252696)
@@ -37,8 +37,8 @@
public:
static void createAndAppendTextItems(InlineItems&, const Box&);
- static std::unique_ptr<InlineTextItem> createWhitespaceItem(const Box&, unsigned start, unsigned length);
- static std::unique_ptr<InlineTextItem> createNonWhitespaceItem(const Box&, unsigned start, unsigned length);
+ static std::unique_ptr<InlineTextItem> createWhitespaceItem(const Box&, unsigned start, unsigned length, Optional<LayoutUnit> width);
+ static std::unique_ptr<InlineTextItem> createNonWhitespaceItem(const Box&, unsigned start, unsigned length, Optional<LayoutUnit> width);
static std::unique_ptr<InlineTextItem> createSegmentBreakItem(const Box&, unsigned position);
static std::unique_ptr<InlineTextItem> createEmptyItem(const Box&);
@@ -49,17 +49,19 @@
bool isWhitespace() const { return m_textItemType == TextItemType::Whitespace || isSegmentBreak(); }
bool isCollapsible() const { return isWhitespace() && style().collapseWhiteSpace(); }
bool isSegmentBreak() const { return m_textItemType == TextItemType::SegmentBreak; }
+ Optional<LayoutUnit> width() const { return m_width; }
std::unique_ptr<InlineTextItem> left(unsigned length) const;
std::unique_ptr<InlineTextItem> right(unsigned length) const;
enum class TextItemType { Undefined, Whitespace, NonWhitespace, SegmentBreak };
- InlineTextItem(const Box&, unsigned start, unsigned length, TextItemType);
+ InlineTextItem(const Box&, unsigned start, unsigned length, Optional<LayoutUnit> width, TextItemType);
InlineTextItem(const Box&);
private:
unsigned m_start { 0 };
unsigned m_length { 0 };
+ Optional<LayoutUnit> m_width;
TextItemType m_textItemType { TextItemType::Undefined };
};
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (252695 => 252696)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2019-11-20 18:53:27 UTC (rev 252695)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2019-11-20 18:57:00 UTC (rev 252696)
@@ -34,7 +34,7 @@
class TextUtil {
public:
- static LayoutUnit width(const Box&, unsigned from, unsigned to, LayoutUnit contentLogicalLeft);
+ static LayoutUnit width(const Box&, unsigned from, unsigned to, LayoutUnit contentLogicalLeft = { });
static Optional<unsigned> hyphenPositionBefore(const InlineItem&, unsigned from, unsigned length);
struct SplitData {
unsigned start { 0 };