Skip to content

Commit a95cde3

Browse files
Calme1709kalenikaliaksandr
authored andcommitted
LibWeb: Separate CSSAnimation::animationName from Animation::id
1 parent 2447b8a commit a95cde3

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

Libraries/LibWeb/CSS/CSSAnimation.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class CSSAnimation : public Animations::Animation {
1919
public:
2020
static GC::Ref<CSSAnimation> create(JS::Realm&);
2121

22-
FlyString const& animation_name() const { return id(); }
22+
FlyString const& animation_name() const { return m_animation_name; }
23+
void set_animation_name(FlyString const& animation_name) { m_animation_name = animation_name; }
2324

2425
virtual Animations::AnimationClass animation_class() const override;
2526
virtual Optional<int> class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
@@ -30,6 +31,9 @@ class CSSAnimation : public Animations::Animation {
3031
virtual void initialize(JS::Realm&) override;
3132

3233
virtual bool is_css_animation() const override { return true; }
34+
35+
// https://drafts.csswg.org/css-animations-2/#dom-cssanimation-animationname
36+
FlyString m_animation_name;
3337
};
3438

3539
}

Libraries/LibWeb/CSS/StyleComputer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ void StyleComputer::process_animation_definitions(ComputedProperties const& comp
12351235
// An animation applies to an element if its name appears as one of the identifiers in the computed value of the
12361236
// animation-name property and the animation uses a valid @keyframes rule
12371237
auto animation = CSSAnimation::create(document.realm());
1238-
animation->set_id(animation_properties.name);
1238+
animation->set_animation_name(animation_properties.name);
12391239
animation->set_timeline(document.timeline());
12401240
animation->set_owning_element(element);
12411241

Libraries/LibWeb/DOM/Document.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2816,7 +2816,7 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::An
28162816
name,
28172817
{
28182818
{ .bubbles = true },
2819-
css_animation.id(),
2819+
css_animation.animation_name(),
28202820
elapsed_time_seconds,
28212821
}),
28222822
.animation = css_animation,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Harness status: OK
2+
3+
Found 1 tests
4+
5+
1 Pass
6+
Pass Animation.id for CSS Animations
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>CSSAnimation.id</title>
4+
<!-- TODO: Add a more specific link for this once it is specified. -->
5+
<link rel="help" href="https://drafts.csswg.org/css-animations-2/#cssanimation">
6+
<script src="../../resources/testharness.js"></script>
7+
<script src="../../resources/testharnessreport.js"></script>
8+
<script src="support/testcommon.js"></script>
9+
<style>
10+
@keyframes abc { }
11+
</style>
12+
<div id="log"></div>
13+
<script>
14+
'use strict';
15+
16+
test(t => {
17+
const div = addDiv(t);
18+
div.style.animation = 'abc 100s';
19+
const animation = div.getAnimations()[0];
20+
assert_equals(animation.id, '', 'id for CSS Animation is initially empty');
21+
22+
animation.id = 'anim'
23+
assert_equals(animation.id, 'anim', 'animation.id reflects the value set');
24+
}, 'Animation.id for CSS Animations');
25+
26+
</script>
27+
</html>

0 commit comments

Comments
 (0)