Title: [292902] trunk
Revision
292902
Author
grao...@webkit.org
Date
2022-04-15 02:37:47 -0700 (Fri, 15 Apr 2022)

Log Message

[model] ASVInlinePreview objects don't get cleared when the model source changes
https://bugs.webkit.org/show_bug.cgi?id=239064
<rdar://problem/90391037>

Reviewed by Dean Jackson.

Source/WebCore:

Expose two new window.internals methods for tests to be able to query the list of UUIDs
currently loaded in the UI process and get the UUID for a given <model> element.

Test: model-element/model-element-inline-preview-deletion-upon-source-change.html

* Modules/model-element/HTMLModelElement.cpp:
(WebCore::HTMLModelElement::inlinePreviewUUIDForTesting const):
* Modules/model-element/HTMLModelElement.h:
* Modules/model-element/HTMLModelElement.idl:
* Modules/model-element/ModelPlayer.cpp:
(WebCore::ModelPlayer::inlinePreviewUUIDForTesting const):
* Modules/model-element/ModelPlayer.h:
* loader/FrameLoaderClient.h:
* testing/Internals.cpp:
(WebCore::Internals::modelInlinePreviewUUIDs const):
(WebCore::Internals::modelInlinePreviewUUIDForModelElement const):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

We add a new ModelElementDestroyRemotePreview message going from the Web process to the
UI process to notify that an ASVInlinePreview with a given UUID should be cleared. This
message is sent via ~ARKitInlinePreviewModelPlayerMac since any unused resource will
trigger the destruction of such objects.

For testing purposes, we also add a new ModelInlinePreviewUUIDs message going from the
Web process to the UI process to retreive the list of UUIDs for the ASVInlinePreview
objects currently loaded in the UI process. This will allow tests to check whether
the UUID for a given <model> element is correctly removed from the UI process.

* UIProcess/Cocoa/ModelElementControllerCocoa.mm:
(WebKit::ModelElementController::modelElementDestroyRemotePreview):
(WebKit::ModelElementController::inlinePreviewUUIDs):
* UIProcess/ModelElementController.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::modelElementDestroyRemotePreview):
(WebKit::WebPageProxy::modelInlinePreviewUUIDs):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h:
* WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm:
(WebKit::ARKitInlinePreviewModelPlayerMac::~ARKitInlinePreviewModelPlayerMac):
(WebKit::ARKitInlinePreviewModelPlayerMac::inlinePreviewUUIDForTesting const):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::modelInlinePreviewUUIDs const):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

LayoutTests:

Add a new test which loads a <model> element with a valid resource, checks its UUID against
those loaded in the UI process, and then removes the <model> source to check that same UUID
is not longer loaded.

This test is currently disabled on OpenSource bots.

* model-element/model-element-inline-preview-deletion-upon-source-change-expected.txt: Added.
* model-element/model-element-inline-preview-deletion-upon-source-change.html: Added.
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (292901 => 292902)


--- trunk/LayoutTests/ChangeLog	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/LayoutTests/ChangeLog	2022-04-15 09:37:47 UTC (rev 292902)
@@ -1,3 +1,22 @@
+2022-04-14  Antoine Quint  <grao...@apple.com>
+
+        [model] ASVInlinePreview objects don't get cleared when the model source changes
+        https://bugs.webkit.org/show_bug.cgi?id=239064
+        <rdar://problem/90391037>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test which loads a <model> element with a valid resource, checks its UUID against
+        those loaded in the UI process, and then removes the <model> source to check that same UUID
+        is not longer loaded.
+
+        This test is currently disabled on OpenSource bots.
+
+        * model-element/model-element-inline-preview-deletion-upon-source-change-expected.txt: Added.
+        * model-element/model-element-inline-preview-deletion-upon-source-change.html: Added.
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2022-04-14  Matteo Flores  <matteo_flo...@apple.com>
 
         EXPECTATIONS: [ Monterey wk2 ] 7 /paymentrequest/* tests are constant text failures

Added: trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change-expected.txt (0 => 292902)


--- trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change-expected.txt	2022-04-15 09:37:47 UTC (rev 292902)
@@ -0,0 +1,3 @@
+
+PASS Changing a <model> resource should clear any associated remote preview.
+

Added: trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change.html (0 => 292902)


--- trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change.html	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-inline-preview-deletion-upon-source-change.html	2022-04-15 09:37:47 UTC (rev 292902)
@@ -0,0 +1,23 @@
+<script src=""
+<script src=""
+<script src=""
+<script>
+
+promise_test(async test => {
+    assert_own_property(window, "internals", "This test only work within the WebKit testing environment.");
+
+    // First, we load a <model> with an existing resource.
+    const model = await readyModel(test);
+    const uuid = window.internals.modelInlinePreviewUUIDForModelElement(model);
+    const initialUUIDS = await window.internals.modelInlinePreviewUUIDs();
+    assert_true(initialUUIDS.includes(uuid), "The UUID for the model matches one of the remote previews.");
+    
+    // Then, we unload it by setting a non-existent resource.
+    model.textContent = "";
+    const updatedUUIDS = await window.internals.modelInlinePreviewUUIDs();
+    assert_false(updatedUUIDS.includes(uuid), "The UUID for the model is no longer present in the list of remote previews.");
+}, "Changing a <model> resource should clear any associated remote preview.");
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (292901 => 292902)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-04-15 09:37:47 UTC (rev 292902)
@@ -3428,6 +3428,7 @@
 # This test requires ARQL SPIs not yet available to OpenSource builds.
 model-element/model-element-camera.html [ Skip ]
 model-element/model-element-interactive-dragging.html [ Skip ]
+model-element/model-element-inline-preview-deletion-upon-source-change.html [ Skip ]
 
 # webkit.org/b/201982 These are flaky failures on iOS
 fast/images/exif-orientation-svg-feimage.html [ Pass Failure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (292901 => 292902)


--- trunk/LayoutTests/platform/mac/TestExpectations	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2022-04-15 09:37:47 UTC (rev 292902)
@@ -110,6 +110,7 @@
 # This test requires ARQL SPIs not yet available to OpenSource builds.
 model-element/model-element-camera.html [ Skip ]
 model-element/model-element-interactive-dragging.html [ Skip ]
+model-element/model-element-inline-preview-deletion-upon-source-change.html [ Skip ]
 
 # Accessibility tests for notifications that don't exist or aren't needed on Mac OS X.
 accessibility/aria-checkbox-sends-notification.html

Modified: trunk/Source/WebCore/ChangeLog (292901 => 292902)


--- trunk/Source/WebCore/ChangeLog	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/ChangeLog	2022-04-15 09:37:47 UTC (rev 292902)
@@ -1,3 +1,30 @@
+2022-04-14  Antoine Quint  <grao...@apple.com>
+
+        [model] ASVInlinePreview objects don't get cleared when the model source changes
+        https://bugs.webkit.org/show_bug.cgi?id=239064
+        <rdar://problem/90391037>
+
+        Reviewed by Dean Jackson.
+
+        Expose two new window.internals methods for tests to be able to query the list of UUIDs
+        currently loaded in the UI process and get the UUID for a given <model> element.
+
+        Test: model-element/model-element-inline-preview-deletion-upon-source-change.html
+
+        * Modules/model-element/HTMLModelElement.cpp:
+        (WebCore::HTMLModelElement::inlinePreviewUUIDForTesting const):
+        * Modules/model-element/HTMLModelElement.h:
+        * Modules/model-element/HTMLModelElement.idl:
+        * Modules/model-element/ModelPlayer.cpp:
+        (WebCore::ModelPlayer::inlinePreviewUUIDForTesting const):
+        * Modules/model-element/ModelPlayer.h:
+        * loader/FrameLoaderClient.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::modelInlinePreviewUUIDs const):
+        (WebCore::Internals::modelInlinePreviewUUIDForModelElement const):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2022-04-14  Martin Robinson  <mrobin...@webkit.org>
 
         [GTK] AddressSanitizer: heap-buffer-overflow in WebCore::Length::ref()

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2022-04-15 09:37:47 UTC (rev 292902)
@@ -668,6 +668,15 @@
     return downcast<RenderReplaced>(*renderer()).replacedContentRect().size();
 }
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+String HTMLModelElement::inlinePreviewUUIDForTesting() const
+{
+    if (!m_modelPlayer)
+        return emptyString();
+    return m_modelPlayer->inlinePreviewUUIDForTesting();
 }
+#endif
 
+}
+
 #endif // ENABLE(MODEL_ELEMENT)

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -109,6 +109,10 @@
 
     void sizeMayHaveChanged();
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+    WEBCORE_EXPORT String inlinePreviewUUIDForTesting() const;
+#endif
+
 private:
     HTMLModelElement(const QualifiedName&, Document&);
 

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2022-04-15 09:37:47 UTC (rev 292902)
@@ -26,7 +26,9 @@
 [
     Conditional=MODEL_ELEMENT,
     EnabledBySetting=ModelElementEnabled,
+    ExportToWrappedFunction,
     Exposed=Window,
+    JSGenerateToNativeObject
 ] interface HTMLModelElement : HTMLElement {
     [URL] readonly attribute USVString currentSrc;
 

Modified: trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp (292901 => 292902)


--- trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp	2022-04-15 09:37:47 UTC (rev 292902)
@@ -44,4 +44,9 @@
 {
 }
 
+String ModelPlayer::inlinePreviewUUIDForTesting() const
+{
+    return emptyString();
 }
+
+}

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


--- trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -65,6 +65,7 @@
     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;
+    virtual String inlinePreviewUUIDForTesting() const;
 #if PLATFORM(COCOA)
     virtual Vector<RetainPtr<id>> accessibilityChildren() = 0;
 #endif

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (292901 => 292902)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -389,6 +389,10 @@
 #endif
 
     virtual bool isParentProcessAFullWebBrowser() const { return false; }
+
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+    virtual void modelInlinePreviewUUIDs(CompletionHandler<void(Vector<String>)>&&) const { }
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.cpp (292901 => 292902)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-04-15 09:37:47 UTC (rev 292902)
@@ -363,6 +363,10 @@
 #include "TextRecognitionResult.h"
 #endif
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+#include "HTMLModelElement.h"
+#endif
+
 using JSC::CallData;
 using JSC::CodeBlock;
 using JSC::FunctionExecutable;
@@ -6763,4 +6767,34 @@
         observer->overrideSearchTermForTesting(term);
 }
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+
+void Internals::modelInlinePreviewUUIDs(ModelInlinePreviewUUIDsPromise&& promise) const
+{
+    auto* document = contextDocument();
+    if (!document) {
+        promise.reject(InvalidStateError);
+        return;
+    }
+
+    auto* frame = document->frame();
+    if (!frame) {
+        promise.reject(InvalidStateError);
+        return;
+    }
+
+    CompletionHandler<void(Vector<String>&&)> completionHandler = [promise = WTFMove(promise)] (Vector<String> uuids) mutable {
+        promise.resolve(uuids);
+    };
+
+    frame->loader().client().modelInlinePreviewUUIDs(WTFMove(completionHandler));
+}
+
+String Internals::modelInlinePreviewUUIDForModelElement(const HTMLModelElement& modelElement) const
+{
+    return modelElement.inlinePreviewUUIDForTesting();
+}
+
+#endif
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (292901 => 292902)


--- trunk/Source/WebCore/testing/Internals.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/testing/Internals.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -157,6 +157,10 @@
 #endif
 #endif
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+class HTMLModelElement;
+#endif
+
 namespace ImageOverlay {
 class CroppedImage;
 }
@@ -1296,6 +1300,12 @@
 
     void overrideModalContainerSearchTermForTesting(const String& term);
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+    using ModelInlinePreviewUUIDsPromise = DOMPromiseDeferred<IDLSequence<IDLDOMString>>;
+    void modelInlinePreviewUUIDs(ModelInlinePreviewUUIDsPromise&&) const;
+    String modelInlinePreviewUUIDForModelElement(const HTMLModelElement&) const;
+#endif
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (292901 => 292902)


--- trunk/Source/WebCore/testing/Internals.idl	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebCore/testing/Internals.idl	2022-04-15 09:37:47 UTC (rev 292902)
@@ -1137,4 +1137,7 @@
     [Conditional=SERVICE_WORKER] PushSubscription createPushSubscription(USVString endpoint, EpochTimeStamp? expirationTime, ArrayBuffer serverVAPIDPublicKey, ArrayBuffer clientECDHPublicKey, ArrayBuffer auth);
 
     undefined overrideModalContainerSearchTermForTesting(DOMString term);
+
+    [Conditional=ARKIT_INLINE_PREVIEW_MAC] Promise<sequence<DOMString>> modelInlinePreviewUUIDs();
+    [Conditional=ARKIT_INLINE_PREVIEW_MAC] DOMString modelInlinePreviewUUIDForModelElement(HTMLModelElement modelElement);
 };

Modified: trunk/Source/WebKit/ChangeLog (292901 => 292902)


--- trunk/Source/WebKit/ChangeLog	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/ChangeLog	2022-04-15 09:37:47 UTC (rev 292902)
@@ -1,3 +1,38 @@
+2022-04-14  Antoine Quint  <grao...@apple.com>
+
+        [model] ASVInlinePreview objects don't get cleared when the model source changes
+        https://bugs.webkit.org/show_bug.cgi?id=239064
+        <rdar://problem/90391037>
+
+        Reviewed by Dean Jackson.
+
+        We add a new ModelElementDestroyRemotePreview message going from the Web process to the
+        UI process to notify that an ASVInlinePreview with a given UUID should be cleared. This
+        message is sent via ~ARKitInlinePreviewModelPlayerMac since any unused resource will
+        trigger the destruction of such objects. 
+
+        For testing purposes, we also add a new ModelInlinePreviewUUIDs message going from the
+        Web process to the UI process to retreive the list of UUIDs for the ASVInlinePreview
+        objects currently loaded in the UI process. This will allow tests to check whether
+        the UUID for a given <model> element is correctly removed from the UI process.
+
+        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
+        (WebKit::ModelElementController::modelElementDestroyRemotePreview):
+        (WebKit::ModelElementController::inlinePreviewUUIDs):
+        * UIProcess/ModelElementController.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::modelElementDestroyRemotePreview):
+        (WebKit::WebPageProxy::modelInlinePreviewUUIDs):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h:
+        * WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm:
+        (WebKit::ARKitInlinePreviewModelPlayerMac::~ARKitInlinePreviewModelPlayerMac):
+        (WebKit::ARKitInlinePreviewModelPlayerMac::inlinePreviewUUIDForTesting const):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::modelInlinePreviewUUIDs const):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2022-04-14  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Undo option after invoking "Markup Image" says "Undo Paste"

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (292901 => 292902)


--- trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2022-04-15 09:37:47 UTC (rev 292902)
@@ -240,6 +240,11 @@
     }).get()];
 }
 
+void ModelElementController::modelElementDestroyRemotePreview(String uuid)
+{
+    m_inlinePreviews.remove(uuid);
+}
+
 RetainPtr<ASVInlinePreview> ModelElementController::previewForUUID(const String& uuid)
 {
     return m_inlinePreviews.get(uuid);
@@ -299,6 +304,12 @@
     }).get()];
 }
 
+void ModelElementController::inlinePreviewUUIDs(CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+{
+    completionHandler(WTF::map(m_inlinePreviews, [](auto& entry) {
+        return entry.key;
+    }));
+}
 #endif
 
 #if ENABLE(ARKIT_INLINE_PREVIEW)

Modified: trunk/Source/WebKit/UIProcess/ModelElementController.h (292901 => 292902)


--- trunk/Source/WebKit/UIProcess/ModelElementController.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/UIProcess/ModelElementController.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -75,10 +75,12 @@
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     void modelElementCreateRemotePreview(String, WebCore::FloatSize, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&&);
     void modelElementLoadRemotePreview(String, URL, CompletionHandler<void(std::optional<WebCore::ResourceError>&&)>&&);
+    void modelElementDestroyRemotePreview(String);
     void modelElementSizeDidChange(const String& uuid, WebCore::FloatSize, CompletionHandler<void(Expected<MachSendRight, WebCore::ResourceError>)>&&);
     void handleMouseDownForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
     void handleMouseMoveForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
     void handleMouseUpForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
+    void inlinePreviewUUIDs(CompletionHandler<void(Vector<String>&&)>&&);
 #endif
 
 private:

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (292901 => 292902)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-04-15 09:37:47 UTC (rev 292902)
@@ -11218,6 +11218,11 @@
     modelElementController()->modelElementLoadRemotePreview(uuid, url, WTFMove(completionHandler));
 }
 
+void WebPageProxy::modelElementDestroyRemotePreview(const String& uuid)
+{
+    modelElementController()->modelElementDestroyRemotePreview(uuid);
+}
+
 void WebPageProxy::modelElementSizeDidChange(const String& uuid, WebCore::FloatSize size, CompletionHandler<void(Expected<MachSendRight, WebCore::ResourceError>)>&& completionHandler)
 {
     modelElementController()->modelElementSizeDidChange(uuid, size, WTFMove(completionHandler));
@@ -11237,6 +11242,11 @@
 {
     modelElementController()->handleMouseUpForModelElement(uuid, flippedLocationInElement, timestamp);
 }
+
+void WebPageProxy::modelInlinePreviewUUIDs(CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+{
+    modelElementController()->inlinePreviewUUIDs(WTFMove(completionHandler));
+}
 #endif
 
 #if !PLATFORM(COCOA) && !ENABLE(CONTENT_FILTERING_IN_NETWORKING_PROCESS)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (292901 => 292902)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -617,10 +617,12 @@
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     void modelElementCreateRemotePreview(const String&, const WebCore::FloatSize&, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&&);
     void modelElementLoadRemotePreview(const String&, const URL&, CompletionHandler<void(std::optional<WebCore::ResourceError>&&)>&&);
+    void modelElementDestroyRemotePreview(const String&);
     void modelElementSizeDidChange(const String&, WebCore::FloatSize, CompletionHandler<void(Expected<MachSendRight, WebCore::ResourceError>)>&&);
     void handleMouseDownForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
     void handleMouseMoveForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
     void handleMouseUpForModelElement(const String&, const WebCore::LayoutPoint&, MonotonicTime);
+    void modelInlinePreviewUUIDs(CompletionHandler<void(Vector<String>&&)>&&);
 #endif
 
 #if ENABLE(APPLE_PAY_AMS_UI)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (292901 => 292902)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2022-04-15 09:37:47 UTC (rev 292902)
@@ -597,10 +597,12 @@
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     ModelElementCreateRemotePreview(String uuid, WebCore::FloatSize size) -> (Expected<std::pair<String, uint32_t>, WebCore::ResourceError> result)
     ModelElementLoadRemotePreview(String uuid, URL url) -> (std::optional<WebCore::ResourceError> error)
+    ModelElementDestroyRemotePreview(String uuid)
     ModelElementSizeDidChange(String uuid, WebCore::FloatSize size) -> (Expected<MachSendRight, WebCore::ResourceError> result)
     HandleMouseDownForModelElement(String uuid, WebCore::LayoutPoint flippedLocationInElement, MonotonicTime timestamp)
     HandleMouseMoveForModelElement(String uuid, WebCore::LayoutPoint flippedLocationInElement, MonotonicTime timestamp)
     HandleMouseUpForModelElement(String uuid, WebCore::LayoutPoint flippedLocationInElement, MonotonicTime timestamp)
+    ModelInlinePreviewUUIDs() -> (Vector<String> uuids)
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW)
     ModelElementGetCamera(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError> result)

Modified: trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h (292901 => 292902)


--- trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -58,6 +58,7 @@
     void handleMouseDown(const WebCore::LayoutPoint&, MonotonicTime) override;
     void handleMouseMove(const WebCore::LayoutPoint&, MonotonicTime) override;
     void handleMouseUp(const WebCore::LayoutPoint&, MonotonicTime) override;
+    String inlinePreviewUUIDForTesting() const override;
 
     void createFile(WebCore::Model&);
     void clearFile();

Modified: trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm (292901 => 292902)


--- trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-04-15 09:37:47 UTC (rev 292902)
@@ -55,6 +55,10 @@
 
 ARKitInlinePreviewModelPlayerMac::~ARKitInlinePreviewModelPlayerMac()
 {
+    if (m_inlinePreview) {
+        if (auto* page = this->page())
+            page->send(Messages::WebPageProxy::ModelElementDestroyRemotePreview([m_inlinePreview uuid].UUIDString));
+    }
     clearFile();
 }
 
@@ -295,6 +299,13 @@
         page->send(Messages::WebPageProxy::HandleMouseUpForModelElement([m_inlinePreview uuid].UUIDString, flippedLocationInElement, timestamp));
 }
 
+String ARKitInlinePreviewModelPlayerMac::inlinePreviewUUIDForTesting() const
+{
+    if (!m_inlinePreview)
+        return emptyString();
+    return [m_inlinePreview uuid].UUIDString;
 }
 
+}
+
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (292901 => 292902)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-04-15 09:37:47 UTC (rev 292902)
@@ -2014,6 +2014,19 @@
     return page && page->isParentProcessAWebBrowser();
 }
 
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+void WebFrameLoaderClient::modelInlinePreviewUUIDs(CompletionHandler<void(Vector<String>)>&& completionHandler) const
+{
+    auto* webPage = m_frame->page();
+    if (!webPage) {
+        completionHandler({ });
+        return;
+    }
+
+    webPage->sendWithAsyncReply(Messages::WebPageProxy::ModelInlinePreviewUUIDs(), WTFMove(completionHandler));
+}
+#endif
+
 } // namespace WebKit
 
 #undef PREFIX_PARAMETERS

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (292901 => 292902)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2022-04-15 06:08:27 UTC (rev 292901)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2022-04-15 09:37:47 UTC (rev 292902)
@@ -296,6 +296,10 @@
 #endif
 
     bool isParentProcessAFullWebBrowser() const final;
+
+#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
+    void modelInlinePreviewUUIDs(CompletionHandler<void(Vector<String>)>&&) const final;
+#endif
 };
 
 // As long as EmptyFrameLoaderClient exists in WebCore, this can return nullptr.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to