WebKit Bugzilla
Attachment 371646 Details for
Bug 198686
: [LFC][IFC] Make baselines alignment explicit in Line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198686-20190607210855.patch (text/plain), 13.04 KB, created by
zalan
on 2019-06-07 21:08:57 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-07 21:08:57 PDT
Size:
13.04 KB
patch
obsolete
>Subversion Revision: 246206 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1a9635ffbc032ee961ecd23990a3cc74d694f5ce..ff16d5bad14d1e21b34843da213934a9f1337663 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,32 @@ >+2019-06-07 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Introduce Baseline to LineBox >+ https://bugs.webkit.org/show_bug.cgi?id=198686 >+ <rdar://problem/51545175> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make baselines alignment explicit in Line. >+ This is in preparation for adding non-baseline vertical alignment support. >+ >+ * 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::baseline const): >+ (WebCore::Layout::Line::Content::setBaseline): >+ (WebCore::Layout::Line::logicalHeight const): >+ (WebCore::Layout::Line::baselineAlignedContentHeight const): >+ (WebCore::Layout::Line::baselineOffset const): >+ * layout/inlineformatting/InlineLineBox.h: >+ (WebCore::Layout::LineBox::baseline const): >+ (WebCore::Layout::LineBox::LineBox): >+ > 2019-06-07 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Line should skip all vertical adjustment when running preferred width computation >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >index ee34338318a41bd4b4f74ada089e5c69d624d7e0..2032caf676ef336244b322697f0090524f562a02 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >@@ -130,8 +130,8 @@ InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLa > std::unique_ptr<Line> line; > if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No) { > auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight(); >- auto baselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).height; >- line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft, lineInput.horizontalConstraint.availableLogicalWidth, mimimumLineHeight, baselineOffset); >+ auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).offset; >+ 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); > >@@ -301,7 +301,7 @@ void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& > 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 }); >+ m_formattingState.addLineBox({ lineBox, lineContent.baseline() }); > return; > } > >@@ -311,7 +311,7 @@ void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& > // A line box is always tall enough for all of the boxes it contains. > > // Ignore the initial strut. >- auto lineBox = Display::Rect { lineContent.logicalTop(), lineContent.logicalLeft(), 0 , !lineContent.isVisuallyEmpty() ? lineContent.logicalHeight() : LayoutUnit { } }; >+ auto lineBox = Display::Rect { lineContent.logicalTop(), lineContent.logicalLeft(), 0, !lineContent.isVisuallyEmpty() ? lineContent.logicalHeight() : LayoutUnit { } }; > // Create final display runs. > auto& lineRuns = lineContent.runs(); > for (unsigned index = 0; index < lineRuns.size(); ++index) { >@@ -392,7 +392,7 @@ void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& > } > } > // FIXME linebox needs to be ajusted after content alignment. >- m_formattingState.addLineBox({ lineBox }); >+ m_formattingState.addLineBox({ lineBox, lineContent.baseline() }); > if (!lineContent.isVisuallyEmpty()) > alignRuns(m_formattingRoot.style().textAlign(), previousLineLastRunIndex.valueOr(-1) + 1, widthConstraint - lineContent.logicalWidth()); > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >index 544ec177138fad7e2a112f361b1c6fdf4cc2c487..27f6a785915b6b9b1767fc87b036b533d676a848 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >@@ -69,7 +69,8 @@ Line::Line(const LayoutState& layoutState, const LayoutPoint& topLeft, LayoutUni > : m_layoutState(layoutState) > , m_content(std::make_unique<Line::Content>()) > , m_logicalTopLeft(topLeft) >- , m_logicalHeight({ baselineOffset, minimumHeight - baselineOffset }) >+ , m_baseline({ baselineOffset, minimumHeight - baselineOffset, { } }) >+ , m_contentLogicalHeight(minimumHeight) > , m_lineLogicalWidth(availableWidth) > { > } >@@ -80,11 +81,12 @@ std::unique_ptr<Line::Content> Line::close() > if (!m_skipVerticalAligment) { > // Convert inline run geometry from relative to the baseline to relative to logical top. > for (auto& run : m_content->runs()) { >- auto adjustedLogicalTop = run->logicalRect.top() + m_logicalHeight.height + m_logicalTopLeft.y(); >+ auto adjustedLogicalTop = run->logicalRect.top() + baselineOffset(); > run->logicalRect.setTop(adjustedLogicalTop); > } > } > m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); >+ m_content->setBaseline(m_baseline); > return WTFMove(m_content); > } > >@@ -245,10 +247,11 @@ void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit > if (inlineItem.isContainerStart()) { > auto& fontMetrics = style.fontMetrics(); > auto halfLeading = halfLeadingMetrics(fontMetrics, style.computedLineHeight()); >- if (halfLeading.depth > 0) >- m_logicalHeight.depth = std::max(m_logicalHeight.depth, halfLeading.depth); >- if (halfLeading.height > 0) >- m_logicalHeight.height = std::max(m_logicalHeight.height, halfLeading.height); >+ if (halfLeading.descent > 0) >+ m_baseline.descent = std::max(m_baseline.descent, halfLeading.descent); >+ if (halfLeading.ascent > 0) >+ m_baseline.ascent = std::max(m_baseline.ascent, halfLeading.ascent); >+ m_contentLogicalHeight = std::max(m_contentLogicalHeight, baselineAlignedContentHeight()); > return; > } > // Replaced and non-replaced inline level box. >@@ -257,13 +260,15 @@ void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit > if (runHeight == logicalHeight()) > return; > // FIXME: This fails when the line height difference comes from font-size diff. >- m_logicalHeight.depth = std::max<LayoutUnit>(0, m_logicalHeight.depth); >- m_logicalHeight.height = std::max(runHeight, m_logicalHeight.height); >+ m_baseline.descent = std::max<LayoutUnit>(0, m_baseline.descent); >+ m_baseline.ascent = std::max(runHeight, m_baseline.ascent); >+ m_contentLogicalHeight = std::max(m_contentLogicalHeight, baselineAlignedContentHeight()); > return; > } > // 0 descent -> baseline aligment for now. >- m_logicalHeight.depth = std::max<LayoutUnit>(0, m_logicalHeight.depth); >- m_logicalHeight.height = std::max(runHeight, m_logicalHeight.height); >+ m_baseline.descent = std::max<LayoutUnit>(0, m_baseline.descent); >+ m_baseline.ascent = std::max(runHeight, m_baseline.ascent); >+ m_contentLogicalHeight = std::max(m_contentLogicalHeight, baselineAlignedContentHeight()); > } > > LayoutUnit Line::inlineItemHeight(const InlineItem& inlineItem) const >@@ -290,7 +295,7 @@ LayoutUnit Line::inlineItemHeight(const InlineItem& inlineItem) const > return displayBox.height(); > } > >-Line::UsedHeightAndDepth Line::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight) >+LineBox::Baseline Line::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight) > { > auto ascent = fontMetrics.ascent(); > auto descent = fontMetrics.descent(); >@@ -299,7 +304,7 @@ Line::UsedHeightAndDepth Line::halfLeadingMetrics(const FontMetrics& fontMetrics > // 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 }; >+ return { adjustedAscent, adjustedDescent, adjustedAscent }; > } > > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.h b/Source/WebCore/layout/inlineformatting/InlineLine.h >index b4a28c1d09e77d2a5e240b56b19bf0c440b92335..44cc01561f357aa43f9547a7321f5a273864211d 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.h >@@ -69,14 +69,17 @@ public: > LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } > LayoutUnit logicalWidth() const { return m_logicalRect.width(); } > LayoutUnit logicalHeight() const { return m_logicalRect.height(); } >+ LineBox::Baseline baseline() const { return m_baseline; } > > private: > friend class Line; > > void setLogicalRect(const Display::Rect& logicalRect) { m_logicalRect = logicalRect; } >+ void setBaseline(LineBox::Baseline baseline) { m_baseline = baseline; } > Runs& runs() { return m_runs; } > > Display::Rect m_logicalRect; >+ LineBox::Baseline m_baseline; > Runs m_runs; > }; > std::unique_ptr<Content> close(); >@@ -100,20 +103,18 @@ public: > LayoutUnit logicalTop() const { return m_logicalTopLeft.y(); } > LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } > >- struct UsedHeightAndDepth { >- LayoutUnit height; >- LayoutUnit depth; >- }; >- static UsedHeightAndDepth halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight); >+ static LineBox::Baseline halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight); > > private: > LayoutUnit logicalLeft() const { return m_logicalTopLeft.x(); } > LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } > > LayoutUnit logicalWidth() const { return m_lineLogicalWidth; } >- LayoutUnit logicalHeight() const { return m_logicalHeight.height + m_logicalHeight.depth; } >+ LayoutUnit logicalHeight() const { return m_contentLogicalHeight; } > > LayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; } >+ LayoutUnit baselineAlignedContentHeight() const { return m_baseline.ascent + m_baseline.descent; } >+ LayoutUnit baselineOffset() const { return m_baseline.offset; } > > void appendNonBreakableSpace(const InlineItem&, const Display::Rect& logicalRect); > void removeTrailingTrimmableContent(); >@@ -128,7 +129,8 @@ private: > LayoutPoint m_logicalTopLeft; > LayoutUnit m_contentLogicalWidth; > >- UsedHeightAndDepth m_logicalHeight; >+ LineBox::Baseline m_baseline; >+ LayoutUnit m_contentLogicalHeight; > LayoutUnit m_lineLogicalWidth; > bool m_skipVerticalAligment { false }; > }; >diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBox.h b/Source/WebCore/layout/inlineformatting/InlineLineBox.h >index ce2f246cdd2609729a82151dbf98f69cf9a2237a..d863b63ec32f85319200eb040ee6c1430f26718d 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBox.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBox.h >@@ -34,7 +34,12 @@ namespace Layout { > > class LineBox { > public: >- LineBox(Display::Rect); >+ 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&); > > LayoutPoint logicalTopLeft() const { return m_rect.topLeft(); } > >@@ -46,12 +51,16 @@ public: > LayoutUnit logicalWidth() const { return m_rect.width(); } > LayoutUnit logicalHeight() const { return m_rect.height(); } > >+ Baseline baseline() const { return m_baseline; } >+ > private: > Display::Rect m_rect; >+ Baseline m_baseline; > }; > >-inline LineBox::LineBox(Display::Rect rect) >+inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline) > : m_rect(rect) >+ , m_baseline(baseline) > { > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198686
: 371646