Diff
Modified: trunk/Source/WebCore/ChangeLog (246483 => 246484)
--- trunk/Source/WebCore/ChangeLog 2019-06-16 20:19:24 UTC (rev 246483)
+++ trunk/Source/WebCore/ChangeLog 2019-06-16 20:41:59 UTC (rev 246484)
@@ -1,5 +1,32 @@
2019-06-16 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Decouple baseline ascent/descent and baseline offset.
+ https://bugs.webkit.org/show_bug.cgi?id=198901
+ <rdar://problem/51782393>
+
+ Reviewed by Antti Koivisto.
+
+ Baseline offset is the baseline's distance from the line's logical top -and it is not necessarily the same as the baseline's ascent.
+ It's easier to track the baseline and its top separately since certain properties only change one or the other.
+
+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+ (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const):
+ (WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::Line):
+ (WebCore::Layout::Line::close):
+ (WebCore::Layout::Line::adjustBaselineAndLineHeight):
+ (WebCore::Layout::Line::halfLeadingMetrics):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::Content::baselineOffset const):
+ (WebCore::Layout::Line::Content::setBaselineOffset):
+ (WebCore::Layout::Line::baselineOffset const):
+ * layout/inlineformatting/InlineLineBox.h:
+ (WebCore::Layout::LineBox::baselineOffset const):
+ (WebCore::Layout::LineBox::LineBox):
+
+2019-06-16 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Intruding float may prevent adding any inline box
https://bugs.webkit.org/show_bug.cgi?id=198891
<rdar://problem/51779956>
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (246483 => 246484)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-06-16 20:19:24 UTC (rev 246483)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-06-16 20:41:59 UTC (rev 246484)
@@ -130,7 +130,7 @@
std::unique_ptr<Line> line;
if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No) {
auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight();
- auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).offset;
+ auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).ascent;
line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft, lineInput.horizontalConstraint.availableLogicalWidth, mimimumLineHeight, initialBaselineOffset);
} else
line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft.x(), lineInput.horizontalConstraint.availableLogicalWidth);
@@ -315,7 +315,7 @@
if (lineContent.isEmpty()) {
// Spec tells us to create a zero height, empty line box.
auto lineBox = Display::Rect { lineContent.logicalTop(), lineContent.logicalLeft(), 0 , 0 };
- m_formattingState.addLineBox({ lineBox, lineContent.baseline() });
+ m_formattingState.addLineBox({ lineBox, lineContent.baseline(), lineContent.baselineOffset() });
return;
}
@@ -406,7 +406,7 @@
}
}
// FIXME linebox needs to be ajusted after content alignment.
- m_formattingState.addLineBox({ lineBox, lineContent.baseline() });
+ m_formattingState.addLineBox({ lineBox, lineContent.baseline(), lineContent.baselineOffset() });
alignRuns(m_formattingRoot.style().textAlign(), previousLineLastRunIndex.valueOr(-1) + 1, widthConstraint - lineContent.logicalWidth());
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (246483 => 246484)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-06-16 20:19:24 UTC (rev 246483)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-06-16 20:41:59 UTC (rev 246484)
@@ -57,7 +57,7 @@
: m_layoutState(layoutState)
, m_content(std::make_unique<Line::Content>())
, m_logicalTopLeft(topLeft)
- , m_baseline({ baselineOffset, minimumHeight - baselineOffset, { } })
+ , m_baseline({ baselineOffset, minimumHeight - baselineOffset })
, m_contentLogicalHeight(minimumHeight)
, m_lineLogicalWidth(availableWidth)
{
@@ -97,6 +97,7 @@
if (!m_skipVerticalAligment) {
if (isVisuallyEmpty()) {
m_baseline = { };
+ m_baselineTop = { };
m_contentLogicalHeight = { };
}
@@ -149,6 +150,7 @@
}
m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() });
m_content->setBaseline(m_baseline);
+ m_content->setBaselineOffset(baselineOffset());
return WTFMove(m_content);
}
@@ -336,7 +338,7 @@
break;
case VerticalAlign::Bottom:
if (m_contentLogicalHeight < runHeight) {
- m_baseline.offset = m_baseline.offset + (runHeight - m_contentLogicalHeight);
+ m_baselineTop += runHeight - m_contentLogicalHeight;
m_contentLogicalHeight = runHeight;
}
break;
@@ -379,7 +381,7 @@
// Inline tree is all integer based.
auto adjustedAscent = std::max((ascent + leading / 2).floor(), 0);
auto adjustedDescent = std::max((descent + leading / 2).ceil(), 0);
- return { adjustedAscent, adjustedDescent, adjustedAscent };
+ return { adjustedAscent, adjustedDescent };
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (246483 => 246484)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-06-16 20:19:24 UTC (rev 246483)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-06-16 20:41:59 UTC (rev 246484)
@@ -68,6 +68,7 @@
LayoutUnit logicalWidth() const { return m_logicalRect.width(); }
LayoutUnit logicalHeight() const { return m_logicalRect.height(); }
LineBox::Baseline baseline() const { return m_baseline; }
+ LayoutUnit baselineOffset() const { return m_baselineOffset; }
private:
friend class Line;
@@ -74,10 +75,12 @@
void setLogicalRect(const Display::Rect& logicalRect) { m_logicalRect = logicalRect; }
void setBaseline(LineBox::Baseline baseline) { m_baseline = baseline; }
+ void setBaselineOffset(LayoutUnit baselineOffset) { m_baselineOffset = baselineOffset; }
Runs& runs() { return m_runs; }
Display::Rect m_logicalRect;
LineBox::Baseline m_baseline;
+ LayoutUnit m_baselineOffset;
Runs m_runs;
};
std::unique_ptr<Content> close();
@@ -112,7 +115,7 @@
LayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
LayoutUnit baselineAlignedContentHeight() const { return m_baseline.ascent + m_baseline.descent; }
- LayoutUnit baselineOffset() const { return m_baseline.offset; }
+ LayoutUnit baselineOffset() const { return m_baseline.ascent + m_baselineTop; }
void appendNonBreakableSpace(const InlineItem&, const Display::Rect& logicalRect);
void removeTrailingTrimmableContent();
@@ -129,6 +132,8 @@
LayoutUnit m_contentLogicalWidth;
LineBox::Baseline m_baseline;
+ LayoutUnit m_baselineTop;
+
LayoutUnit m_contentLogicalHeight;
LayoutUnit m_lineLogicalWidth;
bool m_skipVerticalAligment { false };
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (246483 => 246484)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2019-06-16 20:19:24 UTC (rev 246483)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2019-06-16 20:41:59 UTC (rev 246484)
@@ -37,9 +37,8 @@
struct Baseline {
LayoutUnit ascent;
LayoutUnit descent;
- LayoutUnit offset; // baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
};
- LineBox(Display::Rect, const Baseline&);
+ LineBox(Display::Rect, const Baseline&, LayoutUnit baselineOffset);
LayoutPoint logicalTopLeft() const { return m_rect.topLeft(); }
@@ -52,15 +51,33 @@
LayoutUnit logicalHeight() const { return m_rect.height(); }
Baseline baseline() const { return m_baseline; }
+ // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
+ //
+ // ------------------- line logical top
+ // ^
+ // |
+ // ^ | baseline offset
+ // | |
+ // | ascent |
+ // | |
+ // v v
+ // ----------------- baseline
+ // ^
+ // | descent
+ // v
+ // ------------------- line logical bottom
+ LayoutUnit baselineOffset() const { return m_baselineOffset; }
private:
Display::Rect m_rect;
Baseline m_baseline;
+ LayoutUnit m_baselineOffset;
};
-inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline)
+inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline, LayoutUnit baselineOffset)
: m_rect(rect)
, m_baseline(baseline)
+ , m_baselineOffset(baselineOffset)
{
}