commit 383c32e1f26514b996adfa23def9982194b576de
parent 516286fcfcb6d4c50c269a7f76b40bc3af566c26
Author: Jonathan Kew <jkew@mozilla.com>
Date: Sat, 1 Nov 2025 13:08:20 +0000
Bug 1997706 - During nsTextFrame::UnionAdditionalOverflow, ignore text-decoration-inset values if they would only shorten the line. r=layout-reviewers,emilio
For additional-overflow purposes, only negative insets (i.e. values that actually extend
the decoration line beyond the normal extent of the text) need to be considered. For the
(probably more common) case of positive insets (e.g. the auto value), we can bail out
without doing the full geometric computations to resolve the insets.
Differential Revision: https://phabricator.services.mozilla.com/D270947
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp
@@ -5785,10 +5785,12 @@ static gfxFloat ComputeDecorationLineOffset(
// Helper to determine decoration inset.
// Returns false if the inset would cut off the decoration entirely.
+// If aOnlyExtend is true, this will only consider cases with negative inset
+// (i.e. the line will actually be extended beyond the normal length).
static bool ComputeDecorationInset(
nsTextFrame* aFrame, const nsPresContext* aPresCtx,
const nsIFrame* aDecFrame, const gfxFont::Metrics& aMetrics,
- nsCSSRendering::DecorationRectParams& aParams) {
+ nsCSSRendering::DecorationRectParams& aParams, bool aOnlyExtend = false) {
const WritingMode wm = aDecFrame->GetWritingMode();
bool verticalDec = wm.IsVertical();
@@ -5823,6 +5825,12 @@ static bool ComputeDecorationInset(
insetRight = length.end.ToAppUnits();
}
+ // If we only care about extended lines (for UnionAdditionalOverflow),
+ // we can bail out if neither inset value is negative.
+ if (aOnlyExtend && insetLeft >= 0 && insetRight >= 0) {
+ return true;
+ }
+
if (wm.IsInlineReversed()) {
std::swap(insetLeft, insetRight);
}
@@ -6102,7 +6110,7 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
swapUnderline);
if (!ComputeDecorationInset(this, aPresContext, dec.mFrame, metrics,
- params)) {
+ params, /* aOnlyExtend = */ true)) {
return;
}