Title: [252837] trunk/Source/WebCore
- Revision
- 252837
- Author
- [email protected]
- Date
- 2019-11-23 15:39:24 -0800 (Sat, 23 Nov 2019)
Log Message
[LFC][IFC] Replace redundant Line::isVisuallyEmpty() with LineBox::isConsideredEmpty()
https://bugs.webkit.org/show_bug.cgi?id=204551
<rdar://problem/57454620>
Reviewed by Antti Koivisto.
It turns out the we already cache the visually empty status in LineBox.
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::isEmpty const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::isInlineContainerConsideredEmpty): Deleted.
(WebCore::Layout::Line::isVisuallyEmpty const): Deleted.
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::hasContent const): Deleted.
* layout/inlineformatting/InlineLineLayout.cpp:
(WebCore::Layout::LineLayout::placeInlineItem):
(WebCore::Layout::LineLayout::processUncommittedContent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (252836 => 252837)
--- trunk/Source/WebCore/ChangeLog 2019-11-23 23:23:31 UTC (rev 252836)
+++ trunk/Source/WebCore/ChangeLog 2019-11-23 23:39:24 UTC (rev 252837)
@@ -1,5 +1,28 @@
2019-11-23 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Replace redundant Line::isVisuallyEmpty() with LineBox::isConsideredEmpty()
+ https://bugs.webkit.org/show_bug.cgi?id=204551
+ <rdar://problem/57454620>
+
+ Reviewed by Antti Koivisto.
+
+ It turns out the we already cache the visually empty status in LineBox.
+
+ * layout/displaytree/DisplayBox.h:
+ (WebCore::Display::Box::isEmpty const):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::appendNonReplacedInlineBox):
+ (WebCore::Layout::isInlineContainerConsideredEmpty): Deleted.
+ (WebCore::Layout::Line::isVisuallyEmpty const): Deleted.
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::isVisuallyEmpty const):
+ (WebCore::Layout::Line::hasContent const): Deleted.
+ * layout/inlineformatting/InlineLineLayout.cpp:
+ (WebCore::Layout::LineLayout::placeInlineItem):
+ (WebCore::Layout::LineLayout::processUncommittedContent):
+
+2019-11-23 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Defer run height/baseline adjustment computation until Line::close
https://bugs.webkit.org/show_bug.cgi?id=204550
<rdar://problem/57454497>
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (252836 => 252837)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2019-11-23 23:23:31 UTC (rev 252836)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2019-11-23 23:39:24 UTC (rev 252837)
@@ -52,6 +52,7 @@
LayoutSize size() const { return { width(), height() }; }
LayoutUnit width() const { return borderLeft() + paddingBoxWidth() + borderRight(); }
LayoutUnit height() const { return borderTop() + paddingBoxHeight() + borderBottom(); }
+ bool isEmpty() const { return size().isEmpty(); }
Rect rect() const { return { top(), left(), width(), height() }; }
Rect rectWithMargin() const;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (252836 => 252837)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-23 23:23:31 UTC (rev 252836)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-23 23:39:24 UTC (rev 252837)
@@ -223,13 +223,6 @@
{
}
-static bool isInlineContainerConsideredEmpty(const FormattingContext& formattingContext, const Box& layoutBox)
-{
- // Note that this does not check whether the inline container has content. It simply checks if the container itself is considered empty.
- auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
- return !(boxGeometry.horizontalBorder() || (boxGeometry.horizontalPadding() && boxGeometry.horizontalPadding().value()));
-}
-
static bool shouldPreserveTrailingContent(const InlineTextItem& inlineTextItem)
{
if (!inlineTextItem.isWhitespace())
@@ -246,41 +239,6 @@
return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces;
}
-bool Line::isVisuallyEmpty() const
-{
- // FIXME: This should be cached instead -as the inline items are being added.
- // Return true for empty inline containers like <span></span>.
- auto& formattingContext = this->formattingContext();
- for (auto& run : m_inlineItemRuns) {
- if (run->isText()) {
- if (!run->isCollapsedToZeroAdvanceWidth())
- return false;
- continue;
- }
- if (run->isContainerStart()) {
- if (!isInlineContainerConsideredEmpty(formattingContext, run->layoutBox()))
- return false;
- continue;
- }
- if (run->isContainerEnd())
- continue;
- if (run->isBox()) {
- if (!run->layoutBox().establishesFormattingContext())
- return false;
- ASSERT(run->layoutBox().isInlineBlockBox());
- auto& boxGeometry = formattingContext.geometryForBox(run->layoutBox());
- if (!boxGeometry.width())
- continue;
- if (m_skipAlignment || boxGeometry.height())
- return false;
- continue;
- }
- if (run->isForcedLineBreak())
- return false;
- }
- return true;
-}
-
Line::RunList Line::close(IsLastLineWithInlineContent isLastLineWithInlineContent)
{
// 1. Remove trimmable trailing content.
@@ -575,11 +533,15 @@
void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
{
- auto horizontalMargin = formattingContext().geometryForBox(inlineItem.layoutBox()).horizontalMargin();
+ auto& layoutBox = inlineItem.layoutBox();
+ auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
+ auto horizontalMargin = boxGeometry.horizontalMargin();
m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, Display::Rect { 0, contentLogicalWidth() + horizontalMargin.start, logicalWidth, { } }));
m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
m_lineBox.setIsConsideredNonEmpty();
m_trimmableContent.clear();
+ if (!layoutBox.establishesFormattingContext() || !boxGeometry.isEmpty())
+ m_lineBox.setIsConsideredNonEmpty();
}
void Line::appendReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (252836 => 252837)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-11-23 23:23:31 UTC (rev 252836)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-11-23 23:39:24 UTC (rev 252837)
@@ -59,7 +59,7 @@
~Line();
void append(const InlineItem&, LayoutUnit logicalWidth);
- bool hasContent() const { return !isVisuallyEmpty(); }
+ bool isVisuallyEmpty() const { return m_lineBox.isConsideredEmpty(); }
LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
LayoutUnit trailingTrimmableWidth() const { return m_trimmableContent.width(); }
@@ -140,7 +140,6 @@
void adjustBaselineAndLineHeight(const Run&);
LayoutUnit runContentHeight(const Run&) const;
- bool isVisuallyEmpty() const;
bool isTextAlignJustify() const { return m_horizontalAlignment == TextAlignMode::Justify; };
void justifyRuns(RunList&) const;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineLayout.cpp (252836 => 252837)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineLayout.cpp 2019-11-23 23:23:31 UTC (rev 252836)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineLayout.cpp 2019-11-23 23:39:24 UTC (rev 252837)
@@ -177,7 +177,7 @@
if (processUncommittedContent() == IsEndOfLine::Yes)
return IsEndOfLine::Yes;
}
- auto lineIsConsideredEmpty = !m_line.hasContent() && !m_lineHasIntrusiveFloat;
+ auto lineIsConsideredEmpty = m_line.isVisuallyEmpty() && !m_lineHasIntrusiveFloat;
if (LineBreaker().shouldWrapFloatBox(itemLogicalWidth, m_line.availableWidth() + m_line.trailingTrimmableWidth(), lineIsConsideredEmpty))
return IsEndOfLine::Yes;
@@ -213,7 +213,7 @@
LineLayout::IsEndOfLine LineLayout::processUncommittedContent()
{
// Check if the pending content fits.
- auto lineIsConsideredEmpty = !m_line.hasContent() && !m_lineHasIntrusiveFloat;
+ auto lineIsConsideredEmpty = m_line.isVisuallyEmpty() && !m_lineHasIntrusiveFloat;
auto breakingContext = LineBreaker().breakingContextForInlineContent(m_uncommittedContent.runs(), m_uncommittedContent.width(), m_line.availableWidth(), lineIsConsideredEmpty);
// 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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes