Skip to content

Commit 9a017d0

Browse files
committed
Make Block and inline-block have the same baseline when overflow: hidden
https://bugs.webkit.org/show_bug.cgi?id=307965 Reviewed by Antti Koivisto. Just because a child box's baseline is its margin box, it does not necessarily mean it is not a valid baseline. e.g. <div style="display: inline-block"> <div style="overflow: hidden">text</div> </div> Due to 'overflow: hidden', the inner box's baseline is its margin box and not 'text', but it is still a valid baseline candidate box when computing the baseline for outer. * LayoutTests/TestExpectations: * Source/WebCore/layout/integration/LayoutIntegrationBoxGeometryUpdater.cpp: (WebCore::LayoutIntegration::lastInflowBoxBaseline): Do not use 'shouldUseMarginBoxAsBaseline' to decided whether a child box is a candidate for baseline computation. Canonical link: https://commits.webkit.org/307718@main
1 parent bf5b0fd commit 9a017d0

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

LayoutTests/TestExpectations

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8184,7 +8184,6 @@ imported/w3c/web-platform-tests/css/CSS2/visudet/replaced-elements-min-width-80.
81848184

81858185
imported/w3c/web-platform-tests/css/CSS2/abspos/remove-block-between-inline-and-abspos.html [ ImageOnlyFailure ]
81868186

8187-
imported/w3c/web-platform-tests/css/CSS2/linebox/baseline-block-with-overflow-001.html [ ImageOnlyFailure ]
81888187
imported/w3c/web-platform-tests/css/CSS2/linebox/inline-formatting-context-023.xht [ ImageOnlyFailure ]
81898188
imported/w3c/web-platform-tests/css/CSS2/linebox/vertical-align-117a.xht [ ImageOnlyFailure ]
81908189
imported/w3c/web-platform-tests/css/CSS2/linebox/vertical-align-118a.xht [ ImageOnlyFailure ]

Source/WebCore/layout/integration/LayoutIntegrationBoxGeometryUpdater.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,26 @@ static std::optional<LayoutUnit> lastInflowBoxBaseline(const RenderBlock& blockC
365365
{
366366
auto* lastInFlowChild = blockContainer.lastInFlowChildBox();
367367
for (auto* inflowBox = lastInFlowChild; inflowBox; inflowBox = inflowBox->previousInFlowSiblingBox()) {
368-
if (inflowBox->isWritingModeRoot())
369-
continue;
370368

371-
if (inflowBox->shouldApplyLayoutContainment())
372-
continue;
369+
auto isBaselineCanididate = [&](auto& inflowChildBox) {
370+
if (inflowChildBox.isWritingModeRoot() || inflowChildBox.shouldApplyLayoutContainment() || is<RenderTable>(inflowChildBox))
371+
return false;
372+
373+
if (CheckedPtr scrollableArea = inflowChildBox.layer() ? inflowChildBox.layer()->scrollableArea() : nullptr) {
374+
if (scrollableArea->marquee())
375+
return false;
376+
377+
auto isScrollable = blockContainer.writingMode().isHorizontal() ? (scrollableArea->verticalScrollbar() || scrollableArea->scrollOffset().y()) : (scrollableArea->horizontalScrollbar() || scrollableArea->scrollOffset().x());
378+
return !isScrollable;
379+
}
380+
if (CheckedPtr blockFlow = dynamicDowncast<RenderBlockFlow>(inflowChildBox)) {
381+
auto hasValidBaseline = !blockFlow->childrenInline() || blockFlow->hasContentfulInlineOrBlockLine() || blockFlow->hasLineIfEmpty();
382+
return hasValidBaseline;
383+
}
384+
return true;
385+
};
373386

374-
if (shouldUseMarginBoxAsBaseline(*inflowBox)) {
387+
if (!isBaselineCanididate(*inflowBox)) {
375388
// We need to find a better candidate for baseline.
376389
continue;
377390
}

0 commit comments

Comments
 (0)