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

Changeset 285716 in webkit


Ignore:
Timestamp:
Nov 12, 2021, 6:40:42 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Add inline box margin-start support for visual ordering (bidi)
https://bugs.webkit.org/show_bug.cgi?id=233022

Reviewed by Antti Koivisto.

Line run geometry is margin box based (only applicable for inline level boxes), while
the displayRect() returns border box based geometry (again, only relevant for inline level boxes).
When computing the border box based left position using the distanceFromLogicalPreviousRun (line run based)
we have to offset it with the margin value.

  • layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:

(WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285715 r285716  
     12021-11-12  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Add inline box margin-start support for visual ordering (bidi)
     4        https://bugs.webkit.org/show_bug.cgi?id=233022
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Line run geometry is margin box based (only applicable for inline level boxes), while
     9        the displayRect() returns border box based geometry (again, only relevant for inline level boxes).
     10        When computing the border box based left position using the distanceFromLogicalPreviousRun (line run based)
     11        we have to offset it with the margin value.
     12
     13        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
     14        (WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):
     15
    1162021-11-12  Adrian Perez de Castro  <aperez@igalia.com>
    217
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp

    r285628 r285716  
    9696        auto displayBoxRect = [&] {
    9797            auto logicalRect = InlineRect { };
     98            auto marginStart = std::optional<LayoutUnit> { };
    9899
    99100            if (lineRun.isText() || lineRun.isSoftLineBreak())
     
    103104            else {
    104105                auto& boxGeometry = formattingState.boxGeometry(layoutBox);
     106                marginStart = boxGeometry.marginStart();
    105107                if (lineRun.isBox())
    106108                    logicalRect = lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry);
     
    120122            auto distanceFromLogicalPreviousRun = logicalPreviousRun ? lineRun.logicalLeft() - logicalPreviousRun->logicalRight() : lineRun.logicalLeft();
    121123            auto visualOrderRect = logicalRect;
    122             auto contentLeft = contentRightInVisualOrder + distanceFromLogicalPreviousRun;
     124            auto contentLeft = contentRightInVisualOrder + distanceFromLogicalPreviousRun + marginStart.value_or(0);
    123125            visualOrderRect.setLeft(contentLeft);
    124126            // The inline box right edge includes its content as well as the inline box end (padding-right etc).
    125127            // What we need here is the inline box start run's width.
    126             contentRightInVisualOrder = lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart()
    127                 ? visualOrderRect.left() + lineRun.logicalWidth()
    128                 : visualOrderRect.right();
     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;
    129131            return visualOrderRect;
    130132        };
Note: See TracChangeset for help on using the changeset viewer.