Skip to content

Commit

Permalink
[IFC] Merge InlineContentBuilder::computeIsFirstIsLastBoxForInlineCon…
Browse files Browse the repository at this point in the history
…tent and updateIfTextRenderersNeedVisualReordering

https://bugs.webkit.org/show_bug.cgi?id=261352

Reviewed by Antti Koivisto.

Let's not iterate through the same set of boxes twice.

* Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentBuilder.cpp:
(WebCore::LayoutIntegration::InlineContentBuilder::build const):
(WebCore::LayoutIntegration::InlineContentBuilder::computeIsFirstIsLastBoxAndBidiReorderingForInlineContent const):
(WebCore::LayoutIntegration::InlineContentBuilder::computeIsFirstIsLastBoxForInlineContent const): Deleted.
(WebCore::LayoutIntegration::InlineContentBuilder::updateIfTextRenderersNeedVisualReordering const): Deleted.
* Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentBuilder.h:

Canonical link: https://commits.webkit.org/267832@main
  • Loading branch information
alanbaradlay committed Sep 9, 2023
1 parent 0e602ea commit e019083
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ FloatRect InlineContentBuilder::build(Layout::InlineLayoutResult&& layoutResult,

inlineContent.releaseCaches();

updateIfTextRenderersNeedVisualReordering(layoutResult.displayContent.boxes);
computeIsFirstIsLastBoxForInlineContent(layoutResult.displayContent.boxes);
computeIsFirstIsLastBoxAndBidiReorderingForInlineContent(layoutResult.displayContent.boxes);

switch (layoutResult.range) {
case Layout::InlineLayoutResult::Range::Full:
Expand Down Expand Up @@ -259,7 +258,7 @@ void InlineContentBuilder::adjustDisplayLines(InlineContent& inlineContent, size
}
}

void InlineContentBuilder::computeIsFirstIsLastBoxForInlineContent(InlineDisplay::Boxes& boxes) const
void InlineContentBuilder::computeIsFirstIsLastBoxAndBidiReorderingForInlineContent(InlineDisplay::Boxes& boxes) const
{
if (boxes.isEmpty()) {
// Line clamp may produce a completely empty IFC.
Expand All @@ -280,6 +279,9 @@ void InlineContentBuilder::computeIsFirstIsLastBoxForInlineContent(InlineDisplay
continue;
}
auto& layoutBox = displayBox.layoutBox();
if (is<Layout::InlineTextBox>(layoutBox) && displayBox.bidiLevel() != UBIDI_DEFAULT_LTR)
downcast<RenderText>(m_boxTree.rendererForLayoutBox(layoutBox)).setNeedsVisualReordering();

if (lastDisplayBoxForLayoutBoxIndexes.set(&layoutBox, index).isNewEntry)
displayBox.setIsFirstForLayoutBox(true);
}
Expand All @@ -289,18 +291,6 @@ void InlineContentBuilder::computeIsFirstIsLastBoxForInlineContent(InlineDisplay
boxes[lastRootInlineBoxIndex].setIsLastForLayoutBox(true);
}

void InlineContentBuilder::updateIfTextRenderersNeedVisualReordering(InlineDisplay::Boxes& boxes) const
{
// FIXME: We may want to have a global, "is this a bidi paragraph" flag to avoid this loop for non-rtl, non-bidi content.
for (auto& displayBox : boxes) {
auto& layoutBox = displayBox.layoutBox();
if (!is<Layout::InlineTextBox>(layoutBox))
continue;
if (displayBox.bidiLevel() != UBIDI_DEFAULT_LTR)
downcast<RenderText>(m_boxTree.rendererForLayoutBox(layoutBox)).setNeedsVisualReordering();
}
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class InlineContentBuilder {

private:
void adjustDisplayLines(InlineContent&, size_t startIndex) const;
void computeIsFirstIsLastBoxForInlineContent(InlineDisplay::Boxes&) const;
void updateIfTextRenderersNeedVisualReordering(InlineDisplay::Boxes&) const;
void computeIsFirstIsLastBoxAndBidiReorderingForInlineContent(InlineDisplay::Boxes&) const;

const RenderBlockFlow& m_blockFlow;
BoxTree& m_boxTree;
Expand Down

0 comments on commit e019083

Please sign in to comment.