Skip to content

Commit

Permalink
[LFC][IFC] Introduce LineBuilder::rootStyle
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246383

Reviewed by Antti Koivisto.

* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::inlineBaseDirectionForLineContent):
(WebCore::Layout::LineBuilder::rootStyle const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h:

Canonical link: https://commits.webkit.org/255437@main
  • Loading branch information
alanbaradlay committed Oct 12, 2022
1 parent 219df29 commit 5d60a7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -533,7 +533,7 @@ LineBuilder::CommittedContent LineBuilder::placeInlineContent(const InlineItemRa
LineBuilder::InlineItemRange LineBuilder::close(const InlineItemRange& needsLayoutRange, const CommittedContent& committedContent)
{
ASSERT(committedContent.itemCount || !m_placedFloats.isEmpty() || m_contentIsConstrainedByFloat);
auto& rootStyle = root().style();
auto& rootStyle = this->rootStyle();
auto numberOfCommittedItems = committedContent.itemCount;
auto trailingInlineItemIndex = needsLayoutRange.start + numberOfCommittedItems - 1;
auto lineRange = InlineItemRange { needsLayoutRange.start, trailingInlineItemIndex + 1 };
Expand Down Expand Up @@ -588,7 +588,7 @@ LineBuilder::InlineItemRange LineBuilder::close(const InlineItemRange& needsLayo
return !rootStyle.isOverflowVisible() && rootStyle.textOverflow() == TextOverflow::Ellipsis;
};
if (needsTextOverflowAdjustment()) {
auto ellipsisWidth = isFirstLine() ? root().firstLineStyle().fontCascade().width(TextUtil::ellipsisTextRun()) : rootStyle.fontCascade().width(TextUtil::ellipsisTextRun());
auto ellipsisWidth = rootStyle.fontCascade().width(TextUtil::ellipsisTextRun());
auto logicalRightForContentWithoutEllipsis = std::max(0.f, horizontalAvailableSpace - ellipsisWidth);
m_line.truncate(logicalRightForContentWithoutEllipsis);
}
Expand Down Expand Up @@ -1175,10 +1175,9 @@ bool LineBuilder::isLastLineWithInlineContent(const InlineItemRange& lineRange,
TextDirection LineBuilder::inlineBaseDirectionForLineContent()
{
ASSERT(!m_line.runs().isEmpty());
auto& rootStyle = isFirstLine() ? root().firstLineStyle() : root().style();
auto shouldUseBlockDirection = rootStyle.unicodeBidi() != UnicodeBidi::Plaintext;
auto shouldUseBlockDirection = rootStyle().unicodeBidi() != UnicodeBidi::Plaintext;
if (shouldUseBlockDirection)
return rootStyle.direction();
return rootStyle().direction();
// A previous line ending with a line break (<br> or preserved \n) introduces a new unicode paragraph with its own direction.
if (m_previousLine && !m_previousLine->endsWithLineBreak)
return m_previousLine->inlineBaseDirection;
Expand All @@ -1195,6 +1194,11 @@ const LayoutState& LineBuilder::layoutState() const
return formattingContext().layoutState();
}

const RenderStyle& LineBuilder::rootStyle() const
{
return isFirstLine() ? root().firstLineStyle() : root().style();
}

}
}

Expand Up @@ -146,6 +146,7 @@ class LineBuilder {
const FloatingState* floatingState() const { return m_floatingState; }
const ElementBox& root() const;
const LayoutState& layoutState() const;
const RenderStyle& rootStyle() const;

private:
std::optional<PreviousLine> m_previousLine { };
Expand Down

0 comments on commit 5d60a7d

Please sign in to comment.