WebKit Bugzilla
Attachment 372215 Details for
Bug 198901
: [LFC][IFC] Decouple baseline ascent/descent and baseline offset.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198901-20190615205945.patch (text/plain), 9.58 KB, created by
zalan
on 2019-06-15 20:59:44 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-15 20:59:44 PDT
Size:
9.58 KB
patch
obsolete
>Subversion Revision: 246468 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3f4657138cc1940208b12f4eb4e7d9559e88b50d..81e1b67abee490fe3046b555e1f40dfd4d8f42aa 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2019-06-15 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Decouple baseline ascent/descent and baseline offset. >+ https://bugs.webkit.org/show_bug.cgi?id=198901 >+ <rdar://problem/51782393> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-15 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Completely collapsed runs should not go to the trimmable run list. >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >index e7400811ba37b7e9615ad4c9b606d763a6b8c640..3f0adace06df3e01b835f7ebc89cd049b0662943 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >@@ -130,7 +130,7 @@ InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLa > 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 @@ 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, lineContent.baseline() }); >+ m_formattingState.addLineBox({ lineBox, lineContent.baseline(), lineContent.baselineOffset() }); > return; > } > >@@ -406,7 +406,7 @@ void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& > } > } > // 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()); > } > >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >index e8ee7afddbbadd7dd2e63fd4b0311fb207fd95ea..a9038bc72c76b472617de6b34b00ecfef9182ecd 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >@@ -57,7 +57,7 @@ Line::Line(const LayoutState& layoutState, const LayoutPoint& topLeft, LayoutUni > : 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) > { >@@ -96,6 +96,7 @@ std::unique_ptr<Line::Content> Line::close() > if (!m_skipVerticalAligment) { > if (isVisuallyEmpty()) { > m_baseline = { }; >+ m_baselineTop = { }; > m_contentLogicalHeight = { }; > } > >@@ -148,6 +149,7 @@ std::unique_ptr<Line::Content> Line::close() > } > m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); > m_content->setBaseline(m_baseline); >+ m_content->setBaselineOffset(baselineOffset()); > return WTFMove(m_content); > } > >@@ -335,7 +337,7 @@ void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit > 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; >@@ -378,7 +380,7 @@ LineBox::Baseline Line::halfLeadingMetrics(const FontMetrics& fontMetrics, Layou > // 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 }; > } > > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.h b/Source/WebCore/layout/inlineformatting/InlineLine.h >index 08c1086749764724064121b836cc631dc294da1d..c25b7b57a0c8cbfb247bd213965fd37ae90f0bc8 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.h >@@ -68,16 +68,19 @@ public: > 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; > > 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 @@ private: > > 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 @@ private: > LayoutUnit m_contentLogicalWidth; > > LineBox::Baseline m_baseline; >+ LayoutUnit m_baselineTop; >+ > 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 d863b63ec32f85319200eb040ee6c1430f26718d..6dc6361668d5a4d1b4e95702b5f399c3e2b3bf88 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBox.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBox.h >@@ -37,9 +37,8 @@ public: > 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,19 @@ public: > 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. >+ 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) > { > } >
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
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198901
: 372215