Skip to content

Commit

Permalink
[IFC][Intrinsic width] Let's start using the dedicated BoxGeometryUpd…
Browse files Browse the repository at this point in the history
…ater::setGeometriesForIntrinsicWidth

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

Reviewed by Antti Koivisto.

This is in preparation for using IFC's intrinsic width computation for inline level elements.

* Source/WebCore/layout/integration/inline/LayoutIntegrationBoxGeometryUpdater.cpp:
(WebCore::LayoutIntegration::logicalBorder): Drive-by fix as borderLeft().width() != borderLeftWidth() when border is not visible.

(WebCore::LayoutIntegration::BoxGeometryUpdater::setGeometriesForLayout):
(WebCore::LayoutIntegration::BoxGeometryUpdater::setGeometriesForIntrinsicWidth):
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::computeIntrinsicWidthConstraints):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::tryComputePreferredWidthsUsingModernPath):

Canonical link: https://commits.webkit.org/276242@main
  • Loading branch information
alanbaradlay committed Mar 16, 2024
1 parent 9ac555f commit d574921
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ enum class IsPartOfFormattingContext : bool { No, Yes };
static inline Layout::BoxGeometry::Edges logicalBorder(const RenderBoxModelObject& renderer, bool isLeftToRightInlineDirection, BlockFlowDirection blockFlowDirection, UseComputedValues useComputedValues = UseComputedValues::No, IsPartOfFormattingContext isPartOfFormattingContext = IsPartOfFormattingContext::No, bool retainBorderStart = true, bool retainBorderEnd = true)
{
auto& style = renderer.style();
auto borderLeft = useComputedValues == UseComputedValues::No ? renderer.borderLeft() : LayoutUnit(style.borderLeft().width());
auto borderRight = useComputedValues == UseComputedValues::No ? renderer.borderRight() : LayoutUnit(style.borderRight().width());
auto borderTop = useComputedValues == UseComputedValues::No ? renderer.borderTop() : LayoutUnit(style.borderTop().width());
auto borderBottom = useComputedValues == UseComputedValues::No ? renderer.borderBottom() : LayoutUnit(style.borderBottom().width());
auto borderLeft = useComputedValues == UseComputedValues::No ? renderer.borderLeft() : LayoutUnit(style.borderLeftWidth());
auto borderRight = useComputedValues == UseComputedValues::No ? renderer.borderRight() : LayoutUnit(style.borderRightWidth());
auto borderTop = useComputedValues == UseComputedValues::No ? renderer.borderTop() : LayoutUnit(style.borderTopWidth());
auto borderBottom = useComputedValues == UseComputedValues::No ? renderer.borderBottom() : LayoutUnit(style.borderBottomWidth());

if (blockFlowDirection == BlockFlowDirection::TopToBottom || blockFlowDirection == BlockFlowDirection::BottomToTop) {
if (isLeftToRightInlineDirection)
Expand Down Expand Up @@ -334,6 +334,9 @@ void BoxGeometryUpdater::setGeometriesForLayout()
for (auto walker = InlineWalker(downcast<RenderBlockFlow>(boxTree().rootRenderer())); !walker.atEnd(); walker.advance()) {
auto& renderer = *walker.current();

if (is<RenderText>(renderer))
continue;

if (is<RenderReplaced>(renderer) || is<RenderTable>(renderer) || is<RenderListItem>(renderer) || is<RenderBlock>(renderer) || is<RenderFrameSet>(renderer)) {
updateLayoutBoxDimensions(downcast<RenderBox>(renderer));
continue;
Expand All @@ -358,6 +361,9 @@ void BoxGeometryUpdater::setGeometriesForIntrinsicWidth(Layout::IntrinsicWidthMo
for (auto walker = InlineWalker(downcast<RenderBlockFlow>(boxTree().rootRenderer())); !walker.atEnd(); walker.advance()) {
auto& renderer = *walker.current();

if (is<RenderText>(renderer))
continue;

if (auto* renderLineBreak = dynamicDowncast<RenderLineBreak>(renderer)) {
updateLineBreakBoxDimensions(*renderLineBreak);
continue;
Expand All @@ -366,7 +372,6 @@ void BoxGeometryUpdater::setGeometriesForIntrinsicWidth(Layout::IntrinsicWidthMo
updateInlineBoxDimensions(*renderInline, intrinsicWidthMode);
continue;
}
ASSERT(is<RenderText>(renderer));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ std::pair<LayoutUnit, LayoutUnit> LineLayout::computeIntrinsicWidthConstraints()
if (m_lineDamage)
m_inlineContentCache.resetMinimumMaximumContentSizes();
// FIXME: This is where we need to switch between minimum and maximum box geometries.
// Currently we only support content where min == max.
m_boxGeometryUpdater.setGeometriesForIntrinsicWidth(Layout::IntrinsicWidthMode::Minimum);
auto [minimumContentSize, maximumContentSize] = inlineFormattingContext.minimumMaximumContentSize(m_lineDamage.get());
return { minimumContentSize, maximumContentSize };
}
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/rendering/RenderBlockFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4965,8 +4965,6 @@ bool RenderBlockFlow::tryComputePreferredWidthsUsingModernPath(LayoutUnit& minLo
if (!modernLineLayout())
m_lineLayout = makeUnique<LayoutIntegration::LineLayout>(*this);

modernLineLayout()->updateInlineContentDimensions();

std::tie(minLogicalWidth, maxLogicalWidth) = modernLineLayout()->computeIntrinsicWidthConstraints();
for (auto walker = InlineWalker(*this); !walker.atEnd(); walker.advance()) {
auto* renderer = walker.current();
Expand Down

0 comments on commit d574921

Please sign in to comment.