diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 171e56ab9ea..5e2843b56cb 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -798,6 +798,7 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], position_to_offset(position, total_length) } }; + assert!(offset.is_finite()); stops.push(GradientStop { offset: offset, color: stop.color.to_gfx_color() @@ -3271,6 +3272,9 @@ struct StopRun { } fn position_to_offset(position: LengthOrPercentage, total_length: Au) -> f32 { + if total_length == Au(0) { + return 0.0 + } match position { LengthOrPercentage::Length(l) => l.to_i32_au() as f32 / total_length.0 as f32, LengthOrPercentage::Percentage(percentage) => percentage.0 as f32, diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 30613dca959..5d11cbbfbf0 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -112773,6 +112773,18 @@ {} ] ], + "css/css-images/gradient-crash.html": [ + [ + "/css/css-images/gradient-crash.html", + [ + [ + "/css/css-images/gradient-crash-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-images/gradient-move-stops.html": [ [ "/css/css-images/gradient-move-stops.html", @@ -239589,6 +239601,11 @@ {} ] ], + "css/css-images/gradient-crash-ref.html": [ + [ + {} + ] + ], "css/css-images/gradient-move-stops-ref.html": [ [ {} @@ -481714,6 +481731,14 @@ "5e74191a82ee45a5441d595c79b2a41b34748038", "reftest" ], + "css/css-images/gradient-crash-ref.html": [ + "5ad029bf4f73d96fed5eb085b40ea3daeeb7aaf6", + "support" + ], + "css/css-images/gradient-crash.html": [ + "6dbca7ec2fe3d0596d3ccc50f7a417aa625ad28e", + "reftest" + ], "css/css-images/gradient-move-stops-ref.html": [ "bb2fca5aaeb7fe1abf30620695ad3fd832c0d089", "support" diff --git a/tests/wpt/web-platform-tests/css/css-images/gradient-crash-ref.html b/tests/wpt/web-platform-tests/css/css-images/gradient-crash-ref.html new file mode 100644 index 00000000000..82055fc37ee --- /dev/null +++ b/tests/wpt/web-platform-tests/css/css-images/gradient-crash-ref.html @@ -0,0 +1 @@ + diff --git a/tests/wpt/web-platform-tests/css/css-images/gradient-crash.html b/tests/wpt/web-platform-tests/css/css-images/gradient-crash.html new file mode 100644 index 00000000000..dbdf77bbb1d --- /dev/null +++ b/tests/wpt/web-platform-tests/css/css-images/gradient-crash.html @@ -0,0 +1,12 @@ + + +