mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Separate CSSAnimation::animationName from Animation::id
This commit is contained in:
parent
2447b8a759
commit
a95cde3660
Notes:
github-actions[bot]
2025-11-02 22:55:20 +00:00
Author: https://github.com/Calme1709
Commit: a95cde3660
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6642
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 40 additions and 3 deletions
|
|
@ -19,7 +19,8 @@ class CSSAnimation : public Animations::Animation {
|
||||||
public:
|
public:
|
||||||
static GC::Ref<CSSAnimation> create(JS::Realm&);
|
static GC::Ref<CSSAnimation> create(JS::Realm&);
|
||||||
|
|
||||||
FlyString const& animation_name() const { return id(); }
|
FlyString const& animation_name() const { return m_animation_name; }
|
||||||
|
void set_animation_name(FlyString const& animation_name) { m_animation_name = animation_name; }
|
||||||
|
|
||||||
virtual Animations::AnimationClass animation_class() const override;
|
virtual Animations::AnimationClass animation_class() const override;
|
||||||
virtual Optional<int> class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
|
virtual Optional<int> class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
|
||||||
|
|
@ -30,6 +31,9 @@ private:
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
virtual bool is_css_animation() const override { return true; }
|
virtual bool is_css_animation() const override { return true; }
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-animations-2/#dom-cssanimation-animationname
|
||||||
|
FlyString m_animation_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1235,7 +1235,7 @@ void StyleComputer::process_animation_definitions(ComputedProperties const& comp
|
||||||
// An animation applies to an element if its name appears as one of the identifiers in the computed value of the
|
// An animation applies to an element if its name appears as one of the identifiers in the computed value of the
|
||||||
// animation-name property and the animation uses a valid @keyframes rule
|
// animation-name property and the animation uses a valid @keyframes rule
|
||||||
auto animation = CSSAnimation::create(document.realm());
|
auto animation = CSSAnimation::create(document.realm());
|
||||||
animation->set_id(animation_properties.name);
|
animation->set_animation_name(animation_properties.name);
|
||||||
animation->set_timeline(document.timeline());
|
animation->set_timeline(document.timeline());
|
||||||
animation->set_owning_element(element);
|
animation->set_owning_element(element);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2816,7 +2816,7 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::An
|
||||||
name,
|
name,
|
||||||
{
|
{
|
||||||
{ .bubbles = true },
|
{ .bubbles = true },
|
||||||
css_animation.id(),
|
css_animation.animation_name(),
|
||||||
elapsed_time_seconds,
|
elapsed_time_seconds,
|
||||||
}),
|
}),
|
||||||
.animation = css_animation,
|
.animation = css_animation,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 1 tests
|
||||||
|
|
||||||
|
1 Pass
|
||||||
|
Pass Animation.id for CSS Animations
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>CSSAnimation.id</title>
|
||||||
|
<!-- TODO: Add a more specific link for this once it is specified. -->
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-animations-2/#cssanimation">
|
||||||
|
<script src="../../resources/testharness.js"></script>
|
||||||
|
<script src="../../resources/testharnessreport.js"></script>
|
||||||
|
<script src="support/testcommon.js"></script>
|
||||||
|
<style>
|
||||||
|
@keyframes abc { }
|
||||||
|
</style>
|
||||||
|
<div id="log"></div>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
const div = addDiv(t);
|
||||||
|
div.style.animation = 'abc 100s';
|
||||||
|
const animation = div.getAnimations()[0];
|
||||||
|
assert_equals(animation.id, '', 'id for CSS Animation is initially empty');
|
||||||
|
|
||||||
|
animation.id = 'anim'
|
||||||
|
assert_equals(animation.id, 'anim', 'animation.id reflects the value set');
|
||||||
|
}, 'Animation.id for CSS Animations');
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue