commit 75f70c43d84bb54a6d53e5f7f1ff374ae1d4d465
parent 19f6a3de7a35c9e339550b6f20c42287dae176f6
Author: Jonathan Kew <jkew@mozilla.com>
Date: Thu, 16 Oct 2025 08:50:14 +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
@@ -5790,11 +5790,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 {