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

Changeset 273815 in webkit


Ignore:
Timestamp:
Mar 3, 2021, 8:34:03 AM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Enable simplified vertical alignment for empty inline boxes
​https://bugs.webkit.org/show_bug.cgi?id=222630

Reviewed by Antti Koivisto.

This patch enables the simplified vertical alignment for cases when the line has non-stretching empty inline boxes.
e.g.
<div>text<span></span>content</div>
but not
<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).

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

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

  • layout/inlineformatting/InlineLineBox.h:

(WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::operator== const):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273812 r273815  
     12021-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
    1212021-03-02  Manuel Rego Casasnovas  <rego@igalia.com>
    222
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r273805 r273815  
    342342            setVerticalGeometryForInlineBox(*inlineBox);
    343343            lineBox.addInlineLevelBox(WTFMove(inlineBox));
    344             simplifiedVerticalAlignment.setEnabled(!lineHasContent);
    345344            continue;
    346345        }
    … …  
    350349            ASSERT(inlineBox.isInlineBox());
    351350            // 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());
    353353            auto inlineBoxLogicalRight = logicalLeft + run.logicalWidth() - marginEnd;
    354354            inlineBox.setLogicalWidth(inlineBoxLogicalRight - inlineBox.logicalLeft());
    355             simplifiedVerticalAlignment.setEnabled(!lineHasContent);
     355            simplifiedAlignVerticallyIfApplicable(inlineBox, inlineBoxGeometry);
    356356            continue;
    357357        }
    … …  
    639639    if (inlineLevelBox.isLineBreakBox()) {
    640640        // 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();
    644646    }
    645647    return false;
    … …  
    648650void LineBoxBuilder::SimplifiedVerticalAlignment::align(LineBox::InlineLevelBox& inlineLevelBox)
    649651{
    650     if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox()) {
     652    if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox() || inlineLevelBox.isInlineBox()) {
    651653        // Only baseline alignment for now.
    652654        inlineLevelBox.setLogicalTop(m_rootInlineBox.baseline() - inlineLevelBox.baseline());
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h

    r273723 r273815  
    7373        struct LayoutBounds {
    7474            InlineLayoutUnit height() const { return ascent + descent; }
     75            bool operator==(const LayoutBounds& other) const { return ascent == other.ascent && descent == other.descent; }
    7576
    7677            InlineLayoutUnit ascent { 0 };
Note: See TracChangeset for help on using the changeset viewer.