Changeset 273815 in webkit
- Timestamp:
- Mar 3, 2021, 8:34:03 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContextGeometry.cpp (modified) (4 diffs)
-
layout/inlineformatting/InlineLineBox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273812 r273815 1 2021-03-03 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Enable simplified vertical alignment for empty inline boxes 4 https://bugs.webkit.org/show_bug.cgi?id=222630 5 6 Reviewed by Antti Koivisto. 7 8 This patch enables the simplified vertical alignment for cases when the line has non-stretching empty inline boxes. 9 e.g. 10 <div>text<span></span>content</div> 11 but not 12 <div>text<span style="font-size: 100px"></span>content</div> (in standards mode the empty inline box starts with a strut, so this would be stretching the root inline box to ~100px). 13 14 * layout/inlineformatting/InlineFormattingContextGeometry.cpp: 15 (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes): 16 (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment): 17 (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::align): 18 * layout/inlineformatting/InlineLineBox.h: 19 (WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::operator== const): 20 1 21 2021-03-02 Manuel Rego Casasnovas <rego@igalia.com> 2 22 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp
r273805 r273815 342 342 setVerticalGeometryForInlineBox(*inlineBox); 343 343 lineBox.addInlineLevelBox(WTFMove(inlineBox)); 344 simplifiedVerticalAlignment.setEnabled(!lineHasContent);345 344 continue; 346 345 } … … 350 349 ASSERT(inlineBox.isInlineBox()); 351 350 // Inline box run is based on margin box. Let's convert it to border box. 352 auto marginEnd = std::max(0_lu, formattingContext().geometryForBox(layoutBox).marginEnd()); 351 auto& inlineBoxGeometry = formattingContext().geometryForBox(layoutBox); 352 auto marginEnd = std::max(0_lu, inlineBoxGeometry.marginEnd()); 353 353 auto inlineBoxLogicalRight = logicalLeft + run.logicalWidth() - marginEnd; 354 354 inlineBox.setLogicalWidth(inlineBoxLogicalRight - inlineBox.logicalLeft()); 355 simplified VerticalAlignment.setEnabled(!lineHasContent);355 simplifiedAlignVerticallyIfApplicable(inlineBox, inlineBoxGeometry); 356 356 continue; 357 357 } … … 639 639 if (inlineLevelBox.isLineBreakBox()) { 640 640 // Baseline aligned, non-stretchy line breaks e.g. <div><span><br></span></div> but not <div><span style="font-size: 100px;"><br></span></div>. 641 auto& layoutBox = inlineLevelBox.layoutBox(); 642 return layoutBox.style().verticalAlign() == VerticalAlign::Baseline 643 && inlineLevelBox.baseline() <= rootInlineBox.baseline(); 641 return inlineLevelBox.layoutBox().style().verticalAlign() == VerticalAlign::Baseline && inlineLevelBox.baseline() <= rootInlineBox.baseline(); 642 } 643 if (inlineLevelBox.isInlineBox()) { 644 // Baseline aligned, non-stretchy inline boxes e.g. <div><span></span></div> but not <div><span style="font-size: 100px;"></span></div>. 645 return inlineLevelBox.layoutBox().style().verticalAlign() == VerticalAlign::Baseline && inlineLevelBox.layoutBounds() == rootInlineBox.layoutBounds(); 644 646 } 645 647 return false; … … 648 650 void LineBoxBuilder::SimplifiedVerticalAlignment::align(LineBox::InlineLevelBox& inlineLevelBox) 649 651 { 650 if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox() ) {652 if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox() || inlineLevelBox.isInlineBox()) { 651 653 // Only baseline alignment for now. 652 654 inlineLevelBox.setLogicalTop(m_rootInlineBox.baseline() - inlineLevelBox.baseline()); -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r273723 r273815 73 73 struct LayoutBounds { 74 74 InlineLayoutUnit height() const { return ascent + descent; } 75 bool operator==(const LayoutBounds& other) const { return ascent == other.ascent && descent == other.descent; } 75 76 76 77 InlineLayoutUnit ascent { 0 };
Note:
See TracChangeset
for help on using the changeset viewer.