Title: [286820] trunk/Source/WebCore
Revision
286820
Author
[email protected]
Date
2021-12-09 17:02:59 -0800 (Thu, 09 Dec 2021)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286819 => 286820)


--- trunk/Source/WebCore/ChangeLog	2021-12-10 00:58:22 UTC (rev 286819)
+++ trunk/Source/WebCore/ChangeLog	2021-12-10 01:02:59 UTC (rev 286820)
@@ -1,3 +1,23 @@
+2021-12-09  Alan Bujtas  <[email protected]>
+
+        [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):
+
 2021-12-09  Alex Christensen  <[email protected]>
 
         Prepare for transition to C++20

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (286819 => 286820)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-10 00:58:22 UTC (rev 286819)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-10 01:02:59 UTC (rev 286820)
@@ -288,9 +288,11 @@
             // Start of the range is always where we left off (bidi ranges do not have gaps).
             for (; inlineItemIndex < inlineItemOffsets.size(); ++inlineItemIndex) {
                 auto offset = inlineItemOffsets[inlineItemIndex];
+                auto& inlineItem = inlineItems[inlineItemIndex];
                 if (!offset) {
                     // This is an opaque item. Let's post-process it.
                     hasSeenOpaqueItem = true;
+                    inlineItem.setBidiLevel(bidiLevelForRange);
                     continue;
                 }
                 if (*offset >= bidiEnd) {
@@ -297,7 +299,6 @@
                     // This inline item is outside of the bidi range.
                     break;
                 }
-                auto& inlineItem = inlineItems[inlineItemIndex];
                 inlineItem.setBidiLevel(bidiLevelForRange);
                 if (!inlineItem.isText())
                     continue;
@@ -324,11 +325,9 @@
         enum class InlineBoxHasContent : bool { No, Yes };
         Vector<InlineBoxHasContent> inlineBoxContentFlagStack;
         inlineBoxContentFlagStack.reserveInitialCapacity(inlineItems.size());
-        auto lastBidiLevel = rootBidiLevel;
         for (auto index = inlineItems.size(); index--;) {
             auto& inlineItem = inlineItems[index];
             if (inlineItemOffsets[index]) {
-                lastBidiLevel = inlineItem.bidiLevel();
                 inlineBoxContentFlagStack.fill(InlineBoxHasContent::Yes);
                 continue;
             }
@@ -335,7 +334,8 @@
             if (inlineItem.isInlineBoxStart()) {
                 ASSERT(!inlineBoxContentFlagStack.isEmpty());
                 // Inline box start (e.g <span>) uses its content bidi level (next inline item).
-                inlineItems[index].setBidiLevel(inlineBoxContentFlagStack.takeLast() == InlineBoxHasContent::Yes ? InlineItem::opaqueBidiLevel : lastBidiLevel);
+                if (inlineBoxContentFlagStack.takeLast() == InlineBoxHasContent::Yes)
+                    inlineItems[index].setBidiLevel(InlineItem::opaqueBidiLevel);
                 continue;
             }
             if (inlineItem.isInlineBoxEnd()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to