Title: [285783] trunk/Source/WebCore
Revision
285783
Author
za...@apple.com
Date
2021-11-13 15:21:41 -0800 (Sat, 13 Nov 2021)

Log Message

[LFC][Integration] Add support for optional bidi character coverage checking
https://bugs.webkit.org/show_bug.cgi?id=233049

Reviewed by Antti Koivisto.

This is in preparation for enabling bidi for IFC.

* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::canUseForFontAndText):
(WebCore::LayoutIntegration::canUseForRenderInlineChild):
(WebCore::LayoutIntegration::canUseForLineLayoutWithReason):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285782 => 285783)


--- trunk/Source/WebCore/ChangeLog	2021-11-13 23:04:43 UTC (rev 285782)
+++ trunk/Source/WebCore/ChangeLog	2021-11-13 23:21:41 UTC (rev 285783)
@@ -1,5 +1,20 @@
 2021-11-13  Alan Bujtas  <za...@apple.com>
 
+        [LFC][Integration] Add support for optional bidi character coverage checking
+        https://bugs.webkit.org/show_bug.cgi?id=233049
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for enabling bidi for IFC.
+
+        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::canUseForFontAndText):
+        (WebCore::LayoutIntegration::canUseForRenderInlineChild):
+        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
+
+2021-11-13  Alan Bujtas  <za...@apple.com>
+
         [LFC][Integration] Bring showRenderTree for IFC integration back
         https://bugs.webkit.org/show_bug.cgi?id=233000
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (285782 => 285783)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-11-13 23:04:43 UTC (rev 285782)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-11-13 23:21:41 UTC (rev 285783)
@@ -45,6 +45,9 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
+#define ALLOW_BIDI_CONTENT 0
+#define ALLOW_BIDI_CONTENT_WITH_INLINE_BOX 0
+
 #ifndef NDEBUG
 #define SET_REASON_AND_RETURN_IF_NEEDED(reason, reasons, includeReasons) { \
         reasons.add(AvoidanceReason::reason); \
@@ -388,7 +391,8 @@
     return { };
 }
 
-static OptionSet<AvoidanceReason> canUseForFontAndText(const RenderBoxModelObject& container, IncludeReasons includeReasons)
+enum class CheckForBidiCharacters { Yes, No };
+static OptionSet<AvoidanceReason> canUseForFontAndText(const RenderBoxModelObject& container, CheckForBidiCharacters checkForBidiCharacters, IncludeReasons includeReasons)
 {
     OptionSet<AvoidanceReason> reasons;
     // We assume that all lines have metrics based purely on the primary font.
@@ -418,9 +422,10 @@
                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasComplexFontCodePath, reasons, includeReasons);
         }
 
-        auto textReasons = canUseForText(textRenderer.stringView(), includeReasons);
-        if (textReasons)
-            ADD_REASONS_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
+        if (checkForBidiCharacters == CheckForBidiCharacters::Yes) {
+            if (auto textReasons = canUseForText(textRenderer.stringView(), includeReasons))
+                ADD_REASONS_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
+        }
     }
     return reasons;
 }
@@ -484,9 +489,14 @@
         SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsFloatingOrPositioned, reasons, includeReasons);
     if (renderInline.containingBlock()->style().lineBoxContain() != RenderStyle::initialLineBoxContain())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
-    auto fontAndTextReasons = canUseForFontAndText(renderInline, includeReasons);
+    auto checkForBidiCharacters = CheckForBidiCharacters::Yes;
+#if ALLOW_BIDI_CONTENT_WITH_INLINE_BOX
+    checkForBidiCharacters = CheckForBidiCharacters::No;
+#endif
+    auto fontAndTextReasons = canUseForFontAndText(renderInline, checkForBidiCharacters, includeReasons);
     if (fontAndTextReasons)
         ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
+
     auto styleReasons = canUseForStyle(style, includeReasons);
     if (styleReasons)
         ADD_REASONS_AND_RETURN_IF_NEEDED(styleReasons, reasons, includeReasons);
@@ -632,9 +642,11 @@
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineClamp, reasons, includeReasons);
     // This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
     // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
+    auto hasSeenInlineBox = false;
     for (auto walker = InlineWalker(flow); !walker.atEnd(); walker.advance()) {
         if (auto childReasons = canUseForChild(flow, *walker.current(), includeReasons))
             ADD_REASONS_AND_RETURN_IF_NEEDED(childReasons, reasons, includeReasons);
+        hasSeenInlineBox = hasSeenInlineBox || is<RenderInline>(*walker.current());
     }
     auto styleReasons = canUseForStyle(flow.style(), includeReasons);
     if (styleReasons)
@@ -649,7 +661,15 @@
                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasUnsupportedFloat, reasons, includeReasons);
         }
     }
-    auto fontAndTextReasons = canUseForFontAndText(flow, includeReasons);
+    auto checkForBidiCharacters = CheckForBidiCharacters::Yes;
+#if ALLOW_BIDI_CONTENT
+    if (!hasSeenInlineBox)
+        checkForBidiCharacters = CheckForBidiCharacters::No;
+#endif
+#if ALLOW_BIDI_CONTENT_WITH_INLINE_BOX
+    checkForBidiCharacters = CheckForBidiCharacters::No;
+#endif
+    auto fontAndTextReasons = canUseForFontAndText(flow, checkForBidiCharacters, includeReasons);
     if (fontAndTextReasons)
         ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
     return reasons;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to