WebKit Bugzilla
Attachment 371496 Details for
Bug 198611
: [LFC][IFC] Move baseline and line height computation to a dedicated function
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198611-20190606075410.patch (text/plain), 6.60 KB, created by
zalan
on 2019-06-06 07:54:14 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-06 07:54:14 PDT
Size:
6.60 KB
patch
obsolete
>Subversion Revision: 246152 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 8fc6d372cdd63bad4c46895b67ba9fe8d316d235..e564684cda86c06f1144d5317b383bb1856bebdc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-06-06 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Move baseline and line height computation to a dedicated function >+ https://bugs.webkit.org/show_bug.cgi?id=198611 >+ <rdar://problem/51482708> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is in preparation for adding vertical aligment. >+ >+ * layout/inlineformatting/InlineLine.cpp: >+ (WebCore::Layout::Line::appendInlineContainerStart): >+ (WebCore::Layout::Line::appendNonReplacedInlineBox): >+ (WebCore::Layout::Line::adjustBaselineAndLineHeight): >+ * layout/inlineformatting/InlineLine.h: >+ > 2019-06-06 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Layout and preferred width computation should both call placeInlineItems(). >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >index 07405ae747471d52fb353ace498a2cc9b87ef6a3..ce80d7a38f0f26da8be31e16470398672b716b03 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >@@ -121,22 +121,12 @@ void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display:: > > void Line::appendInlineContainerStart(const InlineItem& inlineItem, InlineItemSize runSize) > { >- auto& layoutBox = inlineItem.layoutBox(); >- auto& style = layoutBox.style(); >- auto& fontMetrics = style.fontMetrics(); >- >- auto alignAndAdjustLineHeight = [&] { >- LayoutUnit inlineBoxHeight = style.computedLineHeight(); >- >- auto halfLeading = halfLeadingMetrics(fontMetrics, inlineBoxHeight); >- 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); >- }; >+ adjustBaselineAndLineHeight(inlineItem); > >- alignAndAdjustLineHeight(); >+ auto& layoutBox = inlineItem.layoutBox(); >+ auto& fontMetrics = layoutBox.style().fontMetrics(); > auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox); >+ > auto logicalTop = -fontMetrics.ascent() - displayBox.borderTop() - displayBox.paddingTop().valueOr(0); > auto logicalRect = Display::Rect { logicalTop, contentLogicalRight(), runSize.logicalWidth, runSize.logicalHeight.valueOr(0) }; > appendNonBreakableSpace(inlineItem, logicalRect); >@@ -191,23 +181,9 @@ void Line::appendTextContent(const InlineTextItem& inlineItem, InlineItemSize ru > > void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, InlineItemSize runSize) > { >- auto inlineBoxHeight = runSize.logicalHeight.valueOr(0); >- auto alignAndAdjustLineHeight = [&] { >- // FIXME: We need to look inside the inline-block's formatting context and check the lineboxes (if any) to be able to baseline align. >- if (inlineItem.layoutBox().establishesInlineFormattingContext()) { >- if (inlineBoxHeight == 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(inlineBoxHeight, m_logicalHeight.height); >- return; >- } >- // 0 descent -> baseline aligment for now. >- m_logicalHeight.depth = std::max<LayoutUnit>(0, m_logicalHeight.depth); >- m_logicalHeight.height = std::max(inlineBoxHeight, m_logicalHeight.height); >- }; >+ adjustBaselineAndLineHeight(inlineItem); > >- alignAndAdjustLineHeight(); >+ auto inlineBoxHeight = runSize.logicalHeight.valueOr(0); > auto& displayBox = m_layoutState.displayBoxForLayoutBox(inlineItem.layoutBox()); > auto logicalTop = -inlineBoxHeight; > auto horizontalMargin = displayBox.horizontalMargin(); >@@ -231,6 +207,37 @@ void Line::appendHardLineBreak(const InlineItem& inlineItem) > m_content->runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false)); > } > >+void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem) >+{ >+ ASSERT(!inlineItem.isContainerEnd() && !inlineItem.isText()); >+ auto& layoutBox = inlineItem.layoutBox(); >+ auto& style = layoutBox.style(); >+ LayoutUnit inlineBoxHeight = style.computedLineHeight(); >+ >+ if (inlineItem.isContainerStart()) { >+ auto& fontMetrics = style.fontMetrics(); >+ auto halfLeading = halfLeadingMetrics(fontMetrics, inlineBoxHeight); >+ 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); >+ return; >+ } >+ // Replaced and non-replaced inline level box. >+ // FIXME: We need to look inside the inline-block's formatting context and check the lineboxes (if any) to be able to baseline align. >+ if (layoutBox.establishesInlineFormattingContext()) { >+ if (inlineBoxHeight == 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(inlineBoxHeight, m_logicalHeight.height); >+ return; >+ } >+ // 0 descent -> baseline aligment for now. >+ m_logicalHeight.depth = std::max<LayoutUnit>(0, m_logicalHeight.depth); >+ m_logicalHeight.height = std::max(inlineBoxHeight, m_logicalHeight.height); >+} >+ > Line::UsedHeightAndDepth Line::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight) > { > auto ascent = fontMetrics.ascent(); >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.h b/Source/WebCore/layout/inlineformatting/InlineLine.h >index 5857499d6797c06270fc913a83de66e7b4ab3648..349d5ddbe17e933b058fd3de8efb0d11d863a0cc 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.h >@@ -116,6 +116,8 @@ private: > void appendNonBreakableSpace(const InlineItem&, const Display::Rect& logicalRect); > void removeTrailingTrimmableContent(); > >+ void adjustBaselineAndLineHeight(const InlineItem&); >+ > const LayoutState& m_layoutState; > std::unique_ptr<Content> m_content; > ListHashSet<Content::Run*> m_trimmableContent;
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 198611
:
371496
|
371504