LibWeb: Don't play initially-paused animations
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Gingeh 2025-06-16 12:26:42 +10:00 committed by Jelle Raaijmakers
parent 6169e91994
commit e96338dd63
Notes: github-actions[bot] 2025-06-18 15:18:49 +00:00
11 changed files with 143 additions and 37 deletions

View file

@ -3967,21 +3967,34 @@ void Element::play_or_cancel_animations_after_display_property_change()
auto has_display_none_inclusive_ancestor = this->has_inclusive_ancestor_with_display_none();
auto play_or_cancel_depending_on_display = [&](Animations::Animation& animation) {
auto play_or_cancel_depending_on_display = [&](Animations::Animation& animation, Optional<CSS::PseudoElement> pseudo_element) {
if (has_display_none_inclusive_ancestor) {
animation.cancel();
} else {
HTML::TemporaryExecutionContext context(realm());
animation.play().release_value_but_fixme_should_propagate_errors();
auto play_state { CSS::AnimationPlayState::Running };
if (auto play_state_property = cascaded_properties(pseudo_element)->property(CSS::PropertyID::AnimationPlayState);
play_state_property && play_state_property->is_keyword()) {
if (auto play_state_value = keyword_to_animation_play_state(
play_state_property->to_keyword());
play_state_value.has_value())
play_state = *play_state_value;
}
if (play_state == CSS::AnimationPlayState::Running) {
HTML::TemporaryExecutionContext context(realm());
animation.play().release_value_but_fixme_should_propagate_errors();
} else if (play_state == CSS::AnimationPlayState::Paused) {
HTML::TemporaryExecutionContext context(realm());
animation.pause().release_value_but_fixme_should_propagate_errors();
}
}
};
if (auto animation = cached_animation_name_animation({}))
play_or_cancel_depending_on_display(*animation);
play_or_cancel_depending_on_display(*animation, {});
for (auto i = 0; i < to_underlying(CSS::PseudoElement::KnownPseudoElementCount); i++) {
auto pseudo_element = static_cast<CSS::PseudoElement>(i);
if (auto animation = cached_animation_name_animation(pseudo_element))
play_or_cancel_depending_on_display(*animation);
play_or_cancel_depending_on_display(*animation, pseudo_element);
}
}