Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (250410 => 250411)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 03:23:32 UTC (rev 250411)
@@ -94,7 +94,7 @@
struct LineContent {
Optional<IndexAndRange> lastCommitted;
Vector<WeakPtr<InlineItem>> floats;
- std::unique_ptr<const Line::Content> runs;
+ const Line::RunList runList;
const LineBox lineBox;
};
@@ -382,7 +382,7 @@
// A line box is always tall enough for all of the boxes it contains.
// Create final display runs.
- auto& lineRuns = lineContent.runs->runs();
+ auto& lineRuns = lineContent.runList;
for (unsigned index = 0; index < lineRuns.size(); ++index) {
auto& run = lineRuns.at(index);
// Inline level containers (<span>) don't generate inline runs.
@@ -400,7 +400,7 @@
if (textContext->isCollapsed)
continue;
// Try to join multiple text runs when possible.
- const Line::Content::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
+ const Line::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
auto previousRunCanBeExtended = previousRun && previousRun->textContext() ? previousRun->textContext()->canBeExtended : false;
auto currentRunCanBeMergedWithPrevious = !previousRun || &run->layoutBox() == &previousRun->layoutBox();
@@ -462,7 +462,7 @@
// Text content. Try to join multiple text runs when possible.
if (lineRun->isText()) {
auto textContext = lineRun->textContext();
- const Line::Content::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
+ 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;
if (firstInlineRunForLayoutBox) {
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (250410 => 250411)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 03:23:32 UTC (rev 250411)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(Line);
-Line::Content::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
+Line::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
: m_layoutBox(inlineItem.layoutBox())
, m_type(inlineItem.type())
, m_logicalRect(logicalRect)
@@ -44,7 +44,7 @@
{
}
-Line::Content::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
+Line::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
: m_layoutBox(inlineItem.layoutBox())
, m_type(inlineItem.type())
, m_logicalRect(logicalRect)
@@ -54,7 +54,6 @@
Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment)
: m_inlineFormattingContext(inlineFormattingContext)
- , m_content(makeUnique<Line::Content>())
, m_initialStrut(initialConstraints.heightAndBaseline.strut)
, m_lineLogicalWidth(initialConstraints.availableLogicalWidth)
, m_skipVerticalAligment(skipVerticalAligment == SkipVerticalAligment::Yes)
@@ -76,7 +75,7 @@
// 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_content->runs()) {
+ for (auto& run : m_runList) {
if (run->isContainerStart()) {
if (!isInlineContainerConsideredEmpty(formattingContext, run->layoutBox()))
return false;
@@ -99,7 +98,7 @@
return true;
}
-std::unique_ptr<Line::Content> Line::close()
+Line::RunList Line::close()
{
removeTrailingTrimmableContent();
if (!m_skipVerticalAligment) {
@@ -110,7 +109,7 @@
}
// Remove descent when all content is baseline aligned but none of them have descent.
- if (formattingContext().quirks().lineDescentNeedsCollapsing(*m_content)) {
+ if (formattingContext().quirks().lineDescentNeedsCollapsing(m_runList)) {
m_lineBox.shrinkVertically(m_lineBox.baseline().descent());
m_lineBox.baseline().setDescent({ });
}
@@ -117,7 +116,7 @@
auto& layoutState = this->layoutState();
auto& formattingContext = this->formattingContext();
- for (auto& run : m_content->runs()) {
+ for (auto& run : m_runList) {
LayoutUnit logicalTop;
auto& layoutBox = run->layoutBox();
auto verticalAlign = layoutBox.style().verticalAlign();
@@ -155,7 +154,7 @@
run->moveHorizontally(this->logicalLeft());
}
}
- return WTFMove(m_content);
+ return WTFMove(m_runList);
}
void Line::removeTrailingTrimmableContent()
@@ -212,7 +211,7 @@
void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
{
- m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+ m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
m_lineBox.expandHorizontally(logicalRect.width());
}
@@ -252,12 +251,11 @@
if (!isTrimmable)
return false;
// Leading whitespace.
- auto& runs = m_content->runs();
- if (runs.isEmpty())
+ if (m_runList.isEmpty())
return true;
// Check if the last item is trimmable as well.
- for (int index = runs.size() - 1; index >= 0; --index) {
- auto& run = runs[index];
+ for (int index = m_runList.size() - 1; index >= 0; --index) {
+ auto& run = m_runList[index];
if (run->isBox())
return false;
if (run->isText())
@@ -280,12 +278,12 @@
adjustBaselineAndLineHeight(inlineItem, runHeight);
}
- auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, inlineItem.isWhitespace(), canBeExtended };
- auto lineItem = makeUnique<Content::Run>(inlineItem, textContext, logicalRect);
+ auto textContext = Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, inlineItem.isWhitespace(), canBeExtended };
+ auto lineItem = makeUnique<Run>(inlineItem, textContext, logicalRect);
if (isTrimmable && !isCompletelyCollapsed)
m_trimmableContent.add(lineItem.get());
- m_content->runs().append(WTFMove(lineItem));
+ m_runList.append(WTFMove(lineItem));
if (!isCompletelyCollapsed)
m_lineBox.expandHorizontally(logicalWidth);
}
@@ -303,7 +301,7 @@
logicalRect.setHeight(inlineItemContentHeight(inlineItem));
}
- m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+ m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
m_trimmableContent.clear();
}
@@ -323,7 +321,7 @@
adjustBaselineAndLineHeight(inlineItem, { });
logicalRect.setHeight(logicalHeight());
}
- m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+ m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
}
void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit runHeight)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (250410 => 250411)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 03:23:32 UTC (rev 250411)
@@ -54,65 +54,54 @@
enum class SkipVerticalAligment { No, Yes };
Line(const InlineFormattingContext&, const InitialConstraints&, SkipVerticalAligment);
- class Content {
- WTF_MAKE_FAST_ALLOCATED;
- public:
- struct Run {
- WTF_MAKE_STRUCT_FAST_ALLOCATED;
- 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&);
+ void append(const InlineItem&, LayoutUnit logicalWidth);
+ bool hasContent() const { return !isVisuallyEmpty(); }
+ LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
- const Box& layoutBox() const { return m_layoutBox; }
- const Display::Rect& logicalRect() const { return m_logicalRect; }
- const Optional<TextContext> textContext() const { return m_textContext; }
- InlineItem::Type type() const { return m_type; }
+ LayoutUnit trailingTrimmableWidth() const;
- bool isText() const { return m_type == InlineItem::Type::Text; }
- bool isBox() const { return m_type == InlineItem::Type::Box; }
- bool isLineBreak() const { return m_type == InlineItem::Type::HardLineBreak; }
- bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
- bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
+ const LineBox& lineBox() const { return m_lineBox; }
+ void moveLogicalLeft(LayoutUnit);
+ void moveLogicalRight(LayoutUnit);
- 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; }
-
- const Box& m_layoutBox;
- const InlineItem::Type m_type;
- Display::Rect m_logicalRect;
- Optional<TextContext> m_textContext;
+ struct Run {
+ WTF_MAKE_STRUCT_FAST_ALLOCATED;
+ struct TextContext {
+ unsigned start { 0 };
+ unsigned length { 0 };
+ bool isCollapsed { false };
+ bool isWhitespace { false };
+ bool canBeExtended { false };
};
- using Runs = Vector<std::unique_ptr<Run>>;
- const Runs& runs() const { return m_runs; }
+ Run(const InlineItem&, const Display::Rect&);
+ Run(const InlineItem&, const TextContext&, const Display::Rect&);
+ const Box& layoutBox() const { return m_layoutBox; }
+ const Display::Rect& logicalRect() const { return m_logicalRect; }
+ const Optional<TextContext> textContext() const { return m_textContext; }
+ InlineItem::Type type() const { return m_type; }
+
+ bool isText() const { return m_type == InlineItem::Type::Text; }
+ bool isBox() const { return m_type == InlineItem::Type::Box; }
+ bool isLineBreak() const { return m_type == InlineItem::Type::HardLineBreak; }
+ bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
+ bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
+
private:
friend class Line;
- Runs& runs() { return m_runs; }
+ 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; }
- Runs m_runs;
+ const Box& m_layoutBox;
+ const InlineItem::Type m_type;
+ Display::Rect m_logicalRect;
+ Optional<TextContext> m_textContext;
};
- std::unique_ptr<Content> close();
+ using RunList = Vector<std::unique_ptr<Run>>;
+ RunList close();
- void append(const InlineItem&, LayoutUnit logicalWidth);
- bool hasContent() const { return !isVisuallyEmpty(); }
- LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
-
- LayoutUnit trailingTrimmableWidth() const;
-
- const LineBox& lineBox() const { return m_lineBox; }
- void moveLogicalLeft(LayoutUnit);
- void moveLogicalRight(LayoutUnit);
-
static LineBox::Baseline halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight);
private:
@@ -147,8 +136,8 @@
const InlineFormattingContext& formattingContext() const;
const InlineFormattingContext& m_inlineFormattingContext;
- std::unique_ptr<Content> m_content;
- ListHashSet<Content::Run*> m_trimmableContent;
+ RunList m_runList;
+ ListHashSet<Run*> m_trimmableContent;
Optional<LineBox::Baseline> m_initialStrut;
LayoutUnit m_lineLogicalWidth;