forked from mirrors/gecko-dev
Bug 1891322 - more robust solution for NaN offset in gradients r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D207904
This commit is contained in:
parent
4508adcf1c
commit
bcc703fbc9
1 changed files with 8 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue