Modified: trunk/Source/WebCore/ChangeLog (253293 => 253294)
--- trunk/Source/WebCore/ChangeLog 2019-12-09 18:34:04 UTC (rev 253293)
+++ trunk/Source/WebCore/ChangeLog 2019-12-09 18:34:55 UTC (rev 253294)
@@ -1,3 +1,36 @@
+2019-12-09 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] fix fast/text/simple-lines-multiple-renderers-break.html
+ https://bugs.webkit.org/show_bug.cgi?id=205014
+ <rdar://problem/57756348>
+
+ Reviewed by Antti Koivisto.
+
+ When dealing with series of runs (<span>text</span><span>content</span>) a partial content does not
+ necessarily mean partial runs. The content can actually be split right at a run boundary.
+ In such cases we have a partial trailing content but not a partial trailing run.
+
+ This patch also covers the case when the overflown run can't be split and
+ we attempt to find a previous breakable run (in the list of candidate runs).
+ Since it's guaranteed (with the FIXME of the extremely long hyphen) that all the previous runs fit the line,
+ we just pass in an infinite available width to LineBreaker::tryBreakingTextRun indicating that we only look for the last breakable position.
+
+ e.g. <span style="word-break: break-all">breakable</span><span>and</span><span>longandunbreakablecontent</span>
+ [breakable][and][longandunbreakablecontent] <- we try to commit this continuous list of runs
+ [longandunbreakablecontent] <- does not fit so let's go back to the previous runs to see if any of them can be split -> [breakableand].
+ result:
+ breakable
+ andlongandunbreakablecontent
+
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::lineLayout):
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::wordBreakingBehavior const):
+ (WebCore::Layout::LineBreaker::tryBreakingTextRun const):
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::LineLayoutContext::processUncommittedContent):
+ * layout/inlineformatting/LineLayoutContext.h:
+
2019-12-07 Darin Adler <[email protected]>
Streamline PODIntervalTree code and remove ValueToString
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (253293 => 253294)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-09 18:34:04 UTC (rev 253293)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-09 18:34:55 UTC (rev 253294)
@@ -111,7 +111,7 @@
leadingInlineItemIndex = *lineContent.trailingInlineItemIndex;
// Turn previous line's overflow content length into the next line's leading content partial length.
// "sp<->litcontent" -> overflow length: 10 -> leading partial content length: 10.
- partialLeadingContentLength = lineContent.partialContent->overlfowContentLength;
+ partialLeadingContentLength = lineContent.partialContent->overflowContentLength;
} else
leadingInlineItemIndex = *lineContent.trailingInlineItemIndex + 1;
} else {
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253293 => 253294)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-09 18:34:04 UTC (rev 253293)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-09 18:34:55 UTC (rev 253294)
@@ -141,7 +141,10 @@
auto& run = runs[index];
if (isContentWrappingAllowed(run)) {
ASSERT(run.inlineItem.isText());
- return BreakingContext::PartialTrailingContent { index, downcast<InlineTextItem>(run.inlineItem).length(), run.logicalWidth, false };
+ if (auto leftSide = tryBreakingTextRun(run, maxInlineLayoutUnit())) {
+ // This run itself might not be partial but the content (series of runs) definitely is.
+ return BreakingContext::PartialTrailingContent { index, leftSide->length, leftSide->logicalWidth, leftSide->needsHyphen };
+ }
}
}
// Give up, there's no breakable run in here.
@@ -152,11 +155,15 @@
{
ASSERT(overflowRun.inlineItem.isText());
auto& style = overflowRun.inlineItem.style();
+ auto findLastBreakablePosition = availableWidth == maxInlineLayoutUnit();
auto breakWords = style.wordBreak();
if (breakWords == WordBreak::KeepAll)
return { };
auto& inlineTextItem = downcast<InlineTextItem>(overflowRun.inlineItem);
if (breakWords == WordBreak::BreakAll) {
+ // When the run can be split at arbitrary positions, let's just return the entire run when it is intended to fit on the line.
+ if (findLastBreakablePosition)
+ return LeftSide { inlineTextItem.length(), overflowRun.logicalWidth, false };
// FIXME: Pass in the content logical left to be able to measure tabs.
auto splitData = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), inlineTextItem.length(), overflowRun.logicalWidth, availableWidth, { });
return LeftSide { splitData.length, splitData.logicalWidth, false };
@@ -174,22 +181,25 @@
if (limitBefore >= runLength || limitAfter >= runLength || limitBefore + limitAfter > runLength)
return { };
- auto& fontCascade = style.fontCascade();
- // FIXME: We might want to cache the hyphen width.
- auto hyphenWidth = InlineLayoutUnit { fontCascade.width(TextRun { StringView { style.hyphenString() } }) };
- auto availableWidthExcludingHyphen = availableWidth - hyphenWidth;
+ unsigned leftSideLength = runLength;
+ if (!findLastBreakablePosition) {
+ auto& fontCascade = style.fontCascade();
+ // FIXME: We might want to cache the hyphen width.
+ auto hyphenWidth = InlineLayoutUnit { fontCascade.width(TextRun { StringView { style.hyphenString() } }) };
+ auto availableWidthExcludingHyphen = availableWidth - hyphenWidth;
- // For spaceWidth() see webkit.org/b/169613
- if (availableWidthExcludingHyphen <= 0 || !enoughWidthForHyphenation(availableWidthExcludingHyphen + fontCascade.spaceWidth(), fontCascade.pixelSize()))
- return { };
+ // For spaceWidth() see webkit.org/b/169613
+ if (availableWidthExcludingHyphen <= 0 || !enoughWidthForHyphenation(availableWidthExcludingHyphen + fontCascade.spaceWidth(), fontCascade.pixelSize()))
+ return { };
- auto splitData = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), runLength, overflowRun.logicalWidth, availableWidthExcludingHyphen, { });
- if (splitData.length < limitBefore)
+ leftSideLength = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), runLength, overflowRun.logicalWidth, availableWidthExcludingHyphen, { }).length;
+ }
+ if (leftSideLength < limitBefore)
return { };
auto textContent = inlineTextItem.layoutBox().textContext()->content;
// Adjust before index to accommodate the limit-after value (it's the last potential hyphen location in this run).
- auto hyphenBefore = std::min(splitData.length, runLength - limitAfter) + 1;
+ auto hyphenBefore = std::min(leftSideLength, runLength - limitAfter) + 1;
unsigned hyphenLocation = lastHyphenLocation(StringView(textContent).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale());
if (!hyphenLocation || hyphenLocation < limitBefore)
return { };
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (253293 => 253294)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-09 18:34:04 UTC (rev 253293)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-09 18:34:55 UTC (rev 253294)
@@ -218,17 +218,26 @@
ASSERT(breakingContext.partialTrailingContent);
ASSERT(m_uncommittedContent.runs()[breakingContext.partialTrailingContent->runIndex].inlineItem.isText());
// Turn the uncommitted trailing run into a partial trailing run.
- auto overflowInlineTextItemIndex = breakingContext.partialTrailingContent->runIndex;
- auto& overflowInlineTextItem = downcast<InlineTextItem>(m_uncommittedContent.runs()[overflowInlineTextItemIndex].inlineItem);
+ auto trailingRunIndex = breakingContext.partialTrailingContent->runIndex;
+ auto& trailingInlineTextItem = downcast<InlineTextItem>(m_uncommittedContent.runs()[trailingRunIndex].inlineItem);
- // Construct a partial trailing inline run.
ASSERT(!m_partialTrailingTextItem);
- auto trailingContentLength = breakingContext.partialTrailingContent->length;
- m_partialTrailingTextItem = overflowInlineTextItem.left(trailingContentLength);
- m_partialContent = LineContent::PartialContent { breakingContext.partialTrailingContent->needsHyphen, overflowInlineTextItem.length() - trailingContentLength };
- // Keep the non-overflow part of the uncommitted runs and add the trailing partial content.
- m_uncommittedContent.trim(overflowInlineTextItemIndex);
- m_uncommittedContent.append(*m_partialTrailingTextItem, breakingContext.partialTrailingContent->logicalWidth);
+ // Construct a partial trailing inline run only if there's a need for one.
+ // When splitting multiple runs <span style="word-break: break-all">text</span><span>content</span>, we might end up splitting them at run boundary.
+ // In such case we don't need to construct a partial trailing item since the trailing run is not partial at all.
+ if (trailingInlineTextItem.length() == breakingContext.partialTrailingContent->length) {
+ // Trim the overflown run and keep the trailing (non-partial) run in the queue.
+ auto overflownRunIndex = trailingRunIndex + 1;
+ ASSERT(overflownRunIndex < m_uncommittedContent.size());
+ m_uncommittedContent.trim(overflownRunIndex);
+ } else {
+ auto trailingContentLength = breakingContext.partialTrailingContent->length;
+ m_partialTrailingTextItem = trailingInlineTextItem.left(trailingContentLength);
+ m_partialContent = LineContent::PartialContent { breakingContext.partialTrailingContent->needsHyphen, trailingInlineTextItem.length() - trailingContentLength };
+ // Keep the non-overflow part of the uncommitted runs and add the trailing partial content.
+ m_uncommittedContent.trim(trailingRunIndex);
+ m_uncommittedContent.append(*m_partialTrailingTextItem, breakingContext.partialTrailingContent->logicalWidth);
+ }
commitPendingContent(line);
} else if (breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Push)
m_uncommittedContent.reset();
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h (253293 => 253294)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2019-12-09 18:34:04 UTC (rev 253293)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2019-12-09 18:34:55 UTC (rev 253294)
@@ -40,7 +40,7 @@
struct LineContent {
struct PartialContent {
bool trailingContentNeedsHyphen { false };
- unsigned overlfowContentLength { 0 };
+ unsigned overflowContentLength { 0 };
};
Optional<unsigned> trailingInlineItemIndex;
Optional<PartialContent> partialContent;