Modified: trunk/Source/WebCore/ChangeLog (253681 => 253682)
--- trunk/Source/WebCore/ChangeLog 2019-12-18 15:34:47 UTC (rev 253681)
+++ trunk/Source/WebCore/ChangeLog 2019-12-18 15:39:48 UTC (rev 253682)
@@ -1,5 +1,24 @@
2019-12-18 Zalan Bujtas <[email protected]>
+ [LFC][IFC] LineBreaker::isAtSoftWrapOpportunity should return the wrap position
+ https://bugs.webkit.org/show_bug.cgi?id=205371
+ <rdar://problem/58029811>
+
+ Reviewed by Antti Koivisto.
+
+ Rename isAtSoftWrapOpportunity to lastSoftWrapOpportunity to reflect that it returns the last soft wrap
+ opportunity index.
+
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::Content::lastSoftWrapOpportunity):
+ (WebCore::Layout::LineBreaker::Content::append):
+ (WebCore::Layout::LineBreaker::Content::isAtSoftWrapOpportunity): Deleted.
+ * layout/inlineformatting/InlineLineBreaker.h:
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::LineLayoutContext::placeInlineItem):
+
+2019-12-18 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Add lastInlineItemWithContent to LineBreaker::Content::isAtSoftWrapOpportunity
https://bugs.webkit.org/show_bug.cgi?id=205362
<rdar://problem/58025349>
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253681 => 253682)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-18 15:34:47 UTC (rev 253681)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-18 15:39:48 UTC (rev 253682)
@@ -280,7 +280,7 @@
return !TextUtil::findNextBreakablePosition(lineBreakIterator, 0, nextInlineTextItem.style());
}
-bool LineBreaker::Content::isAtSoftWrapOpportunity(const InlineItem& inlineItem, const Content& priorContent)
+Optional<unsigned> LineBreaker::Content::lastSoftWrapOpportunity(const InlineItem& inlineItem, const Content& priorContent)
{
// https://drafts.csswg.org/css-text-3/#line-break-details
// Figure out if the new incoming content puts the uncommitted content on a soft wrap opportunity.
@@ -290,7 +290,7 @@
ASSERT(!inlineItem.isFloat() && !inlineItem.isLineBreak());
if (priorContent.isEmpty()) {
// Can't decide it yet.
- return false;
+ return { };
}
auto lastInlineItemWithContent = [&] () -> const InlineItem* {
@@ -308,7 +308,7 @@
if (inlineItem.style().lineBreak() == LineBreak::Anywhere) {
// There is a soft wrap opportunity around every typographic character unit, including around any punctuation character
// or preserved white spaces, or in the middle of words.
- return true;
+ return priorContent.size();
}
if (downcast<InlineTextItem>(inlineItem).isWhitespace()) {
// [prior content][ ] (<span>some_content</span> )
@@ -317,11 +317,11 @@
// [ ][ ] : adjacent whitespace content has soft wrap opportunity.
if (lastUncomittedContent->isText() && downcast<InlineTextItem>(*lastUncomittedContent).isWhitespace())
isAtSoftWrapOpportunityBeforeWhitespace = true;
- return isAtSoftWrapOpportunityBeforeWhitespace;
+ return isAtSoftWrapOpportunityBeforeWhitespace ? makeOptional(priorContent.size()) : WTF::nullopt;
}
if (lastUncomittedContent->isContainerStart()) {
// [container start][text] (<span>text) : the [container start] and the [text] content form a continuous content.
- return false;
+ return { };
}
if (lastUncomittedContent->isContainerEnd()) {
// [container end][text] (</span>text)
@@ -332,7 +332,7 @@
lastUncomittedContent = lastInlineItemWithContent();
if (!lastUncomittedContent) {
// Did not find any content at all (e.g. [container start][container end][text] (<span></span>text)).
- return false;
+ return { };
}
}
if (lastUncomittedContent->isText()) {
@@ -339,11 +339,12 @@
// [text][text] : is a continuous content.
// [text-][text] : after [hyphen] position is a soft wrap opportunity.
// [ ][text] : after [whitespace] position is a soft wrap opportunity.
- return endsWithSoftWrapOpportunity(downcast<InlineTextItem>(*lastUncomittedContent), downcast<InlineTextItem>(inlineItem));
+ auto lastUncomittedEndsWithSoftWrapOpportunity = endsWithSoftWrapOpportunity(downcast<InlineTextItem>(*lastUncomittedContent), downcast<InlineTextItem>(inlineItem));
+ return lastUncomittedEndsWithSoftWrapOpportunity ? makeOptional(priorContent.size()) : WTF::nullopt;
}
if (lastUncomittedContent->isBox()) {
// [inline box][text] (<img>text) : after [inline box] position is a soft wrap opportunity.
- return true;
+ return priorContent.size();
}
ASSERT_NOT_REACHED();
}
@@ -350,15 +351,15 @@
if (inlineItem.isBox()) {
if (lastUncomittedContent->isContainerStart()) {
// [container start][inline box] (<spam><img>) : the [container start] and the [inline box] form a continuous content.
- return false;
+ return { };
}
if (lastUncomittedContent->isContainerEnd()) {
// [container end][inline box] (</span><img>) : after [container end] position is a soft wrap opportunity.
- return true;
+ return priorContent.size();
}
if (lastUncomittedContent->isText() || lastUncomittedContent->isBox()) {
// [inline box][text] (<img>text) and [inline box][inline box] (<img><img>) : after first [inline box] position is a soft wrap opportunity.
- return true;
+ return priorContent.size();
}
ASSERT_NOT_REACHED();
}
@@ -367,17 +368,17 @@
if (lastUncomittedContent->isContainerStart() || lastUncomittedContent->isContainerEnd()) {
// [container start][container end] (<span><span>) or
// [container end][container start] (</span><span>) : need more content to decide.
- return false;
+ return { };
}
if (lastUncomittedContent->isText()) {
// [ ][container start] ( <span>) : after [whitespace] position is a soft wrap opportunity.
// [text][container start] (text<span>) : Need more content to decide (e.g. text<span>text vs. text<span><img>).
- return downcast<InlineTextItem>(*lastUncomittedContent).isWhitespace();
+ return downcast<InlineTextItem>(*lastUncomittedContent).isWhitespace() ? makeOptional(priorContent.size()) : WTF::nullopt;
}
if (lastUncomittedContent->isBox()) {
// [inline box][container start] (<img><span>) : after [inline box] position is a soft wrap opportunity.
// [inline box][container end] (<img></span>) : the [inline box] and the [container end] form a continuous content.
- return inlineItem.isContainerStart();
+ return inlineItem.isContainerStart() ? makeOptional(priorContent.size()) : WTF::nullopt;
}
ASSERT_NOT_REACHED();
}
@@ -388,7 +389,6 @@
void LineBreaker::Content::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
{
ASSERT(!inlineItem.isFloat());
- ASSERT(inlineItem.isLineBreak() || !isAtSoftWrapOpportunity(inlineItem, *this));
m_continousRuns.append({ inlineItem, logicalWidth });
m_width += logicalWidth;
// Figure out the trailing collapsible state.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h (253681 => 253682)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-18 15:34:47 UTC (rev 253681)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-18 15:39:48 UTC (rev 253682)
@@ -70,7 +70,7 @@
void reset();
void shrink(unsigned newSize);
- static bool isAtSoftWrapOpportunity(const InlineItem&, const Content& priorContent);
+ static Optional<unsigned> lastSoftWrapOpportunity(const InlineItem&, const Content& priorContent);
struct Run {
const InlineItem& inlineItem;
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (253681 => 253682)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-18 15:34:47 UTC (rev 253681)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-18 15:39:48 UTC (rev 253682)
@@ -186,7 +186,7 @@
}
auto isEndOfLine = IsEndOfLine::No;
// Can we commit the pending content already?
- if (LineBreaker::Content::isAtSoftWrapOpportunity(inlineItem, m_uncommittedContent))
+ if (LineBreaker::Content::lastSoftWrapOpportunity(inlineItem, m_uncommittedContent))
isEndOfLine = processUncommittedContent(line);
// The current item might fit as well.
if (isEndOfLine == IsEndOfLine::No)