Title: [287132] trunk/Source/WebCore
Revision
287132
Author
[email protected]
Date
2021-12-16 07:00:03 -0800 (Thu, 16 Dec 2021)

Log Message

[LFC][IFC] Add support for mixed ltr/rtl content
https://bugs.webkit.org/show_bug.cgi?id=234381

Reviewed by Antti Koivisto.

Inline boxes can also introduce RTL direction to their content which may initiate visual reordering
(and thus requires bidi handling).
In this patch hasSeenBidiContent (redundant at this point) is replaced with needsVisualReordering.

* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::InlineItemsBuilder::InlineItemsBuilder):
(WebCore::Layout::InlineItemsBuilder::handleTextContent):
(WebCore::Layout::InlineItemsBuilder::handleInlineBoxStart):
(WebCore::Layout::InlineItemsBuilder::handleInlineBoxEnd):
* layout/formattingContexts/inline/InlineItemsBuilder.h:
(WebCore::Layout::InlineItemsBuilder::needsVisualReordering const):
(WebCore::Layout::InlineItemsBuilder::hasSeenBidiContent const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287131 => 287132)


--- trunk/Source/WebCore/ChangeLog	2021-12-16 14:52:10 UTC (rev 287131)
+++ trunk/Source/WebCore/ChangeLog	2021-12-16 15:00:03 UTC (rev 287132)
@@ -1,3 +1,23 @@
+2021-12-16  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add support for mixed ltr/rtl content
+        https://bugs.webkit.org/show_bug.cgi?id=234381
+
+        Reviewed by Antti Koivisto.
+
+        Inline boxes can also introduce RTL direction to their content which may initiate visual reordering
+        (and thus requires bidi handling).
+        In this patch hasSeenBidiContent (redundant at this point) is replaced with needsVisualReordering.
+
+        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+        (WebCore::Layout::InlineItemsBuilder::InlineItemsBuilder):
+        (WebCore::Layout::InlineItemsBuilder::handleTextContent):
+        (WebCore::Layout::InlineItemsBuilder::handleInlineBoxStart):
+        (WebCore::Layout::InlineItemsBuilder::handleInlineBoxEnd):
+        * layout/formattingContexts/inline/InlineItemsBuilder.h:
+        (WebCore::Layout::InlineItemsBuilder::needsVisualReordering const):
+        (WebCore::Layout::InlineItemsBuilder::hasSeenBidiContent const): Deleted.
+
 2021-12-16  Rob Buis  <[email protected]>
 
         Mark range boundary point containers

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-16 14:52:10 UTC (rev 287131)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-16 15:00:03 UTC (rev 287132)
@@ -79,6 +79,7 @@
 InlineItemsBuilder::InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
     : m_root(formattingContextRoot)
     , m_formattingState(formattingState)
+    , m_needsVisualReordering(!formattingContextRoot.style().isLeftToRightDirection())
 {
 }
 
@@ -414,9 +415,7 @@
     if (!contentLength)
         return inlineItems.append(InlineTextItem::createEmptyItem(inlineTextBox));
 
-    if (inlineTextBox.containsBidiText())
-        m_hasSeenBidiContent = true;
-
+    m_needsVisualReordering = m_needsVisualReordering || inlineTextBox.containsBidiText();
     auto& style = inlineTextBox.style();
     auto shouldPreserveSpacesAndTabs = TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
     auto shouldPreserveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
@@ -488,7 +487,7 @@
 {
     inlineItems.append({ inlineBox, InlineItem::Type::InlineBoxStart });
     auto& style = inlineBox.style();
-    m_hasSeenBidiContent = m_hasSeenBidiContent || (style.rtlOrdering() == Order::Logical && style.unicodeBidi() != EUnicodeBidi::UBNormal); 
+    m_needsVisualReordering = m_needsVisualReordering || !style.isLeftToRightDirection() || (style.rtlOrdering() == Order::Logical && style.unicodeBidi() != EUnicodeBidi::UBNormal);
 }
 
 void InlineItemsBuilder::handleInlineBoxEnd(const Box& inlineBox, InlineItems& inlineItems)
@@ -495,7 +494,7 @@
 {
     inlineItems.append({ inlineBox, InlineItem::Type::InlineBoxEnd });
     // Inline box end item itself can not trigger bidi content.
-    ASSERT(hasSeenBidiContent() || inlineBox.style().rtlOrdering() == Order::Visual || inlineBox.style().unicodeBidi() == EUnicodeBidi::UBNormal);
+    ASSERT(needsVisualReordering() || inlineBox.style().isLeftToRightDirection() || inlineBox.style().rtlOrdering() == Order::Visual || inlineBox.style().unicodeBidi() == EUnicodeBidi::UBNormal);
 }
 
 void InlineItemsBuilder::handleInlineLevelBox(const Box& layoutBox, InlineItems& inlineItems)

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (287131 => 287132)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h	2021-12-16 14:52:10 UTC (rev 287131)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h	2021-12-16 15:00:03 UTC (rev 287132)
@@ -50,8 +50,7 @@
     void handleInlineBoxEnd(const Box&, InlineItems&);
     void handleInlineLevelBox(const Box&, InlineItems&);
     
-    bool needsVisualReordering() const { return hasSeenBidiContent() || !root().style().isLeftToRightDirection(); }
-    bool hasSeenBidiContent() const { return m_hasSeenBidiContent; }
+    bool needsVisualReordering() const { return m_needsVisualReordering; }
 
     const ContainerBox& root() const { return m_root; }
 
@@ -58,7 +57,7 @@
     const ContainerBox& m_root;
     // FIXME: We should not need this here. This is only required by the out of flow boxes.
     InlineFormattingState& m_formattingState;
-    bool m_hasSeenBidiContent { false };
+    bool m_needsVisualReordering { false };
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to