https://bugs.webkit.org/show_bug.cgi?id=190934
Reviewed by Antti Koivisto.
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::initializeNewLine const):
(WebCore::Layout::InlineFormattingContext::layoutInlineContent const):
* layout/inlineformatting/InlineFormattingContext.h:
(WebCore::Layout::InlineFormattingContext::Line::isFirstLine const):
(WebCore::Layout::InlineFormattingContext::Line::logicalTop const):
(WebCore::Layout::InlineFormattingContext::Line::logicalBottom const):
* layout/inlineformatting/Line.cpp:
(WebCore::Layout::InlineFormattingContext::Line::init):
(WebCore::Layout::InlineFormattingContext::Line::contentLogicalRight):
(WebCore::Layout::InlineFormattingContext::Line::close):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237453
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2018-10-26 Zalan Bujtas <zalan@apple.com>
+ [LFC][IFC] Add line logical top and bottom
+ https://bugs.webkit.org/show_bug.cgi?id=190934
+
+ Reviewed by Antti Koivisto.
+
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::initializeNewLine const):
+ (WebCore::Layout::InlineFormattingContext::layoutInlineContent const):
+ * layout/inlineformatting/InlineFormattingContext.h:
+ (WebCore::Layout::InlineFormattingContext::Line::isFirstLine const):
+ (WebCore::Layout::InlineFormattingContext::Line::logicalTop const):
+ (WebCore::Layout::InlineFormattingContext::Line::logicalBottom const):
+ * layout/inlineformatting/Line.cpp:
+ (WebCore::Layout::InlineFormattingContext::Line::init):
+ (WebCore::Layout::InlineFormattingContext::Line::contentLogicalRight):
+ (WebCore::Layout::InlineFormattingContext::Line::close):
+
+2018-10-26 Zalan Bujtas <zalan@apple.com>
+
[LFC][IFC] Find floating constraints for a given vertical position
https://bugs.webkit.org/show_bug.cgi?id=190928
return run.content.style().collapseWhiteSpace();
}
-void InlineFormattingContext::layoutInlineContent(const LayoutContext& layoutContext, InlineFormattingState& inlineFormattingState, const InlineRunProvider& inlineRunProvider) const
+void InlineFormattingContext::initializeNewLine(const LayoutContext& layoutContext, Line& line) const
{
auto& formattingRoot = downcast<Container>(root());
auto& formattingRootDisplayBox = layoutContext.displayBoxForLayoutBox(formattingRoot);
auto lineLogicalLeft = formattingRootDisplayBox.contentBoxLeft();
+ auto lineLogicalTop = line.isFirstLine() ? formattingRootDisplayBox.contentBoxTop() : line.logicalBottom();
auto availableWidth = formattingRootDisplayBox.contentBoxWidth();
+
+ Display::Box::Rect logicalRect;
+ logicalRect.setTop(lineLogicalTop);
+ logicalRect.setLeft(lineLogicalLeft);
+ logicalRect.setWidth(availableWidth);
+ logicalRect.setHeight(formattingRoot.style().computedLineHeight());
+
+ line.init(logicalRect);
+}
+
+void InlineFormattingContext::layoutInlineContent(const LayoutContext& layoutContext, InlineFormattingState& inlineFormattingState, const InlineRunProvider& inlineRunProvider) const
+{
auto previousRunPositionIsLineEnd = false;
Line line(inlineFormattingState, root());
- line.init(lineLogicalLeft, availableWidth);
+ initializeNewLine(layoutContext, line);
InlineLineBreaker lineBreaker(layoutContext, inlineFormattingState.inlineContent(), inlineRunProvider.runs());
while (auto run = lineBreaker.nextRun(line.contentLogicalRight(), line.availableWidth(), !line.hasContent())) {
// Previous run ended up being at the line end. Adjust the line accordingly.
if (!previousRunPositionIsLineEnd) {
line.close();
- line.init(lineLogicalLeft, availableWidth);
+ initializeNewLine(layoutContext, line);
}
// Skip leading whitespace.
if (!trimLeadingRun(*run))
line.appendContent(*run);
// Move over to the next line.
line.close();
- line.init(lineLogicalLeft, availableWidth);
+ initializeNewLine(layoutContext, line);
continue;
}
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "DisplayBox.h"
#include "FormattingContext.h"
#include "InlineLineBreaker.h"
#include <wtf/IsoMalloc.h>
public:
Line(InlineFormattingState&, const Box& formattingRoot);
- void init(LayoutUnit lineLogicalLeft, LayoutUnit availableWidth);
+ void init(const Display::Box::Rect&);
+
void appendContent(const InlineLineBreaker::Run&);
enum class LastLine { No, Yes };
void close(LastLine = LastLine::No);
bool hasContent() const { return m_firstRunIndex.has_value(); }
+ bool isFirstLine() const { return m_isFirstLine; }
LayoutUnit contentLogicalRight();
LayoutUnit availableWidth() const { return m_availableWidth; }
+ LayoutUnit logicalTop() const { return m_logicalRect.top(); }
+ LayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
+
private:
void justifyRuns();
void computeExpansionOpportunities(const InlineLineBreaker::Run&);
InlineFormattingState& m_formattingState;
const Box& m_formattingRoot;
- LayoutUnit m_lineLogicalLeft;
+ Display::Box::Rect m_logicalRect;
LayoutUnit m_availableWidth;
- LayoutUnit m_lineWidth;
std::optional<unsigned> m_firstRunIndex;
bool m_alignmentIsJustify { false };
+ bool m_isFirstLine { true };
};
void layoutInlineContent(const LayoutContext&, InlineFormattingState&, const InlineRunProvider&) const;
+ void initializeNewLine(const LayoutContext&, Line&) const;
void computeWidthAndHeight(const LayoutContext&, const Box&) const;
void computeStaticPosition(const LayoutContext&, const Box&) const override;
{
}
-void InlineFormattingContext::Line::init(LayoutUnit lineLogicalLeft, LayoutUnit availableWidth)
+void InlineFormattingContext::Line::init(const Display::Box::Rect& logicalRect)
{
- m_lineLogicalLeft = lineLogicalLeft;
- m_lineWidth = availableWidth;
- m_availableWidth = availableWidth;
+ m_logicalRect = logicalRect;
+ m_availableWidth = logicalRect.width();
m_firstRunIndex = { };
m_lastRunIsWhitespace = false;
LayoutUnit InlineFormattingContext::Line::contentLogicalRight()
{
if (!m_firstRunIndex.has_value())
- return m_lineLogicalLeft;
+ return m_logicalRect.left();
return m_formattingState.inlineRuns().last().logicalRight();
}
if (!hasContent())
return;
- auto adjustedLogicalLeft = adjustedLineLogicalLeft(alignment, m_lineLogicalLeft, m_availableWidth);
- if (m_lineLogicalLeft == adjustedLogicalLeft)
+ auto adjustedLogicalLeft = adjustedLineLogicalLeft(alignment, m_logicalRect.left(), m_availableWidth);
+ if (m_logicalRect.left() == adjustedLogicalLeft)
return;
auto& inlineRuns = m_formattingState.inlineRuns();
- auto delta = adjustedLogicalLeft - m_lineLogicalLeft;
+ auto delta = adjustedLogicalLeft - m_logicalRect.left();
for (auto runIndex = *m_firstRunIndex; runIndex < inlineRuns.size(); ++runIndex)
inlineRuns[runIndex].setLogicalLeft(inlineRuns[runIndex].logicalLeft() + delta);
};
}
textAlignment = TextAlignMode::Left;
}
+
alignRuns(textAlignment);
+ m_isFirstLine = false;
}
}