Changeset 286019 in webkit


Ignore:
Timestamp:
Nov 18, 2021 11:38:01 AM (8 months ago)
Author:
graouts@webkit.org
Message:

[Model] add support for getting and setting the camera
https://bugs.webkit.org/show_bug.cgi?id=233265
<rdar://problem/85426290>

Reviewed by Darin Adler.

Source/WebCore:

We add two new promise-based methods to the HTMLModelElement IDL to access and set the camera:
getCamera() and setCamera(). The camera is represented by a new HTMLModelElementCamera dictionary
which has yaw, pitch and scale members.

  • CMakeLists.txt:
  • Headers.cmake:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/model-element/HTMLModelElement.cpp:

(WebCore::HTMLModelElement::getCamera):
(WebCore::HTMLModelElement::setCamera):

  • Modules/model-element/HTMLModelElement.h:
  • Modules/model-element/HTMLModelElement.idl:
  • Modules/model-element/HTMLModelElementCamera.h: Copied from Source/WebCore/Modules/model-element/HTMLModelElement.idl.

(WebCore::HTMLModelElementCamera::encode const):
(WebCore::HTMLModelElementCamera::decode):

  • Modules/model-element/HTMLModelElementCamera.idl: Copied from Source/WebCore/Modules/model-element/HTMLModelElement.idl.
  • Modules/model-element/ModelPlayer.h:
  • Modules/model-element/dummy/DummyModelPlayer.cpp:

(WebCore::DummyModelPlayer::getCamera):
(WebCore::DummyModelPlayer::setCamera):

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

(WebCore::SceneKitModelPlayer::getCamera):
(WebCore::SceneKitModelPlayer::setCamera):

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • loader/EmptyClients.cpp:

(WebCore::EmptyChromeClient::takeModelElementFullscreen const): Deleted.

  • loader/EmptyClients.h:
  • page/ChromeClient.h:

(WebCore::ChromeClient::takeModelElementFullscreen const): Deleted.

Source/WebCore/PAL:

Add the new ARQL SPIs we are using.

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

Source/WebKit:

The ARQL APIs we'd adopted so far were specific to either macOS or iOS. The new camera
methods are different since they exist on both platforms.

In order to expose a single message for both platforms, we introduce a new ModelIdentifier
struct which wraps the UUID string for macOS and the layer identifier for iOS. Then on
ModelElementController, we have the previewForModelIdentifier() method to get the matching
ASVInlinePreview for the provided ModelIdentifier.

This allows getCameraForModelElement() and setCameraForModelElement to be specified for both
iOS and macOS with a single implementation.

We also modify takeModelElementFullscreen() to take advantage of ModelIdentifier which showed
that we had some lingering code in ChromeClient related to this method that was no longer
necessary following r285922.

  • Shared/ModelIdentifier.h: Copied from Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h.

(WebKit::ModelIdentifier::encode const):
(WebKit::ModelIdentifier::decode):

  • UIProcess/Cocoa/ModelElementControllerCocoa.mm:

(WebKit::ModelElementController::modelViewForModelIdentifier):
(WebKit::ModelElementController::previewForModelIdentifier):
(WebKit::ModelElementController::takeModelElementFullscreen):
(WebKit::previewHasCameraSupport):
(WebKit::ModelElementController::getCameraForModelElement):
(WebKit::ModelElementController::setCameraForModelElement):

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

(WebKit::WebPageProxy::modelElementGetCamera):
(WebKit::WebPageProxy::modelElementSetCamera):
(WebKit::WebPageProxy::takeModelElementFullscreen):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Model/ARKitInlinePreviewModelPlayer.h:
  • WebProcess/Model/ARKitInlinePreviewModelPlayer.mm:

(WebKit::ARKitInlinePreviewModelPlayer::getCamera):
(WebKit::ARKitInlinePreviewModelPlayer::setCamera):

  • WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h:
  • WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm:

(WebKit::ARKitInlinePreviewModelPlayerIOS::modelIdentifier):
(WebKit::ARKitInlinePreviewModelPlayerIOS::enterFullscreen):

  • WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h:
  • WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm:

(WebKit::ARKitInlinePreviewModelPlayerMac::modelIdentifier):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::takeModelElementFullscreen const): Deleted.

  • WebProcess/WebCoreSupport/WebChromeClient.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::takeModelElementFullscreen): Deleted.

  • WebProcess/WebPage/WebPage.h:

Source/WTF:

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

  • wtf/PlatformEnableCocoa.h:
Location:
trunk/Source
Files:
41 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r285967 r286019  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for getting and setting the camera
     4        https://bugs.webkit.org/show_bug.cgi?id=233265
     5        <rdar://problem/85426290>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a new compile-time flag for the new ARQL SPIs we are using.
     10
     11        * wtf/PlatformEnableCocoa.h:
     12
    1132021-11-17  John Wilander  <wilander@apple.com>
    214
  • trunk/Source/WTF/wtf/PlatformEnableCocoa.h

    r285521 r286019  
    744744#define ENABLE_ARKIT_INLINE_PREVIEW 1
    745745#endif
     746
     747#if (ENABLE(ARKIT_INLINE_PREVIEW_MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 120400) || (ENABLE(ARKIT_INLINE_PREVIEW_IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 150400)
     748#define ENABLE_ARKIT_INLINE_PREVIEW_CAMERA_TRANSFORM 1
     749#endif
  • trunk/Source/WebCore/CMakeLists.txt

    r285734 r286019  
    464464
    465465    Modules/model-element/HTMLModelElement.idl
     466    Modules/model-element/HTMLModelElementCamera.idl
    466467
    467468    Modules/notifications/Notification.idl
  • trunk/Source/WebCore/ChangeLog

    r286018 r286019  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for getting and setting the camera
     4        https://bugs.webkit.org/show_bug.cgi?id=233265
     5        <rdar://problem/85426290>
     6
     7        Reviewed by Darin Adler.
     8
     9        We add two new promise-based methods to the HTMLModelElement IDL to access and set the camera:
     10        getCamera() and setCamera(). The camera is represented by a new HTMLModelElementCamera dictionary
     11        which has yaw, pitch and scale members.
     12
     13        * CMakeLists.txt:
     14        * Headers.cmake:
     15        * DerivedSources-input.xcfilelist:
     16        * DerivedSources-output.xcfilelist:
     17        * DerivedSources.make:
     18        * Modules/model-element/HTMLModelElement.cpp:
     19        (WebCore::HTMLModelElement::getCamera):
     20        (WebCore::HTMLModelElement::setCamera):
     21        * Modules/model-element/HTMLModelElement.h:
     22        * Modules/model-element/HTMLModelElement.idl:
     23        * Modules/model-element/HTMLModelElementCamera.h: Copied from Source/WebCore/Modules/model-element/HTMLModelElement.idl.
     24        (WebCore::HTMLModelElementCamera::encode const):
     25        (WebCore::HTMLModelElementCamera::decode):
     26        * Modules/model-element/HTMLModelElementCamera.idl: Copied from Source/WebCore/Modules/model-element/HTMLModelElement.idl.
     27        * Modules/model-element/ModelPlayer.h:
     28        * Modules/model-element/dummy/DummyModelPlayer.cpp:
     29        (WebCore::DummyModelPlayer::getCamera):
     30        (WebCore::DummyModelPlayer::setCamera):
     31        * Modules/model-element/dummy/DummyModelPlayer.h:
     32        * Modules/model-element/scenekit/SceneKitModelPlayer.h:
     33        * Modules/model-element/scenekit/SceneKitModelPlayer.mm:
     34        (WebCore::SceneKitModelPlayer::getCamera):
     35        (WebCore::SceneKitModelPlayer::setCamera):
     36        * Sources.txt:
     37        * WebCore.xcodeproj/project.pbxproj:
     38        * loader/EmptyClients.cpp:
     39        (WebCore::EmptyChromeClient::takeModelElementFullscreen const): Deleted.
     40        * loader/EmptyClients.h:
     41        * page/ChromeClient.h:
     42        (WebCore::ChromeClient::takeModelElementFullscreen const): Deleted.
     43
    1442021-11-18  David Kilzer  <ddkilzer@apple.com>
    245
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r286018 r286019  
    442442$(PROJECT_DIR)/Modules/mediastream/RTCTransformEvent.idl
    443443$(PROJECT_DIR)/Modules/model-element/HTMLModelElement.idl
     444$(PROJECT_DIR)/Modules/model-element/HTMLModelElementCamera.idl
    444445$(PROJECT_DIR)/Modules/modern-media-controls/controls/activity-indicator.css
    445446$(PROJECT_DIR)/Modules/modern-media-controls/controls/airplay-button.css
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r285564 r286019  
    12841284$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLModelElement.cpp
    12851285$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLModelElement.h
     1286$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLModelElementCamera.cpp
     1287$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLModelElementCamera.h
    12861288$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLOListElement.cpp
    12871289$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSHTMLOListElement.h
  • trunk/Source/WebCore/DerivedSources.make

    r286018 r286019  
    458458    $(WebCore)/Modules/mediastream/RTCTransformEvent.idl \
    459459    $(WebCore)/Modules/model-element/HTMLModelElement.idl \
     460    $(WebCore)/Modules/model-element/HTMLModelElementCamera.idl \
    460461    $(WebCore)/Modules/notifications/Notification.idl \
    461462    $(WebCore)/Modules/notifications/NotificationPermission.idl \
  • trunk/Source/WebCore/Headers.cmake

    r286012 r286019  
    138138
    139139    Modules/model-element/HTMLModelElement.h
     140    Modules/model-element/HTMLModelElementCamera.h
    140141    Modules/model-element/ModelPlayer.h
    141142    Modules/model-element/ModelPlayerClient.h
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp

    r285986 r286019  
    3838#include "GraphicsLayer.h"
    3939#include "GraphicsLayerCA.h"
     40#include "HTMLModelElementCamera.h"
    4041#include "HTMLNames.h"
    4142#include "HTMLParserIdioms.h"
    4243#include "HTMLSourceElement.h"
     44#include "JSDOMPromiseDeferred.h"
    4345#include "JSEventTarget.h"
    4446#include "JSHTMLModelElement.h"
     47#include "JSHTMLModelElementCamera.h"
    4548#include "Model.h"
    4649#include "ModelPlayer.h"
     
    361364}
    362365
     366// MARK: – Camera support.
     367
     368void HTMLModelElement::getCamera(CameraPromise&& promise)
     369{
     370    if (!m_modelPlayer) {
     371        promise.reject();
     372        return;
     373    }
     374
     375    m_modelPlayer->getCamera([promise = WTFMove(promise)] (std::optional<HTMLModelElementCamera> camera) mutable {
     376        if (!camera)
     377            promise.reject();
     378        else
     379            promise.resolve(*camera);
     380    });
     381}
     382
     383void HTMLModelElement::setCamera(HTMLModelElementCamera camera, DOMPromiseDeferred<void>&& promise)
     384{
     385    if (!m_modelPlayer) {
     386        promise.reject();
     387        return;
     388    }
     389
     390    m_modelPlayer->setCamera(camera, [promise = WTFMove(promise)] (bool success) mutable {
     391        if (success)
     392            promise.resolve();
     393        else
     394            promise.reject();
     395    });
     396}
     397
    363398}
    364399
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h

    r285986 r286019  
    3333#include "GraphicsLayer.h"
    3434#include "HTMLElement.h"
     35#include "HTMLModelElementCamera.h"
    3536#include "IDLTypes.h"
    3637#include "ModelPlayerClient.h"
     
    4647class MouseEvent;
    4748
     49template<typename IDLType> class DOMPromiseDeferred;
    4850template<typename IDLType> class DOMPromiseProxyWithResolveCallback;
    4951
     
    6971
    7072    void enterFullscreen();
     73
     74    using CameraPromise = DOMPromiseDeferred<IDLDictionary<HTMLModelElementCamera>>;
     75    void getCamera(CameraPromise&&);
     76    void setCamera(HTMLModelElementCamera, DOMPromiseDeferred<void>&&);
    7177
    7278    bool isDraggableIgnoringAttributes() const final { return true; }
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl

    r283463 r286019  
    3434
    3535    undefined enterFullscreen();
     36
     37    Promise<HTMLModelElementCamera> getCamera();
     38    Promise<undefined> setCamera(HTMLModelElementCamera camera);
    3639};
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElementCamera.h

    r286018 r286019  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=MODEL_ELEMENT,
    28     EnabledBySetting=ModelElementEnabled,
    29     Exposed=Window,
    30 ] interface HTMLModelElement : HTMLElement {
    31     [URL] readonly attribute USVString currentSrc;
     26#pragma once
    3227
    33     readonly attribute Promise<HTMLModelElement> ready;
     28#include <optional>
    3429
    35     undefined enterFullscreen();
     30namespace WebCore {
     31
     32struct HTMLModelElementCamera {
     33    double pitch { 0 };
     34    double yaw { 0 };
     35    double scale { 1 };
     36
     37    template<class Encoder> void encode(Encoder&) const;
     38    template<class Decoder> static std::optional<HTMLModelElementCamera> decode(Decoder&);
    3639};
     40
     41template<class Encoder> void HTMLModelElementCamera::encode(Encoder& encoder) const
     42{
     43    encoder << pitch;
     44    encoder << yaw;
     45    encoder << scale;
     46}
     47
     48template<class Decoder> std::optional<HTMLModelElementCamera> HTMLModelElementCamera::decode(Decoder& decoder)
     49{
     50    std::optional<double> pitch;
     51    decoder >> pitch;
     52    if (!pitch)
     53        return std::nullopt;
     54
     55    std::optional<double> yaw;
     56    decoder >> yaw;
     57    if (!yaw)
     58        return std::nullopt;
     59
     60    std::optional<double> scale;
     61    decoder >> scale;
     62    if (!scale)
     63        return std::nullopt;
     64
     65    return { { *pitch, *yaw, *scale } };
     66}
     67
     68} // namespace WebCore
     69
  • trunk/Source/WebCore/Modules/model-element/HTMLModelElementCamera.idl

    r286018 r286019  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727    Conditional=MODEL_ELEMENT,
    2828    EnabledBySetting=ModelElementEnabled,
    29     Exposed=Window,
    30 ] interface HTMLModelElement : HTMLElement {
    31     [URL] readonly attribute USVString currentSrc;
    32 
    33     readonly attribute Promise<HTMLModelElement> ready;
    34 
    35     undefined enterFullscreen();
     29    JSGenerateToJSObject
     30] dictionary HTMLModelElementCamera {
     31    double pitch;
     32    double yaw;
     33    double scale;
    3634};
  • trunk/Source/WebCore/Modules/model-element/ModelPlayer.h

    r285986 r286019  
    2626#pragma once
    2727
     28#include "HTMLModelElementCamera.h"
    2829#include "LayoutPoint.h"
    2930#include "LayoutSize.h"
    3031#include "PlatformLayer.h"
     32#include <optional>
    3133#include <wtf/Forward.h>
    3234#include <wtf/MonotonicTime.h>
     
    4850    virtual void handleMouseMove(const LayoutPoint&, MonotonicTime) = 0;
    4951    virtual void handleMouseUp(const LayoutPoint&, MonotonicTime) = 0;
    50 
     52    virtual void getCamera(CompletionHandler<void(std::optional<HTMLModelElementCamera>&&)>&&) = 0;
     53    virtual void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) = 0;
    5154};
    5255
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp

    r285986 r286019  
    7171}
    7272
     73void DummyModelPlayer::getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&&)
     74{
    7375}
     76
     77void DummyModelPlayer::setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&)
     78{
     79}
     80
     81}
  • trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h

    r285986 r286019  
    4848    void handleMouseMove(const LayoutPoint&, MonotonicTime) override;
    4949    void handleMouseUp(const LayoutPoint&, MonotonicTime) override;
     50    void getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&&) override;
     51    void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
    5052
    5153    WeakPtr<ModelPlayerClient> m_client;
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h

    r285986 r286019  
    6262    void handleMouseMove(const LayoutPoint&, MonotonicTime) override;
    6363    void handleMouseUp(const LayoutPoint&, MonotonicTime) override;
     64    void getCamera(CompletionHandler<void(std::optional<HTMLModelElementCamera>&&)>&&) override;
     65    void setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
    6466
    6567    // SceneKitModelLoaderClient overrides.
  • trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm

    r285986 r286019  
    8989}
    9090
     91void SceneKitModelPlayer::getCamera(CompletionHandler<void(std::optional<HTMLModelElementCamera>&&)>&&)
     92{
     93}
     94
     95void SceneKitModelPlayer::setCamera(HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&)
     96{
     97}
     98
    9199// MARK: - SceneKitModelLoaderClient overrides.
    92100
  • trunk/Source/WebCore/PAL/ChangeLog

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

    r285319 r286019  
    5959@property (nonatomic) CGSize maxThumbnailSize;
    6060@end
    61 #endif
    6261
    6362NS_ASSUME_NONNULL_END
     63
     64#endif
    6465
    6566#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
     
    7879@end
    7980
     81NS_ASSUME_NONNULL_END
     82
    8083#endif
    8184
    8285#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     86
     87#import <simd/simd.h>
     88
     89NS_ASSUME_NONNULL_BEGIN
    8390
    8491@class ASVInlinePreview;
     
    98105- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    99106
     107typedef void (^ASVCameraTransformReplyBlock) (simd_float3 cameraTransform, NSError * _Nullable error);
     108- (void)getCameraTransform:(ASVCameraTransformReplyBlock)reply;
     109- (void)setCameraTransform:(simd_float3)transform;
     110
    100111@end
    101 
    102 #endif
    103112
    104113NS_ASSUME_NONNULL_END
    105114
    106115#endif
     116
     117#endif
  • trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h

    r285986 r286019  
    3232#else // USE(APPLE_INTERNAL_SDK)
    3333
     34#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     35
     36#import <simd/simd.h>
     37
    3438NS_ASSUME_NONNULL_BEGIN
    35 
    36 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    3739
    3840@class ASVInlinePreview;
     
    5355- (void)mouseUpAtLocation:(CGPoint)location timestamp:(NSTimeInterval)timestamp;
    5456
     57typedef void (^ASVCameraTransformReplyBlock) (simd_float3 cameraTransform, NSError * _Nullable error);
     58- (void)getCameraTransform:(ASVCameraTransformReplyBlock)reply;
     59- (void)setCameraTransform:(simd_float3)transform;
     60
    5561@end
     62
     63NS_ASSUME_NONNULL_END
    5664
    5765#endif // ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    5866
    59 NS_ASSUME_NONNULL_END
    60 
    6167#endif // USE(APPLE_INTERNAL_SDK)
  • trunk/Source/WebCore/Sources.txt

    r286012 r286019  
    33023302JSHTMLModElement.cpp
    33033303JSHTMLModelElement.cpp
     3304JSHTMLModelElementCamera.cpp
    33043305JSHTMLOListElement.cpp
    33053306JSHTMLObjectElement.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r286018 r286019  
    22752275                71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    22762276                71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; };
     2277                7177AD57274295D1002F103B /* HTMLModelElementCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 7177AD5627429590002F103B /* HTMLModelElementCamera.h */; settings = {ATTRIBUTES = (Private, ); }; };
    22772278                7181A16C244F0F40007D8A24 /* DocumentTimelinesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7181A169244F0F2C007D8A24 /* DocumentTimelinesController.h */; settings = {ATTRIBUTES = (Private, ); }; };
    22782279                71A1B6081DEE5AD70073BCFB /* modern-media-controls-localized-strings.js in Resources */ = {isa = PBXBuildFile; fileRef = 71A1B6061DEE5A820073BCFB /* modern-media-controls-localized-strings.js */; };
     
    1077610777                71729F7D20F3BABA00801CE6 /* JSDocumentTimelineOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTimelineOptions.cpp; sourceTree = "<group>"; };
    1077710778                7173DEBD2614DF040097DF32 /* Styleable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Styleable.cpp; sourceTree = "<group>"; };
     10779                7177AD542742952F002F103B /* HTMLModelElementCamera.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLModelElementCamera.idl; sourceTree = "<group>"; };
     10780                7177AD5627429590002F103B /* HTMLModelElementCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLModelElementCamera.h; sourceTree = "<group>"; };
     10781                7177AD5827429CCA002F103B /* JSHTMLModelElementCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLModelElementCamera.cpp; sourceTree = "<group>"; };
     10782                7177AD5927429CCB002F103B /* JSHTMLModelElementCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLModelElementCamera.h; sourceTree = "<group>"; };
    1077810783                7177E2461DB80D2F00919A0B /* media-controller-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "media-controller-support.js"; sourceTree = "<group>"; };
    1077910784                7177E2471DB80D2F00919A0B /* mute-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "mute-support.js"; sourceTree = "<group>"; };
     
    2380823813                                71A3D17D2562B8240064E2A6 /* HTMLModelElement.h */,
    2380923814                                71A3D17F2562B8240064E2A6 /* HTMLModelElement.idl */,
     23815                                7177AD5627429590002F103B /* HTMLModelElementCamera.h */,
     23816                                7177AD542742952F002F103B /* HTMLModelElementCamera.idl */,
    2381023817                                BC2B41142732F06200A2D191 /* ModelPlayer.cpp */,
    2381123818                                BC2B41132732F06200A2D191 /* ModelPlayer.h */,
     
    2608626093                                71A3D1822562BDDB0064E2A6 /* JSHTMLModelElement.cpp */,
    2608726094                                71A3D1832562BDDB0064E2A6 /* JSHTMLModelElement.h */,
     26095                                7177AD5827429CCA002F103B /* JSHTMLModelElementCamera.cpp */,
     26096                                7177AD5927429CCB002F103B /* JSHTMLModelElementCamera.h */,
    2608826097                                1AE2AB1F0A1CE63B00B42B25 /* JSHTMLModElement.cpp */,
    2608926098                                1AE2AB200A1CE63B00B42B25 /* JSHTMLModElement.h */,
     
    3371933728                                A454424B119B3661009BE912 /* HTMLMeterElement.h in Headers */,
    3372033729                                71A3D1812562B85B0064E2A6 /* HTMLModelElement.h in Headers */,
     33730                                7177AD57274295D1002F103B /* HTMLModelElementCamera.h in Headers */,
    3372133731                                A8CFF7A70A156978000A4234 /* HTMLModElement.h in Headers */,
    3372233732                                A8DF3FD4097FA0FC0052981B /* HTMLNameCollection.h in Headers */,
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r285637 r286019  
    584584}
    585585
    586 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    587 void EmptyChromeClient::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID) const
    588 {
    589 }
    590 #endif
    591 
    592586void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, PolicyCheckIdentifier, FramePolicyFunction&&)
    593587{
  • trunk/Source/WebCore/loader/EmptyClients.h

    r285637 r286019  
    218218    bool shouldNotifyOnFormChanges() final { return false; }
    219219
    220 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    221     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID) const final;
    222 #endif
    223 
    224220    RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) final { return nullptr; }
    225221};
  • trunk/Source/WebCore/page/ChromeClient.h

    r285973 r286019  
    606606#endif
    607607
    608 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    609     virtual void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID) const { }
    610 #endif
    611 
    612608#if ENABLE(APPLE_PAY_AMS_UI)
    613609    virtual void startApplePayAMSUISession(const URL&, const ApplePayAMSUIRequest&, CompletionHandler<void(std::optional<bool>&&)>&& completionHandler) { completionHandler(std::nullopt); }
  • trunk/Source/WebKit/ChangeLog

    r286012 r286019  
     12021-11-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [Model] add support for getting and setting the camera
     4        https://bugs.webkit.org/show_bug.cgi?id=233265
     5        <rdar://problem/85426290>
     6
     7        Reviewed by Darin Adler.
     8
     9        The ARQL APIs we'd adopted so far were specific to either macOS or iOS. The new camera
     10        methods are different since they exist on both platforms.
     11
     12        In order to expose a single message for both platforms, we introduce a new ModelIdentifier
     13        struct which wraps the UUID string for macOS and the layer identifier for iOS. Then on
     14        ModelElementController, we have the previewForModelIdentifier() method to get the matching
     15        ASVInlinePreview for the provided ModelIdentifier.
     16
     17        This allows getCameraForModelElement() and setCameraForModelElement to be specified for both
     18        iOS and macOS with a single implementation.
     19
     20        We also modify takeModelElementFullscreen() to take advantage of ModelIdentifier which showed
     21        that we had some lingering code in ChromeClient related to this method that was no longer
     22        necessary following r285922.
     23
     24        * Shared/ModelIdentifier.h: Copied from Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h.
     25        (WebKit::ModelIdentifier::encode const):
     26        (WebKit::ModelIdentifier::decode):
     27        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
     28        (WebKit::ModelElementController::modelViewForModelIdentifier):
     29        (WebKit::ModelElementController::previewForModelIdentifier):
     30        (WebKit::ModelElementController::takeModelElementFullscreen):
     31        (WebKit::previewHasCameraSupport):
     32        (WebKit::ModelElementController::getCameraForModelElement):
     33        (WebKit::ModelElementController::setCameraForModelElement):
     34        * UIProcess/ModelElementController.h:
     35        * UIProcess/WebPageProxy.cpp:
     36        (WebKit::WebPageProxy::modelElementGetCamera):
     37        (WebKit::WebPageProxy::modelElementSetCamera):
     38        (WebKit::WebPageProxy::takeModelElementFullscreen):
     39        * UIProcess/WebPageProxy.h:
     40        * UIProcess/WebPageProxy.messages.in:
     41        * WebKit.xcodeproj/project.pbxproj:
     42        * WebProcess/Model/ARKitInlinePreviewModelPlayer.h:
     43        * WebProcess/Model/ARKitInlinePreviewModelPlayer.mm:
     44        (WebKit::ARKitInlinePreviewModelPlayer::getCamera):
     45        (WebKit::ARKitInlinePreviewModelPlayer::setCamera):
     46        * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h:
     47        * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm:
     48        (WebKit::ARKitInlinePreviewModelPlayerIOS::modelIdentifier):
     49        (WebKit::ARKitInlinePreviewModelPlayerIOS::enterFullscreen):
     50        * WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h:
     51        * WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm:
     52        (WebKit::ARKitInlinePreviewModelPlayerMac::modelIdentifier):
     53        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     54        (WebKit::WebChromeClient::takeModelElementFullscreen const): Deleted.
     55        * WebProcess/WebCoreSupport/WebChromeClient.h:
     56        * WebProcess/WebPage/WebPage.cpp:
     57        (WebKit::WebPage::takeModelElementFullscreen): Deleted.
     58        * WebProcess/WebPage/WebPage.h:
     59
    1602021-11-18  Chris Dumez  <cdumez@apple.com>
    261
  • trunk/Source/WebKit/Shared/ModelIdentifier.h

    r286018 r286019  
    2626#pragma once
    2727
    28 #if HAVE(SCENEKIT)
     28namespace WebKit {
    2929
    30 #include "Model.h"
    31 #include "ModelPlayer.h"
    32 #include "ModelPlayerClient.h"
    33 #include "SceneKitModelLoaderClient.h"
    34 #include <wtf/RetainPtr.h>
    35 #include <wtf/URL.h>
    36 #include <wtf/WeakPtr.h>
    37 #include <wtf/Forward.h>
     30#if ENABLE(ARKIT_INLINE_PREVIEW)
    3831
    39 OBJC_CLASS SCNMetalLayer;
     32#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     33#import <WebCore/GraphicsLayer.h>
     34#endif
    4035
    41 namespace WebCore {
     36struct ModelIdentifier {
     37#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     38    String uuid;
     39#elif ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     40    WebCore::GraphicsLayer::PlatformLayerID layerIdentifier;
     41#endif
    4242
    43 class ModelPlayerClient;
    44 class SceneKitModel;
    45 class SceneKitModelLoader;
    46 
    47 class WEBCORE_EXPORT SceneKitModelPlayer final : public ModelPlayer, public SceneKitModelLoaderClient {
    48 public:
    49     static Ref<SceneKitModelPlayer> create(ModelPlayerClient&);
    50     virtual ~SceneKitModelPlayer();
    51 
    52 private:
    53     SceneKitModelPlayer(ModelPlayerClient&);
    54 
    55     void updateScene();
    56 
    57     // ModelPlayer overrides.
    58     void load(Model&, LayoutSize) override;
    59     CALayer *layer() override;
    60     void enterFullscreen() override;
    61     void handleMouseDown(const LayoutPoint&, MonotonicTime) override;
    62     void handleMouseMove(const LayoutPoint&, MonotonicTime) override;
    63     void handleMouseUp(const LayoutPoint&, MonotonicTime) override;
    64 
    65     // SceneKitModelLoaderClient overrides.
    66     virtual void didFinishLoading(SceneKitModelLoader&, Ref<SceneKitModel>) override;
    67     virtual void didFailLoading(SceneKitModelLoader&, const ResourceError&) override;
    68 
    69     WeakPtr<ModelPlayerClient> m_client;
    70 
    71     RefPtr<SceneKitModelLoader> m_loader;
    72     RefPtr<SceneKitModel> m_model;
    73 
    74     RetainPtr<SCNMetalLayer> m_layer;
     43    template<class Encoder> void encode(Encoder&) const;
     44    template<class Decoder> static std::optional<ModelIdentifier> decode(Decoder&);
    7545};
    7646
     47template<class Encoder> void ModelIdentifier::encode(Encoder& encoder) const
     48{
     49#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     50    encoder << uuid;
     51#elif ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     52    encoder << layerIdentifier;
     53#endif
     54}
     55
     56template<class Decoder> std::optional<ModelIdentifier> ModelIdentifier::decode(Decoder& decoder)
     57{
     58#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     59    std::optional<String> uuid;
     60    decoder >> uuid;
     61    if (!uuid)
     62        return std::nullopt;
     63    return { { WTFMove(*uuid) } };
     64#elif ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     65    std::optional<WebCore::GraphicsLayer::PlatformLayerID> layerIdentifier;
     66    decoder >> layerIdentifier;
     67    if (!layerIdentifier)
     68        return std::nullopt;
     69    return { { *layerIdentifier } };
     70#endif
    7771}
    7872
    7973#endif
     74
     75} // namespace WebKit
     76
  • trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm

    r285986 r286019  
    3131#import "Logging.h"
    3232#import "WebPageProxy.h"
     33#import <WebCore/LayoutPoint.h>
     34#import <WebCore/LayoutUnit.h>
     35#import <WebCore/ResourceError.h>
     36#import <simd/simd.h>
     37#import <wtf/MainThread.h>
     38#import <wtf/MonotonicTime.h>
    3339
    3440#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     
    4349
    4450#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    45 #import <WebCore/LayoutPoint.h>
    46 #import <WebCore/LayoutUnit.h>
    47 #import <WebCore/ResourceError.h>
    4851#import <pal/spi/mac/SystemPreviewSPI.h>
    49 #import <wtf/MainThread.h>
    50 #import <wtf/MonotonicTime.h>
    5152#endif
    5253
     
    5859#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    5960
    60 void ModelElementController::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
     61WKModelView * ModelElementController::modelViewForModelIdentifier(ModelIdentifier modelIdentifier)
    6162{
    6263    if (!m_webPageProxy.preferences().modelElementEnabled())
    63         return;
     64        return nil;
    6465
    6566    if (!is<RemoteLayerTreeDrawingAreaProxy>(m_webPageProxy.drawingArea()))
    66         return;
    67 
    68     auto* node = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_webPageProxy.drawingArea()).remoteLayerTreeHost().nodeForID(contentLayerId);
     67        return nil;
     68
     69    auto* node = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_webPageProxy.drawingArea()).remoteLayerTreeHost().nodeForID(modelIdentifier.layerIdentifier);
    6970    if (!node)
    70         return;
    71 
    72     auto *view = node->uiView();
    73     if (!view)
    74         return;
    75 
    76     if (![view isKindOfClass:[WKModelView class]])
    77         return;
    78 
     71        return nil;
     72
     73    return dynamic_objc_cast<WKModelView>(node->uiView());
     74}
     75
     76ASVInlinePreview * ModelElementController::previewForModelIdentifier(ModelIdentifier modelIdentifier)
     77{
     78    return [modelViewForModelIdentifier(modelIdentifier) preview];
     79}
     80
     81void ModelElementController::takeModelElementFullscreen(ModelIdentifier modelIdentifier)
     82{
    7983    auto *presentingViewController = m_webPageProxy.uiClient().presentingViewController();
    8084    if (!presentingViewController)
    8185        return;
    8286
    83     WKModelView *modelView = (WKModelView *)view;
     87    auto modelView = modelViewForModelIdentifier(modelIdentifier);
     88    if (!modelView)
     89        return;
     90
    8491    CGRect initialFrame = [modelView convertRect:modelView.frame toView:nil];
    8592
     
    99106            [presentingViewController presentViewController:remoteViewController animated:NO completion:^(void) {
    100107                [CATransaction begin];
    101                 [view.layer.superlayer.context addFence:fenceHandle];
     108                [modelView.layer.superlayer.context addFence:fenceHandle];
    102109                [CATransaction commit];
    103110                [fenceHandle invalidate];
     
    113120
    114121                    [CATransaction begin];
    115                     [view.layer.superlayer.context addFence:dismissFenceHandle];
     122                    [modelView.layer.superlayer.context addFence:dismissFenceHandle];
    116123                    [CATransaction setCompletionBlock:^{
    117124                        [remoteViewController dismissViewControllerAnimated:NO completion:nil];
     
    129136#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    130137
     138ASVInlinePreview * ModelElementController::previewForModelIdentifier(ModelIdentifier modelIdentifier)
     139{
     140    if (!m_webPageProxy.preferences().modelElementEnabled())
     141        return nullptr;
     142
     143    return m_inlinePreviews.get(modelIdentifier.uuid).get();
     144}
     145
    131146void ModelElementController::modelElementDidCreatePreview(URL fileURL, String uuid, WebCore::FloatSize size, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&& completionHandler)
    132147{
     
    151166
    152167    RELEASE_ASSERT(isMainRunLoop());
    153     [preview setupRemoteConnectionWithCompletionHandler:makeBlockPtr([weakThis = WeakPtr { *this }, preview, uuid = WTFMove(uuid), url = WTFMove(url), completionHandler = WTFMove(completionHandler)] (NSError * _Nullable contextError) mutable {
     168    [preview setupRemoteConnectionWithCompletionHandler:makeBlockPtr([weakThis = WeakPtr { *this }, preview, uuid = WTFMove(uuid), url = WTFMove(url), completionHandler = WTFMove(completionHandler)] (NSError *contextError) mutable {
    154169        if (contextError) {
    155170            LOG(ModelElement, "Unable to create remote connection for uuid %s: %@.", uuid.utf8().data(), contextError.localizedDescription);
     
    166181        LOG(ModelElement, "Established remote connection with UUID %s.", uuid.utf8().data());
    167182
    168         [preview preparePreviewOfFileAtURL:url.get() completionHandler:makeBlockPtr([weakThis = WTFMove(weakThis), preview, uuid = WTFMove(uuid), url = WTFMove(url), completionHandler = WTFMove(completionHandler)] (NSError * _Nullable loadError) mutable {
     183        [preview preparePreviewOfFileAtURL:url.get() completionHandler:makeBlockPtr([weakThis = WTFMove(weakThis), preview, uuid = WTFMove(uuid), url = WTFMove(url), completionHandler = WTFMove(completionHandler)] (NSError *loadError) mutable {
    169184            if (loadError) {
    170185                LOG(ModelElement, "Unable to load file for uuid %s: %@.", uuid.utf8().data(), loadError.localizedDescription);
     
    217232#endif
    218233
    219 }
    220 
    221 #endif
     234#if ENABLE(ARKIT_INLINE_PREVIEW)
     235
     236static bool previewHasCameraSupport(ASVInlinePreview *preview)
     237{
     238#if ENABLE(ARKIT_INLINE_PREVIEW_CAMERA_TRANSFORM)
     239    return [preview respondsToSelector:@selector(getCameraTransform:)];
     240#else
     241    return false;
     242#endif
     243}
     244
     245void ModelElementController::getCameraForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&& completionHandler)
     246{
     247    auto* preview = previewForModelIdentifier(modelIdentifier);
     248    if (!preview || !previewHasCameraSupport(preview)) {
     249        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler), error = WebCore::ResourceError { WebCore::ResourceError::Type::General }] () mutable {
     250            if (weakThis)
     251                completionHandler(makeUnexpected(error));
     252        });
     253        return;
     254    }
     255
     256    [preview getCameraTransform:makeBlockPtr([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] (simd_float3 cameraTransform, NSError *error) mutable {
     257        if (error) {
     258            callOnMainRunLoop([weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler), error = WebCore::ResourceError { WebCore::ResourceError::Type::General }] () mutable {
     259                if (weakThis)
     260                    completionHandler(makeUnexpected(error));
     261            });
     262            return;
     263        }
     264
     265        callOnMainRunLoop([cameraTransform, weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler)] () mutable {
     266            if (weakThis)
     267                completionHandler(WebCore::HTMLModelElementCamera { cameraTransform.x, cameraTransform.y, cameraTransform.z });
     268        });
     269    }).get()];
     270}
     271
     272void ModelElementController::setCameraForModelElement(ModelIdentifier modelIdentifier, WebCore::HTMLModelElementCamera camera, CompletionHandler<void(bool)>&& completionHandler)
     273{
     274    auto* preview = previewForModelIdentifier(modelIdentifier);
     275    if (!preview || !previewHasCameraSupport(preview)) {
     276        callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
     277            if (weakThis)
     278                completionHandler(false);
     279        });
     280        return;
     281    }
     282
     283    [preview setCameraTransform:simd_make_float3(camera.pitch, camera.yaw, camera.scale)];
     284
     285    callOnMainRunLoop([weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] () mutable {
     286        if (weakThis)
     287            completionHandler(true);
     288    });
     289}
     290
     291#endif
     292
     293}
     294
     295#endif
  • trunk/Source/WebKit/UIProcess/ModelElementController.h

    r285986 r286019  
    2828#if ENABLE(ARKIT_INLINE_PREVIEW)
    2929
     30#include "ModelIdentifier.h"
    3031#include <WebCore/ElementContext.h>
    3132#include <WebCore/GraphicsLayer.h>
     
    3435#include <wtf/WeakPtr.h>
    3536
    36 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
    3737OBJC_CLASS ASVInlinePreview;
     38
     39#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     40OBJC_CLASS WKModelView;
    3841#endif
    3942
     
    4952    WebPageProxy& page() { return m_webPageProxy; }
    5053
     54#if ENABLE(ARKIT_INLINE_PREVIEW)
     55    void getCameraForModelElement(ModelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&&);
     56    void setCameraForModelElement(ModelIdentifier, WebCore::HTMLModelElementCamera, CompletionHandler<void(bool)>&&);
     57#endif
    5158#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    52     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
     59    void takeModelElementFullscreen(ModelIdentifier);
    5360#endif
    5461#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     
    6067
    6168private:
     69#if ENABLE(ARKIT_INLINE_PREVIEW)
     70    ASVInlinePreview * previewForModelIdentifier(ModelIdentifier);
     71#endif
     72
     73#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     74    WKModelView * modelViewForModelIdentifier(ModelIdentifier);
     75#endif
     76
    6277    WebPageProxy& m_webPageProxy;
    6378#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r285986 r286019  
    1083310833#endif
    1083410834
     10835#if ENABLE(ARKIT_INLINE_PREVIEW)
     10836void WebPageProxy::modelElementGetCamera(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&& completionHandler)
     10837{
     10838    modelElementController()->getCameraForModelElement(modelIdentifier, WTFMove(completionHandler));
     10839}
     10840
     10841void WebPageProxy::modelElementSetCamera(ModelIdentifier modelIdentifier, WebCore::HTMLModelElementCamera camera, CompletionHandler<void(bool)>&& completionHandler)
     10842{
     10843    modelElementController()->setCameraForModelElement(modelIdentifier, camera, WTFMove(completionHandler));
     10844}
     10845#endif
     10846
    1083510847#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    10836 void WebPageProxy::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
    10837 {
    10838     modelElementController()->takeModelElementFullscreen(contentLayerId);
     10848void WebPageProxy::takeModelElementFullscreen(ModelIdentifier modelIdentifier)
     10849{
     10850    modelElementController()->takeModelElementFullscreen(modelIdentifier);
    1083910851}
    1084010852#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r285986 r286019  
    197197#if ENABLE(ARKIT_INLINE_PREVIEW)
    198198#include "ModelElementController.h"
     199#include "ModelIdentifier.h"
    199200#endif
    200201
     
    588589#if ENABLE(ARKIT_INLINE_PREVIEW)
    589590    ModelElementController* modelElementController() { return m_modelElementController.get(); }
     591    void modelElementGetCamera(ModelIdentifier, CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)>&&);
     592    void modelElementSetCamera(ModelIdentifier, WebCore::HTMLModelElementCamera, CompletionHandler<void(bool)>&&);
    590593#endif
    591594#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    592     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
     595    void takeModelElementFullscreen(ModelIdentifier);
    593596#endif
    594597#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r285986 r286019  
    587587
    588588#if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    589     TakeModelElementFullscreen(uint64_t contentLayerID)
     589    TakeModelElementFullscreen(struct WebKit::ModelIdentifier modelIdentifier)
    590590#endif
    591591#if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     
    595595    HandleMouseUpForModelElement(String uuid, WebCore::LayoutPoint locationInPageCoordinates, MonotonicTime timestamp)
    596596#endif
     597#if ENABLE(ARKIT_INLINE_PREVIEW)
     598    ModelElementGetCamera(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError> result) Async
     599    ModelElementSetCamera(struct WebKit::ModelIdentifier modelIdentifier, struct WebCore::HTMLModelElementCamera camera) -> (bool success) Async
     600#endif
    597601
    598602    requestPermission(struct WebCore::ClientOrigin origin, struct WebCore::PermissionDescriptor descriptor) -> (enum:uint8_t WebCore::PermissionState state) Async
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r285981 r286019  
    47094709                71BAA73125FFCCBA00D7CD5D /* WKModelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKModelView.h; path = ios/WKModelView.h; sourceTree = "<group>"; };
    47104710                71BAA73225FFCCBA00D7CD5D /* WKModelView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKModelView.mm; path = ios/WKModelView.mm; sourceTree = "<group>"; };
     4711                71E9650F2745682E00ADCF43 /* ModelIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ModelIdentifier.h; sourceTree = "<group>"; };
    47114712                71FB810A2260627A00323677 /* WebsiteSimulatedMouseEventsDispatchPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteSimulatedMouseEventsDispatchPolicy.h; sourceTree = "<group>"; };
    47124713                7203449A26A6C44C000A5F54 /* MonotonicObjectIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MonotonicObjectIdentifier.h; sourceTree = "<group>"; };
     
    68356836                                2D10875F1D2C573E00B85F82 /* LoadParameters.h */,
    68366837                                49917DB0252E30750050313F /* MediaPlaybackState.h */,
     6838                                71E9650F2745682E00ADCF43 /* ModelIdentifier.h */,
    68376839                                7203449A26A6C44C000A5F54 /* MonotonicObjectIdentifier.h */,
    68386840                                2D50366A1BCDE17900E20BB3 /* NativeWebGestureEvent.h */,
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h

    r285922 r286019  
    2828#if ENABLE(ARKIT_INLINE_PREVIEW)
    2929
    30 #include <WebCore/ModelPlayer.h>
    31 #include <WebCore/ModelPlayerClient.h>
    32 #include <wtf/Compiler.h>
     30#import "ModelIdentifier.h"
     31#import "WebPage.h"
     32#import "WebPageProxyMessages.h"
     33#import <WebCore/ModelPlayer.h>
     34#import <WebCore/ModelPlayerClient.h>
     35#import <wtf/Compiler.h>
    3336
    3437namespace WebKit {
     
    4447    WebCore::ModelPlayerClient* client() { return m_client.get(); }
    4548
     49    virtual std::optional<ModelIdentifier> modelIdentifier() = 0;
     50
    4651private:
    4752    // WebCore::ModelPlayer overrides.
     
    4954    PlatformLayer* layer() override;
    5055    void enterFullscreen() override;
     56    void getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&&) override;
     57    void setCamera(WebCore::HTMLModelElementCamera, CompletionHandler<void(bool&&)>&&) override;
    5158
    5259    WeakPtr<WebPage> m_page;
  • trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm

    r285922 r286019  
    5656}
    5757
     58void ARKitInlinePreviewModelPlayer::getCamera(CompletionHandler<void(std::optional<WebCore::HTMLModelElementCamera>&&)>&& completionHandler)
     59{
     60    auto modelIdentifier = this->modelIdentifier();
     61    if (!modelIdentifier) {
     62        completionHandler(std::nullopt);
     63        return;
     64    }
     65
     66    auto* strongPage = m_page.get();
     67    if (!strongPage) {
     68        completionHandler(std::nullopt);
     69        return;
     70    }
     71
     72    CompletionHandler<void(Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<WebCore::HTMLModelElementCamera, WebCore::ResourceError> result) mutable {
     73        if (!result) {
     74            completionHandler(std::nullopt);
     75            return;
     76        }
     77
     78        completionHandler(*result);
     79    };
     80
     81    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementGetCamera(*modelIdentifier), WTFMove(remoteCompletionHandler));
     82}
     83
     84void ARKitInlinePreviewModelPlayer::setCamera(WebCore::HTMLModelElementCamera camera, CompletionHandler<void(bool&&)>&& completionHandler)
     85{
     86    auto modelIdentifier = this->modelIdentifier();
     87    if (!modelIdentifier) {
     88        completionHandler(false);
     89        return;
     90    }
     91
     92    auto* strongPage = m_page.get();
     93    if (!strongPage) {
     94        completionHandler(false);
     95        return;
     96    }
     97
     98    CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable {
     99        completionHandler(WTFMove(success));
     100    };
     101
     102    strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetCamera(*modelIdentifier, camera), WTFMove(remoteCompletionHandler));
     103}
     104
    58105}
    59106
  • trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h

    r285986 r286019  
    4242    ARKitInlinePreviewModelPlayerIOS(WebPage&, WebCore::ModelPlayerClient&);
    4343
     44    std::optional<ModelIdentifier> modelIdentifier() override;
     45
    4446    // WebCore::ModelPlayer overrides.
    4547    void enterFullscreen() override;
  • trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm

    r285986 r286019  
    4949}
    5050
     51std::optional<ModelIdentifier> ARKitInlinePreviewModelPlayerIOS::modelIdentifier()
     52{
     53    if (!client())
     54        return { };
     55
     56    if (auto layerId = client()->platformLayerID())
     57        return { { layerId } };
     58
     59    return { };
     60}
     61
    5162// MARK: - WebCore::ModelPlayer overrides.
    5263
    5364void ARKitInlinePreviewModelPlayerIOS::enterFullscreen()
    5465{
    55     if (!client() || !page())
     66    auto* strongPage = page();
     67    if (!strongPage)
    5668        return;
    5769
    58     if (auto layerId = client()->platformLayerID())
    59         page()->takeModelElementFullscreen(layerId);
     70    if (auto modelIdentifier = this->modelIdentifier())
     71        strongPage->send(Messages::WebPageProxy::TakeModelElementFullscreen(*modelIdentifier));
    6072}
    6173
  • trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.h

    r285986 r286019  
    4848    ARKitInlinePreviewModelPlayerMac(WebPage&, WebCore::ModelPlayerClient&);
    4949
     50    std::optional<ModelIdentifier> modelIdentifier() override;
     51
    5052    // WebCore::ModelPlayer overrides.
    5153    void load(WebCore::Model&, WebCore::LayoutSize) override;
  • trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm

    r285986 r286019  
    5656}
    5757
     58std::optional<ModelIdentifier> ARKitInlinePreviewModelPlayerMac::modelIdentifier()
     59{
     60    if (m_inlinePreview)
     61        return { { [m_inlinePreview uuid].UUIDString } };
     62    return { };
     63}
     64
    5865static String& sharedModelElementCacheDirectory()
    5966{
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r285973 r286019  
    15251525#endif
    15261526
    1527 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    1528 void WebChromeClient::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId) const
    1529 {
    1530     m_page.takeModelElementFullscreen(contentLayerId);
    1531 }
    1532 #endif
    1533 
    15341527#if ENABLE(APPLE_PAY_AMS_UI)
    15351528
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r285973 r286019  
    456456#endif
    457457
    458 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    459     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId) const final;
    460 #endif
    461 
    462458#if ENABLE(APPLE_PAY_AMS_UI)
    463459    void startApplePayAMSUISession(const URL&, const WebCore::ApplePayAMSUIRequest&, CompletionHandler<void(std::optional<bool>&&)>&&) final;
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r285973 r286019  
    77907790#endif
    77917791
    7792 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    7793 void WebPage::takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId)
    7794 {
    7795     send(Messages::WebPageProxy::TakeModelElementFullscreen(contentLayerId));
    7796 }
    7797 #endif
    7798 
    77997792void WebPage::scrollToRect(const WebCore::FloatRect& targetRect, const WebCore::FloatPoint& origin)
    78007793{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r285973 r286019  
    14911491#endif
    14921492
    1493 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
    1494     void takeModelElementFullscreen(WebCore::GraphicsLayer::PlatformLayerID contentLayerId);
    1495 #endif
    1496 
    14971493    void prepareToRunModalJavaScriptDialog();
    14981494
Note: See TracChangeset for help on using the changeset viewer.