Changeset 286068 in webkit


Ignore:
Timestamp:
Nov 19, 2021 11:05:53 AM (8 months ago)
Author:
graouts@webkit.org
Message:

[Model] add support for seeking animations
https://bugs.webkit.org/show_bug.cgi?id=233362
<rdar://problem/85428812>

Reviewed by Wenson Hsieh.

Source/WebCore:

We add three new promise-based methods to the HTMLModelElement IDL to allow seeking the animation
built into the USDZ asset: animationDuration(), animationCurrentTime() and setAnimationCurrentTime().
All these methods are promise-based.

  • Modules/model-element/HTMLModelElement.cpp:

(WebCore::HTMLModelElement::animationDuration):
(WebCore::HTMLModelElement::animationCurrentTime):
(WebCore::HTMLModelElement::setAnimationCurrentTime):

  • Modules/model-element/HTMLModelElement.h:
  • Modules/model-element/HTMLModelElement.idl:
  • Modules/model-element/ModelPlayer.h:
  • Modules/model-element/dummy/DummyModelPlayer.cpp:

(WebCore::DummyModelPlayer::animationDuration):
(WebCore::DummyModelPlayer::animationCurrentTime):
(WebCore::DummyModelPlayer::setAnimationCurrentTime):

  • Modules/model-element/dummy/DummyModelPlayer.h:
  • Modules/model-element/scenekit/SceneKitModelPlayer.h:
  • Modules/model-element/scenekit/SceneKitModelPlayer.mm:

(WebCore::SceneKitModelPlayer::animationDuration):
(WebCore::SceneKitModelPlayer::animationCurrentTime):
(WebCore::SceneKitModelPlayer::setAnimationCurrentTime):

Source/WebCore/PAL:

Add the new ARQL SPIs we are using to query the animation duration, the current and time
as well as allowing to set the latter.

  • pal/spi/ios/SystemPreviewSPI.h:
  • pal/spi/mac/SystemPreviewSPI.h:

Source/WebKit:

Expose new WebPageProxy messages to let the WebProcess message the UIProcess
to call into ASVInlinePreview methods to get and set the animation's current
time as well as getting its duration.

  • UIProcess/Cocoa/ModelElementControllerCocoa.mm:

(WebKit::ModelElementController::animationDurationForModelElement):
(WebKit::ModelElementController::animationCurrentTimeForModelElement):
(WebKit::ModelElementController::setAnimationCurrentTimeForModelElement):

  • UIProcess/ModelElementController.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::modelElementAnimationDuration):
(WebKit::WebPageProxy::modelElementAnimationCurrentTime):
(WebKit::WebPageProxy::modelElementSetAnimationCurrentTime):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/Model/ARKitInlinePreviewModelPlayer.h:
  • WebProcess/Model/ARKitInlinePreviewModelPlayer.mm:

(WebKit::ARKitInlinePreviewModelPlayer::animationDuration):
(WebKit::ARKitInlinePreviewModelPlayer::animationCurrentTime):
(WebKit::ARKitInlinePreviewModelPlayer::setAnimationCurrentTime):

Location:
trunk/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286067 r286068  
     12021-11-19  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for seeking animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233362
     5        <rdar://problem/85428812>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        We add three new promise-based methods to the HTMLModelElement IDL to allow seeking the animation
     10        built into the USDZ asset: animationDuration(), animationCurrentTime() and setAnimationCurrentTime().
     11        All these methods are promise-based.
     12
     13        * Modules/model-element/HTMLModelElement.cpp:
     14        (WebCore::HTMLModelElement::animationDuration):
     15        (WebCore::HTMLModelElement::animationCurrentTime):
     16        (WebCore::HTMLModelElement::setAnimationCurrentTime):
     17        * Modules/model-element/HTMLModelElement.h:
     18        * Modules/model-element/HTMLModelElement.idl:
     19        * Modules/model-element/ModelPlayer.h:
     20        * Modules/model-element/dummy/DummyModelPlayer.cpp:
     21        (WebCore::DummyModelPlayer::animationDuration):
     22        (WebCore::DummyModelPlayer::animationCurrentTime):
     23        (WebCore::DummyModelPlayer::setAnimationCurrentTime):
     24        * Modules/model-element/dummy/DummyModelPlayer.h:
     25        * Modules/model-element/scenekit/SceneKitModelPlayer.h:
     26        * Modules/model-element/scenekit/SceneKitModelPlayer.mm:
     27        (WebCore::SceneKitModelPlayer::animationDuration):
     28        (WebCore::SceneKitModelPlayer::animationCurrentTime):
     29        (WebCore::SceneKitModelPlayer::setAnimationCurrentTime):
     30
    1312021-11-19  Ryan Haddad  <ryanhaddad@apple.com>
    232
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp

    r286066 r286068  
    5757#include "RenderModel.h"
    5858#include <wtf/IsoMallocInlines.h>
     59#include <wtf/Seconds.h>
    5960#include <wtf/URL.h>
    6061
     
    468469}
    469470
     471void HTMLModelElement::animationDuration(DurationPromise&& promise)
     472{
     473    if (!m_modelPlayer) {
     474        promise.reject();
     475        return;
     476    }
     477
     478    m_modelPlayer->animationDuration([promise = WTFMove(promise)] (std::optional<Seconds> duration) mutable {
     479        if (!duration)
     480            promise.reject();
     481        else
     482            promise.resolve(duration->seconds());
     483    });
     484}
     485
     486void HTMLModelElement::animationCurrentTime(CurrentTimePromise&& promise)
     487{
     488    if (!m_modelPlayer) {
     489        promise.reject();
     490        return;
     491    }
     492
     493    m_modelPlayer->animationCurrentTime([promise = WTFMove(promise)] (std::optional<Seconds> currentTime) mutable {
     494        if (!currentTime)
     495            promise.reject();
     496        else
     497            promise.resolve(currentTime->seconds());
     498    });
     499}
     500
     501void HTMLModelElement::setAnimationCurrentTime(double currentTime, DOMPromiseDeferred<void>&& promise)
     502{
     503    if (!m_modelPlayer) {
     504        promise.reject();
     505        return;
     506    }
     507
     508    m_modelPlayer->setAnimationCurrentTime(Seconds(currentTime), [promise = WTFMove(promise)] (bool success) mutable {
     509        if (success)
     510            promise.resolve();
     511        else
     512            promise.reject();
     513    });
     514}
     515
    470516// MARK: - Audio support.
    471517
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h

    r286066 r286068  
    8585    void setIsLoopingAnimation(bool, DOMPromiseDeferred<void>&&);
    8686
     87    using DurationPromise = DOMPromiseDeferred<IDLDouble>;
     88    void animationDuration(DurationPromise&&);
     89    using CurrentTimePromise = DOMPromiseDeferred<IDLDouble>;
     90    void animationCurrentTime(CurrentTimePromise&&);
     91    void setAnimationCurrentTime(double, DOMPromiseDeferred<void>&&);
     92
    8793    using HasAudioPromise = DOMPromiseDeferred<IDLBoolean>;
    8894    void hasAudio(HasAudioPromise&&);
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl

    r286066 r286068  
    4545    Promise<undefined> setIsLoopingAnimation(boolean looping);
    4646
     47    Promise<double> animationDuration();
     48    Promise<double> animationCurrentTime();
     49    Promise<undefined> setAnimationCurrentTime(double currentTime);
     50
    4751    Promise<boolean> hasAudio();
    4852    Promise<boolean> isMuted();
  • trunk/Source/WebCore/Modules/model-element/ModelPlayer.h

    r286066 r286068  
    3333#include <wtf/Forward.h>
    3434#include <wtf/MonotonicTime.h>
     35#include <wtf/Seconds.h>
    3536
    3637namespace WebCore {
     
    5657    virtual void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
    5758    virtual void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) = 0;
     59    virtual void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) = 0;
     60    virtual void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) = 0;
     61    virtual void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) = 0;
    5862    virtual void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
    5963    virtual void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp

    r286066 r286068  
    8787}
    8888
    89 void DummyModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
    90 {
    91 }
    92 
    9389void DummyModelPlayer::isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&)
    9490{
     
    9692
    9793void DummyModelPlayer::setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&)
     94{
     95}
     96
     97void DummyModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&)
     98{
     99}
     100
     101void DummyModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&)
     102{
     103}
     104
     105void DummyModelPlayer::setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&)
     106{
     107}
     108
     109void DummyModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
    98110{
    99111}
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h

    r286066 r286068  
    5454    void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    5555    void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
     56    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     57    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     58    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
    5659    void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    5760    void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h

    r286066 r286068  
    6868    void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    6969    void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
     70    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     71    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     72    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
    7073    void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    7174    void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm

    r286066 r286068  
    113113}
    114114
     115void SceneKitModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&)
     116{
     117}
     118
     119void SceneKitModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&)
     120{
     121}
     122
     123void SceneKitModelPlayer::setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&)
     124{
     125}
     126
    115127void SceneKitModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
    116128{
  • trunk/Source/WebCore/PAL/ChangeLog

    r286067 r286068  
     12021-11-19  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for seeking animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233362
     5        <rdar://problem/85428812>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Add the new ARQL SPIs we are using to query the animation duration, the current and time
     10        as well as allowing to set the latter.
     11
     12        * pal/spi/ios/SystemPreviewSPI.h:
     13        * pal/spi/mac/SystemPreviewSPI.h:
     14
    1152021-11-19  Ryan Haddad  <ryanhaddad@apple.com>
    216
  • trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h

    r286066 r286068  
    109109- (void)setCameraTransform:(simd_float3)transform;
    110110
     111@property (nonatomic, readwrite) NSTimeInterval currentTime;
     112@property (nonatomic, readonly) NSTimeInterval duration;
    111113@property (nonatomic, readwrite) BOOL isLooping;
    112114@property (nonatomic, readonly) BOOL isPlaying;
  • trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h

    r286066 r286068  
    5959- (void)setCameraTransform:(simd_float3)transform;
    6060
     61@property (nonatomic, readwrite) NSTimeInterval currentTime;
     62@property (nonatomic, readonly) NSTimeInterval duration;
    6163@property (nonatomic, readwrite) BOOL isLooping;
    6264@property (nonatomic, readonly) BOOL isPlaying;
  • trunk/Source/WebKit/ChangeLog

    r286067 r286068  
     12021-11-19  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for seeking animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233362
     5        <rdar://problem/85428812>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Expose new WebPageProxy messages to let the WebProcess message the UIProcess
     10        to call into ASVInlinePreview methods to get and set the animation's current
     11        time as well as getting its duration.
     12
     13        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
     14        (WebKit::ModelElementController::animationDurationForModelElement):
     15        (WebKit::ModelElementController::animationCurrentTimeForModelElement):
     16        (WebKit::ModelElementController::setAnimationCurrentTimeForModelElement):
     17        * UIProcess/ModelElementController.h:
     18        * UIProcess/WebPageProxy.cpp:
     19        (WebKit::WebPageProxy::modelElementAnimationDuration):
     20        (WebKit::WebPageProxy::modelElementAnimationCurrentTime):
     21        (WebKit::WebPageProxy::modelElementSetAnimationCurrentTime):
     22        * UIProcess/WebPageProxy.h:
     23        * UIProcess/WebPageProxy.messages.in:
     24        * WebProcess/Model/ARKitInlinePreviewModelPlayer.h:
     25        * WebProcess/Model/ARKitInlinePreviewModelPlayer.mm:
     26        (WebKit::ARKitInlinePreviewModelPlayer::animationDuration):
     27        (WebKit::ARKitInlinePreviewModelPlayer::animationCurrentTime):
     28        (WebKit::ARKitInlinePreviewModelPlayer::setAnimationCurrentTime):
     29
    1302021-11-19  Ryan Haddad  <ryanhaddad@apple.com>
    231
  • trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm

    r286066 r286068  
    391391}
    392392
     393void ModelElementController::animationDurationForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
     394{
     395    auto* preview = previewForModelIdentifier(modelIdentifier);
     396    if (!previewHasAnimationSupport(preview)) {
     397        completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General }));
     398        return;
     399    }
     400
     401#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     402    completionHandler(Seconds([preview duration]));
     403#else
     404    ASSERT_NOT_REACHED();
     405#endif
     406}
     407
     408void ModelElementController::animationCurrentTimeForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
     409{
     410    auto* preview = previewForModelIdentifier(modelIdentifier);
     411    if (!previewHasAnimationSupport(preview)) {
     412        completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General }));
     413        return;
     414    }
     415
     416#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     417    completionHandler(Seconds([preview currentTime]));
     418#else
     419    ASSERT_NOT_REACHED();
     420#endif
     421}
     422
     423void ModelElementController::setAnimationCurrentTimeForModelElement(ModelIdentifier modelIdentifier, Seconds currentTime, CompletionHandler<void(bool)>&& completionHandler)
     424{
     425    auto* preview = previewForModelIdentifier(modelIdentifier);
     426    if (!previewHasAnimationSupport(preview)) {
     427        completionHandler(false);
     428        return;
     429    }
     430
     431#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     432    preview.currentTime = currentTime.seconds();
     433    completionHandler(true);
     434#else
     435    ASSERT_NOT_REACHED();
     436#endif
     437}
    393438
    394439static bool previewHasAudioSupport(ASVInlinePreview *preview)
  • trunk/Source/WebKit/UIProcess/ModelElementController.h

    r286066 r286068  
    5959    void isLoopingAnimationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
    6060    void setIsLoopingAnimationForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
     61    void animationDurationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
     62    void animationCurrentTimeForModelElement(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
     63    void setAnimationCurrentTimeForModelElement(ModelIdentifier, Seconds, CompletionHandler<void(bool)>&&);
    6164    void hasAudioForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
    6265    void isMutedForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r286066 r286068  
    1086410864}
    1086510865
     10866void WebPageProxy::modelElementAnimationDuration(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
     10867{
     10868    modelElementController()->animationDurationForModelElement(modelIdentifier, WTFMove(completionHandler));
     10869}
     10870
     10871void WebPageProxy::modelElementAnimationCurrentTime(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
     10872{
     10873    modelElementController()->animationCurrentTimeForModelElement(modelIdentifier, WTFMove(completionHandler));
     10874}
     10875
     10876void WebPageProxy::modelElementSetAnimationCurrentTime(ModelIdentifier modelIdentifier, Seconds currentTime, CompletionHandler<void(bool)>&& completionHandler)
     10877{
     10878    modelElementController()->setAnimationCurrentTimeForModelElement(modelIdentifier, currentTime, WTFMove(completionHandler));
     10879}
     10880
    1086610881void WebPageProxy::modelElementHasAudio(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, ResourceError>)>&& completionHandler)
    1086710882{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r286066 r286068  
    595595    void modelElementIsLoopingAnimation(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
    596596    void modelElementSetIsLoopingAnimation(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
     597    void modelElementAnimationDuration(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
     598    void modelElementAnimationCurrentTime(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
     599    void modelElementSetAnimationCurrentTime(ModelIdentifier, Seconds, CompletionHandler<void(bool)>&&);
    597600    void modelElementHasAudio(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
    598601    void modelElementIsMuted(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r286066 r286068  
    602602    ModelElementIsLoopingAnimation(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
    603603    ModelElementSetIsLoopingAnimation(struct WebKit::ModelIdentifier modelIdentifier, bool isLooping) -> (bool success) Async
     604    ModelElementAnimationDuration(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<Seconds, WebCore::ResourceError> result) Async
     605    ModelElementAnimationCurrentTime(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<Seconds, WebCore::ResourceError> result) Async
     606    ModelElementSetAnimationCurrentTime(struct WebKit::ModelIdentifier modelIdentifier, Seconds currentTime) -> (bool success) Async
    604607    ModelElementHasAudio(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
    605608    ModelElementIsMuted(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h

    r286066 r286068  
    6060    void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    6161    void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
     62    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     63    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
     64    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
    6265    void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
    6366    void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm

    r286066 r286068  
    197197}
    198198
     199void ARKitInlinePreviewModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&& completionHandler)
     200{
     201    auto modelIdentifier = this->modelIdentifier();
     202    if (!modelIdentifier) {
     203        completionHandler(std::nullopt);
     204        return;
     205    }
     206
     207    RefPtr strongPage = m_page.get();
     208    if (!strongPage) {
     209        completionHandler(std::nullopt);
     210        return;
     211    }
     212
     213    CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<Seconds, WebCore::ResourceError> result) mutable {
     214        if (!result) {
     215            completionHandler(std::nullopt);
     216            return;
     217        }
     218
     219        completionHandler(*result);
     220    };
     221
     222    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementAnimationDuration(*modelIdentifier), WTFMove(remoteCompletionHandler));
     223}
     224
     225void ARKitInlinePreviewModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&& completionHandler)
     226{
     227    auto modelIdentifier = this->modelIdentifier();
     228    if (!modelIdentifier) {
     229        completionHandler(std::nullopt);
     230        return;
     231    }
     232
     233    RefPtr strongPage = m_page.get();
     234    if (!strongPage) {
     235        completionHandler(std::nullopt);
     236        return;
     237    }
     238
     239    CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<Seconds, WebCore::ResourceError> result) mutable {
     240        if (!result) {
     241            completionHandler(std::nullopt);
     242            return;
     243        }
     244
     245        completionHandler(*result);
     246    };
     247
     248    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementAnimationCurrentTime(*modelIdentifier), WTFMove(remoteCompletionHandler));
     249}
     250
     251void ARKitInlinePreviewModelPlayer::setAnimationCurrentTime(Seconds currentTime, CompletionHandler<void(bool success)>&& completionHandler)
     252{
     253    auto modelIdentifier = this->modelIdentifier();
     254    if (!modelIdentifier) {
     255        completionHandler(false);
     256        return;
     257    }
     258
     259    RefPtr strongPage = m_page.get();
     260    if (!strongPage) {
     261        completionHandler(false);
     262        return;
     263    }
     264
     265    CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable {
     266        completionHandler(success);
     267    };
     268
     269    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetAnimationCurrentTime(*modelIdentifier, currentTime), WTFMove(remoteCompletionHandler));
     270}
     271
    199272void ARKitInlinePreviewModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&& completionHandler)
    200273{
Note: See TracChangeset for help on using the changeset viewer.