Skip to content
Permalink
Browse files
threejs.org renders mostly blank (lazy image loading inside 0-height …
…inline is broken?)

https://bugs.webkit.org/show_bug.cgi?id=246060
rdar://99905638

Reviewed by Antti Koivisto.

This part of the "inline level box affects the line box height" logic is a leftover from when
we used the notion of "setIsNonEmpty" to decide if an inline level box should be taken into account
at line box sizing (see webkit.org/b/218767 216957 and 220232).
However with the most recent "layout bounds" approach, ignoring "empty" atomic inline level boxes is incorrect.
While an inline level box with zero height produces the layout bounds of (0, 0), it may still put constraint on
the line box when a non-normal "line-height" triggers negative layout bounds on the inline boxes (most notably on the root inline box).
(Like in this case the root inline box ends up with the layout bounds of [5, -5] (triggered by line-height: 0) but
merging it with the <img>'s [0, 0] layout bounds will still produce a 5px tall line box).

* LayoutTests/fast/text/line-height-zero-with-inline-level-content-expected.html: Added.
* LayoutTests/fast/text/line-height-zero-with-inline-level-content.html: Added.
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp:
(WebCore::Layout::InlineFormattingGeometry::inlineLevelBoxAffectsLineBox const):

Canonical link: https://commits.webkit.org/257565@main
  • Loading branch information
alanbaradlay committed Dec 8, 2022
1 parent a6fb713 commit 7e8fe9be9b2266454fc088151004b49c49535cf8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
@@ -0,0 +1,8 @@
<style>
div {
width: 100px;
height: 6px;
background-color: green;
}
</style>
<div></div>
@@ -0,0 +1,11 @@
<style>
.container {
font-family: Ahem;
font-size: 20px;
line-height: 0;
background-color: green;
color: transparent;
width: 100px;
}
</style>
<div class=container>PASS if the line green box shows up<div style="display: inline-block; width: 0px; height: 0px;"></div></div>
@@ -130,14 +130,8 @@ bool InlineFormattingGeometry::inlineLevelBoxAffectsLineBox(const InlineLevelBox
return downcast<ElementBox>(inlineLevelBox.layoutBox()).isListMarkerImage();
if (inlineLevelBox.isInlineBox())
return layoutState().inStandardsMode() ? true : formattingContext().formattingQuirks().inlineBoxAffectsLineBox(inlineLevelBox);
if (inlineLevelBox.isAtomicInlineLevelBox()) {
if (inlineLevelBox.logicalHeight())
return true;
// While in practice when the negative vertical margin makes the layout bounds empty (e.g: height: 100px; margin-top: -100px;), and this inline
// level box contributes 0px to the line box height, it still needs to be taken into account while computing line box geometries.
auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
return boxGeometry.marginBefore() || boxGeometry.marginAfter();
}
if (inlineLevelBox.isAtomicInlineLevelBox())
return true;
return false;
}

0 comments on commit 7e8fe9b

Please sign in to comment.