LibWeb: Use machine epsilon when approximating cubic bezier

This commit is contained in:
Gingeh 2024-11-02 20:23:50 +11:00 committed by Alexander Kalenik
commit c2cd191864
Notes: github-actions[bot] 2024-11-03 16:36:14 +00:00
3 changed files with 29 additions and 4 deletions

View file

@ -126,9 +126,9 @@ double EasingStyleValue::Function::evaluate_at(double input_progress, bool befor
size_t nearby_index = 0;
if (auto found = binary_search(cached_x_samples, x, &nearby_index, [](auto x, auto& sample) {
if (x > sample.x)
if (x - sample.x >= NumericLimits<double>::epsilon())
return 1;
if (x < sample.x)
if (x - sample.x <= NumericLimits<double>::epsilon())
return -1;
return 0;
}))
@ -146,9 +146,9 @@ double EasingStyleValue::Function::evaluate_at(double input_progress, bool befor
}
if (auto found = binary_search(cached_x_samples, x, &nearby_index, [](auto x, auto& sample) {
if (x > sample.x)
if (x - sample.x >= NumericLimits<double>::epsilon())
return 1;
if (x < sample.x)
if (x - sample.x <= NumericLimits<double>::epsilon())
return -1;
return 0;
}))