mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +00:00
LibWeb: Apply all animations and transitions before invalidating style
This fixes an issue where only the last KeyframeEffect applied to an element would actually have an effect on the computed properties. It was particularly noticeable when animating a shorthand property like border-width, since only one of the border edges would have its width actually animate. By deferring the invalidation until all animations have been processed, we also reduce the amount of work that gets done on pages with many animations/transitions per element. Discord is very fond of this for example.
This commit is contained in:
parent
50422eb563
commit
92221f0c57
Notes:
github-actions[bot]
2025-07-19 15:10:06 +00:00
Author: https://github.com/awesomekling
Commit: 92221f0c57
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5520
Reviewed-by: https://github.com/kalenikaliaksandr ✅
11 changed files with 198 additions and 152 deletions
|
@ -9,6 +9,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Bitmap.h>
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
|
@ -1537,15 +1538,18 @@ void Document::update_animated_style_if_needed()
|
|||
if (!m_needs_animated_style_update)
|
||||
return;
|
||||
|
||||
Animations::AnimationUpdateContext context;
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines) {
|
||||
for (auto& animation : timeline->associated_animations()) {
|
||||
if (animation->is_idle() || animation->is_finished())
|
||||
continue;
|
||||
if (auto effect = animation->effect()) {
|
||||
effect->update_computed_properties();
|
||||
effect->update_computed_properties(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_needs_animated_style_update = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue