mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 21:49:42 +00:00
LibWeb: Ensure large animation progress values don't overflow
This commit is contained in:
parent
d18d40f7b9
commit
6cb0f0fbcd
Notes:
github-actions[bot]
2025-09-26 10:22:24 +00:00
Author: https://github.com/tcl3
Commit: 6cb0f0fbcd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6245
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 11 additions and 3 deletions
|
@ -901,7 +901,16 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto key = static_cast<i64>(round(output_progress.value() * 100.0 * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor));
|
double progress = round(output_progress.value() * 100.0 * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor);
|
||||||
|
// FIXME: Support progress values outside the range of i64.
|
||||||
|
i64 key = 0;
|
||||||
|
if (progress > NumericLimits<i64>::max()) {
|
||||||
|
key = NumericLimits<i64>::max();
|
||||||
|
} else if (progress < NumericLimits<i64>::min()) {
|
||||||
|
key = NumericLimits<i64>::min();
|
||||||
|
} else {
|
||||||
|
key = static_cast<i64>(progress);
|
||||||
|
}
|
||||||
auto keyframe_start_it = [&] {
|
auto keyframe_start_it = [&] {
|
||||||
if (output_progress.value() <= 0) {
|
if (output_progress.value() <= 0) {
|
||||||
return keyframes.begin();
|
return keyframes.begin();
|
||||||
|
@ -922,8 +931,7 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
|
||||||
auto keyframe_end = static_cast<i64>(keyframe_end_it.key());
|
auto keyframe_end = static_cast<i64>(keyframe_end_it.key());
|
||||||
auto keyframe_end_values = *keyframe_end_it;
|
auto keyframe_end_values = *keyframe_end_it;
|
||||||
|
|
||||||
auto progress_in_keyframe
|
auto progress_in_keyframe = (progress - keyframe_start) / static_cast<double>(keyframe_end - keyframe_start);
|
||||||
= static_cast<float>(key - keyframe_start) / static_cast<float>(keyframe_end - keyframe_start);
|
|
||||||
|
|
||||||
if constexpr (LIBWEB_CSS_ANIMATION_DEBUG) {
|
if constexpr (LIBWEB_CSS_ANIMATION_DEBUG) {
|
||||||
auto valid_properties = keyframe_values.properties.size();
|
auto valid_properties = keyframe_values.properties.size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue