From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- gfx/wr/webrender_api/src/gradient_builder.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gfx/wr/webrender_api') diff --git a/gfx/wr/webrender_api/src/gradient_builder.rs b/gfx/wr/webrender_api/src/gradient_builder.rs index 6347396f79..545b2d328a 100644 --- a/gfx/wr/webrender_api/src/gradient_builder.rs +++ b/gfx/wr/webrender_api/src/gradient_builder.rs @@ -132,10 +132,6 @@ impl GradientBuilder { let first = *stops.first().unwrap(); let last = *stops.last().unwrap(); - // Express the assertion so that if one of the offsets is NaN, we don't panic - // and instead take the branch that handles degenerate gradients. - assert!(!(first.offset > last.offset)); - let stops_delta = last.offset - first.offset; if stops_delta > 0.000001 { @@ -144,6 +140,14 @@ impl GradientBuilder { } (first.offset, last.offset) + } else if stops_delta.is_nan() { + // We have no good way to render a NaN offset, but make something + // that is at least renderable. + stops.clear(); + stops.push(di::GradientStop { color: last.color, offset: 0.0, }); + stops.push(di::GradientStop { color: last.color, offset: 1.0, }); + + (0.0, 1.0) } else { // We have a degenerate gradient and can't accurately transform the stops // what happens here depends on the repeat behavior, but in any case -- cgit v1.2.3