Changeset 271359 in webkit


Ignore:
Timestamp:
Jan 11, 2021 6:56:06 AM (3 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] InlineBox::setHasContent should be called when the inline box actually has some content
https://bugs.webkit.org/show_bug.cgi?id=220245

Reviewed by Antti Koivisto.

Do not call setHasContent unless the inline box has actual content (excluding border and padding).
However the "will stretch the line" logic checks against borders and paddings so move that over to
Quirks::inlineLevelBoxAffectsLineBox.
This change makes Quirks::inlineLevelBoxAffectsLineBox the only client of LineBox::isConsideredEmpty.

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

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

  • layout/inlineformatting/InlineFormattingContextQuirks.cpp:

(WebCore::Layout::InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox const):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271358 r271359  
     12021-01-11  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] InlineBox::setHasContent should be called when the inline box actually has some content
     4        https://bugs.webkit.org/show_bug.cgi?id=220245
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Do not call setHasContent unless the inline box has actual content (excluding border and padding).
     9        However the "will stretch the line" logic checks against borders and paddings so move that over to
     10        Quirks::inlineLevelBoxAffectsLineBox.
     11        This change makes Quirks::inlineLevelBoxAffectsLineBox the only client of LineBox::isConsideredEmpty.
     12
     13        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     14        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
     15        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
     16        (WebCore::Layout::InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox const):
     17
    1182021-01-11  Kimmo Kinnunen  <kkinnunen@apple.com>
    219
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r271351 r271359  
    218218    auto createRootInlineBox = [&] {
    219219        auto rootInlineBox = LineBox::InlineLevelBox::createRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth());
    220 
    221         auto inlineBoxHasImaginaryStrut = layoutState().inNoQuirksMode();
    222         auto isInitiallyConsideredNonEmpty = !lineBox.isConsideredEmpty() && inlineBoxHasImaginaryStrut;
    223         if (isInitiallyConsideredNonEmpty)
    224             rootInlineBox->setHasContent();
    225220        setVerticalGeometryForInlineBox(*rootInlineBox);
    226221        simplifiedVerticalAlignment = { { } , rootInlineBox->layoutBounds().height(), rootInlineBox->layoutBounds().ascent - rootInlineBox->baseline() };
     
    327322            ASSERT(initialLogicalWidth >= 0);
    328323            auto inlineBox = LineBox::InlineLevelBox::createInlineBox(layoutBox, logicalLeft, initialLogicalWidth);
    329             auto& inlineBoxGeometry = formattingContext().geometryForBox(layoutBox);
    330             // Inline level boxes on empty lines are still considered empty (e.g. <span><div>pre and post blocks are empty</div></span>)
    331             auto inlineBoxHasImaginaryStrut = layoutState().inNoQuirksMode() && !lineBox.isConsideredEmpty();
    332             auto isConsideredNonEmpty = inlineBoxHasImaginaryStrut || inlineBoxGeometry.horizontalPadding().valueOr(0_lu) || inlineBoxGeometry.horizontalBorder();
    333             if (isConsideredNonEmpty)
    334                 inlineBox->setHasContent();
    335324            setVerticalGeometryForInlineBox(*inlineBox);
    336325            lineBox.addInlineLevelBox(WTFMove(inlineBox));
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp

    r271351 r271359  
    4343bool InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
    4444{
    45     if (inlineLevelBox.isInlineBox())
    46         return inlineLevelBox.hasContent();
     45    if (inlineLevelBox.isInlineBox()) {
     46        // Inline boxes (e.g. root inline box or <span>) affects line boxes either through the strut or actual content.
     47        if (inlineLevelBox.hasContent())
     48            return true;
     49        if (!inlineLevelBox.isRootInlineBox()) {
     50            auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
     51            if (boxGeometry.horizontalBorder() || boxGeometry.horizontalPadding().valueOr(0_lu)) {
     52                // Horizontal border and padding make the inline box stretch the line (e.g. <span style="padding: 10px;"></span>).
     53                return true;
     54            }
     55        }
     56        auto inlineBoxHasImaginaryStrut = layoutState().inNoQuirksMode();
     57        return inlineBoxHasImaginaryStrut && !lineBox.isConsideredEmpty();
     58    }
    4759    if (inlineLevelBox.isLineBreakBox()) {
    4860        // <br> in non-standard mode stretches the line box only when the line is empty.
Note: See TracChangeset for help on using the changeset viewer.