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

Changeset 286820 in webkit


Ignore:
Timestamp:
Dec 9, 2021, 5:02:59 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Stop using the last-bidi value for opaque inline items
https://bugs.webkit.org/show_bug.cgi?id=234043

Reviewed by Antti Koivisto.

Now that we only need to guess the bidi level for empty inline boxes, let's stop applying the "keep tracking
the last bidi level from the end" logic. It may work for non-empty inline boxes (when the last bidi value
comes from an actual content run), but it is somewhat incorrect for empty inline boxes.

e.g. <span id=visually-second>&#8238;END OF CONTENT</span><span id=visually-first></span>

The "visually-first" inline box's "guessed" bidi level comes from the root direction (since it's the very list run)
making it LTR while the RTL override character (&#8238;) makes it RTL. It produces incorrect visual ordering for
these inline boxes.

  • layout/formattingContexts/inline/InlineItemsBuilder.cpp:

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

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286816 r286820  
     12021-12-09  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Stop using the last-bidi value for opaque inline items
     4        https://bugs.webkit.org/show_bug.cgi?id=234043
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Now that we only need to guess the bidi level for empty inline boxes, let's stop applying the "keep tracking
     9        the last bidi level from the end" logic. It may work for non-empty inline boxes (when the last bidi value
     10        comes from an actual content run), but it is somewhat incorrect for empty inline boxes.
     11
     12          e.g. <span id=visually-second>&#8238;END OF CONTENT</span><span id=visually-first></span>
     13
     14        The "visually-first" inline box's "guessed" bidi level comes from the root direction (since it's the very list run)
     15        making it LTR while the RTL override character (&#8238;) makes it RTL. It produces incorrect visual ordering for
     16        these inline boxes.
     17
     18        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
     19        (WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels):
     20
    1212021-12-09  Alex Christensen  <achristensen@webkit.org>
    222
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp

    r286807 r286820  
    289289            for (; inlineItemIndex < inlineItemOffsets.size(); ++inlineItemIndex) {
    290290                auto offset = inlineItemOffsets[inlineItemIndex];
     291                auto& inlineItem = inlineItems[inlineItemIndex];
    291292                if (!offset) {
    292293                    // This is an opaque item. Let's post-process it.
    293294                    hasSeenOpaqueItem = true;
     295                    inlineItem.setBidiLevel(bidiLevelForRange);
    294296                    continue;
    295297                }
     
    298300                    break;
    299301                }
    300                 auto& inlineItem = inlineItems[inlineItemIndex];
    301302                inlineItem.setBidiLevel(bidiLevelForRange);
    302303                if (!inlineItem.isText())
     
    325326        Vector<InlineBoxHasContent> inlineBoxContentFlagStack;
    326327        inlineBoxContentFlagStack.reserveInitialCapacity(inlineItems.size());
    327         auto lastBidiLevel = rootBidiLevel;
    328328        for (auto index = inlineItems.size(); index--;) {
    329329            auto& inlineItem = inlineItems[index];
    330330            if (inlineItemOffsets[index]) {
    331                 lastBidiLevel = inlineItem.bidiLevel();
    332331                inlineBoxContentFlagStack.fill(InlineBoxHasContent::Yes);
    333332                continue;
     
    336335                ASSERT(!inlineBoxContentFlagStack.isEmpty());
    337336                // Inline box start (e.g <span>) uses its content bidi level (next inline item).
    338                 inlineItems[index].setBidiLevel(inlineBoxContentFlagStack.takeLast() == InlineBoxHasContent::Yes ? InlineItem::opaqueBidiLevel : lastBidiLevel);
     337                if (inlineBoxContentFlagStack.takeLast() == InlineBoxHasContent::Yes)
     338                    inlineItems[index].setBidiLevel(InlineItem::opaqueBidiLevel);
    339339                continue;
    340340            }
Note: See TracChangeset for help on using the changeset viewer.