- Revision
- 237453
- Author
- [email protected]
- Date
- 2018-10-26 07:34:54 -0700 (Fri, 26 Oct 2018)
Log Message
[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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (237452 => 237453)
--- trunk/Source/WebCore/ChangeLog 2018-10-26 14:29:22 UTC (rev 237452)
+++ trunk/Source/WebCore/ChangeLog 2018-10-26 14:34:54 UTC (rev 237453)
@@ -1,5 +1,24 @@
2018-10-26 Zalan Bujtas <[email protected]>
+ [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 <[email protected]>
+
[LFC][IFC] Find floating constraints for a given vertical position
https://bugs.webkit.org/show_bug.cgi?id=190928
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (237452 => 237453)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-26 14:29:22 UTC (rev 237452)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-26 14:34:54 UTC (rev 237453)
@@ -101,17 +101,30 @@
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())) {
@@ -122,7 +135,7 @@
// 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))
@@ -136,7 +149,7 @@
line.appendContent(*run);
// Move over to the next line.
line.close();
- line.init(lineLogicalLeft, availableWidth);
+ initializeNewLine(layoutContext, line);
continue;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (237452 => 237453)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-10-26 14:29:22 UTC (rev 237452)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-10-26 14:34:54 UTC (rev 237453)
@@ -27,6 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "DisplayBox.h"
#include "FormattingContext.h"
#include "InlineLineBreaker.h"
#include <wtf/IsoMalloc.h>
@@ -51,15 +52,20 @@
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&);
@@ -75,15 +81,16 @@
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;
Modified: trunk/Source/WebCore/layout/inlineformatting/Line.cpp (237452 => 237453)
--- trunk/Source/WebCore/layout/inlineformatting/Line.cpp 2018-10-26 14:29:22 UTC (rev 237452)
+++ trunk/Source/WebCore/layout/inlineformatting/Line.cpp 2018-10-26 14:34:54 UTC (rev 237453)
@@ -40,11 +40,10 @@
{
}
-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;
@@ -82,7 +81,7 @@
LayoutUnit InlineFormattingContext::Line::contentLogicalRight()
{
if (!m_firstRunIndex.has_value())
- return m_lineLogicalLeft;
+ return m_logicalRect.left();
return m_formattingState.inlineRuns().last().logicalRight();
}
@@ -214,12 +213,12 @@
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);
};
@@ -237,7 +236,9 @@
}
textAlignment = TextAlignMode::Left;
}
+
alignRuns(textAlignment);
+ m_isFirstLine = false;
}
}