- Revision
- 271562
- Author
- [email protected]
- Date
- 2021-01-17 06:44:37 -0800 (Sun, 17 Jan 2021)
Log Message
[LFC][IFC] No need to maintain the "is considered empty" bit anymore.
https://bugs.webkit.org/show_bug.cgi?id=220228
Reviewed by Antti Koivisto.
Now that isConsideredEmpty() bit is only used as input to line breaking, let's change it to a more
focused check and remove the concept of "is considered empty" completely.
* layout/inlineformatting/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processInlineContent):
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
* layout/inlineformatting/InlineContentBreaker.h:
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::initialize):
(WebCore::Layout::Line::removeTrailingTrimmableContent):
(WebCore::Layout::Line::append):
(WebCore::Layout::Line::appendTextContent):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::isConsideredEmpty const): Deleted.
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::handleInlineContent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (271561 => 271562)
--- trunk/Source/WebCore/ChangeLog 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/ChangeLog 2021-01-17 14:44:37 UTC (rev 271562)
@@ -1,3 +1,28 @@
+2021-01-17 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] No need to maintain the "is considered empty" bit anymore.
+ https://bugs.webkit.org/show_bug.cgi?id=220228
+
+ Reviewed by Antti Koivisto.
+
+ Now that isConsideredEmpty() bit is only used as input to line breaking, let's change it to a more
+ focused check and remove the concept of "is considered empty" completely.
+
+ * layout/inlineformatting/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processInlineContent):
+ (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+ * layout/inlineformatting/InlineContentBreaker.h:
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::initialize):
+ (WebCore::Layout::Line::removeTrailingTrimmableContent):
+ (WebCore::Layout::Line::append):
+ (WebCore::Layout::Line::appendTextContent):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::isConsideredEmpty const): Deleted.
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::close):
+ (WebCore::Layout::LineBuilder::handleInlineContent):
+
2021-01-16 Nikolas Zimmermann <[email protected]>
Separate scrolling code out of RenderLayer
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2021-01-17 14:44:37 UTC (rev 271562)
@@ -136,7 +136,7 @@
if (auto lastLineWrapOpportunityIndex = lastWrapOpportunityIndex(candidateContent.runs())) {
auto isEligibleLineWrapOpportunity = [&] (auto& candidateItem) {
// Just check for leading preserved whitespace for now.
- if (!lineStatus.isEmpty || !is<InlineTextItem>(candidateItem))
+ if (lineStatus.hasContent || !is<InlineTextItem>(candidateItem))
return true;
auto inlineTextItem = downcast<InlineTextItem>(candidateItem);
return !inlineTextItem.isWhitespace() || InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem);
@@ -199,7 +199,7 @@
// We tried to break the content but the available space can't even accommodate the first character.
// 1. Wrap the content over to the next line when we've got content on the line already.
// 2. Keep the first character on the empty line (or keep the whole run if it has only one character/completely empty).
- if (!lineStatus.isEmpty)
+ if (lineStatus.hasContent)
return { Result::Action::Wrap, IsEndOfLine::Yes };
auto leadingTextRunIndex = *firstTextRunIndex(continuousContent);
auto& inlineTextItem = downcast<InlineTextItem>(continuousContent.runs()[leadingTextRunIndex].inlineItem);
@@ -214,7 +214,7 @@
}
}
// If we are not allowed to break this overflowing content, we still need to decide whether keep it or wrap it to the next line.
- if (lineStatus.isEmpty) {
+ if (!lineStatus.hasContent) {
ASSERT(!m_hasWrapOpportunityAtPreviousPosition);
return { Result::Action::Keep, IsEndOfLine::No };
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h 2021-01-17 14:44:37 UTC (rev 271562)
@@ -110,7 +110,7 @@
InlineLayoutUnit collapsibleWidth { 0 };
Optional<InlineLayoutUnit> trailingSoftHyphenWidth;
bool hasFullyCollapsibleTrailingRun { false };
- bool isEmpty { true };
+ bool hasContent { false };
};
Result processInlineContent(const ContinuousContent&, const LineStatus&);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2021-01-17 14:44:37 UTC (rev 271562)
@@ -67,7 +67,7 @@
}
auto inlineBoxHasImaginaryStrut = layoutState().inStandardsMode();
// Inline box with strut only stetches the line box when it has additional inline level boxes (not inline boxes) or the root inline box has content.
- // e.g. <!DOCTYPE html><div"><span style="font-size: 100px;"></span><img src="" style="width: 0px; height: 0px;"></div>
+ // e.g. <!DOCTYPE html><div><span style="font-size: 100px;"></span><img src="" style="width: 0px; height: 0px;"></div>
return inlineBoxHasImaginaryStrut && (lineBox.hasNonInlineBox() || lineBox.rootInlineBox().hasContent());
}
if (inlineLevelBox.isAtomicInlineLevelBox()) {
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2021-01-17 14:44:37 UTC (rev 271562)
@@ -56,8 +56,6 @@
m_runs.clear();
m_trailingSoftHyphenWidth = { };
m_trimmableTrailingContent.reset();
- m_isConsideredEmpty = true;
- m_isConsideredEmptyBeforeTrimmableTrailingContent = { };
}
void Line::removeCollapsibleContent(InlineLayoutUnit extraHorizontalSpace)
@@ -132,19 +130,6 @@
}
m_contentLogicalWidth -= m_trimmableTrailingContent.remove();
- // If we removed the first visible run on the line, we need to re-check the visibility status.
- if (m_isConsideredEmptyBeforeTrimmableTrailingContent) {
- // Just because the line was considered empty before the removed content, it does not necessarily mean it is still empty.
- // <span> </span><span style="padding-left: 10px"></span> <- non-empty
- m_isConsideredEmpty = [&] {
- for (auto& run : m_runs) {
- if (!isRunConsideredEmpty(run))
- return false;
- }
- return true;
- }();
- m_isConsideredEmptyBeforeTrimmableTrailingContent = { };
- }
}
void Line::visuallyCollapsePreWrapOverflowContent(InlineLayoutUnit extraHorizontalSpace)
@@ -204,10 +189,6 @@
appendNonReplacedInlineBox(inlineItem, logicalWidth);
else
ASSERT_NOT_REACHED();
-
- // Check if this newly appended content makes the line non-empty.
- if (m_isConsideredEmpty && !m_runs.isEmpty() && !isRunConsideredEmpty(m_runs.last()))
- m_isConsideredEmpty = false;
}
void Line::appendNonBreakableSpace(const InlineItem& inlineItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
@@ -295,9 +276,6 @@
// Set the trailing trimmable content.
if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
m_trimmableTrailingContent.addFullyTrimmableContent(m_runs.size() - 1, contentLogicalWidth() - oldContentLogicalWidth);
- // If we ever trim this content, we need to know if the line visibility state needs to be recomputed.
- if (m_trimmableTrailingContent.isEmpty())
- m_isConsideredEmptyBeforeTrimmableTrailingContent = isConsideredEmpty();
return;
}
// Any non-whitespace, no-trimmable content resets the existing trimmable.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2021-01-17 14:44:37 UTC (rev 271562)
@@ -46,12 +46,6 @@
void append(const InlineItem&, InlineLayoutUnit logicalWidth);
- // <span></span> considered empty.
- // <span><br></span> is considered empty.
- // <span>text</span> is not considered empty.
- // <span style="padding: 10px"></span> is not considered empty.
- bool isConsideredEmpty() const { return m_isConsideredEmpty; }
-
InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
InlineLayoutUnit contentLogicalRight() const { return m_runs.isEmpty() ? 0.0f : m_runs.last().logicalRight(); }
@@ -178,8 +172,6 @@
TrimmableTrailingContent m_trimmableTrailingContent;
InlineLayoutUnit m_contentLogicalWidth { 0 };
Optional<InlineLayoutUnit> m_trailingSoftHyphenWidth { 0 };
- bool m_isConsideredEmpty { true };
- Optional<bool> m_isConsideredEmptyBeforeTrimmableTrailingContent;
};
inline void Line::TrimmableTrailingContent::reset()
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (271561 => 271562)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2021-01-17 12:36:52 UTC (rev 271561)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2021-01-17 14:44:37 UTC (rev 271562)
@@ -355,8 +355,7 @@
if (runsExpandHorizontally)
m_line.applyRunExpansion(m_lineLogicalRect.width() - m_line.contentLogicalRight());
auto lineEndsWithHyphen = false;
- if (!m_line.isConsideredEmpty()) {
- ASSERT(!m_line.runs().isEmpty());
+ if (!m_line.runs().isEmpty()) {
auto& lastTextContent = m_line.runs().last().textContent();
lineEndsWithHyphen = lastTextContent && lastTextContent->needsHyphen();
}
@@ -622,9 +621,9 @@
return adjustedLineLogicalRect;
}();
auto availableWidth = lineLogicalRectForCandidateContent.width() - m_line.contentLogicalRight();
- // Check if this new content fits.
- auto isLineConsideredEmpty = m_line.isConsideredEmpty() && !m_contentIsConstrainedByFloat;
- auto lineStatus = InlineContentBreaker::LineStatus { m_line.contentLogicalRight(), availableWidth, m_line.trimmableTrailingWidth(), m_line.trailingSoftHyphenWidth(), m_line.isTrailingRunFullyTrimmable(), isLineConsideredEmpty };
+ // While the floats are not considered to be on the line, they make the line contentful for line breaking.
+ auto lineHasContent = !m_line.runs().isEmpty() || m_contentIsConstrainedByFloat;
+ auto lineStatus = InlineContentBreaker::LineStatus { m_line.contentLogicalRight(), availableWidth, m_line.trimmableTrailingWidth(), m_line.trailingSoftHyphenWidth(), m_line.isTrailingRunFullyTrimmable(), lineHasContent };
auto result = inlineContentBreaker.processInlineContent(continuousInlineContent, lineStatus);
if (result.lastWrapOpportunityItem)
m_wrapOpportunityList.append(result.lastWrapOpportunityItem);