Skip to content
Permalink
Browse files
Incorrect inline box decoration position when content box is vertical…
…ly shifted (text-underline-position/vertical edition)

https://bugs.webkit.org/show_bug.cgi?id=245316
<rdar://problem/100071411>

Reviewed by Simon Fraser.

This is a follow-up on 254554@main (https://commits.webkit.org/254554@main) where an inline box with vertical border/padding produces incorrect underline position.
This patch addresses both the vertical (ideographic baseline) and the "text-underline-position: under" cases where we use the inline box's logical height to compute the underline offset.

* LayoutTests/fast/inline/text-decoration-underline-inline-box-offset-expected.html: Added.
* LayoutTests/fast/inline/text-decoration-underline-inline-box-offset.html: Added.
* Source/WebCore/style/InlineTextBoxStyle.cpp: use the inline box's content box to compute the underline offset.
(WebCore::underlineOffsetForTextBoxPainting):

Canonical link: https://commits.webkit.org/254593@main
  • Loading branch information
alanbaradlay committed Sep 17, 2022
1 parent 3e2be5f commit 086a03457d7f6ae8ac0504951426277393d1b402
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
@@ -0,0 +1,19 @@
<style>
div {
font-family: Monospace;
font-size: 40px;
margin: 50px;
}
span {
text-decoration: underline;
border: 20px solid transparent;
padding: 30px;
}
.vertical {
writing-mode: vertical-lr;
text-underline-position: under;
text-underline-offset: -10px;
}
</style>
<div><span>XXX</span></div>
<div class=vertical><span>XXX</span></div>
@@ -0,0 +1,16 @@
<style>
div {
font-family: Monospace;
font-size: 40px;
margin: 50px;
}
span {
text-decoration: underline;
text-underline-position: under;
text-underline-offset: -10px;
border: 20px solid transparent;
padding: 30px;
}
</style>
<div><span>XXX</span></div>
<div style="writing-mode: vertical-lr"><span>XXX</span></div>
@@ -307,7 +307,10 @@ float underlineOffsetForTextBoxPainting(const InlineIterator::InlineBox& inlineB

if (underlinePositionValue == TextUnderlinePosition::Under) {
auto textRunOffset = boxOffsetFromBottomMost(inlineBox.lineBox(), inlineBox.renderer(), inlineBox.logicalTop(), inlineBox.logicalBottom());
textUnderlinePositionUnder = TextUnderlinePositionUnder { inlineBox.logicalHeight(), textRunOffset };
auto inlineBoxContentBoxHeight = inlineBox.logicalHeight();
if (!inlineBox.isRootInlineBox())
inlineBoxContentBoxHeight -= (inlineBox.renderer().borderAndPaddingBefore() + inlineBox.renderer().borderAndPaddingAfter());
textUnderlinePositionUnder = TextUnderlinePositionUnder { inlineBoxContentBoxHeight, textRunOffset };
}

return computedUnderlineOffset({ style, underlinePositionValue, defaultGap(style), textUnderlinePositionUnder });

0 comments on commit 086a034

Please sign in to comment.