Skip to content

Commit

Permalink
Avoid infinite loop due to rounding errors in gamut mapping
Browse files Browse the repository at this point in the history
Fixes #446
  • Loading branch information
devongovett committed Apr 9, 2023
1 parent 1583dd1 commit c5fcb63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/lib.rs
Expand Up @@ -15916,6 +15916,23 @@ mod tests {
".foo { --color: color-mix(in lch, teal 65%, olive); }",
".foo{--color:lch(49.4431% 40.4806 162.546)}",
);
minify_test(
".foo { color: color-mix(in xyz, transparent, green 65%); }",
".foo{color:color(xyz .0771883 .154377 .0257295/.65)}",
);
prefix_test(
".foo { color: color-mix(in xyz, transparent, green 65%); }",
indoc! { r#"
.foo {
color: #008000a6;
color: color(xyz .0771883 .154377 .0257295 / .65);
}
"# },
Browsers {
chrome: Some(95 << 16),
..Default::default()
},
);

// regex for converting web platform tests:
// test_computed_value\(.*?, `(.*?)`, `(.*?)`\);
Expand Down
2 changes: 1 addition & 1 deletion src/values/color.rs
Expand Up @@ -2787,7 +2787,7 @@ where
let mut min = 0.0;
let mut max = current.c;

while min < max {
while (max - min) > EPSILON {
let chroma = (min + max) / 2.0;
current.c = chroma;

Expand Down

0 comments on commit c5fcb63

Please sign in to comment.