commit 264a5e93188a679f0118ec124347f2ee00806586
parent e810283b0d941c394cfc63e8ad3efdf93da282b0
Author: Jonathan Kew <jkew@mozilla.com>
Date: Wed, 15 Oct 2025 21:18:39 +0000
Bug 1980101 - Slightly reduce the amount of trimming applied by text-decoration-trim:auto. r=layout-jp-market-reviewers,layout-reviewers,AlaskanEmily
Minor cosmetic adjustment to make 'auto' trim less noticeable at the
"exposed" ends, following discussion in the Slack channel.
This is in preparation for applying 'auto' by default for CJK content.
Differential Revision: https://phabricator.services.mozilla.com/D268709
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp
@@ -5802,11 +5802,14 @@ static bool ComputeDecorationTrim(
aDecFrame->StyleTextReset()->mTextDecorationTrim;
gfxFloat trimLeft, trimRight;
if (cssTrim.IsAuto()) {
- // Use the EM size divide by 8, or 1 dev pixel if this is too
- // small to ensure that at least some separation occurs.
+ // Use a trim factor of 1/12.5, so we get 2px of trim (resulting in a 4px
+ // gap between adjacent lines) at font-size 25px.
+ constexpr gfxFloat kAutoTrimFactor = 1.0 / 12.5;
+ // Use the EM size multiplied by kAutoTrimFactor, with a minimum of one
+ // CSS pixel to ensure that at least some separation occurs.
const gfxFloat scale = aPresCtx->CSSToDevPixelScale().scale;
const nscoord autoDecorationTrim =
- std::max(aMetrics.emHeight * 0.125, scale);
+ std::max(aMetrics.emHeight * kAutoTrimFactor, scale);
trimLeft = autoDecorationTrim;
trimRight = autoDecorationTrim;
} else {