Commit fa794342 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Animations: fix animationiteration event to be fired just once per animation

... originally regressed by
https://chromium-review.googlesource.com/c/chromium/src/+/2107302

Bug: 1063506, 1059968
Change-Id: Id7fd285c9e5cf9a70981e34c4645f778fbf2899f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2113801
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752588}
parent 153ffd6c
......@@ -1191,8 +1191,11 @@ void CSSAnimations::AnimationEventDelegate::OnEventCondition(
event_type_names::kAnimationiteration, elapsed_time);
}
previous_iteration_ = current_iteration;
if (previous_phase_ == current_phase)
return;
previous_phase_ = current_phase;
if (current_phase == Timing::kPhaseAfter) {
MaybeDispatch(Document::kAnimationEndListener,
......@@ -1209,9 +1212,6 @@ void CSSAnimations::AnimationEventDelegate::OnEventCondition(
event_type_names::kAnimationcancel,
AnimationTimeDelta::FromSecondsD(cancel_time));
}
previous_phase_ = current_phase;
previous_iteration_ = current_iteration;
}
void CSSAnimations::AnimationEventDelegate::Trace(Visitor* visitor) {
......
<!DOCTYPE html>
<title>Tests that correct number of iteration events is fired.</title>
<style>
#box {
position: relative;
left: 100px;
top: 10px;
height: 100px;
width: 100px;
animation-duration: 0.1s;
animation-name: anim;
background-color: #999;
animation-iteration-count: 2;
}
@keyframes anim {
from { left: 200px; }
to { left: 300px; }
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var count = 0;
async_test(t => {
window.addEventListener("load", t.step_func(() => {
document.addEventListener('animationiteration', t.step_func(() => {
++count;
}));
document.addEventListener('animationend', t.step_func_done(() => {
assert_equals(count, 1, 'Got correct number of animationCount events');
}));
// Animation begins once we append the DOM node to the document.
var boxNode = document.createElement('div');
boxNode.id = 'box';
document.body.appendChild(boxNode);
}));
}, "Tests that correct number of iteration events is fired");
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment