Changeset 286048 in webkit


Ignore:
Timestamp:
Nov 18, 2021 11:27:51 PM (8 months ago)
Author:
graouts@webkit.org
Message:

[Model] add support for pausing and resuming animations
https://bugs.webkit.org/show_bug.cgi?id=233319
<rdar://problem/85428464>

Reviewed by Wenson Hsieh.

Source/WebCore:

We add three new promise-based methods to the HTMLModelElement IDL to control the playback state
of the animation built into the USDZ asset: isPlayingAnimation(), playAnimation() and pauseAnimation().
All these methods are promise-based.

  • Modules/model-element/HTMLModelElement.cpp:

(WebCore::HTMLModelElement::isPlayingAnimation):
(WebCore::HTMLModelElement::setAnimationIsPlaying):
(WebCore::HTMLModelElement::playAnimation):
(WebCore::HTMLModelElement::pauseAnimation):

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

(WebCore::DummyModelPlayer::isPlayingAnimation):
(WebCore::DummyModelPlayer::setAnimationIsPlaying):

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

(WebCore::SceneKitModelPlayer::isPlayingAnimation):
(WebCore::SceneKitModelPlayer::setAnimationIsPlaying):

Source/WebCore/PAL:

Add the new ARQL SPIs we are using.

  • 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 playback
state.

  • UIProcess/Cocoa/ModelElementControllerCocoa.mm:

(WebKit::previewHasAnimationSupport):
(WebKit::ModelElementController::isPlayingAnimationForModelElement):
(WebKit::ModelElementController::setAnimationIsPlayingForModelElement):

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

(WebKit::WebPageProxy::modelElementIsPlayingAnimation):
(WebKit::WebPageProxy::modelElementSetAnimationIsPlaying):

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

(WebKit::ARKitInlinePreviewModelPlayer::isPlayingAnimation):
(WebKit::ARKitInlinePreviewModelPlayer::setAnimationIsPlaying):

Source/WTF:

Add a new compile-time flag for the new ARQL SPIs we are using.

  • wtf/PlatformEnableCocoa.h:
Location:
trunk/Source
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r286019 r286048  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for pausing and resuming animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233319
     5        <rdar://problem/85428464>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Add a new compile-time flag for the new ARQL SPIs we are using.
     10
     11        * wtf/PlatformEnableCocoa.h:
     12
    1132021-11-18  Antoine Quint  <graouts@webkit.org>
    214
  • trunk/Source/WTF/wtf/PlatformEnableCocoa.h

    r286019 r286048  
    747747#if (ENABLE(ARKIT_INLINE_PREVIEW_MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 120400) || (ENABLE(ARKIT_INLINE_PREVIEW_IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 150400)
    748748#define ENABLE_ARKIT_INLINE_PREVIEW_CAMERA_TRANSFORM 1
    749 #endif
     749#define ENABLE_ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL 1
     750#endif
  • trunk/Source/WebCore/ChangeLog

    r286046 r286048  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for pausing and resuming animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233319
     5        <rdar://problem/85428464>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        We add three new promise-based methods to the HTMLModelElement IDL to control the playback state
     10        of the animation built into the USDZ asset: isPlayingAnimation(), playAnimation() and pauseAnimation().
     11        All these methods are promise-based.
     12
     13        * Modules/model-element/HTMLModelElement.cpp:
     14        (WebCore::HTMLModelElement::isPlayingAnimation):
     15        (WebCore::HTMLModelElement::setAnimationIsPlaying):
     16        (WebCore::HTMLModelElement::playAnimation):
     17        (WebCore::HTMLModelElement::pauseAnimation):
     18        * Modules/model-element/HTMLModelElement.h:
     19        * Modules/model-element/HTMLModelElement.idl:
     20        * Modules/model-element/ModelPlayer.h:
     21        * Modules/model-element/dummy/DummyModelPlayer.cpp:
     22        (WebCore::DummyModelPlayer::isPlayingAnimation):
     23        (WebCore::DummyModelPlayer::setAnimationIsPlaying):
     24        * Modules/model-element/dummy/DummyModelPlayer.h:
     25        * Modules/model-element/scenekit/SceneKitModelPlayer.h:
     26        * Modules/model-element/scenekit/SceneKitModelPlayer.mm:
     27        (WebCore::SceneKitModelPlayer::isPlayingAnimation):
     28        (WebCore::SceneKitModelPlayer::setAnimationIsPlaying):
     29
    1302021-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
    231
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp

    r286019 r286048  
    364364}
    365365
    366 // MARK: Camera support.
     366// MARK: - Camera support.
    367367
    368368void HTMLModelElement::getCamera(CameraPromise&& promise)
     
    396396}
    397397
     398// MARK: - Animations support.
     399
     400void HTMLModelElement::isPlayingAnimation(IsPlayingAnimationPromise&& promise)
     401{
     402    if (!m_modelPlayer) {
     403        promise.reject();
     404        return;
     405    }
     406
     407    m_modelPlayer->isPlayingAnimation([promise = WTFMove(promise)] (std::optional<bool> isPlaying) mutable {
     408        if (!isPlaying)
     409            promise.reject();
     410        else
     411            promise.resolve(*isPlaying);
     412    });
     413}
     414
     415void HTMLModelElement::setAnimationIsPlaying(bool isPlaying, DOMPromiseDeferred<void>&& promise)
     416{
     417    if (!m_modelPlayer) {
     418        promise.reject();
     419        return;
     420    }
     421
     422    m_modelPlayer->setAnimationIsPlaying(isPlaying, [promise = WTFMove(promise)] (bool success) mutable {
     423        if (success)
     424            promise.resolve();
     425        else
     426            promise.reject();
     427    });
     428}
     429
     430void HTMLModelElement::playAnimation(DOMPromiseDeferred<void>&& promise)
     431{
     432    setAnimationIsPlaying(true, WTFMove(promise));
     433}
     434
     435void HTMLModelElement::pauseAnimation(DOMPromiseDeferred<void>&& promise)
     436{
     437    setAnimationIsPlaying(false, WTFMove(promise));
     438}
     439
    398440}
    399441
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h

    r286019 r286048  
    7676    void setCamera(HTMLModelElementCamera, DOMPromiseDeferred<void>&&);
    7777
     78    using IsPlayingAnimationPromise = DOMPromiseDeferred<IDLBoolean>;
     79    void isPlayingAnimation(IsPlayingAnimationPromise&&);
     80    void playAnimation(DOMPromiseDeferred<void>&&);
     81    void pauseAnimation(DOMPromiseDeferred<void>&&);
     82
    7883    bool isDraggableIgnoringAttributes() const final { return true; }
    7984
     
    106111    void dragDidEnd(MouseEvent&);
    107112
     113    void setAnimationIsPlaying(bool, DOMPromiseDeferred<void>&&);
     114
    108115    URL m_sourceURL;
    109116    CachedResourceHandle<CachedRawResource> m_resource;
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl

    r286019 r286048  
    3737    Promise<HTMLModelElementCamera> getCamera();
    3838    Promise<undefined> setCamera(HTMLModelElementCamera camera);
     39
     40    Promise<boolean> isPlayingAnimation();
     41    Promise<undefined> playAnimation();
     42    Promise<undefined> pauseAnimation();
    3943};
  • trunk/Source/WebCore/Modules/model-element/ModelPlayer.h

    r286019 r286048  
    5151    virtual void handleMouseUp(const LayoutPoint&, MonotonicTime) = 0;
    5252    virtual void getCamera(CompletionHandler<void(std::optional<HTMLModelElementCamera>&&)>&&) = 0;
    53     virtual void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) = 0;
     53    virtual void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool success)>&&) = 0;
     54    virtual void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
     55    virtual void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) = 0;
    5456};
    5557
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp

    r286019 r286048  
    7575}
    7676
    77 void DummyModelPlayer::setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&)
     77void DummyModelPlayer::setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool success)>&&)
     78{
     79}
     80
     81void DummyModelPlayer::isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&)
     82{
     83}
     84
     85void DummyModelPlayer::setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&)
    7886{
    7987}
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h

    r286019 r286048  
    4949    void handleMouseUp(const LayoutPoint&, MonotonicTime) override;
    5050    void getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&&) override;
    51     void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
     51    void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool success)>&&) override;
     52    void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     53    void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
    5254
    5355    WeakPtr<ModelPlayerClient> m_client;
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h

    r286019 r286048  
    6363    void handleMouseUp(const LayoutPoint&, MonotonicTime) override;
    6464    void getCamera(CompletionHandler<void(std::optional<HTMLModelElementCamera>&&)>&&) override;
    65     void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
     65    void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool success)>&&) override;
     66    void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     67    void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
    6668
    6769    // SceneKitModelLoaderClient overrides.
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm

    r286019 r286048  
    9393}
    9494
    95 void SceneKitModelPlayer::setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&)
     95void SceneKitModelPlayer::setCamera(HTMLModelElementCamera, CompletionHandler<void(bool success)>&&)
     96{
     97}
     98
     99void SceneKitModelPlayer::isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&)
     100{
     101}
     102
     103void SceneKitModelPlayer::setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&)
    96104{
    97105}
  • trunk/Source/WebCore/PAL/ChangeLog

    r286019 r286048  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for pausing and resuming animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233319
     5        <rdar://problem/85428464>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Add the new ARQL SPIs we are using.
     10
     11        * pal/spi/ios/SystemPreviewSPI.h:
     12        * pal/spi/mac/SystemPreviewSPI.h:
     13
    1142021-11-18  Antoine Quint  <graouts@webkit.org>
    215
  • trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h

    r286019 r286048  
    109109- (void)setCameraTransform:(simd_float3)transform;
    110110
     111@property (nonatomic, readonly) BOOL isPlaying;
     112typedef void (^ASVSetIsPlayingReplyBlock) (BOOL isPlaying, NSError * _Nullable error);
     113- (void)setIsPlaying:(BOOL)isPlaying reply:(ASVSetIsPlayingReplyBlock)reply;
     114
    111115@end
    112116
  • trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h

    r286019 r286048  
    5959- (void)setCameraTransform:(simd_float3)transform;
    6060
     61@property (nonatomic, readonly) BOOL isPlaying;
     62typedef void (^ASVSetIsPlayingReplyBlock) (BOOL isPlaying, NSError * _Nullable error);
     63- (void)setIsPlaying:(BOOL)isPlaying reply:(ASVSetIsPlayingReplyBlock)reply;
     64
    6165@end
    6266
  • trunk/Source/WebKit/ChangeLog

    r286047 r286048  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for pausing and resuming animations
     4        https://bugs.webkit.org/show_bug.cgi?id=233319
     5        <rdar://problem/85428464>
     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 playback
     11        state.
     12
     13        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
     14        (WebKit::previewHasAnimationSupport):
     15        (WebKit::ModelElementController::isPlayingAnimationForModelElement):
     16        (WebKit::ModelElementController::setAnimationIsPlayingForModelElement):
     17        * UIProcess/ModelElementController.h:
     18        * UIProcess/WebPageProxy.cpp:
     19        (WebKit::WebPageProxy::modelElementIsPlayingAnimation):
     20        (WebKit::WebPageProxy::modelElementSetAnimationIsPlaying):
     21        * UIProcess/WebPageProxy.h:
     22        * UIProcess/WebPageProxy.messages.in:
     23        * WebProcess/Model/ARKitInlinePreviewModelPlayer.h:
     24        * WebProcess/Model/ARKitInlinePreviewModelPlayer.mm:
     25        (WebKit::ARKitInlinePreviewModelPlayer::isPlayingAnimation):
     26        (WebKit::ARKitInlinePreviewModelPlayer::setAnimationIsPlaying):
     27
    1282021-11-18  Myles C. Maxfield  <mmaxfield@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm

    r286023 r286048  
    246246{
    247247    auto* preview = previewForModelIdentifier(modelIdentifier);
    248     if (!preview || !previewHasCameraSupport(preview)) {
     248    if (!previewHasCameraSupport(preview)) {
    249249        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler), error = WebCore::ResourceError { WebCore::ResourceError::Type::General }] () mutable {
    250250            if (weakThis)
     
    281281{
    282282    auto* preview = previewForModelIdentifier(modelIdentifier);
    283     if (!preview || !previewHasCameraSupport(preview)) {
     283    if (!previewHasCameraSupport(preview)) {
    284284        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
    285285            if (weakThis)
     
    303303}
    304304
    305 #endif
    306 
    307 }
    308 
    309 #endif
     305static bool previewHasAnimationSupport(ASVInlinePreview *preview)
     306{
     307#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     308    return [preview respondsToSelector:@selector(isPlaying)];
     309#else
     310    return false;
     311#endif
     312}
     313
     314void ModelElementController::isPlayingAnimationForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&& completionHandler)
     315{
     316    auto* preview = previewForModelIdentifier(modelIdentifier);
     317    if (!previewHasAnimationSupport(preview)) {
     318        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler), error = WebCore::ResourceError { WebCore::ResourceError::Type::General }] () mutable {
     319            if (weakThis)
     320                completionHandler(makeUnexpected(error));
     321        });
     322        return;
     323    }
     324
     325#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     326    auto isPlaying = [preview isPlaying];
     327#else
     328    auto isPlaying = false;
     329#endif
     330    callOnMainRunLoop([isPlaying, weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
     331        if (weakThis)
     332            completionHandler(isPlaying);
     333    });
     334}
     335
     336void ModelElementController::setAnimationIsPlayingForModelElement(ModelIdentifier modelIdentifier, bool isPlaying, CompletionHandler<void(bool)>&& completionHandler)
     337{
     338    auto* preview = previewForModelIdentifier(modelIdentifier);
     339    if (!previewHasAnimationSupport(preview)) {
     340        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
     341            if (weakThis)
     342                completionHandler(false);
     343        });
     344        return;
     345    }
     346
     347#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
     348    [preview setIsPlaying:isPlaying reply:makeBlockPtr([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] (BOOL, NSError *error) mutable {
     349        callOnMainRunLoop([error, weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler)] () mutable {
     350            if (weakThis)
     351                completionHandler(!error);
     352        });
     353    }).get()];
     354#else
     355    callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
     356        if (weakThis)
     357            completionHandler(false);
     358    });
     359#endif
     360}
     361
     362#endif
     363
     364}
     365
     366#endif
  • trunk/Source/WebKit/UIProcess/ModelElementController.h

    r286019 r286048  
    5555    void getCameraForModelElement(ModelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&&);
    5656    void setCameraForModelElement(ModelIdentifier, WebCore::HTMLModelElementCamera, CompletionHandler<void(bool)>&&);
     57    void isPlayingAnimationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     58    void setAnimationIsPlayingForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
    5759#endif
    5860#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r286019 r286048  
    1083410834
    1083510835#if ENABLE(ARKIT_INLINE_PREVIEW)
    10836 void WebPageProxy::modelElementGetCamera(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&& completionHandler)
     10836void WebPageProxy::modelElementGetCamera(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, ResourceError>)>&& completionHandler)
    1083710837{
    1083810838    modelElementController()->getCameraForModelElement(modelIdentifier, WTFMove(completionHandler));
     
    1084210842{
    1084310843    modelElementController()->setCameraForModelElement(modelIdentifier, camera, WTFMove(completionHandler));
     10844}
     10845
     10846void WebPageProxy::modelElementIsPlayingAnimation(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, ResourceError>)>&& completionHandler)
     10847{
     10848    modelElementController()->isPlayingAnimationForModelElement(modelIdentifier, WTFMove(completionHandler));
     10849}
     10850
     10851void WebPageProxy::modelElementSetAnimationIsPlaying(ModelIdentifier modelIdentifier, bool isPlaying, CompletionHandler<void(bool)>&& completionHandler)
     10852{
     10853    modelElementController()->setAnimationIsPlayingForModelElement(modelIdentifier, isPlaying, WTFMove(completionHandler));
    1084410854}
    1084510855#endif
     
    1085310863
    1085410864#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    10855 void WebPageProxy::modelElementDidCreatePreview(const URL& url, const String& uuid, const FloatSize& size, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&& completionHandler)
     10865void WebPageProxy::modelElementDidCreatePreview(const URL& url, const String& uuid, const FloatSize& size, CompletionHandler<void(Expected<std::pair<String, uint32_t>, ResourceError>)>&& completionHandler)
    1085610866{
    1085710867    modelElementController()->modelElementDidCreatePreview(url, uuid, size, WTFMove(completionHandler));
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r286019 r286048  
    591591    void modelElementGetCamera(ModelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&&);
    592592    void modelElementSetCamera(ModelIdentifier, WebCore::HTMLModelElementCamera, CompletionHandler<void(bool)>&&);
     593    void modelElementIsPlayingAnimation(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     594    void modelElementSetAnimationIsPlaying(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
    593595#endif
    594596#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r286019 r286048  
    598598    ModelElementGetCamera(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError> result) Async
    599599    ModelElementSetCamera(struct WebKit::ModelIdentifier modelIdentifier, struct WebCore::HTMLModelElementCamera camera) -> (bool success) Async
     600    ModelElementIsPlayingAnimation(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
     601    ModelElementSetAnimationIsPlaying(struct WebKit::ModelIdentifier modelIdentifier, bool isPlaying) -> (bool success) Async
    600602#endif
    601603
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h

    r286019 r286048  
    5555    void enterFullscreen() override;
    5656    void getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&&) override;
    57     void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
     57    void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool success)>&&) override;
     58    void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     59    void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
    5860
    5961    WeakPtr<WebPage> m_page;
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm

    r286019 r286048  
    8282}
    8383
    84 void ARKitInlinePreviewModelPlayer::setCamera(WebCore::HTMLModelElementCamera camera, CompletionHandler<void(bool&&)>&& completionHandler)
     84void ARKitInlinePreviewModelPlayer::setCamera(WebCore::HTMLModelElementCamera camera, CompletionHandler<void(bool success)>&& completionHandler)
    8585{
    8686    auto modelIdentifier = this->modelIdentifier();
     
    9797
    9898    CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable {
    99         completionHandler(WTFMove(success));
     99        completionHandler(success);
    100100    };
    101101
     
    103103}
    104104
     105void ARKitInlinePreviewModelPlayer::isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&& completionHandler)
     106{
     107    auto modelIdentifier = this->modelIdentifier();
     108    if (!modelIdentifier) {
     109        completionHandler(std::nullopt);
     110        return;
     111    }
     112
     113    auto* strongPage = m_page.get();
     114    if (!strongPage) {
     115        completionHandler(std::nullopt);
     116        return;
     117    }
     118
     119    CompletionHandler<void(Expected<bool, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<bool, WebCore::ResourceError> result) mutable {
     120        if (!result) {
     121            completionHandler(std::nullopt);
     122            return;
     123        }
     124
     125        completionHandler(*result);
     126    };
     127
     128    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementIsPlayingAnimation(*modelIdentifier), WTFMove(remoteCompletionHandler));
     129}
     130
     131void ARKitInlinePreviewModelPlayer::setAnimationIsPlaying(bool isPlaying, CompletionHandler<void(bool success)>&& completionHandler)
     132{
     133    auto modelIdentifier = this->modelIdentifier();
     134    if (!modelIdentifier) {
     135        completionHandler(false);
     136        return;
     137    }
     138
     139    auto* strongPage = m_page.get();
     140    if (!strongPage) {
     141        completionHandler(false);
     142        return;
     143    }
     144
     145    CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable {
     146        completionHandler(success);
     147    };
     148
     149    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetAnimationIsPlaying(*modelIdentifier, isPlaying), WTFMove(remoteCompletionHandler));
     150}
     151
    105152}
    106153
Note: See TracChangeset for help on using the changeset viewer.