Skip to content

Commit

Permalink
[leading-trim][IFC] Inflate layout bounds with margin/border/padding …
Browse files Browse the repository at this point in the history
…when text-edge is not leading

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

Reviewed by Antti Koivisto.

https://www.w3.org/TR/css-inline-3/#inline-height
"Additionally, when text-edge is not leading, the layout bounds are inflated by the sum of the margin, border, and padding on each side."

* LayoutTests/fast/text/text-edge-with-margin-padding-border-simple-expected-mismatch.html: Added.
* LayoutTests/fast/text/text-edge-with-margin-padding-border-simple.html: Added.
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::setVerticalPropertiesForInlineLevelBox const):

Canonical link: https://commits.webkit.org/257323@main
  • Loading branch information
alanbaradlay committed Dec 3, 2022
1 parent 943d096 commit 76780a8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
@@ -0,0 +1,12 @@
<style>
div {
font-family: "Arial";
background-color: green;
text-edge: leading;
color: transparent;
}
</style>
<div><span style="font-size: 100px;">XXXXX</span></div>
<div><span style="margin: 10px; font-size: 100px;">XXXXX</span></div>
<div><span style="border: 10px solid green; font-size: 100px;">XXXXX</span></div>
<div><span style="padding: 10px; font-size: 100px;">XXXXX</span></div>
@@ -0,0 +1,12 @@
<style>
div {
font-family: "Arial";
background-color: green;
text-edge: text;
color: transparent;
}
</style>
<div><span style="font-size: 100px;">XXXXX</span></div>
<div><span style="margin: 10px; font-size: 100px;">XXXXX</span></div>
<div><span style="border: 10px solid green; font-size: 100px;">XXXXX</span></div>
<div><span style="padding: 10px; font-size: 100px;">XXXXX</span></div>
Expand Up @@ -254,6 +254,14 @@ void LineBoxBuilder::setVerticalPropertiesForInlineLevelBox(const LineBox& lineB
descent += halfLeading;
}
}
if (!shouldIncorporateHalfLeading) {
// Additionally, when text-edge is not leading, the layout bounds are inflated by the sum of the margin,
// border, and padding on each side.
ASSERT(!inlineLevelBox.isRootInlineBox());
auto& inlineBoxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
ascent += inlineBoxGeometry.marginBorderAndPaddingBefore();
descent += inlineBoxGeometry.marginBorderAndPaddingAfter();
}
inlineLevelBox.setLayoutBounds({ floorf(ascent), ceilf(descent) });
};
setLayoutBounds();
Expand Down

0 comments on commit 76780a8

Please sign in to comment.