Modified: trunk/Source/WebCore/ChangeLog (253936 => 253937)
--- trunk/Source/WebCore/ChangeLog 2019-12-29 17:38:14 UTC (rev 253936)
+++ trunk/Source/WebCore/ChangeLog 2019-12-29 18:28:25 UTC (rev 253937)
@@ -1,3 +1,20 @@
+2019-12-29 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Add LineBreaker::Result::Revert to indicate an earlier line wrap opportunity
+ https://bugs.webkit.org/show_bug.cgi?id=205623
+ <rdar://problem/58228339>
+
+ Reviewed by Antti Koivisto.
+
+ See webkit.org/b/205613 for more info.
+
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::Result::Result):
+ (WebCore::Layout::LineBreaker::tryWrappingInlineContent const):
+ * layout/inlineformatting/InlineLineBreaker.h:
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::LineLayoutContext::checkForLineWrapAndCommit):
+
2019-12-29 Antti Koivisto <[email protected]>
Make RuleSet refcounted
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253936 => 253937)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-29 17:38:14 UTC (rev 253936)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-29 18:28:25 UTC (rev 253937)
@@ -129,28 +129,28 @@
LineBreaker::Result LineBreaker::tryWrappingInlineContent(const ContinousContent& candidateContent, const LineStatus& lineStatus) const
{
if (candidateContent.width() <= lineStatus.availableWidth)
- return { Result::Action::Keep, IsEndOfLine::No, { } };
+ return { Result::Action::Keep };
if (candidateContent.hasTrailingCollapsibleContent()) {
ASSERT(candidateContent.hasTextContentOnly());
auto IsEndOfLine = isContentWrappingAllowed(candidateContent) ? IsEndOfLine::Yes : IsEndOfLine::No;
// First check if the content fits without the trailing collapsible part.
if (candidateContent.nonCollapsibleWidth() <= lineStatus.availableWidth)
- return { Result::Action::Keep, IsEndOfLine, { } };
+ return { Result::Action::Keep, IsEndOfLine };
// Now check if we can trim the line too.
if (lineStatus.lineHasFullyCollapsibleTrailingRun && candidateContent.isTrailingContentFullyCollapsible()) {
// If this new content is fully collapsible, it shoud surely fit.
- return { Result::Action::Keep, IsEndOfLine, { } };
+ return { Result::Action::Keep, IsEndOfLine };
}
} else if (lineStatus.collapsibleWidth && candidateContent.hasNonContentRunsOnly()) {
// Let's see if the non-content runs fit when the line has trailing collapsible content.
// "text content <span style="padding: 1px"></span>" <- the <span></span> runs could fit after collapsing the trailing whitespace.
if (candidateContent.width() <= lineStatus.availableWidth + lineStatus.collapsibleWidth)
- return { Result::Action::Keep, IsEndOfLine::No, { } };
+ return { Result::Action::Keep };
}
if (candidateContent.isVisuallyEmptyWhitespaceContentOnly() && shouldKeepEndOfLineWhitespace(candidateContent)) {
// This overflowing content apparently falls into the remove/hang end-of-line-spaces catergory.
// see https://www.w3.org/TR/css-text-3/#white-space-property matrix
- return { Result::Action::Keep, IsEndOfLine::No, { } };
+ return { Result::Action::Keep };
}
if (candidateContent.hasTextContentOnly()) {
@@ -166,7 +166,7 @@
auto& inlineTextItem = downcast<InlineTextItem>(runs[firstTextRunIndex].inlineItem);
ASSERT(inlineTextItem.length());
if (inlineTextItem.length() == 1)
- return { Result::Action::Keep, IsEndOfLine::Yes, { } };
+ return Result { Result::Action::Keep, IsEndOfLine::Yes };
auto firstCharacterWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.start() + 1);
auto firstCharacterRun = PartialRun { 1, firstCharacterWidth, false };
return { Result::Action::Split, IsEndOfLine::Yes, Result::PartialTrailingContent { firstTextRunIndex, firstCharacterRun } };
@@ -176,11 +176,13 @@
}
}
// If we are not allowed to break this content, we still need to decide whether keep it or push it to the next line.
- auto isWrappingAllowed = isContentWrappingAllowed(candidateContent);
- auto letContentOverflow = lineStatus.lineIsEmpty || !isWrappingAllowed;
- if (!letContentOverflow)
- return { Result::Action::Push, IsEndOfLine::Yes, { } };
- return { Result::Action::Keep, isWrappingAllowed ? IsEndOfLine::Yes : IsEndOfLine::No, { } };
+ if (lineStatus.lineIsEmpty) {
+ ASSERT(!m_lastWrapOpportunity);
+ return { Result::Action::Keep, IsEndOfLine::Yes };
+ }
+ if (m_lastWrapOpportunity)
+ return { Result::Action::Revert, IsEndOfLine::Yes, { }, m_lastWrapOpportunity };
+ return { Result::Action::Keep, isContentWrappingAllowed(candidateContent) ? IsEndOfLine::Yes : IsEndOfLine::No };
}
bool LineBreaker::shouldWrapFloatBox(InlineLayoutUnit floatLogicalWidth, InlineLayoutUnit availableWidth, bool lineIsEmpty)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h (253936 => 253937)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-29 17:38:14 UTC (rev 253936)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-29 18:28:25 UTC (rev 253937)
@@ -49,15 +49,18 @@
enum class Action {
Keep, // Keep content on the current line.
Split, // Partial content is on the current line.
- Push // Content is pushed to the next line.
+ Push, // Content is pushed to the next line.
+ Revert // The current content overflows and can't get wrapped. The line needs to be reverted back to the last line wrapping opportunity.
};
- Action action { Action::Keep };
- IsEndOfLine isEndOfLine { IsEndOfLine::No };
struct PartialTrailingContent {
size_t trailingRunIndex { 0 };
Optional<PartialRun> partialRun; // nullopt partial run means the trailing run is a complete run.
};
- Optional<PartialTrailingContent> partialTrailingContent;
+
+ Action action { Action::Keep };
+ IsEndOfLine isEndOfLine { IsEndOfLine::No };
+ Optional<PartialTrailingContent> partialTrailingContent { };
+ const InlineItem* revertTo { nullptr };
};
struct Run {
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (253936 => 253937)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-29 17:38:14 UTC (rev 253936)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-29 18:28:25 UTC (rev 253937)
@@ -412,6 +412,10 @@
// This continuous content can't be placed on the current line. Nothing to commit at this time.
return { result.isEndOfLine, 0, { } };
}
+ if (result.action == LineBreaker::Result::Action::Revert) {
+ ASSERT_NOT_IMPLEMENTED_YET();
+ return { result.isEndOfLine, 0, { } };
+ }
if (result.action == LineBreaker::Result::Action::Split) {
// Commit the combination of full and partial content on the current line.
ASSERT(result.partialTrailingContent);