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

Changeset 285780 in webkit


Ignore:
Timestamp:
Nov 13, 2021, 1:59:47 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Inline box end (opaque to bidi) should get the bidi level from its adjacent content
https://bugs.webkit.org/show_bug.cgi?id=233082

Reviewed by Antti Koivisto.

While the inline box start item (<span>) gets the bidi level from the next (adjacent) content, inline box end (</span>)
should get it from the previous content (these are opaque inline items).

e.g <span>bidi content</span>
both the inline box start and the inline box end items get their bidi level from the "bidi content" inline text item.

  • layout/formattingContexts/inline/InlineItemsBuilder.cpp:

(WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285771 r285780  
     12021-11-13  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Inline box end (opaque to bidi) should get the bidi level from its adjacent content
     4        https://bugs.webkit.org/show_bug.cgi?id=233082
     5
     6        Reviewed by Antti Koivisto.
     7
     8        While the inline box start item (<span>) gets the bidi level from the next (adjacent) content, inline box end (</span>)
     9        should get it from the previous content (these are opaque inline items).
     10
     11          e.g <span>bidi content</span> 
     12          both the inline box start and the inline box end items get their bidi level from the "bidi content" inline text item.
     13
     14        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
     15        (WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels):
     16
    1172021-11-12  Timothy Hatcher  <timothy@apple.com>
    218
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp

    r285626 r285780  
    325325        auto lastBidiLevel = rootBidiLevel;
    326326        for (auto index = inlineItems.size(); index--;) {
    327             if (!inlineItemOffsets[index])
     327            if (inlineItemOffsets[index]) {
     328                lastBidiLevel = inlineItems[index].bidiLevel();
     329                continue;
     330            }
     331            if (inlineItems[index].isInlineBoxStart()) {
     332                // Inline box start (e.g <span>) uses its content bidi level (next inline item).
    328333                inlineItems[index].setBidiLevel(lastBidiLevel);
    329             else
    330                 lastBidiLevel = inlineItems[index].bidiLevel();
     334                continue;
     335            }
     336            if (inlineItems[index].isInlineBoxEnd()) {
     337                // Inline box end (e.g. </span>) also uses the content bidi level, but in this case it's the previous content.
     338                auto previousBidiLevel = [&]() -> std::optional<UBiDiLevel> {
     339                    for (auto i = index; i--;) {
     340                        if (inlineItemOffsets[i])
     341                            return inlineItems[i].bidiLevel();
     342                    }
     343                    return { };
     344                }();
     345                inlineItems[index].setBidiLevel(previousBidiLevel.value_or(rootBidiLevel));
     346                continue;
     347            }
     348            ASSERT_NOT_REACHED();
    331349        }
    332350    };
Note: See TracChangeset for help on using the changeset viewer.