tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ff84b5499016ea42d9accb81270bb6f89ac18929
parent d45de9c0f73a5fe192041547d6b0f64135a62b78
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Wed,  3 Dec 2025 07:14:05 +0000

Bug 1999938 - Take foreground color into account in border transparency computation. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D274854

Diffstat:
Mlayout/painting/nsCSSRendering.cpp | 16+++++++---------
Atesting/web-platform/tests/css/css-borders/border-radius-currentcolor-ref.html | 19+++++++++++++++++++
Atesting/web-platform/tests/css/css-borders/border-radius-currentcolor.html | 24++++++++++++++++++++++++
3 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp @@ -1940,7 +1940,7 @@ ImgDrawResult nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer( } static bool IsOpaqueBorderEdge(const nsStyleBorder& aBorder, - mozilla::Side aSide) { + mozilla::Side aSide, const nsIFrame* aForFrame) { if (aBorder.GetComputedBorder().Side(aSide) == 0) { return true; } @@ -1962,19 +1962,16 @@ static bool IsOpaqueBorderEdge(const nsStyleBorder& aBorder, if (!aBorder.mBorderImageSource.IsNone()) { return false; } - - StyleColor color = aBorder.BorderColorFor(aSide); - // We don't know the foreground color here, so if it's being used - // we must assume it might be transparent. - return !color.MaybeTransparent(); + return NS_GET_A(aBorder.BorderColorFor(aSide).CalcColor(aForFrame)) == 255; } /** * Returns true if all border edges are either missing or opaque. */ -static bool IsOpaqueBorder(const nsStyleBorder& aBorder) { +static bool IsOpaqueBorder(const nsStyleBorder& aBorder, + const nsIFrame* aForFrame) { for (const auto i : mozilla::AllPhysicalSides()) { - if (!IsOpaqueBorderEdge(aBorder, i)) { + if (!IsOpaqueBorderEdge(aBorder, i, aForFrame)) { return false; } } @@ -2144,7 +2141,8 @@ void nsCSSRendering::GetImageLayerClip( haveRoundedCorners = GetRadii(aForFrame, aBorder, aBorderArea, clipBorderArea, aClipState->mRadii); } - bool isSolidBorder = aWillPaintBorder && IsOpaqueBorder(aBorder); + const bool isSolidBorder = + aWillPaintBorder && IsOpaqueBorder(aBorder, aForFrame); if (isSolidBorder && layerClip == StyleGeometryBox::BorderBox) { // If we have rounded corners, we need to inflate the background // drawing area a bit to avoid seams between the border and diff --git a/testing/web-platform/tests/css/css-borders/border-radius-currentcolor-ref.html b/testing/web-platform/tests/css/css-borders/border-radius-currentcolor-ref.html @@ -0,0 +1,19 @@ +<!doctype html> +<meta charset="utf-8"> +<title>CSS Test Reference</title> +<style> +:root { + --color: #fff; + background: var(--color); + color: var(--color); +} +div { + display: block; + width: 51px; + height: 51px; + border-radius: 50%; + background-color: #323232; + border: 10px solid var(--color); +} +</style> +<div></div> diff --git a/testing/web-platform/tests/css/css-borders/border-radius-currentcolor.html b/testing/web-platform/tests/css/css-borders/border-radius-currentcolor.html @@ -0,0 +1,24 @@ +<!doctype html> +<meta charset="utf-8"> +<title>border-color: currentColor + border-radius</title> +<link rel="help" href="https://drafts.csswg.org/css-borders-4/#border-color"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1999938"> +<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> +<link rel="author" title="Mozilla" href="https://mozilla.com"> +<link rel="match" href="border-radius-currentcolor-ref.html"> +<style> +:root { + --color: #fff; + background: var(--color); + color: var(--color); +} +div { + display: block; + width: 51px; + height: 51px; + border-radius: 50%; + background-color: #323232; + border: 10px solid currentcolor; +} +</style> +<div></div>