Changeset 287447 in webkit


Ignore:
Timestamp:
Dec 26, 2021, 11:24:52 AM (4 years ago)
Author:
Alan Bujtas
Message:

[IFC][Integration] Update text renderer's needsVisualReordering bit
https://bugs.webkit.org/show_bug.cgi?id=234688

Reviewed by Antti Koivisto.

This is similar to legacy line layout where the RenderText's needsVisualReordering is
updated as the (bidi) text box is being placed on the line.
Here we update this bit right after the line layout, when we finished constructing the display boxes.

  • layout/formattingContexts/inline/InlineItemsBuilder.cpp:

(WebCore::Layout::InlineItemsBuilder::handleTextContent):

  • layout/integration/LayoutIntegrationBoxTree.cpp:

(WebCore::LayoutIntegration::BoxTree::buildTree):

  • layout/integration/LayoutIntegrationInlineContentBuilder.cpp:

(WebCore::LayoutIntegration::InlineContentBuilder::InlineContentBuilder):
(WebCore::LayoutIntegration::InlineContentBuilder::build const):

  • layout/integration/LayoutIntegrationInlineContentBuilder.h:
  • layout/layouttree/LayoutInlineTextBox.cpp:

(WebCore::Layout::InlineTextBox::InlineTextBox):
(WebCore::Layout::m_canUseSimplifiedContentMeasuring):
(WebCore::Layout::m_containsBidiText): Deleted.

  • layout/layouttree/LayoutInlineTextBox.h:

(WebCore::Layout::InlineTextBox::canUseSimplifiedContentMeasuring const):
(WebCore::Layout::InlineTextBox::containsBidiText const): Deleted. No need to cache this value on the layout box
InlineTextItems more or less have the same lifecycle as their associated layout boxes.

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::TreeBuilder::createTextBox):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287446 r287447  
     12021-12-26  Alan Bujtas  <zalan@apple.com>
     2
     3        [IFC][Integration] Update text renderer's needsVisualReordering bit
     4        https://bugs.webkit.org/show_bug.cgi?id=234688
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is similar to legacy line layout where the RenderText's needsVisualReordering is
     9        updated as the (bidi) text box is being placed on the line.
     10        Here we update this bit right after the line layout, when we finished constructing the display boxes.
     11
     12        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
     13        (WebCore::Layout::InlineItemsBuilder::handleTextContent):
     14        * layout/integration/LayoutIntegrationBoxTree.cpp:
     15        (WebCore::LayoutIntegration::BoxTree::buildTree):
     16        * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
     17        (WebCore::LayoutIntegration::InlineContentBuilder::InlineContentBuilder):
     18        (WebCore::LayoutIntegration::InlineContentBuilder::build const):
     19        * layout/integration/LayoutIntegrationInlineContentBuilder.h:
     20        * layout/layouttree/LayoutInlineTextBox.cpp:
     21        (WebCore::Layout::InlineTextBox::InlineTextBox):
     22        (WebCore::Layout::m_canUseSimplifiedContentMeasuring):
     23        (WebCore::Layout::m_containsBidiText): Deleted.
     24        * layout/layouttree/LayoutInlineTextBox.h:
     25        (WebCore::Layout::InlineTextBox::canUseSimplifiedContentMeasuring const):
     26        (WebCore::Layout::InlineTextBox::containsBidiText const): Deleted. No need to cache this value on the layout box
     27        InlineTextItems more or less have the same lifecycle as their associated layout boxes.
     28        * layout/layouttree/LayoutTreeBuilder.cpp:
     29        (WebCore::Layout::TreeBuilder::createTextBox):
     30
    1312021-12-26  Tim Nguyen  <ntim@apple.com>
    232
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp

    r287395 r287447  
    453453        return inlineItems.append(InlineTextItem::createEmptyItem(inlineTextBox));
    454454
    455     m_needsVisualReordering = m_needsVisualReordering || inlineTextBox.containsBidiText();
     455    m_needsVisualReordering = m_needsVisualReordering || TextUtil::containsStrongDirectionalityText(text);
    456456    auto& style = inlineTextBox.style();
    457457    auto shouldPreserveSpacesAndTabs = TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp

    r287444 r287447  
    9898            auto style = RenderStyle::createAnonymousStyleWithDisplay(textRenderer.style(), DisplayType::Inline);
    9999            auto text = style.textSecurity() == TextSecurity::None ? textRenderer.text() : RenderBlock::updateSecurityDiscCharacters(style, textRenderer.text());
    100             auto containsBidiText = Layout::TextUtil::containsStrongDirectionalityText(text);
    101             if (containsBidiText)
    102                 textRenderer.setNeedsVisualReordering();
    103100            auto useSimplifiedTextMeasuring = textRenderer.canUseSimplifiedTextMeasuring() && (!firstLineStyle || firstLineStyle->fontCascade() == style.fontCascade());
    104             return makeUnique<Layout::InlineTextBox>(text, useSimplifiedTextMeasuring, containsBidiText, WTFMove(style), WTFMove(firstLineStyle));
     101            return makeUnique<Layout::InlineTextBox>(text, useSimplifiedTextMeasuring, WTFMove(style), WTFMove(firstLineStyle));
    105102        }
    106103
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp

    r287393 r287447  
    5858}
    5959
    60 InlineContentBuilder::InlineContentBuilder(const RenderBlockFlow& blockFlow, const BoxTree& boxTree)
     60InlineContentBuilder::InlineContentBuilder(const RenderBlockFlow& blockFlow, BoxTree& boxTree)
    6161    : m_blockFlow(blockFlow)
    6262    , m_boxTree(boxTree)
     
    6868    // FIXME: This might need a different approach with partial layout where the layout code needs to know about the boxes.
    6969    inlineContent.boxes = WTFMove(inlineFormattingState.boxes());
     70
     71    auto updateIfTextRenderersNeedVisualReordering = [&] {
     72        // FIXME: We may want to have a global, "is this a bidi paragraph" flag to avoid this loop for non-rtl, non-bidi content.
     73        for (auto& displayBox : inlineContent.boxes) {
     74            auto& layoutBox = displayBox.layoutBox();
     75            if (!is<Layout::InlineTextBox>(layoutBox))
     76                continue;
     77            if (displayBox.bidiLevel() != UBIDI_DEFAULT_LTR)
     78                downcast<RenderText>(m_boxTree.rendererForLayoutBox(layoutBox)).setNeedsVisualReordering();
     79        }
     80    };
     81    updateIfTextRenderersNeedVisualReordering();
    7082    createDisplayLines(inlineFormattingState, inlineContent);
    7183}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h

    r282319 r287447  
    4242class InlineContentBuilder {
    4343public:
    44     InlineContentBuilder(const RenderBlockFlow&, const BoxTree&);
     44    InlineContentBuilder(const RenderBlockFlow&, BoxTree&);
    4545
    4646    void build(Layout::InlineFormattingState&, InlineContent&) const;
     
    5050
    5151    const RenderBlockFlow& m_blockFlow;
    52     const BoxTree& m_boxTree;
     52    BoxTree& m_boxTree;
    5353};
    5454
  • trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp

    r285807 r287447  
    3737WTF_MAKE_ISO_ALLOCATED_IMPL(InlineTextBox);
    3838
    39 InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, bool containsBidiText, RenderStyle&& style, std::unique_ptr<RenderStyle>&& firstLineStyle)
     39InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, RenderStyle&& style, std::unique_ptr<RenderStyle>&& firstLineStyle)
    4040    : Box({ }, WTFMove(style), WTFMove(firstLineStyle), Box::InlineTextBoxFlag)
    4141    , m_content(content)
    4242    , m_canUseSimplifiedContentMeasuring(canUseSimplifiedContentMeasuring)
    43     , m_containsBidiText(containsBidiText)
    4443{
    4544    setIsAnonymous();
  • trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h

    r285807 r287447  
    3838    WTF_MAKE_ISO_ALLOCATED(InlineTextBox);
    3939public:
    40     InlineTextBox(String, bool canUseSimplifiedContentMeasuring, bool containsBidiText, RenderStyle&&, std::unique_ptr<RenderStyle>&& firstLineStyle = nullptr);
     40    InlineTextBox(String, bool canUseSimplifiedContentMeasuring, RenderStyle&&, std::unique_ptr<RenderStyle>&& firstLineStyle = nullptr);
    4141    virtual ~InlineTextBox() = default;
    4242
     
    4444    // FIXME: This should not be a box's property.
    4545    bool canUseSimplifiedContentMeasuring() const { return m_canUseSimplifiedContentMeasuring; }
    46     bool containsBidiText() const { return m_containsBidiText; }
    4746
    4847private:
    4948    String m_content;
    5049    bool m_canUseSimplifiedContentMeasuring { false };
    51     bool m_containsBidiText { false };
    5250};
    5351
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r287444 r287447  
    135135std::unique_ptr<Box> TreeBuilder::createTextBox(String text, bool canUseSimplifiedTextMeasuring, RenderStyle&& style)
    136136{
    137     return makeUnique<InlineTextBox>(text, canUseSimplifiedTextMeasuring, TextUtil::containsStrongDirectionalityText(text), WTFMove(style));
     137    return makeUnique<InlineTextBox>(text, canUseSimplifiedTextMeasuring, WTFMove(style));
    138138}
    139139
Note: See TracChangeset for help on using the changeset viewer.