Skip to content

Commit ed7a86b

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb/DOM: Set the pseudo_element on created Animation/TransitionEvents
Also import a couple of WPT tests that now pass.
1 parent d717dd6 commit ed7a86b

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

Libraries/LibWeb/DOM/Document.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,10 +2696,12 @@ void Document::dispatch_events_for_transition(GC::Ref<CSS::CSSTransition> transi
26962696
type,
26972697
CSS::TransitionEventInit {
26982698
{ .bubbles = true },
2699-
// FIXME: Correctly set pseudo_element
27002699
MUST(String::from_utf8(transition->transition_property())),
27012700
elapsed_time,
2702-
String {},
2701+
transition->owning_element()->pseudo_element().map([](auto it) {
2702+
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
2703+
})
2704+
.value_or({}),
27032705
}),
27042706
.animation = transition,
27052707
.target = transition->owning_element()->element(),
@@ -2791,6 +2793,10 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::An
27912793
{ .bubbles = true },
27922794
css_animation.animation_name(),
27932795
elapsed_time_seconds,
2796+
owning_element->pseudo_element().map([](auto it) {
2797+
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
2798+
})
2799+
.value_or({}),
27942800
}),
27952801
.animation = css_animation,
27962802
.target = *target,
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 AnimationEvent should have the correct pseudoElement memeber
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 AnimationEvent should have the correct pseudoElement memeber
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Animations Test: AnimationEvent pseudoElement</title>
4+
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
5+
<link rel="help" href="https://drafts.csswg.org/css-animations/#interface-animationevent">
6+
<script src="../../resources/testharness.js"></script>
7+
<script src="../../resources/testharnessreport.js"></script>
8+
<style>
9+
#target::marker {
10+
content: "";
11+
animation: move 1s;
12+
}
13+
14+
@keyframes move {
15+
to { transform: translate(100px); }
16+
}
17+
18+
#target {
19+
display: list-item;
20+
list-style-position: inside;
21+
}
22+
</style>
23+
<div id='target'></div>
24+
<script>
25+
async_test(function(t) {
26+
var target = document.getElementById('target');
27+
target.addEventListener("animationstart", t.step_func(function(evt) {
28+
assert_true(evt instanceof window.AnimationEvent);
29+
assert_equals(evt.pseudoElement, "::marker");
30+
31+
t.done();
32+
}), true);
33+
}, "AnimationEvent should have the correct pseudoElement memeber");
34+
</script>
35+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Animations Test: AnimationEvent pseudoElement</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-animations/#interface-animationevent">
5+
<script src="../../resources/testharness.js"></script>
6+
<script src="../../resources/testharnessreport.js"></script>
7+
<style>
8+
#target::before {
9+
content: "";
10+
animation: move 1s;
11+
}
12+
13+
@keyframes move {
14+
to { transform: translate(100px); }
15+
}
16+
</style>
17+
<div id='target'></div>
18+
<script>
19+
async_test(function(t) {
20+
var target = document.getElementById('target');
21+
target.addEventListener("animationstart", t.step_func(function(evt) {
22+
assert_true(evt instanceof window.AnimationEvent);
23+
assert_equals(evt.pseudoElement, "::before");
24+
25+
t.done();
26+
}), true);
27+
}, "AnimationEvent should have the correct pseudoElement memeber");
28+
</script>
29+

0 commit comments

Comments
 (0)