mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 09:01:53 +00:00
LibWeb: Round to the nearest integer when interpolating integer values
This commit is contained in:
parent
8257788a20
commit
b3980d40f7
Notes:
github-actions[bot]
2025-04-11 10:32:54 +00:00
Author: https://github.com/tcl3
Commit: b3980d40f7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4318
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 393 additions and 2 deletions
|
@ -586,8 +586,13 @@ NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, Calc
|
|||
layout_node = *node;
|
||||
return CSSColorValue::create_from_color(interpolate_color(from.to_color(layout_node), to.to_color(layout_node), delta), ColorSyntax::Modern);
|
||||
}
|
||||
case CSSStyleValue::Type::Integer:
|
||||
return IntegerStyleValue::create(interpolate_raw(from.as_integer().integer(), to.as_integer().integer(), delta));
|
||||
case CSSStyleValue::Type::Integer: {
|
||||
// https://drafts.csswg.org/css-values/#combine-integers
|
||||
// Interpolation of <integer> is defined as Vresult = round((1 - p) × VA + p × VB);
|
||||
// that is, interpolation happens in the real number space as for <number>s, and the result is converted to an <integer> by rounding to the nearest integer.
|
||||
auto interpolated_value = interpolate_raw(from.as_integer().value(), to.as_integer().value(), delta);
|
||||
return IntegerStyleValue::create(round_to<i64>(interpolated_value));
|
||||
}
|
||||
case CSSStyleValue::Type::Length: {
|
||||
// FIXME: Absolutize values
|
||||
auto const& from_length = from.as_length().length();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue