Changeset 271347 in webkit


Ignore:
Timestamp:
Jan 9, 2021 4:31:53 AM (3 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Use the bottom margin edge as the baseline for inline-block when overflow is not visible
https://bugs.webkit.org/show_bug.cgi?id=220481

Reviewed by Antti Koivisto.

"The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes
or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge."
https://www.w3.org/TR/CSS22/visudet.html#leading

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271341 r271347  
     12021-01-09  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Use the bottom margin edge as the baseline for inline-block when overflow is not visible
     4        https://bugs.webkit.org/show_bug.cgi?id=220481
     5
     6        Reviewed by Antti Koivisto.
     7
     8        "The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes
     9        or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge."
     10        https://www.w3.org/TR/CSS22/visudet.html#leading
     11
     12        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     13        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
     14
    1152021-01-08  Peng Liu  <peng.liu6@apple.com>
    216
  • trunk/Source/WebCore/layout/LayoutState.cpp

    r267515 r271347  
    245245}
    246246
     247bool LayoutState::shouldNotSynthesizeInlineBlockBaseline() const
     248{
     249    return RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled();
     250}
     251
    247252}
    248253}
  • trunk/Source/WebCore/layout/LayoutState.h

    r267515 r271347  
    9494    void setIsIntegratedRootBoxFirstChild(bool);
    9595    bool shouldIgnoreTrailingLetterSpacing() const;
     96    bool shouldNotSynthesizeInlineBlockBaseline() const;
    9697
    9798private:
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r271116 r271347  
    272272            auto marginBoxHeight = inlineLevelBoxGeometry.marginBoxHeight();
    273273            auto ascent = InlineLayoutUnit { };
    274             if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
    275                 auto& formattingState = layoutState().establishedInlineFormattingState(downcast<ContainerBox>(layoutBox));
    276                 auto& lastLine = formattingState.lines().last();
    277                 auto inlineBlockBaseline = lastLine.lineBoxLogicalRect().top() + lastLine.baseline();
    278                 ascent = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
     274            if (layoutState().shouldNotSynthesizeInlineBlockBaseline()) {
     275                // Integration codepath constructs replaced boxes for inline-block content.
     276                ASSERT(layoutBox.isReplacedBox());
     277                ascent = *downcast<ReplacedBox>(layoutBox).baseline();
     278            } else if (layoutBox.isInlineBlockBox()) {
     279                // The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or
     280                // if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge.
     281                auto synthesizeBaseline = !layoutBox.establishesInlineFormattingContext() || !layoutBox.style().isOverflowVisible();
     282                if (synthesizeBaseline)
     283                    ascent = marginBoxHeight;
     284                else {
     285                    auto& formattingState = layoutState().establishedInlineFormattingState(downcast<ContainerBox>(layoutBox));
     286                    auto& lastLine = formattingState.lines().last();
     287                    auto inlineBlockBaseline = lastLine.lineBoxLogicalRect().top() + lastLine.baseline();
     288                    ascent = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
     289                }
    279290            } else if (layoutBox.isReplacedBox())
    280291                ascent = downcast<ReplacedBox>(layoutBox).baseline().valueOr(marginBoxHeight);
Note: See TracChangeset for help on using the changeset viewer.