From 3ad2791ea1d2eef8f8460b2542013db2474ef2b1 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 29 May 2026 22:53:43 +0200 Subject: [PATCH] Issue #3109 - Clamp border-radius value to Int32.MaxValue This avoids artifacts from out-of-bounds values. Resolves #3109 --- layout/style/nsRuleNode.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 7479e34344..d6c16296fd 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -8157,11 +8157,14 @@ nsRuleNode::ComputeBorderData(void* aStartStruct, NS_FOR_CSS_FULL_CORNERS(corner) { int cx = FullToHalfCorner(corner, false); int cy = FullToHalfCorner(corner, true); - const nsCSSValue& radius = *aRuleData->ValueFor(subprops[corner]); + nsCSSValue radius = *aRuleData->ValueFor(subprops[corner]); nsStyleCoord parentX = parentBorder->mBorderRadius.Get(cx); nsStyleCoord parentY = parentBorder->mBorderRadius.Get(cy); nsStyleCoord coordX, coordY; - + // Clamp border radius to the max value so it will not wrap and cause artifacts. + if (radius.GetFloatValue() > RADIUS_MAX) { + radius.SetFloatValue(RADIUS_MAX, eCSSUnit_Number); + } if (SetPairCoords(radius, coordX, coordY, parentX, parentY, SETCOORD_LPH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC | SETCOORD_UNSET_INITIAL,