WebKit Bugzilla
Attachment 372529 Details for
Bug 199057
: [LFC][IFC] Make the initial strut explicit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199057-20190619213125.patch (text/plain), 9.83 KB, created by
zalan
on 2019-06-19 21:31:26 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-19 21:31:26 PDT
Size:
9.83 KB
patch
obsolete
>Subversion Revision: 246627 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7c96ac054fce8973ced00cb6acc23b98402e4236..fbf7c9eec99be4055d394dd5b9f730638e880e49 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-06-19 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Make the initial strut explicit >+ https://bugs.webkit.org/show_bug.cgi?id=199057 >+ <rdar://problem/51927864> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The strut always sets the initial vertical constraints on the new line in strict mode. However in quirks mode >+ we can ignore it as long as there's no baseline type content on the line. >+ >+ * layout/inlineformatting/InlineFormattingContext.h: >+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: >+ (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): >+ * layout/inlineformatting/InlineFormattingContextQuirks.cpp: >+ (WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints): >+ * layout/inlineformatting/InlineLine.cpp: >+ (WebCore::Layout::Line::appendTextContent): >+ (WebCore::Layout::Line::appendHardLineBreak): >+ (WebCore::Layout::Line::adjustBaselineAndLineHeight): >+ * layout/inlineformatting/InlineLine.h: >+ > 2019-06-19 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Introduce Line::InitialConstraints >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index 3a8cd394a3cccc8bda87e91f912ab6866f3917ee..d675f10102271adf0394b9de838f1329caaf86b5 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -97,6 +97,13 @@ private: > class Quirks { > public: > static bool lineDescentNeedsCollapsing(const LayoutState&, const Line::Content&); >+ >+ struct HeightConstraints { >+ LayoutUnit height; >+ LayoutUnit baselineOffset; >+ Optional<LineBox::Baseline> strut; >+ }; >+ static HeightConstraints lineHeightConstraints(const LayoutState&, const Box& formattingRoot); > }; > > class Geometry : public FormattingContext::Geometry { >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >index 914ed3011f768c6d0e24690590d0c2fd68a0ea88..09edd385c28620ae4a2f2fa26c233a22c1205e70 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >@@ -127,13 +127,13 @@ static LayoutUnit inlineItemWidth(const LayoutState& layoutState, const InlineIt > > InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLayout::placeInlineItems(const LineInput& lineInput) const > { >- auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight(); >- auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).ascent; >+ auto heightConstraints = Quirks::lineHeightConstraints(layoutState(), m_formattingRoot); > auto initialLineConstraints = Line::InitialConstraints { > lineInput.horizontalConstraint.logicalTopLeft, > lineInput.horizontalConstraint.availableLogicalWidth, >- mimimumLineHeight, >- initialBaselineOffset >+ heightConstraints.height, >+ heightConstraints.baselineOffset, >+ heightConstraints.strut > }; > auto line = Line { layoutState(), initialLineConstraints, lineInput.skipVerticalAligment }; > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp >index 13ec8e8bba4a0878584cf817b551b24f77579913..e89410ed8418598673cf7b98c79f5e36b04ed9a6 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp >@@ -82,6 +82,26 @@ bool InlineFormattingContext::Quirks::lineDescentNeedsCollapsing(const LayoutSta > return true; > } > >+InlineFormattingContext::Quirks::HeightConstraints InlineFormattingContext::Quirks::lineHeightConstraints(const LayoutState& layoutState, const Box& formattingRoot) >+{ >+ // computedLineHeight takes font-size into account when line-height is not set. >+ // Strut is the imaginary box that we put on every line. It sets the initial vertical constraints for each new line. >+ auto strutHeight = formattingRoot.style().computedLineHeight(); >+ auto strutBaselineOffset = Line::halfLeadingMetrics(formattingRoot.style().fontMetrics(), strutHeight).ascent; >+ if (layoutState.inNoQuirksMode()) >+ return { strutHeight, strutBaselineOffset, { } }; >+ >+ auto lineHeight = formattingRoot.style().lineHeight(); >+ if (lineHeight.isPercentOrCalculated()) { >+ auto initialBaselineOffset = Line::halfLeadingMetrics(formattingRoot.style().fontMetrics(), { }).ascent; >+ return { initialBaselineOffset, initialBaselineOffset, LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } }; >+ } >+ // FIXME: The only reason why we use intValue() here is to match current inline tree (integral)behavior. >+ auto initialLineHeight = LayoutUnit { lineHeight.intValue() }; >+ auto initialBaselineOffset = Line::halfLeadingMetrics(formattingRoot.style().fontMetrics(), initialLineHeight).ascent; >+ return { initialLineHeight, initialBaselineOffset, LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } }; >+} >+ > } > } > >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >index 66fca2f5ba478152b132d6e0ddbb5e45ae3e9361..b017bb065b201f7b91eacc9ee6b30f62482da8a7 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >@@ -49,6 +49,7 @@ Line::Line(const LayoutState& layoutState, const InitialConstraints& initialCons > , m_content(std::make_unique<Line::Content>()) > , m_logicalTopLeft(initialConstraints.topLeft) > , m_baseline({ initialConstraints.baselineOffset, initialConstraints.height - initialConstraints.baselineOffset }) >+ , m_initialStrut(initialConstraints.strut) > , m_contentLogicalHeight(initialConstraints.height) > , m_lineLogicalWidth(initialConstraints.availableWidth) > , m_skipVerticalAligment(skipVerticalAligment == SkipVerticalAligment::Yes) >@@ -254,8 +255,11 @@ void Line::appendTextContent(const InlineTextItem& inlineItem, LayoutUnit logica > auto logicalRect = Display::Rect { }; > logicalRect.setLeft(contentLogicalRight()); > logicalRect.setWidth(logicalWidth); >- if (!m_skipVerticalAligment) >- logicalRect.setHeight(inlineItemContentHeight(inlineItem)); >+ if (!m_skipVerticalAligment) { >+ auto runHeight = inlineItemContentHeight(inlineItem); >+ logicalRect.setHeight(runHeight); >+ adjustBaselineAndLineHeight(inlineItem, runHeight); >+ } > > auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() }; > auto lineItem = std::make_unique<Content::Run>(inlineItem, logicalRect, textContext, isCompletelyCollapsed, canBeExtended); >@@ -295,14 +299,16 @@ void Line::appendHardLineBreak(const InlineItem& inlineItem) > auto logicalRect = Display::Rect { }; > logicalRect.setLeft(contentLogicalRight()); > logicalRect.setWidth({ }); >- if (!m_skipVerticalAligment) >+ if (!m_skipVerticalAligment) { >+ adjustBaselineAndLineHeight(inlineItem, { }); > logicalRect.setHeight(logicalHeight()); >+ } > m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false)); > } > > void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit runHeight) > { >- ASSERT(!inlineItem.isContainerEnd() && !inlineItem.isText()); >+ ASSERT(!inlineItem.isContainerEnd()); > auto& layoutBox = inlineItem.layoutBox(); > auto& style = layoutBox.style(); > >@@ -316,6 +322,16 @@ void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit > m_contentLogicalHeight = std::max(m_contentLogicalHeight, baselineAlignedContentHeight()); > return; > } >+ // Apply initial strut if needed. >+ if (inlineItem.isText() || inlineItem.isHardLineBreak()) { >+ if (!m_initialStrut) >+ return; >+ m_baseline.ascent = std::max(m_initialStrut->ascent, m_baseline.ascent); >+ m_baseline.descent = std::max(m_initialStrut->descent, m_baseline.descent); >+ m_contentLogicalHeight = std::max(m_contentLogicalHeight, baselineAlignedContentHeight()); >+ m_initialStrut = { }; >+ return; >+ } > // Replaced and non-replaced inline level box. > switch (inlineItem.style().verticalAlign()) { > case VerticalAlign::Baseline: >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.h b/Source/WebCore/layout/inlineformatting/InlineLine.h >index c3e601ace6343d3dfcdb150778847e38d5689c0f..4ee893fcbe6fc7feaf7760e3fbbf9a28bde7ee8b 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.h >@@ -43,6 +43,7 @@ public: > LayoutUnit availableWidth; > LayoutUnit height; > LayoutUnit baselineOffset; >+ Optional<LineBox::Baseline> strut; > }; > enum class SkipVerticalAligment { No, Yes }; > Line(const LayoutState&, const InitialConstraints&, SkipVerticalAligment); >@@ -141,6 +142,7 @@ private: > LineBox::Baseline m_baseline; > LayoutUnit m_baselineTop; > >+ Optional<LineBox::Baseline> m_initialStrut; > LayoutUnit m_contentLogicalHeight; > LayoutUnit m_lineLogicalWidth; > bool m_skipVerticalAligment { false };
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 199057
:
372529
|
372554