Changeset 266978 in webkit
- Timestamp:
- Sep 12, 2020 10:07:38 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r266976 r266978 1 2020-09-12 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for non-root-inline-box line spacing 4 https://bugs.webkit.org/show_bug.cgi?id=216433 5 6 Reviewed by Antti Koivisto. 7 8 * fast/layoutformattingcontext/inline-box-with-line-spacing-simple-expected.html: Added. 9 * fast/layoutformattingcontext/inline-box-with-line-spacing-simple.html: Added. 10 1 11 2020-09-12 Rob Buis <rbuis@igalia.com> 2 12 -
trunk/LayoutTests/platform/win/TestExpectations
r266913 r266978 3692 3692 fast/forms/file/entries-api/webkitdirectory-open-panel.html [ Skip ] 3693 3693 3694 fast/layoutformattingcontext [ Skip ] 3695 3694 3696 # Requires WK2 loading support 3695 3697 http/wpt/fetch/dnt-header-after-redirection.html [ Skip ] … … 4446 4448 webkit.org/b/204794 webanimations/accelerated-animation-removal-upon-transition-completion.html [ Timeout ] 4447 4449 4448 webkit.org/b/204795 fast/layoutformattingcontext/flow-integration-basic.html [ Failure ]4449 4450 4450 webkit.org/b/204974 http/tests/xmlhttprequest/sync-xhr-in-unload.html [ Failure ] 4451 4451 -
trunk/Source/WebCore/ChangeLog
r266977 r266978 1 2020-09-12 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for non-root-inline-box line spacing 4 https://bugs.webkit.org/show_bug.cgi?id=216433 5 6 Reviewed by Antti Koivisto. 7 8 While the LineBox vertically contains all the LineBox::InlineBoxes, its height value does not 9 include any line spacing (FontMetrics::lineSpacing). 10 Each LineBox::InlineBox may have a different line spacing value (this value is zero in many cases). 11 This patch collects line spacing values from the LineBox::InlineBoxes on the line and adjusts the final 12 line height value accordingly. 13 14 Test: fast/layoutformattingcontext/inline-box-with-line-spacing-simple.html 15 16 * layout/inlineformatting/InlineFormattingContext.cpp: 17 (WebCore::Layout::InlineFormattingContext::computedLineLogicalRect const): 18 * layout/inlineformatting/InlineLineBox.cpp: 19 (WebCore::Layout::LineBox::constructInlineBoxes): 20 * layout/inlineformatting/InlineLineBox.h: 21 (WebCore::Layout::LineBox::InlineBox::lineSpacing const): 22 (WebCore::Layout::LineBox::InlineBox::setLineSpacing): 23 (WebCore::Layout::LineBox::inlineBoxList const): 24 1 25 2020-09-12 Myles C. Maxfield <mmaxfield@apple.com> 2 26 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r266848 r266978 410 410 // |____________________v_______________________| scrollable overflow 411 411 // 412 if (lineContent.runs.isEmpty() || lineContent.lineBox.isLineVisuallyEmpty()) 412 auto& lineBox = lineContent.lineBox; 413 if (lineContent.runs.isEmpty() || lineBox.isLineVisuallyEmpty()) 413 414 return { { }, { lineContent.logicalTopLeft, lineContent.lineLogicalWidth, { } } }; 415 414 416 auto& rootStyle = root().style(); 415 auto& fontMetrics = rootStyle.fontMetrics(); 416 InlineLayoutUnit lineSpacing = fontMetrics.lineSpacing(); 417 auto& lineBox = lineContent.lineBox; 418 auto lineLogicalHeight = rootStyle.lineHeight().isNegative() ? std::max(lineBox.logicalHeight(), lineSpacing) : rootStyle.computedLineHeight(); 417 auto lineLogicalHeight = InlineLayoutUnit { }; 418 if (rootStyle.lineHeight().isNegative()) { 419 // Negative line height value means the line height is driven by the content. 420 auto usedLineSpacing = [&] { 421 auto lineBoxLogicalHeight = lineBox.logicalHeight(); 422 auto logicalTopWithLineSpacing = InlineLayoutUnit { }; 423 auto logicalBottomWithLineSpacing = lineBoxLogicalHeight; 424 for (auto& inlineBox : lineBox.inlineBoxList()) { 425 if (auto lineSpacing = inlineBox->lineSpacing()) { 426 // FIXME: check if line spacing is distributed evenly. 427 logicalTopWithLineSpacing = std::min(logicalTopWithLineSpacing, inlineBox->logicalTop() - *lineSpacing / 2); 428 logicalBottomWithLineSpacing = std::max(logicalBottomWithLineSpacing, inlineBox->logicalBottom() + *lineSpacing / 2); 429 } 430 } 431 return -logicalTopWithLineSpacing + (logicalBottomWithLineSpacing - lineBoxLogicalHeight); 432 }; 433 lineLogicalHeight = lineBox.logicalHeight() + usedLineSpacing(); 434 } else 435 lineLogicalHeight = rootStyle.computedLineHeight(); 436 419 437 auto logicalRect = Display::InlineRect { lineContent.logicalTopLeft, lineContent.lineLogicalWidth, lineLogicalHeight}; 420 421 438 auto halfLeadingOffset = [&] { 439 auto& fontMetrics = rootStyle.fontMetrics(); 422 440 InlineLayoutUnit ascent = fontMetrics.ascent(); 423 441 InlineLayoutUnit descent = fontMetrics.descent(); -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp
r266921 r266978 165 165 inlineBox.setBaseline(baseline); 166 166 inlineBox.setDescent(logicalHeight - baseline); 167 if (auto lineSpacing = fontMetrics.lineSpacing() - logicalHeight) 168 inlineBox.setLineSpacing(lineSpacing); 167 169 }; 168 170 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r266921 r266978 77 77 void setIsNonEmpty() { m_isEmpty = false; } 78 78 79 Optional<InlineLayoutUnit> lineSpacing() const { return m_lineSpacing; } 79 80 const FontMetrics& fontMetrics() const { return layoutBox().style().fontMetrics(); } 80 81 const Box& layoutBox() const { return *m_layoutBox; } … … 88 89 void setBaseline(InlineLayoutUnit baseline) { m_baseline = baseline; } 89 90 void setDescent(InlineLayoutUnit descent) { m_descent = descent; } 91 void setLineSpacing(InlineLayoutUnit lineSpacing) { m_lineSpacing = lineSpacing; } 90 92 91 93 WeakPtr<const Box> m_layoutBox; … … 93 95 InlineLayoutUnit m_baseline { 0 }; 94 96 Optional<InlineLayoutUnit> m_descent; 97 Optional<InlineLayoutUnit> m_lineSpacing; 95 98 bool m_isEmpty { true }; 96 99 }; … … 109 112 const InlineBox& inlineBoxForLayoutBox(const Box& layoutBox) const { return *m_inlineBoxRectMap.get(&layoutBox); } 110 113 Display::InlineRect logicalRectForTextRun(const Line::Run&) const; 114 115 using InlineBoxMap = HashMap<const Box*, InlineBox*>; 116 auto inlineBoxList() const { return m_inlineBoxRectMap.values(); } 111 117 112 118 InlineLayoutUnit alignmentBaseline() const { return m_rootInlineBox.logicalTop() + m_rootInlineBox.baseline(); } … … 130 136 131 137 Optional<InlineLayoutUnit> m_horizontalAlignmentOffset; 132 HashMap<const Box*, InlineBox*>m_inlineBoxRectMap;138 InlineBoxMap m_inlineBoxRectMap; 133 139 Vector<std::unique_ptr<InlineBox>> m_inlineBoxList; 134 140 const InlineFormattingContext& m_inlineFormattingContext;
Note: See TracChangeset
for help on using the changeset viewer.