Changeset 285783 in webkit


Ignore:
Timestamp:
Nov 13, 2021, 3:21:41 PM (4 years ago)
Author:
Alan Bujtas
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285782 r285783  
     12021-11-13  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][Integration] Add support for optional bidi character coverage checking
     4        https://bugs.webkit.org/show_bug.cgi?id=233049
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for enabling bidi for IFC.
     9
     10        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
     11        * layout/integration/LayoutIntegrationCoverage.cpp:
     12        (WebCore::LayoutIntegration::canUseForFontAndText):
     13        (WebCore::LayoutIntegration::canUseForRenderInlineChild):
     14        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
     15
    1162021-11-13  Alan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp

    r284857 r285783  
    4646#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    4747
     48#define ALLOW_BIDI_CONTENT 0
     49#define ALLOW_BIDI_CONTENT_WITH_INLINE_BOX 0
     50
    4851#ifndef NDEBUG
    4952#define SET_REASON_AND_RETURN_IF_NEEDED(reason, reasons, includeReasons) { \
     
    389392}
    390393
    391 static OptionSet<AvoidanceReason> canUseForFontAndText(const RenderBoxModelObject& container, IncludeReasons includeReasons)
     394enum class CheckForBidiCharacters { Yes, No };
     395static OptionSet<AvoidanceReason> canUseForFontAndText(const RenderBoxModelObject& container, CheckForBidiCharacters checkForBidiCharacters, IncludeReasons includeReasons)
    392396{
    393397    OptionSet<AvoidanceReason> reasons;
     
    419423        }
    420424
    421         auto textReasons = canUseForText(textRenderer.stringView(), includeReasons);
    422         if (textReasons)
    423             ADD_REASONS_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     425        if (checkForBidiCharacters == CheckForBidiCharacters::Yes) {
     426            if (auto textReasons = canUseForText(textRenderer.stringView(), includeReasons))
     427                ADD_REASONS_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     428        }
    424429    }
    425430    return reasons;
     
    485490    if (renderInline.containingBlock()->style().lineBoxContain() != RenderStyle::initialLineBoxContain())
    486491        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
    487     auto fontAndTextReasons = canUseForFontAndText(renderInline, includeReasons);
     492    auto checkForBidiCharacters = CheckForBidiCharacters::Yes;
     493#if ALLOW_BIDI_CONTENT_WITH_INLINE_BOX
     494    checkForBidiCharacters = CheckForBidiCharacters::No;
     495#endif
     496    auto fontAndTextReasons = canUseForFontAndText(renderInline, checkForBidiCharacters, includeReasons);
    488497    if (fontAndTextReasons)
    489498        ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
     499
    490500    auto styleReasons = canUseForStyle(style, includeReasons);
    491501    if (styleReasons)
     
    633643    // This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
    634644    // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
     645    auto hasSeenInlineBox = false;
    635646    for (auto walker = InlineWalker(flow); !walker.atEnd(); walker.advance()) {
    636647        if (auto childReasons = canUseForChild(flow, *walker.current(), includeReasons))
    637648            ADD_REASONS_AND_RETURN_IF_NEEDED(childReasons, reasons, includeReasons);
     649        hasSeenInlineBox = hasSeenInlineBox || is<RenderInline>(*walker.current());
    638650    }
    639651    auto styleReasons = canUseForStyle(flow.style(), includeReasons);
     
    650662        }
    651663    }
    652     auto fontAndTextReasons = canUseForFontAndText(flow, includeReasons);
     664    auto checkForBidiCharacters = CheckForBidiCharacters::Yes;
     665#if ALLOW_BIDI_CONTENT
     666    if (!hasSeenInlineBox)
     667        checkForBidiCharacters = CheckForBidiCharacters::No;
     668#endif
     669#if ALLOW_BIDI_CONTENT_WITH_INLINE_BOX
     670    checkForBidiCharacters = CheckForBidiCharacters::No;
     671#endif
     672    auto fontAndTextReasons = canUseForFontAndText(flow, checkForBidiCharacters, includeReasons);
    653673    if (fontAndTextReasons)
    654674        ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
Note: See TracChangeset for help on using the changeset viewer.