Title: [279451] trunk/Source
Revision
279451
Author
grao...@webkit.org
Date
2021-06-30 23:32:12 -0700 (Wed, 30 Jun 2021)

Log Message

[Model] [macOS] Add support for rendering model resources
https://bugs.webkit.org/show_bug.cgi?id=227530
<rdar://problem/79968206>

Reviewed by Dean Jackson.

Source/WebCore:

On macOS, ASVInlinePreview requires an instance in both the WebProcess and the UIProcess to exist with a matching UUID.

On the WebCore side, in the WebProcess, after writing the model resource as a file to disk, we create an instance when a
<model> element is created and message the UIProcess through the ChromeClient providing the UUID generated for it. When
the UIProcess is done processing this message, it will reply with another message which calls into
HTMLModelElement::inlinePreviewDidObtainContextId() with the matching UUID and a context ID for the remote context.
We can then set that remote context ID on our ASVInlinePreview instance.

We also introduce a HTMLModelElement::platformLayer() method such that RenderLayerBacking::updateConfiguration() can call
it to host the ASVInlinePreview layer.

* Modules/model-element/HTMLModelElement.cpp:
(WebCore::HTMLModelElement::~HTMLModelElement):
(WebCore::HTMLModelElement::setSourceURL):
(WebCore::HTMLModelElement::notifyFinished):
* Modules/model-element/HTMLModelElement.h:
* Modules/model-element/HTMLModelElementCocoa.mm: Added.
(WebCore::HTMLModelElement::createFile):
(WebCore::HTMLModelElement::clearFile):
(WebCore::HTMLModelElement::modelDidChange):
(WebCore::HTMLModelElement::inlinePreviewDidObtainContextId):
(WebCore::HTMLModelElement::platformLayer const):
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* loader/EmptyClients.cpp:
(WebCore::EmptyChromeClient::modelElementDidCreatePreview const):
* loader/EmptyClients.h:
* page/ChromeClient.h:
(WebCore::ChromeClient::modelElementDidCreatePreview const):
* platform/Logging.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):

Source/WebCore/PAL:

Declare the ASVInlinePreview class for macOS.

* PAL.xcodeproj/project.pbxproj:
* pal/spi/mac/SystemPreviewSPI.h: Added.

Source/WebKit:

On macOS, ASVInlinePreview requires an instance in both the WebProcess and the UIProcess to exist with a matching UUID.

On the WebKit side, in the UIProcess, we receive a message from the WebProcess when the ASVInlinePreview in that process
was created with its generated UUID. We provide this to the ModelElementController, set the remote connection up and load
the file. When those tasks complete successfully we message back the WebProcess with the UUID and the provided ElementContext
to talk back to the HTMLModelElement instance that initiated the message to the UIProcess in the first place.

* UIProcess/Cocoa/ModelElementControllerCocoa.mm:
(WebKit::ModelElementController::modelElementDidCreatePreview):
* UIProcess/ModelElementController.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::modelElementDidCreatePreview):
(WebKit::WebPageProxy::modelElementPreviewDidObtainContextId):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::modelElementDidCreatePreview const):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::modelElementDidCreatePreview):
(WebKit::WebPage::modelElementPreviewDidObtainContextId):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WTF:

Add a new compile-time flag indicating the availability of the ASVInlinePreview SPI on macOS.
We only define it when the header itself is present for now to avoid issues with older macOS
12 SDKs, but ultimately we will only use the macOS version check.

* wtf/PlatformHave.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (279450 => 279451)


--- trunk/Source/WTF/ChangeLog	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WTF/ChangeLog	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1,3 +1,17 @@
+2021-06-30  Antoine Quint  <grao...@webkit.org>
+
+        [Model] [macOS] Add support for rendering model resources
+        https://bugs.webkit.org/show_bug.cgi?id=227530
+        <rdar://problem/79968206>
+
+        Reviewed by Dean Jackson.
+
+        Add a new compile-time flag indicating the availability of the ASVInlinePreview SPI on macOS.
+        We only define it when the header itself is present for now to avoid issues with older macOS
+        12 SDKs, but ultimately we will only use the macOS version check.
+
+        * wtf/PlatformHave.h:
+
 2021-06-30  Megan Gardner  <megan_gard...@apple.com>
 
         Add ID and versioning support for AppHighlights

Modified: trunk/Source/WTF/wtf/PlatformHave.h (279450 => 279451)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1014,7 +1014,11 @@
 #if (PLATFORM(IOS) || PLATFORM(MACCATALYST)) && !PLATFORM(IOS_SIMULATOR) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000
 #define HAVE_ARKIT_INLINE_PREVIEW_IOS 1
 #endif
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
+#define HAVE_ARKIT_INLINE_PREVIEW_MAC 1
 #endif
+#endif
 
 #if PLATFORM(IOS) || PLATFORM(MACCATALYST) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000)
 #define HAVE_NSURLPROTOCOL_WITH_SKIPAPPSSO 1

Modified: trunk/Source/WebCore/ChangeLog (279450 => 279451)


--- trunk/Source/WebCore/ChangeLog	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/ChangeLog	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1,3 +1,44 @@
+2021-06-30  Antoine Quint  <grao...@webkit.org>
+
+        [Model] [macOS] Add support for rendering model resources
+        https://bugs.webkit.org/show_bug.cgi?id=227530
+        <rdar://problem/79968206>
+
+        Reviewed by Dean Jackson.
+
+        On macOS, ASVInlinePreview requires an instance in both the WebProcess and the UIProcess to exist with a matching UUID.
+
+        On the WebCore side, in the WebProcess, after writing the model resource as a file to disk, we create an instance when a
+        <model> element is created and message the UIProcess through the ChromeClient providing the UUID generated for it. When
+        the UIProcess is done processing this message, it will reply with another message which calls into
+        HTMLModelElement::inlinePreviewDidObtainContextId() with the matching UUID and a context ID for the remote context.
+        We can then set that remote context ID on our ASVInlinePreview instance.
+
+        We also introduce a HTMLModelElement::platformLayer() method such that RenderLayerBacking::updateConfiguration() can call
+        it to host the ASVInlinePreview layer.
+
+        * Modules/model-element/HTMLModelElement.cpp:
+        (WebCore::HTMLModelElement::~HTMLModelElement):
+        (WebCore::HTMLModelElement::setSourceURL):
+        (WebCore::HTMLModelElement::notifyFinished):
+        * Modules/model-element/HTMLModelElement.h:
+        * Modules/model-element/HTMLModelElementCocoa.mm: Added.
+        (WebCore::HTMLModelElement::createFile):
+        (WebCore::HTMLModelElement::clearFile):
+        (WebCore::HTMLModelElement::modelDidChange):
+        (WebCore::HTMLModelElement::inlinePreviewDidObtainContextId):
+        (WebCore::HTMLModelElement::platformLayer const):
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/EmptyClients.cpp:
+        (WebCore::EmptyChromeClient::modelElementDidCreatePreview const):
+        * loader/EmptyClients.h:
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::modelElementDidCreatePreview const):
+        * platform/Logging.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+
 2021-06-30  Megan Gardner  <megan_gard...@apple.com>
 
         Add ID and versioning support for AppHighlights

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -69,6 +69,10 @@
         m_resource->removeClient(*this);
         m_resource = nullptr;
     }
+
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    clearFile();
+#endif
 }
 
 Ref<HTMLModelElement> HTMLModelElement::create(const QualifiedName& tagName, Document& document)
@@ -131,8 +135,12 @@
 
     m_readyPromise = makeUniqueRef<ReadyPromise>(*this, &HTMLModelElement::readyPromiseResolve);
 
-    if (m_sourceURL.isEmpty())
+    if (m_sourceURL.isEmpty()) {
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+        clearFile();
+#endif
         return;
+    }
 
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
     options.destination = FetchOptions::Destination::Model;
@@ -224,6 +232,10 @@
     invalidateResourceHandleAndUpdateRenderer();
 
     m_readyPromise->resolve(*this);
+
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    modelDidChange();
+#endif
 }
 
 void HTMLModelElement::enterFullscreen()

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -35,6 +35,11 @@
 #include "SharedBuffer.h"
 #include <wtf/UniqueRef.h>
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+#include "PlatformLayer.h"
+OBJC_CLASS ASVInlinePreview;
+#endif
+
 namespace WebCore {
 
 class Model;
@@ -59,6 +64,11 @@
     WEBCORE_EXPORT static void setModelElementCacheDirectory(const String&);
     WEBCORE_EXPORT static const String& modelElementCacheDirectory();
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    PlatformLayer* platformLayer() const;
+    WEBCORE_EXPORT void inlinePreviewDidObtainContextId(const String& uuid, uint32_t contextId);
+#endif
+
     void enterFullscreen();
 
 private:
@@ -67,6 +77,12 @@
     void setSourceURL(const URL&);
     HTMLModelElement& readyPromiseResolve();
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    void clearFile();
+    void createFile();
+    void modelDidChange();
+#endif
+
     // DOM overrides.
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
@@ -83,6 +99,11 @@
     RefPtr<Model> m_model;
     UniqueRef<ReadyPromise> m_readyPromise;
     bool m_dataComplete { false };
+
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    String m_filePath;
+    RetainPtr<ASVInlinePreview> m_inlinePreview;
+#endif
 };
 
 } // namespace WebCore

Added: trunk/Source/WebCore/Modules/model-element/HTMLModelElementCocoa.mm (0 => 279451)


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElementCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElementCocoa.mm	2021-07-01 06:32:12 UTC (rev 279451)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HTMLModelElement.h"
+
+#if ENABLE(MODEL_ELEMENT) && HAVE(ARKIT_INLINE_PREVIEW_MAC)
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Logging.h"
+#include "Page.h"
+#include "RenderLayer.h"
+#include "RenderLayerModelObject.h"
+#include <pal/spi/mac/SystemPreviewSPI.h>
+#include <wtf/FileSystem.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/SoftLinking.h>
+#include <wtf/URL.h>
+#include <wtf/UUID.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK(AssetViewer);
+SOFT_LINK_CLASS(AssetViewer, ASVInlinePreview);
+
+namespace WebCore {
+
+void HTMLModelElement::createFile()
+{
+    // The need for a file is only temporary due to the nature of ASVInlinePreview,
+    // https://bugs.webkit.org/show_bug.cgi?id=227567.
+
+    clearFile();
+
+    auto pathToDirectory = HTMLModelElement::modelElementCacheDirectory();
+    if (pathToDirectory.isEmpty())
+        return;
+
+    auto directoryExists = FileSystem::fileExists(pathToDirectory);
+    if (directoryExists && FileSystem::fileTypeFollowingSymlinks(pathToDirectory) != FileSystem::FileType::Directory) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    if (!directoryExists && !FileSystem::makeAllDirectories(pathToDirectory)) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    // We need to support .reality files as well, https://bugs.webkit.org/show_bug.cgi?id=227568.
+    auto fileName = FileSystem::encodeForFileName(createCanonicalUUIDString()) + ".usdz";
+    auto filePath = FileSystem::pathByAppendingComponent(pathToDirectory, fileName);
+    auto file = FileSystem::openFile(filePath, FileSystem::FileOpenMode::Write);
+    if (file <= 0)
+        return;
+
+    FileSystem::writeToFile(file, m_data->data(), m_data->size());
+    FileSystem::closeFile(file);
+    m_filePath = filePath;
+}
+
+void HTMLModelElement::clearFile()
+{
+    if (m_filePath.isEmpty())
+        return;
+
+    FileSystem::deleteFile(m_filePath);
+    m_filePath = emptyString();
+}
+
+void HTMLModelElement::modelDidChange()
+{
+    createFile();
+
+    auto* renderer = this->renderer();
+    if (!renderer)
+        return;
+
+    auto size = renderer->absoluteBoundingBoxRect(false).size();
+
+    m_inlinePreview = adoptNS([allocASVInlinePreviewInstance() initWithFrame:CGRectMake(0, 0, size.width(), size.height())]);
+    LOG(ModelElement, "HTMLModelElement::modelDidChange() created preview with UUID %s and size %f x %f.", ((String)[m_inlinePreview uuid].UUIDString).utf8().data(), size.width(), size.height());
+
+    if (auto* page = document().page())
+        page->chrome().client().modelElementDidCreatePreview(*this, URL::fileURLWithFileSystemPath(m_filePath), [m_inlinePreview uuid].UUIDString, size);
+}
+
+void HTMLModelElement::inlinePreviewDidObtainContextId(const String& uuid, uint32_t contextId)
+{
+    if (uuid != (String)[m_inlinePreview uuid].UUIDString) {
+        LOG(ModelElement, "HTMLModelElement::inlinePreviewDidObtainContextId() UUID mismatch, received %s but expected %s.", uuid.utf8().data(), ((String)[m_inlinePreview uuid].UUIDString).utf8().data());
+        return;
+    }
+
+    [m_inlinePreview setRemoteContext:contextId];
+    LOG(ModelElement, "HTMLModelElement::inlinePreviewDidObtainContextId() successfully established remote connection for UUID %s.", uuid.utf8().data());
+
+    if (auto* renderer = this->renderer())
+        renderer->updateFromElement();
+}
+
+PlatformLayer* HTMLModelElement::platformLayer() const
+{
+    return [m_inlinePreview layer];
+}
+
+}
+
+#endif // ENABLE(MODEL_ELEMENT) && HAVE(ARKIT_INLINE_PREVIEW_MAC)

Modified: trunk/Source/WebCore/PAL/ChangeLog (279450 => 279451)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1,5 +1,18 @@
 2021-06-30  Antoine Quint  <grao...@webkit.org>
 
+        [Model] [macOS] Add support for rendering model resources
+        https://bugs.webkit.org/show_bug.cgi?id=227530
+        <rdar://problem/79968206>
+
+        Reviewed by Dean Jackson.
+
+        Declare the ASVInlinePreview class for macOS.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/mac/SystemPreviewSPI.h: Added.
+
+2021-06-30  Antoine Quint  <grao...@webkit.org>
+
         [Model] [iOS] Add support for displaying <model> in fullscreen
         https://bugs.webkit.org/show_bug.cgi?id=227443
         <rdar://problem/79859937>

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (279450 => 279451)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2021-07-01 06:32:12 UTC (rev 279451)
@@ -148,6 +148,7 @@
 		5C7C787423AC3E770065F47E /* ManagedConfigurationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */; };
 		5C7C787623AC3E850065F47E /* ManagedConfigurationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */; };
 		63C7EDC721AFAE04006A7B99 /* NSProgressSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 63E369F921AFA83F001C14BC /* NSProgressSPI.h */; };
+		71B1142026823ACD004D6701 /* SystemPreviewSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1141F26823ACD004D6701 /* SystemPreviewSPI.h */; };
 		72E5BE972679A80A00ADBFA9 /* VideoToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 72E5BE962679A80900ADBFA9 /* VideoToolboxSPI.h */; };
 		7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */; };
 		7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; };
@@ -367,6 +368,7 @@
 		5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ManagedConfigurationSoftLink.mm; sourceTree = "<group>"; };
 		5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagedConfigurationSPI.h; sourceTree = "<group>"; };
 		63E369F921AFA83F001C14BC /* NSProgressSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSProgressSPI.h; sourceTree = "<group>"; };
+		71B1141F26823ACD004D6701 /* SystemPreviewSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemPreviewSPI.h; sourceTree = "<group>"; };
 		72E5BE962679A80900ADBFA9 /* VideoToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoToolboxSPI.h; sourceTree = "<group>"; };
 		7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
 		7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
@@ -628,6 +630,7 @@
 				0C7785851F45130F00F4EBB6 /* PIPSPI.h */,
 				0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
 				A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
+				71B1141F26823ACD004D6701 /* SystemPreviewSPI.h */,
 				0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */,
 			);
 			path = mac;
@@ -990,6 +993,7 @@
 				93B38EC225821D2200198E63 /* SpeechSPI.h in Headers */,
 				A1175B491F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h in Headers */,
 				0C5AF9211F43A4C7002EAC02 /* SQLite3SPI.h in Headers */,
+				71B1142026823ACD004D6701 /* SystemPreviewSPI.h in Headers */,
 				31308B1420A21705003FB929 /* SystemPreviewSPI.h in Headers */,
 				A3AB6E581F3D1DDB009C14B1 /* SystemSleepListener.h in Headers */,
 				A3AB6E641F3D217F009C14B1 /* SystemSleepListenerMac.h in Headers */,

Copied: trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h (from rev 279450, trunk/Source/WebKit/UIProcess/ModelElementController.h) (0 => 279451)


--- trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+#import <AssetViewer/ASVInlinePreview.h>
+#endif
+
+#else
+
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+
+@class ASVInlinePreview;
+
+@interface ASVInlinePreview : NSObject
+@property (nonatomic, readonly) NSUUID *uuid;
+@property (nonatomic, readonly) CALayer *layer;
+@property (nonatomic, readonly) uint32_t contextId;
+
+- (instancetype)initWithFrame:(CGRect)frame;
+- (instancetype)initWithFrame:(CGRect)frame UUID:(NSUUID *)uuid;
+- (void)setupRemoteConnectionWithCompletionHandler:(void (^)(NSError * _Nullable error))handler;
+- (void)preparePreviewOfFileAtURL:(NSURL *)url completionHandler:(void (^)(NSError * _Nullable error))handler;
+- (void)setRemoteContext:(uint32_t)contextId;
+
+@end
+
+#endif
+
+#endif

Modified: trunk/Source/WebCore/SourcesCocoa.txt (279450 => 279451)


--- trunk/Source/WebCore/SourcesCocoa.txt	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2021-07-01 06:32:12 UTC (rev 279451)
@@ -99,6 +99,7 @@
 Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm
 Modules/async-clipboard/mac/ClipboardImageReaderMac.mm
 Modules/mediastream/RTCRtpSFrameTransformerCocoa.cpp
+Modules/model-element/HTMLModelElementCocoa.mm
 Modules/plugins/QuickTimePluginReplacement.mm
 Modules/plugins/YouTubePluginReplacement.cpp
 Modules/speech/cocoa/SpeechRecognizerCocoa.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (279450 => 279451)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-01 06:32:12 UTC (rev 279451)
@@ -10293,6 +10293,7 @@
 		71C29E31203CE76C008F36D2 /* CSSAnimation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CSSAnimation.idl; sourceTree = "<group>"; };
 		71C5BB1B1FB611EA0007A2AE /* Animatable.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Animatable.idl; sourceTree = "<group>"; };
 		71C916071D1483A300ACA47D /* UserInterfaceLayoutDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInterfaceLayoutDirection.h; sourceTree = "<group>"; };
+		71CAA3D9268D0BF900F25410 /* HTMLModelElementCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLModelElementCocoa.mm; sourceTree = "<group>"; };
 		71CE2C512209DC7F00C494BD /* MouseEventIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventIOS.cpp; sourceTree = "<group>"; };
 		71D02D901DB55C4E00DD5CF5 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = main.js; sourceTree = "<group>"; };
 		71D02D921DB55C4E00DD5CF5 /* media-controller.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "media-controller.js"; sourceTree = "<group>"; };
@@ -23122,6 +23123,7 @@
 				71A3D1802562B8250064E2A6 /* HTMLModelElement.cpp */,
 				71A3D17D2562B8240064E2A6 /* HTMLModelElement.h */,
 				71A3D17F2562B8240064E2A6 /* HTMLModelElement.idl */,
+				71CAA3D9268D0BF900F25410 /* HTMLModelElementCocoa.mm */,
 			);
 			path = "model-element";
 			sourceTree = "<group>";

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (279450 => 279451)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -579,9 +579,15 @@
 }
 
 #if ENABLE(MODEL_ELEMENT)
+
 void EmptyChromeClient::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID) const
 {
 }
+
+void EmptyChromeClient::modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const
+{
+}
+
 #endif
 
 void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, PolicyCheckIdentifier, FramePolicyFunction&&)

Modified: trunk/Source/WebCore/loader/EmptyClients.h (279450 => 279451)


--- trunk/Source/WebCore/loader/EmptyClients.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -221,6 +221,10 @@
 #endif
 
     RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) final { return nullptr; }
+
+#if ENABLE(MODEL_ELEMENT)
+    void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const final;
+#endif
 };
 
 DiagnosticLoggingClient& emptyDiagnosticLoggingClient();

Modified: trunk/Source/WebCore/page/ChromeClient.h (279450 => 279451)


--- trunk/Source/WebCore/page/ChromeClient.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/page/ChromeClient.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -78,6 +78,10 @@
 #include "MediaUsageInfo.h"
 #endif
 
+#if ENABLE(MODEL_ELEMENT)
+class HTMLModelElement;
+#endif
+
 #if ENABLE(WEBXR)
 #include "PlatformXR.h"
 #endif
@@ -598,6 +602,7 @@
 
 #if ENABLE(MODEL_ELEMENT)
     virtual void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID) const { }
+    virtual void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const { };
 #endif
 
 protected:

Modified: trunk/Source/WebCore/platform/Logging.h (279450 => 279451)


--- trunk/Source/WebCore/platform/Logging.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/platform/Logging.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -84,6 +84,7 @@
     M(MediaSourceSamples) \
     M(MemoryPressure) \
     M(MessagePorts) \
+    M(ModelElement) \
     M(Network) \
     M(NotYetImplemented) \
     M(OverlayScrollbars) \

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (279450 => 279451)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1075,8 +1075,13 @@
 #if ENABLE(MODEL_ELEMENT)
     else if (is<RenderModel>(renderer())) {
         auto element = downcast<HTMLModelElement>(renderer().element());
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+        if (auto* platformLayer = element->platformLayer())
+            m_graphicsLayer->setContentsToPlatformLayer(platformLayer, GraphicsLayer::ContentsLayerPurpose::Model);
+#else
         if (auto model = element->model())
             m_graphicsLayer->setContentsToModel(WTFMove(model));
+#endif
 
         layerConfigChanged = true;
     }

Modified: trunk/Source/WebKit/ChangeLog (279450 => 279451)


--- trunk/Source/WebKit/ChangeLog	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/ChangeLog	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1,3 +1,36 @@
+2021-06-30  Antoine Quint  <grao...@webkit.org>
+
+        [Model] [macOS] Add support for rendering model resources
+        https://bugs.webkit.org/show_bug.cgi?id=227530
+        <rdar://problem/79968206>
+
+        Reviewed by Dean Jackson.
+
+        On macOS, ASVInlinePreview requires an instance in both the WebProcess and the UIProcess to exist with a matching UUID.
+
+        On the WebKit side, in the UIProcess, we receive a message from the WebProcess when the ASVInlinePreview in that process
+        was created with its generated UUID. We provide this to the ModelElementController, set the remote connection up and load
+        the file. When those tasks complete successfully we message back the WebProcess with the UUID and the provided ElementContext
+        to talk back to the HTMLModelElement instance that initiated the message to the UIProcess in the first place.
+
+        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
+        (WebKit::ModelElementController::modelElementDidCreatePreview):
+        * UIProcess/ModelElementController.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::modelElementDidCreatePreview):
+        (WebKit::WebPageProxy::modelElementPreviewDidObtainContextId):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::modelElementDidCreatePreview const):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::modelElementDidCreatePreview):
+        (WebKit::WebPage::modelElementPreviewDidObtainContextId):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2021-06-30  Chris Dumez  <cdu...@apple.com>
 
         Regression(r278737): WebContent crash when calling [WKWebView loadHTMLString:] with an invalid URL

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2021-07-01 06:32:12 UTC (rev 279451)
@@ -28,18 +28,24 @@
 
 #if ENABLE(MODEL_ELEMENT)
 
+#import "Logging.h"
+#import "WebPageProxy.h"
+
+#if HAVE(ARKIT_INLINE_PREVIEW_IOS)
 #import "APIUIClient.h"
-#import "Logging.h"
 #import "RemoteLayerTreeDrawingAreaProxy.h"
 #import "RemoteLayerTreeHost.h"
 #import "RemoteLayerTreeViews.h"
 #import "WKModelView.h"
-#import "WebPageProxy.h"
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
-#if HAVE(ARKIT_INLINE_PREVIEW_IOS)
 #import <pal/spi/ios/SystemPreviewSPI.h>
 #endif
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+#import <pal/spi/mac/SystemPreviewSPI.h>
+#import <wtf/MainThread.h>
+#endif
+
 SOFT_LINK_PRIVATE_FRAMEWORK(AssetViewer);
 SOFT_LINK_CLASS(AssetViewer, ASVInlinePreview);
 
@@ -46,6 +52,7 @@
 namespace WebKit {
 
 #if HAVE(ARKIT_INLINE_PREVIEW_IOS)
+
 void ModelElementController::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
 {
     if (!is<RemoteLayerTreeDrawingAreaProxy>(m_webPageProxy.drawingArea()))
@@ -109,8 +116,53 @@
         });
     }];
 }
+
 #endif
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+
+void ModelElementController::modelElementDidCreatePreview(const WebCore::ElementContext& context, const URL& fileURL, const String& uuid, const WebCore::FloatSize& size)
+{
+    auto preview = adoptNS([allocASVInlinePreviewInstance() initWithFrame:CGRectMake(0, 0, size.width(), size.height()) UUID:[[NSUUID alloc] initWithUUIDString:uuid]]);
+
+    LOG(ModelElement, "Created remote preview with UUID %s.", uuid.utf8().data());
+
+    auto iterator = m_inlinePreviews.find(uuid);
+    if (iterator == m_inlinePreviews.end())
+        m_inlinePreviews.set(uuid, preview);
+    else
+        iterator->value = preview;
+
+    RELEASE_ASSERT(isMainRunLoop());
+    auto weakThis = makeWeakPtr(*this);
+    auto elementContextCopy = context;
+    auto uuidCopy = uuid;
+    NSURL *url = "" fileURLWithPath:fileURL.fileSystemPath()];
+    [preview setupRemoteConnectionWithCompletionHandler:^(NSError * _Nullable contextError) {
+        if (contextError) {
+            LOG(ModelElement, "Unable to create remote connection for uuid %s: %@.", uuidCopy.utf8().data(), [contextError localizedDescription]);
+            return;
+        }
+
+        LOG(ModelElement, "Established remote connection with UUID %s.", uuidCopy.utf8().data());
+
+        [preview preparePreviewOfFileAtURL:url completionHandler:^(NSError * _Nullable loadError) {
+            if (loadError) {
+                LOG(ModelElement, "Unable to load file for uuid %s: %@.", uuidCopy.utf8().data(), [loadError localizedDescription]);
+                return;
+            }
+
+            LOG(ModelElement, "Loaded file with UUID %s.", uuidCopy.utf8().data());
+
+            callOnMainRunLoop([weakThis, elementContextCopy, uuidCopy, contextId = [preview contextId]]() mutable {
+                weakThis->m_webPageProxy.modelElementPreviewDidObtainContextId(elementContextCopy, uuidCopy, contextId);
+            });
+        }];
+    }];
 }
 
 #endif
+
+}
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/ModelElementController.h (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/ModelElementController.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/ModelElementController.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -52,8 +52,15 @@
     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
 #endif
 
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    void modelElementDidCreatePreview(const WebCore::ElementContext&, const URL&, const String&, const WebCore::FloatSize&);
+#endif
+
 private:
     WebPageProxy& m_webPageProxy;
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    HashMap<String, RetainPtr<ASVInlinePreview>> m_inlinePreviews;
+#endif
 };
 
 }

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -132,6 +132,10 @@
 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS)
 struct TranslationContextMenuInfo;
 #endif
+
+#if ENABLE(MODEL_ELEMENT)
+struct ElementContext;
+#endif
 }
 
 namespace WebKit {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -10689,6 +10689,7 @@
 #endif
 
 #if ENABLE(MODEL_ELEMENT)
+
 void WebPageProxy::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
 {
 #if HAVE(ARKIT_INLINE_PREVIEW_IOS)
@@ -10695,8 +10696,22 @@
     modelElementController()->takeModelElementFullscreen(contentLayerId);
 #endif
 }
+
+void WebPageProxy::modelElementDidCreatePreview(const WebCore::ElementContext& context, const URL& url, const String& uuid, const FloatSize& size)
+{
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    modelElementController()->modelElementDidCreatePreview(context, url, uuid, size);
 #endif
+}
 
+void WebPageProxy::modelElementPreviewDidObtainContextId(const WebCore::ElementContext& context, const String& uuid, uint32_t contextId)
+{
+    if (hasRunningProcess())
+        send(Messages::WebPage::ModelElementPreviewDidObtainContextId(context, uuid, contextId));
+}
+
+#endif
+
 #if !PLATFORM(COCOA)
 SandboxExtension::HandleArray WebPageProxy::createNetworkExtensionsSandboxExtensions(WebProcessProxy& process)
 {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -576,6 +576,8 @@
 #if ENABLE(MODEL_ELEMENT)
     ModelElementController* modelElementController() { return m_modelElementController.get(); }
     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
+    void modelElementDidCreatePreview(const WebCore::ElementContext&, const URL&, const String&, const WebCore::FloatSize&);
+    void modelElementPreviewDidObtainContextId(const WebCore::ElementContext&, const String&, uint32_t);
 #endif
 
 #if ENABLE(CONTEXT_MENUS)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (279450 => 279451)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-07-01 06:32:12 UTC (rev 279451)
@@ -595,5 +595,6 @@
 
 #if ENABLE(MODEL_ELEMENT)
     TakeModelElementFullscreen(uint64_t contentLayerID)
+    ModelElementDidCreatePreview(struct WebCore::ElementContext elementContext, URL url, String uuid, WebCore::FloatSize size)
 #endif
 }

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (279450 => 279451)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -1516,10 +1516,17 @@
 }
 
 #if ENABLE(MODEL_ELEMENT)
+
 void WebChromeClient::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId) const
 {
     m_page.takeModelElementFullscreen(contentLayerId);
 }
+
+void WebChromeClient::modelElementDidCreatePreview(WebCore::HTMLModelElement& element, const URL& url, const String& uuid, const WebCore::FloatSize& size) const
+{
+    m_page.modelElementDidCreatePreview(element, url, uuid, size);
+}
+
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (279450 => 279451)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -454,6 +454,7 @@
 
 #if ENABLE(MODEL_ELEMENT)
     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId) const final;
+    void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const final;
 #endif
 
     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (279450 => 279451)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-07-01 06:32:12 UTC (rev 279451)
@@ -269,6 +269,10 @@
 #include <WebCore/AppHighlightStorage.h>
 #endif
 
+#if ENABLE(MODEL_ELEMENT)
+#include <WebCore/HTMLModelElement.h>
+#endif
+
 #if ENABLE(DATA_DETECTION)
 #include "DataDetectionResult.h"
 #endif
@@ -7675,13 +7679,33 @@
 #endif
 
 #if ENABLE(MODEL_ELEMENT)
+
 void WebPage::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
 {
     send(Messages::WebPageProxy::TakeModelElementFullscreen(contentLayerId));
 }
 
+void WebPage::modelElementDidCreatePreview(WebCore::HTMLModelElement& element, const URL& url, const String& uuid, const WebCore::FloatSize& size)
+{
+    if (auto elementContext = contextForElement(element))
+        send(Messages::WebPageProxy::ModelElementDidCreatePreview(*elementContext, url, uuid, size));
+}
+
+void WebPage::modelElementPreviewDidObtainContextId(const WebCore::ElementContext& elementContext, const String& uuid, uint32_t contextId)
+{
+#if HAVE(ARKIT_INLINE_PREVIEW_MAC)
+    auto element = elementForContext(elementContext);
+    if (is<WebCore::HTMLModelElement>(element))
+        downcast<WebCore::HTMLModelElement>(*element).inlinePreviewDidObtainContextId(uuid, contextId);
+#else
+    UNUSED_PARAM(elementContext);
+    UNUSED_PARAM(uuid);
+    UNUSED_PARAM(contextId);
 #endif
+}
 
+#endif
+
 } // namespace WebKit
 
 #undef WEBPAGE_RELEASE_LOG

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (279450 => 279451)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-01 06:32:12 UTC (rev 279451)
@@ -210,6 +210,10 @@
 class TextCheckingRequest;
 class VisiblePosition;
 
+#if ENABLE(MODEL_ELEMENT)
+class HTMLModelElement;
+#endif
+
 enum SyntheticClickType : int8_t;
 enum class CreateNewGroupForHighlight : bool;
 enum class DOMPasteAccessResponse : uint8_t;
@@ -1463,6 +1467,8 @@
 
 #if ENABLE(MODEL_ELEMENT)
     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
+    void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&);
+    void modelElementPreviewDidObtainContextId(const WebCore::ElementContext&, const String&, uint32_t);
 #endif
 
     void didHandleOrPreventMouseDownOrMouseUpEvent();

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (279450 => 279451)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-01 06:09:40 UTC (rev 279450)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-01 06:32:12 UTC (rev 279451)
@@ -643,4 +643,8 @@
 #if ENABLE(IMAGE_ANALYSIS)
     UpdateWithTextRecognitionResult(struct WebCore::TextRecognitionResult result, struct WebCore::ElementContext element, WebCore::FloatPoint location) -> (enum:uint8_t WebKit::TextRecognitionUpdateResult result) Async
 #endif
+
+#if ENABLE(MODEL_ELEMENT)
+    ModelElementPreviewDidObtainContextId(struct WebCore::ElementContext elementContext, String uuid, uint32_t contextId)
+#endif
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to