- Revision
- 250423
- Author
- [email protected]
- Date
- 2019-09-27 08:31:00 -0700 (Fri, 27 Sep 2019)
Log Message
[LFC][IFC] Remove redundant Line::TextContext member variables
https://bugs.webkit.org/show_bug.cgi?id=202300
<rdar://problem/55769916>
Reviewed by Antti Koivisto.
This is in preparation for using Display::Run in Line::Run instead of Display::Rect + TextContext.
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::Run::isWhitespace const):
(WebCore::Layout::Line::Run::canBeExtended const):
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::removeTrailingTrimmableContent):
(WebCore::Layout::Line::trailingTrimmableWidth const):
(WebCore::Layout::Line::appendTextContent):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::isVisuallyEmpty const):
(WebCore::Layout::Line::Run::setVisuallyIsEmpty):
(WebCore::Layout::Line::Run::setTextIsCollapsed): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (250422 => 250423)
--- trunk/Source/WebCore/ChangeLog 2019-09-27 14:34:13 UTC (rev 250422)
+++ trunk/Source/WebCore/ChangeLog 2019-09-27 15:31:00 UTC (rev 250423)
@@ -1,3 +1,29 @@
+2019-09-27 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Remove redundant Line::TextContext member variables
+ https://bugs.webkit.org/show_bug.cgi?id=202300
+ <rdar://problem/55769916>
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for using Display::Run in Line::Run instead of Display::Rect + TextContext.
+
+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+ (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
+ * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+ (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::Run::isWhitespace const):
+ (WebCore::Layout::Line::Run::canBeExtended const):
+ (WebCore::Layout::Line::isVisuallyEmpty const):
+ (WebCore::Layout::Line::removeTrailingTrimmableContent):
+ (WebCore::Layout::Line::trailingTrimmableWidth const):
+ (WebCore::Layout::Line::appendTextContent):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::Run::isVisuallyEmpty const):
+ (WebCore::Layout::Line::Run::setVisuallyIsEmpty):
+ (WebCore::Layout::Line::Run::setTextIsCollapsed): Deleted.
+
2019-09-27 Zan Dobersek <[email protected]>
[Nicosia] Implement frame scrolling functionality
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (250422 => 250423)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 14:34:13 UTC (rev 250422)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 15:31:00 UTC (rev 250423)
@@ -397,11 +397,11 @@
if (run->isText()) {
// Collapsed line runs don't generate display runs.
auto textContext = run->textContext();
- if (textContext->isCollapsed)
+ if (run->isVisuallyEmpty())
continue;
// Try to join multiple text runs when possible.
const Line::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
- auto previousRunCanBeExtended = previousRun && previousRun->textContext() ? previousRun->textContext()->canBeExtended : false;
+ auto previousRunCanBeExtended = previousRun && previousRun->canBeExtended();
auto currentRunCanBeMergedWithPrevious = !previousRun || &run->layoutBox() == &previousRun->layoutBox();
if (previousRunCanBeExtended && currentRunCanBeMergedWithPrevious) {
@@ -461,18 +461,18 @@
// Text content. Try to join multiple text runs when possible.
if (lineRun->isText()) {
- auto textContext = lineRun->textContext();
const Line::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
// FIXME take content breaking into account when part of the layout box is on the previous line.
auto firstInlineRunForLayoutBox = !previousLineRun || &previousLineRun->layoutBox() != &layoutBox;
+ auto logicalWidth = lineRun->isVisuallyEmpty() ? LayoutUnit() : logicalRect.width();
if (firstInlineRunForLayoutBox) {
// Setup display box for the associated layout box.
displayBox.setTopLeft(logicalRect.topLeft());
- displayBox.setContentBoxWidth(textContext->isCollapsed ? LayoutUnit() : logicalRect.width());
+ displayBox.setContentBoxWidth(logicalWidth);
displayBox.setContentBoxHeight(logicalRect.height());
- } else if (!textContext->isCollapsed) {
+ } else {
// FIXME fix it for multirun/multiline.
- displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalRect.width());
+ displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalWidth);
}
continue;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (250422 => 250423)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2019-09-27 14:34:13 UTC (rev 250422)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2019-09-27 15:31:00 UTC (rev 250423)
@@ -52,7 +52,7 @@
if (run->isLineBreak())
return false;
if (run->isText()) {
- if (!run->textContext() || !run->textContext()->isCollapsed)
+ if (!run->textContext() || !run->isVisuallyEmpty())
return false;
continue;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (250422 => 250423)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 14:34:13 UTC (rev 250422)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 15:31:00 UTC (rev 250423)
@@ -50,6 +50,20 @@
{
}
+bool Line::Run::isWhitespace() const
+{
+ if (!isText())
+ return false;
+ return downcast<InlineTextItem>(m_inlineItem).isWhitespace();
+}
+
+bool Line::Run::canBeExtended() const
+{
+ if (!isText())
+ return false;
+ return !downcast<InlineTextItem>(m_inlineItem).isCollapsed() && !isVisuallyEmpty();
+}
+
Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment)
: m_inlineFormattingContext(inlineFormattingContext)
, m_initialStrut(initialConstraints.heightAndBaseline.strut)
@@ -90,7 +104,7 @@
return false;
continue;
}
- if (!run->textContext() || !run->textContext()->isCollapsed)
+ if (!run->textContext() || !run->isVisuallyEmpty())
return false;
}
return true;
@@ -161,7 +175,7 @@
LayoutUnit trimmableWidth;
for (auto* trimmableRun : m_trimmableContent) {
ASSERT(trimmableRun->isText());
- trimmableRun->setTextIsCollapsed();
+ trimmableRun->setVisuallyIsEmpty();
trimmableWidth += trimmableRun->logicalRect().width();
}
m_lineBox.shrinkHorizontally(trimmableWidth);
@@ -186,7 +200,7 @@
{
LayoutUnit trimmableWidth;
for (auto* trimmableRun : m_trimmableContent) {
- ASSERT(!trimmableRun->textContext()->isCollapsed);
+ ASSERT(!trimmableRun->isVisuallyEmpty());
trimmableWidth += trimmableRun->logicalRect().width();
}
return trimmableWidth;
@@ -240,7 +254,7 @@
if (!isTrimmable)
m_trimmableContent.clear();
- auto shouldCollapseCompletely = [&] {
+ auto willCollapseCompletely = [&] {
// Empty run.
if (!inlineItem.length()) {
ASSERT(!logicalWidth);
@@ -257,16 +271,12 @@
if (run->isBox())
return false;
if (run->isText())
- return run->textContext()->isWhitespace && run->layoutBox().style().collapseWhiteSpace();
+ return run->isWhitespace() && run->layoutBox().style().collapseWhiteSpace();
ASSERT(run->isContainerStart() || run->isContainerEnd());
}
return true;
};
- // Collapsed line items don't contribute to the line width.
- auto isCompletelyCollapsed = shouldCollapseCompletely();
- auto canBeExtended = !isCompletelyCollapsed && !inlineItem.isCollapsed();
-
auto logicalRect = Display::Rect { };
logicalRect.setLeft(contentLogicalWidth());
logicalRect.setWidth(logicalWidth);
@@ -276,13 +286,17 @@
adjustBaselineAndLineHeight(inlineItem, runHeight);
}
- auto textContext = Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, inlineItem.isWhitespace(), canBeExtended };
+ auto textContext = Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() };
auto lineItem = makeUnique<Run>(inlineItem, textContext, logicalRect);
- if (isTrimmable && !isCompletelyCollapsed)
+ auto isVisuallyEmpty = willCollapseCompletely();
+ if (isVisuallyEmpty)
+ lineItem->setVisuallyIsEmpty();
+ else if (isTrimmable)
m_trimmableContent.add(lineItem.get());
m_runList.append(WTFMove(lineItem));
- if (!isCompletelyCollapsed)
+ // Collapsed line items don't contribute to the line width.
+ if (!isVisuallyEmpty)
m_lineBox.expandHorizontally(logicalWidth);
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (250422 => 250423)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 14:34:13 UTC (rev 250422)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 15:31:00 UTC (rev 250423)
@@ -69,9 +69,6 @@
struct TextContext {
unsigned start { 0 };
unsigned length { 0 };
- bool isCollapsed { false };
- bool isWhitespace { false };
- bool canBeExtended { false };
};
Run(const InlineItem&, const Display::Rect&);
Run(const InlineItem&, const TextContext&, const Display::Rect&);
@@ -86,15 +83,20 @@
bool isContainerStart() const { return m_inlineItem.isContainerStart(); }
bool isContainerEnd() const { return m_inlineItem.isContainerEnd(); }
+ bool isVisuallyEmpty() const { return m_isVisuallyEmpty; }
+ bool isWhitespace() const;
+ bool canBeExtended() const;
+
private:
friend class Line;
void adjustLogicalTop(LayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
void moveVertically(LayoutUnit offset) { m_logicalRect.moveVertically(offset); }
void moveHorizontally(LayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
- void setTextIsCollapsed() { m_textContext->isCollapsed = true; }
+ void setVisuallyIsEmpty() { m_isVisuallyEmpty = true; }
const InlineItem& m_inlineItem;
Display::Rect m_logicalRect;
+ bool m_isVisuallyEmpty { false };
Optional<TextContext> m_textContext;
};
using RunList = Vector<std::unique_ptr<Run>>;