Open Bug 1472922 Opened 6 years ago Updated 2 years ago

Use a fallback AnimationEventDispatcher if there is no timeline in Animation::QueuePlaybackEvent

Categories

(Core :: DOM: Animation, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: hiro, Unassigned)

References

Details

In bug 1354501, I didn't implement fallback case if there is no timeline when we queue animation playback events. As Brian noted in bug 1354501 comment 63, the spec says we should use a task queue is used for such case. But it sounds bit opposed what we did in 1354501. As per the HTML processing model [1], the task queue is processed before '7. Update the rendering:' which means the event is processed at different timings. Also it actually means what we did before 1354501. I think, even if there is no timeline, the animation is still associated with a document, then the document should have a pending animation event queue [2], so we can use the queue instead. It's still unclear to me that which document, the document for the target element or for the animation object is better, though. [1] https://html.spec.whatwg.org/multipage/webappapis.html#processing-model-8 [2] https://drafts.csswg.org/web-animations-1/#pending-animation-event-queue
I just realized that, IIUC, we do use the timeline for the document in the current JS context [1]. So, const target = subframe.contentDocument.getElementById('target'); target.animate({ opacity: [ 0, 1 ] }, 1000); in this case, the animation events are dispatched in the parent document instead of the subframe one. So if the animation has no timeline, then we should use the document that the animation object belongs to, which means we should use GetDocumentIfCurrent(). Anyway, we should write wpt somehow for this. I might be wrong though. :) [1] https://hg.mozilla.org/mozilla-central/file/987ea0d6a000/dom/animation/Animation.cpp#l102
Assignee: nobody → hikezoe
Status: NEW → ASSIGNED
Priority: P3 → P2
Assignee: hikezoe → nobody
Status: ASSIGNED → NEW
Priority: P2 → P3
(In reply to Hiroyuki Ikezoe (:hiro) from comment #1) > I just realized that, IIUC, we do use the timeline for the document in the > current JS context [1]. > > So, > > const target = subframe.contentDocument.getElementById('target'); > target.animate({ opacity: [ 0, 1 ] }, 1000); This example is wrong. Element.animate() uses the document timeline for the target element. const effect = new KeyframeEffect(target, null, 1000); const animation = new Animation(effect); This animation uses the parent document timeline.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.