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

Changeset 285784 in webkit


Ignore:
Timestamp:
Nov 13, 2021, 3:28:17 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Inline box end's padding/border/margin should be taken into account when computing horizontal position for bidi content
https://bugs.webkit.org/show_bug.cgi?id=233083

Reviewed by Antti Koivisto.

Let's decouple the "display box rect" and the "content right in visual order" computation.
There are runs (e.g. inline box end) that don't need to call displayBoxRect() but they
still affect the "content right in visual order" (<span style="border-right: 10px solid green">).

  • layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:

(WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent): add the additional lineRun.isInlineBoxEnd() case.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285783 r285784  
     12021-11-13  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Inline box end's padding/border/margin should be taken into account when computing horizontal position for bidi content
     4        https://bugs.webkit.org/show_bug.cgi?id=233083
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Let's decouple the "display box rect" and the "content right in visual order" computation.
     9        There are runs (e.g. inline box end) that don't need to call displayBoxRect() but they
     10        still affect the "content right in visual order" (<span style="border-right: 10px solid green">).
     11
     12        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
     13        (WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent): add the additional lineRun.isInlineBoxEnd() case.
     14
    1152021-11-13  Alan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp

    r285716 r285784  
    104104            else {
    105105                auto& boxGeometry = formattingState.boxGeometry(layoutBox);
    106                 marginStart = boxGeometry.marginStart();
    107                 if (lineRun.isBox())
     106                if (lineRun.isBox()) {
     107                    marginStart = boxGeometry.marginStart();
    108108                    logicalRect = lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry);
    109                 else if (lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart())
     109                } else if (lineRun.isInlineBoxStart()) {
     110                    marginStart = boxGeometry.marginStart();
     111                    logicalRect = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
     112                } else if (lineRun.isLineSpanningInlineBoxStart())
    110113                    logicalRect = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
    111114                else
     
    124127            auto contentLeft = contentRightInVisualOrder + distanceFromLogicalPreviousRun + marginStart.value_or(0);
    125128            visualOrderRect.setLeft(contentLeft);
    126             // The inline box right edge includes its content as well as the inline box end (padding-right etc).
    127             // What we need here is the inline box start run's width.
    128             // Note that content width does not refer to content _box_ here (it does include padding and border for inline level boxes).
    129             auto contentWidth = lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart() ? lineRun.logicalWidth() - *marginStart : logicalRect.width();
    130             contentRightInVisualOrder = visualOrderRect.left() + contentWidth;
    131129            return visualOrderRect;
    132130        };
     
    134132        if (lineRun.isText()) {
    135133            auto textRunRect = displayBoxRect();
     134            contentRightInVisualOrder = textRunRect.right();
     135
    136136            auto inkOverflow = [&] {
    137137                auto initialContaingBlockSize = RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
     
    191191            ASSERT(layoutBox.isAtomicInlineLevelBox());
    192192            auto borderBoxRect = displayBoxRect();
     193            contentRightInVisualOrder = borderBoxRect.right();
    193194            // FIXME: Add ink overflow support for atomic inline level boxes (e.g. box shadow).
    194195            boxes.append({ lineIndex, InlineDisplay::Box::Type::AtomicInlineLevelBox, layoutBox, lineRun.bidiLevel(), borderBoxRect, borderBoxRect, lineRun.expansion(), { } });
     
    211212        }
    212213        if (lineRun.isInlineBoxStart()) {
     214            auto& boxGeometry = formattingState.boxGeometry(layoutBox);
    213215            // This inline box showed up first on this line.
    214216            auto inlineBoxBorderBox = displayBoxRect();
     217            contentRightInVisualOrder += lineRun.logicalWidth();
    215218            if (lineBox.hasContent()) {
    216219                // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
     
    223226            }
    224227
    225             auto& boxGeometry = formattingState.boxGeometry(layoutBox);
    226228            auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
    227229            auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };
     
    244246            auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
    245247            auto inlineBoxBorderBox = displayBoxRect();
     248            // The content right edge should not include the entire inline box here (including its content and right edge).
     249            contentRightInVisualOrder += lineRun.logicalWidth();
    246250            ASSERT(!inlineBox.isFirstBox());
    247251            boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
     
    259263            continue;
    260264        }
    261         ASSERT(lineRun.isInlineBoxEnd() || lineRun.isWordBreakOpportunity());
     265        if (lineRun.isInlineBoxEnd()) {
     266            contentRightInVisualOrder += lineRun.logicalWidth();
     267            continue;
     268        }
     269        ASSERT(lineRun.isWordBreakOpportunity());
    262270    }
    263271}
Note: See TracChangeset for help on using the changeset viewer.