[webkit-changes] [WebKit/WebKit] 845d49: Support animations in Model element with model pro...

Ada Chan noreply at github.com
Fri Sep 27 08:14:05 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 845d49cbfca7509085faa9620bd1b942a6ff709e
      https://github.com/WebKit/WebKit/commit/845d49cbfca7509085faa9620bd1b942a6ff709e
  Author: Ada Chan <adachan at apple.com>
  Date:   2024-09-27 (Fri, 27 Sep 2024)

  Changed paths:
    A LayoutTests/model-element/model-element-animations-current-time-expected.txt
    A LayoutTests/model-element/model-element-animations-current-time.html
    A LayoutTests/model-element/model-element-animations-initial-values-expected.txt
    A LayoutTests/model-element/model-element-animations-initial-values.html
    A LayoutTests/model-element/model-element-animations-loop-expected.txt
    A LayoutTests/model-element/model-element-animations-loop.html
    A LayoutTests/model-element/model-element-animations-playback-expected.txt
    A LayoutTests/model-element/model-element-animations-playback.html
    A LayoutTests/model-element/model-element-animations-replace-sources-expected.txt
    A LayoutTests/model-element/model-element-animations-replace-sources.html
    M LayoutTests/model-element/resources/model-utils.js
    A LayoutTests/model-element/resources/stopwatch-30s.usdz
    A LayoutTests/model-element/resources/stopwatch-60s.usdz
    M Source/WebCore/Modules/model-element/HTMLModelElement.cpp
    M Source/WebCore/Modules/model-element/HTMLModelElement.h
    M Source/WebCore/Modules/model-element/HTMLModelElement.idl
    M Source/WebCore/Modules/model-element/ModelPlayer.cpp
    M Source/WebCore/Modules/model-element/ModelPlayer.h
    M Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.h
    M Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.messages.in
    M Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.mm
    M Source/WebKit/WebKitSwift/RealityKit/RKEntity.swift
    M Source/WebKit/WebKitSwift/RealityKit/RealityKitBridging.h
    M Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.cpp
    M Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.h
    M Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.messages.in

  Log Message:
  -----------
  Support animations in Model element with model process
https://bugs.webkit.org/show_bug.cgi?id=280312
rdar://114258826

Reviewed by Mike Wyrzykowski.

Initial implementation of animations API that is based on the latest <model>
explainer where animation properties follow more closely to similar ones in
the media element. These API are implemented for the model process only.

This initial implementation is based on a single animation track (first animation
found in the model). Properties supported are: autoplay, loop, playbackRate,
duration, paused, currentTime. Methods supported are play() and pause().

* LayoutTests/model-element/model-element-animations-current-time-expected.txt: Added.
* LayoutTests/model-element/model-element-animations-current-time.html: Added.
* LayoutTests/model-element/model-element-animations-initial-values-expected.txt: Added.
* LayoutTests/model-element/model-element-animations-initial-values.html: Added.
* LayoutTests/model-element/model-element-animations-loop-expected.txt: Added.
* LayoutTests/model-element/model-element-animations-loop.html: Added.
* LayoutTests/model-element/model-element-animations-playback-expected.txt: Added.
* LayoutTests/model-element/model-element-animations-playback.html: Added.
* LayoutTests/model-element/model-element-animations-replace-sources-expected.txt: Added.
* LayoutTests/model-element/model-element-animations-replace-sources.html: Added.
* LayoutTests/model-element/resources/model-utils.js:
(sleepForSeconds):
* LayoutTests/model-element/resources/stopwatch-30s.usdz: Added.
* LayoutTests/model-element/resources/stopwatch-60s.usdz: Added.
* Source/WebCore/Modules/model-element/HTMLModelElement.cpp:
(WebCore::HTMLModelElement::createModelPlayer):
Set up the model player with the initial autoplay, loop, and playbackRate values.
(WebCore::HTMLModelElement::attributeChanged):
(WebCore::HTMLModelElement::setPlaybackRate):
(WebCore::HTMLModelElement::duration const):
(WebCore::HTMLModelElement::paused const):
(WebCore::HTMLModelElement::play):
(WebCore::HTMLModelElement::pause):
(WebCore::HTMLModelElement::setPaused):
(WebCore::HTMLModelElement::autoplay const):
(WebCore::HTMLModelElement::updateAutoplay):
(WebCore::HTMLModelElement::loop const):
(WebCore::HTMLModelElement::updateLoop):
(WebCore::HTMLModelElement::currentTime const):
(WebCore::HTMLModelElement::setCurrentTime):
* Source/WebCore/Modules/model-element/HTMLModelElement.h:
* Source/WebCore/Modules/model-element/HTMLModelElement.idl:
* Source/WebCore/Modules/model-element/ModelPlayer.cpp:
(WebCore::ModelPlayer::setAutoplay):
(WebCore::ModelPlayer::setLoop):
(WebCore::ModelPlayer::setPlaybackRate):
(WebCore::ModelPlayer::duration const):
(WebCore::ModelPlayer::paused const):
(WebCore::ModelPlayer::setPaused):
(WebCore::ModelPlayer::currentTime const):
(WebCore::ModelPlayer::setCurrentTime):
* Source/WebCore/Modules/model-element/ModelPlayer.h:
* Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.h:
* Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.messages.in:
* Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.mm:
Introduce WKModelProcessModelPlayerProxyObjCAdapter which implements WKSRKEntityDelegate
for getting callbacks when the animation playback state changes.
(-[WKModelProcessModelPlayerProxyObjCAdapter initWithModelProcessModelPlayerProxy:]):
(-[WKModelProcessModelPlayerProxyObjCAdapter entityAnimationPlaybackStateDidUpdate:]):
(WebKit::ModelProcessModelPlayerProxy::ModelProcessModelPlayerProxy):
(WebKit::ModelProcessModelPlayerProxy::startAnimating):
Pass in the autoplay state when setting up the animation. Set up the entity
with the loop and playbackRate values.
(WebKit::ModelProcessModelPlayerProxy::animationPlaybackStateDidUpdate):
Send the latest animation playback state back to ModelProcessModelPlayer in the WP.
(WebKit::ModelProcessModelPlayerProxy::didFinishLoading):
(WebKit::ModelProcessModelPlayerProxy::setAutoplay):
(WebKit::ModelProcessModelPlayerProxy::setLoop):
(WebKit::ModelProcessModelPlayerProxy::setPlaybackRate):
(WebKit::ModelProcessModelPlayerProxy::duration const):
(WebKit::ModelProcessModelPlayerProxy::paused const):
(WebKit::ModelProcessModelPlayerProxy::setPaused):
(WebKit::ModelProcessModelPlayerProxy::currentTime const):
(WebKit::ModelProcessModelPlayerProxy::setCurrentTime):
* Source/WebKit/WebKitSwift/RealityKit/RKEntity.swift:
(WKSRKEntity.delegate):
(WKSRKEntity.animationPlaybackController):
(WKSRKEntity.animationFinishedSubscription):
(WKSRKEntity._duration):
(WKSRKEntity._playbackRate):
(WKSRKEntity.duration):
(WKSRKEntity.loop):
(WKSRKEntity.playbackRate):
(WKSRKEntity.paused):
(WKSRKEntity.currentTime):
(WKSRKEntity.setUpAnimation(with:)):
If an animation track is found in the entity, call playAnimation with startsPaused
based on the current autoplay state. That returns an animation playback controller
that we can use to play/pause this current animation, set its playback rate, and
query its current time. Subscribe to the PlaybackCompleted animation event, and on
animation completion, we can set up the next animation based on the current
loop and playbackRate values.
(WKSRKEntity.animationPlaybackStateDidUpdate):
(WKSRKEntity.startAnimating): Deleted.
* Source/WebKit/WebKitSwift/RealityKit/RealityKitBridging.h:
* Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.cpp:
(WebKit::ModelProcessModelPlayer::sendWithAsyncReply):
(WebKit::ModelProcessModelPlayer::didUpdateAnimationPlaybackState):
(WebKit::ModelProcessModelPlayer::setAutoplay):
(WebKit::ModelProcessModelPlayer::setLoop):
(WebKit::ModelProcessModelPlayer::setPlaybackRate):
(WebKit::ModelProcessModelPlayer::duration const):
(WebKit::ModelProcessModelPlayer::paused const):
(WebKit::ModelProcessModelPlayer::setPaused):
(WebKit::ModelProcessModelPlayer::currentTime const):
We make our best effort to estimate the current time based on the last reported
animation time, playback rate, and duration from the model process, and the clock
timestamp of that last update. If the web content just manually set the
current time and it's still pending being handled by the model process, return
that previously set time.
(WebKit::ModelProcessModelPlayer::setCurrentTime):
Clamp the set time to be between 0 and the animation duration. Store the time being
set to m_pendingCurrentTime, and clear it in the completion handler.

* Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.h:
* Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.messages.in:

Canonical link: https://commits.webkit.org/284359@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list