⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273805 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 8:29:26 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Enable simplified vertical alignment for hard line breaks
​https://bugs.webkit.org/show_bug.cgi?id=222606

Reviewed by Antti Koivisto.

This patch enables the simplified vertical alignment for cases when the line ends with a non-stretching hard line break.
e.g.
<div>text<br>content</div>
<div>text<span><br></span>content</div>
but not when
<div>text<span style="font-size: 100px;"><br></span>content</div>

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

(WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
(WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment):
(WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::align):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273777 r273805  
     12021-03-02  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Enable simplified vertical alignment for hard line breaks
     4        https://bugs.webkit.org/show_bug.cgi?id=222606
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch enables the simplified vertical alignment for cases when the line ends with a non-stretching hard line break.
     9        e.g.
     10        <div>text<br>content</div>
     11        <div>text<span><br></span>content</div>
     12        but not when
     13        <div>text<span style="font-size: 100px;"><br></span>content</div>
     14
     15        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     16        (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
     17        (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment):
     18        (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::align):
     19
    1202021-03-02  Yusuke Suzuki  <ysuzuki@apple.com>
    221
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r273754 r273805  
    365365            auto lineBreakBox = LineBox::InlineLevelBox::createLineBreakBox(layoutBox, logicalLeft);
    366366            setVerticalGeometryForInlineBox(*lineBreakBox);
     367            simplifiedAlignVerticallyIfApplicable(*lineBreakBox, formattingContext().geometryForBox(layoutBox));
    367368            lineBox.addInlineLevelBox(WTFMove(lineBreakBox));
    368             simplifiedVerticalAlignment.setEnabled(false);
    369369            continue;
    370370        }
    … …  
    637637            && inlineLevelBoxGeometry.marginBoxHeight() <= rootInlineBox.baseline();
    638638    }
     639    if (inlineLevelBox.isLineBreakBox()) {
     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();
     644    }
    639645    return false;
    640646}
    … …  
    642648void LineBoxBuilder::SimplifiedVerticalAlignment::align(LineBox::InlineLevelBox& inlineLevelBox)
    643649{
    644     if (inlineLevelBox.isAtomicInlineLevelBox()) {
     650    if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox()) {
    645651        // Only baseline alignment for now.
    646652        inlineLevelBox.setLogicalTop(m_rootInlineBox.baseline() - inlineLevelBox.baseline());
Note: See TracChangeset for help on using the changeset viewer.