Title: [286068] trunk/Source
Revision
286068
Author
grao...@webkit.org
Date
2021-11-19 11:05:53 -0800 (Fri, 19 Nov 2021)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286067 => 286068)


--- trunk/Source/WebCore/ChangeLog	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/ChangeLog	2021-11-19 19:05:53 UTC (rev 286068)
@@ -1,3 +1,33 @@
+2021-11-19  Antoine Quint  <grao...@webkit.org>
+
+        [Model] add support for seeking animations
+        https://bugs.webkit.org/show_bug.cgi?id=233362
+        <rdar://problem/85428812>
+
+        Reviewed by Wenson Hsieh.
+
+        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):
+
 2021-11-19  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, reverting r286047.

Modified: trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2021-11-19 19:05:53 UTC (rev 286068)
@@ -56,6 +56,7 @@
 #include "RenderLayerModelObject.h"
 #include "RenderModel.h"
 #include <wtf/IsoMallocInlines.h>
+#include <wtf/Seconds.h>
 #include <wtf/URL.h>
 
 namespace WebCore {
@@ -467,6 +468,51 @@
     });
 }
 
+void HTMLModelElement::animationDuration(DurationPromise&& promise)
+{
+    if (!m_modelPlayer) {
+        promise.reject();
+        return;
+    }
+
+    m_modelPlayer->animationDuration([promise = WTFMove(promise)] (std::optional<Seconds> duration) mutable {
+        if (!duration)
+            promise.reject();
+        else
+            promise.resolve(duration->seconds());
+    });
+}
+
+void HTMLModelElement::animationCurrentTime(CurrentTimePromise&& promise)
+{
+    if (!m_modelPlayer) {
+        promise.reject();
+        return;
+    }
+
+    m_modelPlayer->animationCurrentTime([promise = WTFMove(promise)] (std::optional<Seconds> currentTime) mutable {
+        if (!currentTime)
+            promise.reject();
+        else
+            promise.resolve(currentTime->seconds());
+    });
+}
+
+void HTMLModelElement::setAnimationCurrentTime(double currentTime, DOMPromiseDeferred<void>&& promise)
+{
+    if (!m_modelPlayer) {
+        promise.reject();
+        return;
+    }
+
+    m_modelPlayer->setAnimationCurrentTime(Seconds(currentTime), [promise = WTFMove(promise)] (bool success) mutable {
+        if (success)
+            promise.resolve();
+        else
+            promise.reject();
+    });
+}
+
 // MARK: - Audio support.
 
 void HTMLModelElement::hasAudio(HasAudioPromise&& promise)

Modified: trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -84,6 +84,12 @@
     void isLoopingAnimation(IsLoopingAnimationPromise&&);
     void setIsLoopingAnimation(bool, DOMPromiseDeferred<void>&&);
 
+    using DurationPromise = DOMPromiseDeferred<IDLDouble>;
+    void animationDuration(DurationPromise&&);
+    using CurrentTimePromise = DOMPromiseDeferred<IDLDouble>;
+    void animationCurrentTime(CurrentTimePromise&&);
+    void setAnimationCurrentTime(double, DOMPromiseDeferred<void>&&);
+
     using HasAudioPromise = DOMPromiseDeferred<IDLBoolean>;
     void hasAudio(HasAudioPromise&&);
     using IsMutedPromise = DOMPromiseDeferred<IDLBoolean>;

Modified: trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2021-11-19 19:05:53 UTC (rev 286068)
@@ -44,6 +44,10 @@
     Promise<boolean> isLoopingAnimation();
     Promise<undefined> setIsLoopingAnimation(boolean looping);
 
+    Promise<double> animationDuration();
+    Promise<double> animationCurrentTime();
+    Promise<undefined> setAnimationCurrentTime(double currentTime);
+
     Promise<boolean> hasAudio();
     Promise<boolean> isMuted();
     Promise<undefined> setIsMuted(boolean isMuted);

Modified: trunk/Source/WebCore/Modules/model-element/ModelPlayer.h (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -32,6 +32,7 @@
 #include <optional>
 #include <wtf/Forward.h>
 #include <wtf/MonotonicTime.h>
+#include <wtf/Seconds.h>
 
 namespace WebCore {
 
@@ -55,6 +56,9 @@
     virtual void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) = 0;
     virtual void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
     virtual void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) = 0;
+    virtual void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) = 0;
+    virtual void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) = 0;
+    virtual void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) = 0;
     virtual void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
     virtual void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) = 0;
     virtual void setIsMuted(bool, CompletionHandler<void(bool success)>&&) = 0;

Modified: trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp	2021-11-19 19:05:53 UTC (rev 286068)
@@ -86,18 +86,30 @@
 {
 }
 
-void DummyModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
+void DummyModelPlayer::isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&)
 {
 }
 
-void DummyModelPlayer::isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&)
+void DummyModelPlayer::setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&)
 {
 }
 
-void DummyModelPlayer::setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&)
+void DummyModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&)
 {
 }
 
+void DummyModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&)
+{
+}
+
+void DummyModelPlayer::setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&)
+{
+}
+
+void DummyModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
+{
+}
+
 void DummyModelPlayer::isMuted(CompletionHandler<void(std::optional<bool>&&)>&&)
 {
 }

Modified: trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -53,6 +53,9 @@
     void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
     void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
+    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
     void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override;

Modified: trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -67,6 +67,9 @@
     void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
     void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
+    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
     void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override;

Modified: trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm (286067 => 286068)


--- trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm	2021-11-19 19:05:53 UTC (rev 286068)
@@ -112,6 +112,18 @@
 {
 }
 
+void SceneKitModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&)
+{
+}
+
+void SceneKitModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&)
+{
+}
+
+void SceneKitModelPlayer::setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&)
+{
+}
+
 void SceneKitModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&)
 {
 }

Modified: trunk/Source/WebCore/PAL/ChangeLog (286067 => 286068)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-11-19 19:05:53 UTC (rev 286068)
@@ -1,3 +1,17 @@
+2021-11-19  Antoine Quint  <grao...@webkit.org>
+
+        [Model] add support for seeking animations
+        https://bugs.webkit.org/show_bug.cgi?id=233362
+        <rdar://problem/85428812>
+
+        Reviewed by Wenson Hsieh.
+
+        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:
+
 2021-11-19  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, reverting r286047.

Modified: trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h (286067 => 286068)


--- trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -108,6 +108,8 @@
 - (void)getCameraTransform:(ASVCameraTransformReplyBlock)reply;
 - (void)setCameraTransform:(simd_float3)transform;
 
+@property (nonatomic, readwrite) NSTimeInterval currentTime;
+@property (nonatomic, readonly) NSTimeInterval duration;
 @property (nonatomic, readwrite) BOOL isLooping;
 @property (nonatomic, readonly) BOOL isPlaying;
 typedef void (^ASVSetIsPlayingReplyBlock) (BOOL isPlaying, NSError * _Nullable error);

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h (286067 => 286068)


--- trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -58,6 +58,8 @@
 - (void)getCameraTransform:(ASVCameraTransformReplyBlock)reply;
 - (void)setCameraTransform:(simd_float3)transform;
 
+@property (nonatomic, readwrite) NSTimeInterval currentTime;
+@property (nonatomic, readonly) NSTimeInterval duration;
 @property (nonatomic, readwrite) BOOL isLooping;
 @property (nonatomic, readonly) BOOL isPlaying;
 typedef void (^ASVSetIsPlayingReplyBlock) (BOOL isPlaying, NSError * _Nullable error);

Modified: trunk/Source/WebKit/ChangeLog (286067 => 286068)


--- trunk/Source/WebKit/ChangeLog	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/ChangeLog	2021-11-19 19:05:53 UTC (rev 286068)
@@ -1,3 +1,32 @@
+2021-11-19  Antoine Quint  <grao...@webkit.org>
+
+        [Model] add support for seeking animations
+        https://bugs.webkit.org/show_bug.cgi?id=233362
+        <rdar://problem/85428812>
+
+        Reviewed by Wenson Hsieh.
+
+        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):
+
 2021-11-19  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, reverting r286047.

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (286067 => 286068)


--- trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2021-11-19 19:05:53 UTC (rev 286068)
@@ -390,7 +390,52 @@
 #endif
 }
 
+void ModelElementController::animationDurationForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
+{
+    auto* preview = previewForModelIdentifier(modelIdentifier);
+    if (!previewHasAnimationSupport(preview)) {
+        completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General }));
+        return;
+    }
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
+    completionHandler(Seconds([preview duration]));
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
+void ModelElementController::animationCurrentTimeForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
+{
+    auto* preview = previewForModelIdentifier(modelIdentifier);
+    if (!previewHasAnimationSupport(preview)) {
+        completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General }));
+        return;
+    }
+
+#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
+    completionHandler(Seconds([preview currentTime]));
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
+void ModelElementController::setAnimationCurrentTimeForModelElement(ModelIdentifier modelIdentifier, Seconds currentTime, CompletionHandler<void(bool)>&& completionHandler)
+{
+    auto* preview = previewForModelIdentifier(modelIdentifier);
+    if (!previewHasAnimationSupport(preview)) {
+        completionHandler(false);
+        return;
+    }
+
+#if ENABLE(ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL)
+    preview.currentTime = currentTime.seconds();
+    completionHandler(true);
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
 static bool previewHasAudioSupport(ASVInlinePreview *preview)
 {
 #if ENABLE(ARKIT_INLINE_PREVIEW_AUDIO_CONTROL)

Modified: trunk/Source/WebKit/UIProcess/ModelElementController.h (286067 => 286068)


--- trunk/Source/WebKit/UIProcess/ModelElementController.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/UIProcess/ModelElementController.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -58,6 +58,9 @@
     void setAnimationIsPlayingForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
     void isLoopingAnimationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void setIsLoopingAnimationForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
+    void animationDurationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
+    void animationCurrentTimeForModelElement(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
+    void setAnimationCurrentTimeForModelElement(ModelIdentifier, Seconds, CompletionHandler<void(bool)>&&);
     void hasAudioForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void isMutedForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void setIsMutedForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (286067 => 286068)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-19 19:05:53 UTC (rev 286068)
@@ -10863,6 +10863,21 @@
     modelElementController()->setIsLoopingAnimationForModelElement(modelIdentifier, isLooping, WTFMove(completionHandler));
 }
 
+void WebPageProxy::modelElementAnimationDuration(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
+{
+    modelElementController()->animationDurationForModelElement(modelIdentifier, WTFMove(completionHandler));
+}
+
+void WebPageProxy::modelElementAnimationCurrentTime(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&& completionHandler)
+{
+    modelElementController()->animationCurrentTimeForModelElement(modelIdentifier, WTFMove(completionHandler));
+}
+
+void WebPageProxy::modelElementSetAnimationCurrentTime(ModelIdentifier modelIdentifier, Seconds currentTime, CompletionHandler<void(bool)>&& completionHandler)
+{
+    modelElementController()->setAnimationCurrentTimeForModelElement(modelIdentifier, currentTime, WTFMove(completionHandler));
+}
+
 void WebPageProxy::modelElementHasAudio(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, ResourceError>)>&& completionHandler)
 {
     modelElementController()->hasAudioForModelElement(modelIdentifier, WTFMove(completionHandler));

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (286067 => 286068)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -594,6 +594,9 @@
     void modelElementSetAnimationIsPlaying(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
     void modelElementIsLoopingAnimation(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void modelElementSetIsLoopingAnimation(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);
+    void modelElementAnimationDuration(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
+    void modelElementAnimationCurrentTime(ModelIdentifier, CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)>&&);
+    void modelElementSetAnimationCurrentTime(ModelIdentifier, Seconds, CompletionHandler<void(bool)>&&);
     void modelElementHasAudio(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void modelElementIsMuted(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&);
     void modelElementSetIsMuted(ModelIdentifier, bool, CompletionHandler<void(bool)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (286067 => 286068)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-11-19 19:05:53 UTC (rev 286068)
@@ -601,6 +601,9 @@
     ModelElementSetAnimationIsPlaying(struct WebKit::ModelIdentifier modelIdentifier, bool isPlaying) -> (bool success) Async
     ModelElementIsLoopingAnimation(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
     ModelElementSetIsLoopingAnimation(struct WebKit::ModelIdentifier modelIdentifier, bool isLooping) -> (bool success) Async
+    ModelElementAnimationDuration(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<Seconds, WebCore::ResourceError> result) Async
+    ModelElementAnimationCurrentTime(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<Seconds, WebCore::ResourceError> result) Async
+    ModelElementSetAnimationCurrentTime(struct WebKit::ModelIdentifier modelIdentifier, Seconds currentTime) -> (bool success) Async
     ModelElementHasAudio(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
     ModelElementIsMuted(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async
     ModelElementSetIsMuted(struct WebKit::ModelIdentifier modelIdentifier, bool isMuted) -> (bool success) Async

Modified: trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h (286067 => 286068)


--- trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h	2021-11-19 19:05:53 UTC (rev 286068)
@@ -59,6 +59,9 @@
     void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override;
     void isLoopingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsLoopingAnimation(bool, CompletionHandler<void(bool success)>&&) override;
+    void animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&&) override;
+    void setAnimationCurrentTime(Seconds, CompletionHandler<void(bool success)>&&) override;
     void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override;
     void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override;

Modified: trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm (286067 => 286068)


--- trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm	2021-11-19 18:52:40 UTC (rev 286067)
+++ trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm	2021-11-19 19:05:53 UTC (rev 286068)
@@ -196,6 +196,79 @@
     strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetIsLoopingAnimation(*modelIdentifier, isLooping), WTFMove(remoteCompletionHandler));
 }
 
+void ARKitInlinePreviewModelPlayer::animationDuration(CompletionHandler<void(std::optional<Seconds>&&)>&& completionHandler)
+{
+    auto modelIdentifier = this->modelIdentifier();
+    if (!modelIdentifier) {
+        completionHandler(std::nullopt);
+        return;
+    }
+
+    RefPtr strongPage = m_page.get();
+    if (!strongPage) {
+        completionHandler(std::nullopt);
+        return;
+    }
+
+    CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<Seconds, WebCore::ResourceError> result) mutable {
+        if (!result) {
+            completionHandler(std::nullopt);
+            return;
+        }
+
+        completionHandler(*result);
+    };
+
+    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementAnimationDuration(*modelIdentifier), WTFMove(remoteCompletionHandler));
+}
+
+void ARKitInlinePreviewModelPlayer::animationCurrentTime(CompletionHandler<void(std::optional<Seconds>&&)>&& completionHandler)
+{
+    auto modelIdentifier = this->modelIdentifier();
+    if (!modelIdentifier) {
+        completionHandler(std::nullopt);
+        return;
+    }
+
+    RefPtr strongPage = m_page.get();
+    if (!strongPage) {
+        completionHandler(std::nullopt);
+        return;
+    }
+
+    CompletionHandler<void(Expected<Seconds, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<Seconds, WebCore::ResourceError> result) mutable {
+        if (!result) {
+            completionHandler(std::nullopt);
+            return;
+        }
+
+        completionHandler(*result);
+    };
+
+    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementAnimationCurrentTime(*modelIdentifier), WTFMove(remoteCompletionHandler));
+}
+
+void ARKitInlinePreviewModelPlayer::setAnimationCurrentTime(Seconds currentTime, CompletionHandler<void(bool success)>&& completionHandler)
+{
+    auto modelIdentifier = this->modelIdentifier();
+    if (!modelIdentifier) {
+        completionHandler(false);
+        return;
+    }
+
+    RefPtr strongPage = m_page.get();
+    if (!strongPage) {
+        completionHandler(false);
+        return;
+    }
+
+    CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable {
+        completionHandler(success);
+    };
+
+    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetAnimationCurrentTime(*modelIdentifier, currentTime), WTFMove(remoteCompletionHandler));
+}
+
 void ARKitInlinePreviewModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&& completionHandler)
 {
     auto modelIdentifier = this->modelIdentifier();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to