Diff
Modified: trunk/Source/WebCore/ChangeLog (253146 => 253147)
--- trunk/Source/WebCore/ChangeLog 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/ChangeLog 2019-12-05 14:11:05 UTC (rev 253147)
@@ -1,3 +1,36 @@
+2019-12-05 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Move trailing trimming logic to LineBuilder::TrimmableContent
+ https://bugs.webkit.org/show_bug.cgi?id=204872
+ <rdar://problem/57652365>
+
+ Reviewed by Antti Koivisto.
+
+ Move trimming logic from LineBuilder::removeTrailingTrimmableContent to inside TrimmableContent.
+ This is also in preparation for adding partial trimming at inline container boundary.
+
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::breakingContextForInlineContent):
+ * layout/inlineformatting/InlineLineBreaker.h:
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::LineBuilder):
+ (WebCore::Layout::LineBuilder::initialize):
+ (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
+ (WebCore::Layout::LineBuilder::appendTextContent):
+ (WebCore::Layout::LineBuilder::appendNonReplacedInlineBox):
+ (WebCore::Layout::LineBuilder::TrimmableContent::TrimmableContent):
+ (WebCore::Layout::LineBuilder::TrimmableContent::append):
+ (WebCore::Layout::LineBuilder::TrimmableContent::trim):
+ * layout/inlineformatting/InlineLineBuilder.h:
+ (WebCore::Layout::LineBuilder::isTrailingRunFullyTrimmable const):
+ (WebCore::Layout::LineBuilder::TrimmableContent::isTrailingRunFullyTrimmable const):
+ (WebCore::Layout::LineBuilder::TrimmableContent::reset):
+ (WebCore::Layout::LineBuilder::isTrailingContentFullyTrimmable const): Deleted.
+ (WebCore::Layout::LineBuilder::TrimmableContent::isTrailingContentFullyTrimmable const): Deleted.
+ (WebCore::Layout::LineBuilder::TrimmableContent::clear): Deleted.
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::LineLayoutContext::processUncommittedContent):
+
2019-12-05 youenn fablet <[email protected]>
getStats() promise never rejects nor resolves when peer connection state is closed.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253146 => 253147)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-05 14:11:05 UTC (rev 253147)
@@ -59,7 +59,7 @@
if (candidateRuns.nonTrimmableWidth() <= lineStatus.availableWidth)
return { BreakingContext::ContentBreak::Keep, { } };
// Now check if we can trim the line too.
- if (lineStatus.lineHasFullyTrimmableTrailingContent && candidateRuns.isTrailingContentFullyTrimmable()) {
+ if (lineStatus.lineHasFullyTrimmableTrailingRun && candidateRuns.isTrailingContentFullyTrimmable()) {
// If this new content is fully trimmable, it shoud surely fit.
return { BreakingContext::ContentBreak::Keep, { } };
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h (253146 => 253147)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h 2019-12-05 14:11:05 UTC (rev 253147)
@@ -98,7 +98,7 @@
struct LineStatus {
LayoutUnit availableWidth;
LayoutUnit trimmableWidth;
- bool lineHasFullyTrimmableTrailingContent;
+ bool lineHasFullyTrimmableTrailingRun;
bool lineIsEmpty;
};
BreakingContext breakingContextForInlineContent(const Content& candidateRuns, const LineStatus&);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (253146 => 253147)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-05 14:11:05 UTC (rev 253147)
@@ -153,6 +153,7 @@
LineBuilder::LineBuilder(const InlineFormattingContext& inlineFormattingContext, Optional<TextAlignMode> horizontalAlignment, SkipAlignment skipAlignment)
: m_inlineFormattingContext(inlineFormattingContext)
+ , m_trimmableContent(m_inlineItemRuns)
, m_horizontalAlignment(horizontalAlignment)
, m_skipAlignment(skipAlignment == SkipAlignment::Yes)
{
@@ -182,7 +183,7 @@
m_hasIntrusiveFloat = constraints.lineIsConstrainedByFloat;
m_inlineItemRuns.clear();
- m_trimmableContent.clear();
+ m_trimmableContent.reset();
m_lineIsVisuallyEmptyBeforeTrimmableContent = { };
}
@@ -366,53 +367,24 @@
if (m_trimmableContent.isEmpty() || m_inlineItemRuns.isEmpty())
return;
-#ifndef NDEBUG
- auto hasSeenNonWhitespaceTextContent = false;
-#endif
- // Collapse trimmable trailing content and move all the other trailing runs.
- // <span> </span><span></span> ->
- // [whitespace][container end][container start][container end]
- // Trim the whitespace run and move the trailing inline container runs to the left.
- LayoutUnit accumulatedTrimmedWidth;
- for (auto index = *m_trimmableContent.firstRunIndex(); index < m_inlineItemRuns.size(); ++index) {
- auto& run = m_inlineItemRuns[index];
- run.moveHorizontally(-accumulatedTrimmedWidth);
- if (!run.isText()) {
- ASSERT(run.isContainerStart() || run.isContainerEnd() || run.isForcedLineBreak());
- continue;
- }
- if (run.isWhitespace()) {
- accumulatedTrimmedWidth += run.logicalWidth();
- run.setCollapsesToZeroAdvanceWidth();
- } else {
- ASSERT(!hasSeenNonWhitespaceTextContent);
-#ifndef NDEBUG
- hasSeenNonWhitespaceTextContent = true;
-#endif
- // Must be a letter spacing trim.
- ASSERT(run.hasTrailingLetterSpacing());
- accumulatedTrimmedWidth += run.trailingLetterSpacing();
- run.removeTrailingLetterSpacing();
- }
- }
- ASSERT(accumulatedTrimmedWidth == m_trimmableContent.width());
m_lineBox.shrinkHorizontally(m_trimmableContent.width());
- m_trimmableContent.clear();
+
+ m_trimmableContent.trim();
// If we trimmed the first visible run on the line, we need to re-check the visibility status.
- if (m_lineIsVisuallyEmptyBeforeTrimmableContent) {
- // Just because the line was visually empty before the trimmed content, it does not necessarily mean it is still visually empty.
- // <span> </span><span style="padding-left: 10px"></span> <- non-empty
- auto lineIsVisuallyEmpty = [&] {
- for (auto& run : m_inlineItemRuns) {
- if (isVisuallyNonEmpty(run))
- return false;
- }
- return true;
- };
- // We could only go from visually non empty -> to visually empty. Trimming runs should never make the line visible.
- if (lineIsVisuallyEmpty())
- m_lineBox.setIsConsideredEmpty();
- }
+ if (!m_lineIsVisuallyEmptyBeforeTrimmableContent)
+ return;
+ // Just because the line was visually empty before the trimmed content, it does not necessarily mean it is still visually empty.
+ // <span> </span><span style="padding-left: 10px"></span> <- non-empty
+ auto lineIsVisuallyEmpty = [&] {
+ for (auto& run : m_inlineItemRuns) {
+ if (isVisuallyNonEmpty(run))
+ return false;
+ }
+ return true;
+ };
+ // We could only go from visually non empty -> to visually empty. Trimming runs should never make the line visible.
+ if (lineIsVisuallyEmpty())
+ m_lineBox.setIsConsideredEmpty();
m_lineIsVisuallyEmptyBeforeTrimmableContent = { };
}
@@ -503,12 +475,13 @@
return true;
};
+ auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
auto collapsedRun = inlineItem.isCollapsible() && inlineItem.length() > 1;
auto contentStart = inlineItem.start();
auto contentLength = collapsedRun ? 1 : inlineItem.length();
- auto lineRun = InlineItemRun { inlineItem, contentLogicalWidth(), logicalWidth, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext()->content } };
+ m_inlineItemRuns.append({ inlineItem, contentLogicalWidth(), logicalWidth, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext()->content } });
+ auto& lineRun = m_inlineItemRuns.last();
- auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
if (collapsesToZeroAdvanceWidth)
lineRun.setCollapsesToZeroAdvanceWidth();
@@ -515,24 +488,19 @@
if (collapsedRun)
lineRun.setIsCollapsed();
- auto lineRunWidth = lineRun.logicalWidth();
- // Trailing whitespace content is fully trimmable so as the trailing letter space.
- auto isFullyTrimmable = lineRun.isTrimmableWhitespace();
- auto isPartiallyTrimmable = lineRun.hasTrailingLetterSpacing();
- auto isTrimmable = isFullyTrimmable || isPartiallyTrimmable;
- // Reset the trimmable content if needed.
- if (!isTrimmable || isPartiallyTrimmable || (isFullyTrimmable && !m_trimmableContent.isTrailingContentFullyTrimmable()))
- m_trimmableContent.clear();
- if (isFullyTrimmable) {
+ m_lineBox.expandHorizontally(lineRun.logicalWidth());
+
+ // Existing trailing trimmable content can only be expanded if the current rus is fully trimmable.
+ auto trimmableListNeedsReset = !m_trimmableContent.isEmpty() && !lineRun.isTrimmableWhitespace();
+ if (trimmableListNeedsReset)
+ m_trimmableContent.reset();
+ auto isTrimmable = lineRun.isTrimmableWhitespace() || lineRun.hasTrailingLetterSpacing();
+ if (isTrimmable) {
// If we ever trim this content, we need to know if the line visibility state needs to be recomputed.
if (m_trimmableContent.isEmpty())
m_lineIsVisuallyEmptyBeforeTrimmableContent = isVisuallyEmpty();
- m_trimmableContent.append(lineRunWidth, m_inlineItemRuns.size(), TrimmableContent::IsFullyTrimmable::Yes);
- } else if (isPartiallyTrimmable)
- m_trimmableContent.append(LayoutUnit { lineRun.trailingLetterSpacing() }, m_inlineItemRuns.size(), TrimmableContent::IsFullyTrimmable::No);
-
- m_lineBox.expandHorizontally(lineRunWidth);
- m_inlineItemRuns.append(WTFMove(lineRun));
+ m_trimmableContent.append(m_inlineItemRuns.size() - 1);
+ }
}
void LineBuilder::appendNonReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
@@ -542,7 +510,7 @@
auto horizontalMargin = boxGeometry.horizontalMargin();
m_inlineItemRuns.append({ inlineItem, contentLogicalWidth() + horizontalMargin.start, logicalWidth });
m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
- m_trimmableContent.clear();
+ m_trimmableContent.reset();
}
void LineBuilder::appendReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
@@ -719,15 +687,68 @@
return m_inlineFormattingContext;
}
-void LineBuilder::TrimmableContent::append(LayoutUnit itemRunWidth, size_t runIndex, IsFullyTrimmable isFullyTrimmable)
+LineBuilder::TrimmableContent::TrimmableContent(InlineItemRunList& inlineItemRunList)
+ : m_inlineitemRunList(inlineItemRunList)
{
+}
+
+void LineBuilder::TrimmableContent::append(size_t runIndex)
+{
+ auto& trimmableRun = m_inlineitemRunList[runIndex];
+ LayoutUnit trimmableWidth;
+ auto isFullyTrimmable = trimmableRun.isTrimmableWhitespace();
+ if (isFullyTrimmable)
+ trimmableWidth = trimmableRun.logicalWidth();
+ else {
+ ASSERT(trimmableRun.hasTrailingLetterSpacing());
+ trimmableWidth = trimmableRun.trailingLetterSpacing();
+ }
// word-spacing could very well be negative, but it does not mean that the line gains that much extra space when the content is trimmed.
- itemRunWidth = std::max(0_lu, itemRunWidth);
- m_width += itemRunWidth;
+ trimmableWidth = std::max(0_lu, trimmableWidth);
+
+ ASSERT(trimmableWidth >= 0);
+ m_width += trimmableWidth;
+ m_lastRunIsFullyTrimmable = isFullyTrimmable;
m_firstRunIndex = m_firstRunIndex.valueOr(runIndex);
- m_lastRunIsFullyTrimmable = isFullyTrimmable == IsFullyTrimmable::Yes;
}
+void LineBuilder::TrimmableContent::trim()
+{
+ if (!m_firstRunIndex)
+ return;
+#ifndef NDEBUG
+ auto hasSeenNonWhitespaceTextContent = false;
+#endif
+ // Collapse trimmable trailing content and move all the other trailing runs.
+ // <span> </span><span></span> ->
+ // [whitespace][container end][container start][container end]
+ // Trim the whitespace run and move the trailing inline container runs to the left.
+ LayoutUnit accumulatedTrimmedWidth;
+ for (auto index = *m_firstRunIndex; index < m_inlineitemRunList.size(); ++index) {
+ auto& run = m_inlineitemRunList[index];
+ run.moveHorizontally(-accumulatedTrimmedWidth);
+ if (!run.isText()) {
+ ASSERT(run.isContainerStart() || run.isContainerEnd() || run.isForcedLineBreak());
+ continue;
+ }
+ if (run.isWhitespace()) {
+ accumulatedTrimmedWidth += run.logicalWidth();
+ run.setCollapsesToZeroAdvanceWidth();
+ } else {
+ ASSERT(!hasSeenNonWhitespaceTextContent);
+#ifndef NDEBUG
+ hasSeenNonWhitespaceTextContent = true;
+#endif
+ // Must be a letter spacing trim.
+ ASSERT(run.hasTrailingLetterSpacing());
+ accumulatedTrimmedWidth += run.trailingLetterSpacing();
+ run.removeTrailingLetterSpacing();
+ }
+ }
+ ASSERT(accumulatedTrimmedWidth == width());
+ reset();
+}
+
LineBuilder::InlineItemRun::InlineItemRun(const InlineItem& inlineItem, LayoutUnit logicalLeft, LayoutUnit logicalWidth, WTF::Optional<Display::Run::TextContext> textContext)
: m_inlineItem(inlineItem)
, m_logicalLeft(logicalLeft)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (253146 => 253147)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-05 14:11:05 UTC (rev 253147)
@@ -65,7 +65,7 @@
LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
LayoutUnit trailingTrimmableWidth() const { return m_trimmableContent.width(); }
- bool isTrailingContentFullyTrimmable() const { return m_trimmableContent.isTrailingContentFullyTrimmable(); }
+ bool isTrailingRunFullyTrimmable() const { return m_trimmableContent.isTrailingRunFullyTrimmable(); }
const LineBox& lineBox() const { return m_lineBox; }
void moveLogicalLeft(LayoutUnit);
@@ -199,17 +199,22 @@
bool m_collapsedToZeroAdvanceWidth { false };
};
+ using InlineItemRunList = Vector<InlineItemRun, 50>;
+
struct TrimmableContent {
- enum class IsFullyTrimmable { No, Yes };
- void append(LayoutUnit itemRunWidth, size_t runIndex, IsFullyTrimmable);
- void clear();
+ TrimmableContent(InlineItemRunList&);
+ void append(size_t runIndex);
+ void trim();
+ void reset();
+
LayoutUnit width() const { return m_width; }
Optional<size_t> firstRunIndex() { return m_firstRunIndex; }
bool isEmpty() const { return !m_firstRunIndex.hasValue(); }
- bool isTrailingContentFullyTrimmable() const { return m_lastRunIsFullyTrimmable; }
+ bool isTrailingRunFullyTrimmable() const { return m_lastRunIsFullyTrimmable; }
private:
+ InlineItemRunList& m_inlineitemRunList;
Optional<size_t> m_firstRunIndex;
LayoutUnit m_width;
bool m_lastRunIsFullyTrimmable { false };
@@ -216,7 +221,7 @@
};
const InlineFormattingContext& m_inlineFormattingContext;
- Vector<InlineItemRun, 50> m_inlineItemRuns;
+ InlineItemRunList m_inlineItemRuns;
TrimmableContent m_trimmableContent;
Optional<LineBox::Baseline> m_initialStrut;
LayoutUnit m_lineLogicalWidth;
@@ -227,7 +232,7 @@
Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableContent;
};
-inline void LineBuilder::TrimmableContent::clear()
+inline void LineBuilder::TrimmableContent::reset()
{
m_firstRunIndex = { };
m_width = { };
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (253146 => 253147)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2019-12-05 14:11:05 UTC (rev 253147)
@@ -209,7 +209,7 @@
auto lineBreaker = LineBreaker { };
if (shouldDisableHyphenation())
lineBreaker.setHyphenationDisabled();
- auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trailingTrimmableWidth(), line.isTrailingContentFullyTrimmable(), lineIsConsideredEmpty };
+ auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trailingTrimmableWidth(), line.isTrailingRunFullyTrimmable(), lineIsConsideredEmpty };
auto breakingContext = lineBreaker.breakingContextForInlineContent(m_uncommittedContent, lineStatus);
// The uncommitted content can fully, partially fit the current line (commit/partial commit) or not at all (reset).
if (breakingContext.contentBreak == LineBreaker::BreakingContext::ContentBreak::Keep)
Modified: trunk/Tools/ChangeLog (253146 => 253147)
--- trunk/Tools/ChangeLog 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Tools/ChangeLog 2019-12-05 14:11:05 UTC (rev 253147)
@@ -1,3 +1,13 @@
+2019-12-05 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Move trailing trimming logic to LineBuilder::TrimmableContent
+ https://bugs.webkit.org/show_bug.cgi?id=204872
+ <rdar://problem/57652365>
+
+ Reviewed by Antti Koivisto.
+
+ * LayoutReloaded/misc/LFC-passing-tests.txt:
+
2019-12-04 Fujii Hironori <[email protected]>
run-_javascript_core-tests is failing to run testmasm of 64bit AppleWin on Buildbot
Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (253146 => 253147)
--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2019-12-05 12:56:19 UTC (rev 253146)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2019-12-05 14:11:05 UTC (rev 253147)
@@ -2071,7 +2071,8 @@
fast/text/zero-sized-fonts.html
fast/text/zero-width-characters.html
fast/text/basic/002.html
-fast/text/basic/003.html
+// letter-spacing progression.
+// fast/text/basic/003.html
fast/text/basic/008.html
fast/text/basic/009.html
fast/text/basic/012.html