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

Changeset 286807 in webkit


Ignore:
Timestamp:
Dec 9, 2021, 3:11:34 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Stop including inline box start/end inline items in the visual reordering unless they are completely empty
https://bugs.webkit.org/show_bug.cgi?id=234035

Reviewed by Antti Koivisto.

When the visual order == logical order, we use the inline box start/end markers to
construct/finalize the inline box type of display boxes.
e.g <span>content</span> when we see the "<span>" run, we construct the inline box type of display box
and later when we come across the "</span>" run, we finalize its geometry.
Now with visual reordering, those explicit markers may be out of order. In such cases (bidi in general) we
switch over to relying solely on the content type of runs to create/finalize the required inline box type of display boxes (see InlineDisplayContentBuilder::ensureDisplayBoxForContainer).

This implicit way of constructing the inline box type of display boxes allows us to include only the minimum set of inline
items for visual reordering:
<span><span><span>content</span></span></span>
should produce only one entry for visual reordering.
It is essential to minimize the "noise" to limit the potential confusion introduced by non-content bidi runs (with their guessed levels).

  • layout/formattingContexts/inline/InlineItemsBuilder.cpp:

(WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels): Reserve the guess bidi level for empty inline boxes only.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286803 r286807  
     12021-12-09  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Stop including inline box start/end inline items in the visual reordering unless they are completely empty
     4        https://bugs.webkit.org/show_bug.cgi?id=234035
     5
     6        Reviewed by Antti Koivisto.
     7
     8        When the visual order == logical order, we use the inline box start/end markers to
     9        construct/finalize the inline box type of display boxes.
     10        e.g <span>content</span> when we see the "<span>" run, we construct the inline box type of display box
     11        and later when we come across the "</span>" run, we finalize its geometry.
     12        Now with visual reordering, those explicit markers may be out of order. In such cases (bidi in general) we
     13        switch over to relying solely on the content type of runs to create/finalize the required inline box type of display boxes (see InlineDisplayContentBuilder::ensureDisplayBoxForContainer).
     14
     15        This implicit way of constructing the inline box type of display boxes allows us to include only the minimum set of inline
     16        items for visual reordering:
     17        <span><span><span>content</span></span></span>
     18        should produce only one entry for visual reordering.
     19        It is essential to minimize the "noise" to limit the potential confusion introduced by non-content bidi runs (with their guessed levels).
     20
     21        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
     22        (WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels): Reserve the guess bidi level for empty inline boxes only.
     23
    1242021-12-09  Brent Fulgham  <bfulgham@apple.com>
    225
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp

    r286801 r286807  
    322322            return;
    323323        // Opaque items (inline items with no paragraph content) get their bidi level values from their adjacent items.
     324        enum class InlineBoxHasContent : bool { No, Yes };
     325        Vector<InlineBoxHasContent> inlineBoxContentFlagStack;
     326        inlineBoxContentFlagStack.reserveInitialCapacity(inlineItems.size());
    324327        auto lastBidiLevel = rootBidiLevel;
    325328        for (auto index = inlineItems.size(); index--;) {
     329            auto& inlineItem = inlineItems[index];
    326330            if (inlineItemOffsets[index]) {
    327                 lastBidiLevel = inlineItems[index].bidiLevel();
     331                lastBidiLevel = inlineItem.bidiLevel();
     332                inlineBoxContentFlagStack.fill(InlineBoxHasContent::Yes);
    328333                continue;
    329334            }
    330             if (inlineItems[index].isInlineBoxStart()) {
     335            if (inlineItem.isInlineBoxStart()) {
     336                ASSERT(!inlineBoxContentFlagStack.isEmpty());
    331337                // Inline box start (e.g <span>) uses its content bidi level (next inline item).
    332                 inlineItems[index].setBidiLevel(lastBidiLevel);
     338                inlineItems[index].setBidiLevel(inlineBoxContentFlagStack.takeLast() == InlineBoxHasContent::Yes ? InlineItem::opaqueBidiLevel : lastBidiLevel);
    333339                continue;
    334340            }
    335             if (inlineItems[index].isInlineBoxEnd()) {
     341            if (inlineItem.isInlineBoxEnd()) {
     342                inlineBoxContentFlagStack.append(InlineBoxHasContent::No);
    336343                // Let's not confuse ubidi with non-content entries. Opaque runs are excluded from the visual list.
    337                 inlineItems[index].setBidiLevel(InlineItem::opaqueBidiLevel);
     344                inlineItem.setBidiLevel(InlineItem::opaqueBidiLevel);
     345                continue;
     346            }
     347            if (inlineItem.isWordBreakOpportunity()) {
     348                inlineItem.setBidiLevel(InlineItem::opaqueBidiLevel);
    338349                continue;
    339350            }
Note: See TracChangeset for help on using the changeset viewer.