summaryrefslogtreecommitdiffstats
path: root/gfx/wr/webrender_api
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/wr/webrender_api')
-rw-r--r--gfx/wr/webrender_api/src/gradient_builder.rs12
1 files changed, 8 insertions, 4 deletions
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