Title: [288728] trunk
Revision
288728
Author
grao...@webkit.org
Date
2022-01-27 23:02:29 -0800 (Thu, 27 Jan 2022)

Log Message

[Model] Allow disabling interaction
https://bugs.webkit.org/show_bug.cgi?id=227621
<rdar://problem/80079703>

Reviewed by Darin Adler.

Source/WebCore:

We add support for the "interactive" IDL property and HTML attribute as discussed
in the <model> explainer at https://github.com/WebKit/explainers/tree/main/model.

If the "interactive" property is "true", then the HTML "interactive" attribute is
set on the element. If the property is "false", then the HTML attribute is absent.

Likewise, if the HTML attribute is present, the property returns "true". If the
HTML attribute is midding, the property returns "false".

Note that the value held by the HTML attribute is not taken into account, its mere
presence is all that is required.

Based on the value of the "interactive" property, we either disable or enable
interaction. On macOS, we check the property in HTMLModelElement::defaultEventHandler()
while on iOS, where dragging is performed entirely in the UI process, we use the
new ModelPlayer::setInteractionEnabled() method.

By default, interaction is disabled.

Tests: model-element/model-element-interactive-dragging.html
       model-element/model-element-interactive.html

* Modules/model-element/HTMLModelElement.cpp:
(WebCore::HTMLModelElement::isInteractive const):
(WebCore::HTMLModelElement::attributeChanged):
(WebCore::HTMLModelElement::defaultEventHandler):
* Modules/model-element/HTMLModelElement.h:
* Modules/model-element/HTMLModelElement.idl:
* Modules/model-element/ModelPlayer.cpp:
(WebCore::ModelPlayer::setInteractionEnabled):
* Modules/model-element/ModelPlayer.h:
* html/HTMLAttributeNames.in:

Source/WebKit:

Override the new ModelPlayer::setInteractionEnabled() method for the iOS flavor
and send the value up to the UI process such that it may set the matching value
for UIView.userInteractionEnabled on the matching WKModelView.

* UIProcess/Cocoa/ModelElementControllerCocoa.mm:
(WebKit::ModelElementController::setInteractionEnabledForModelElement):
* UIProcess/ModelElementController.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::modelElementSetInteractionEnabled):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WKModelView.mm:
(-[WKModelView initWithModel:]):
* WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h:
* WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm:
(WebKit::ARKitInlinePreviewModelPlayerIOS::setInteractionEnabled):

LayoutTests:

Add two new tests:

- model-element/model-element-interactive.html tests the "interactive" IDL property
and the "interactive" HTML attribute,
- model-element/model-element-interactive-dragging.html tests that the "interactive"
IDL property correctly disables setting the camera by dragging when "false", and allows
it when "true".

We also refactor some code previously found in model-element/model-element-camera.html
to now be in the shared model-element/resources/model-utils.js to ease writing <model>
tests.

* model-element/model-element-camera.html:
* model-element/model-element-interactive-dragging-expected.txt: Added.
* model-element/model-element-interactive-dragging.html: Added.
* model-element/model-element-interactive-expected.txt: Added.
* model-element/model-element-interactive.html: Added.
* model-element/resources/model-utils.js: Added.
(const.makeModel):
(const.bodyAvailability.async return):
(const.bodyAvailability):
(const.readyModel.async test):
(const.assert_cameras_are_equal):
(const.assert_cameras_are_not_equal):
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288727 => 288728)


--- trunk/LayoutTests/ChangeLog	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/LayoutTests/ChangeLog	2022-01-28 07:02:29 UTC (rev 288728)
@@ -1,3 +1,38 @@
+2022-01-27  Antoine Quint  <grao...@webkit.org>
+
+        [Model] Allow disabling interaction
+        https://bugs.webkit.org/show_bug.cgi?id=227621
+        <rdar://problem/80079703>
+
+        Reviewed by Darin Adler.
+
+        Add two new tests:
+        
+        - model-element/model-element-interactive.html tests the "interactive" IDL property
+        and the "interactive" HTML attribute,
+        - model-element/model-element-interactive-dragging.html tests that the "interactive"
+        IDL property correctly disables setting the camera by dragging when "false", and allows
+        it when "true".
+
+        We also refactor some code previously found in model-element/model-element-camera.html
+        to now be in the shared model-element/resources/model-utils.js to ease writing <model>
+        tests.
+
+        * model-element/model-element-camera.html:
+        * model-element/model-element-interactive-dragging-expected.txt: Added.
+        * model-element/model-element-interactive-dragging.html: Added.
+        * model-element/model-element-interactive-expected.txt: Added.
+        * model-element/model-element-interactive.html: Added.
+        * model-element/resources/model-utils.js: Added.
+        (const.makeModel):
+        (const.bodyAvailability.async return):
+        (const.bodyAvailability):
+        (const.readyModel.async test):
+        (const.assert_cameras_are_equal):
+        (const.assert_cameras_are_not_equal):
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2022-01-27  Chris Dumez  <cdu...@apple.com>
 
         Geolocation API should callback with error if doc is not fully active

Modified: trunk/LayoutTests/model-element/model-element-camera.html (288727 => 288728)


--- trunk/LayoutTests/model-element/model-element-camera.html	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/LayoutTests/model-element/model-element-camera.html	2022-01-28 07:02:29 UTC (rev 288728)
@@ -1,33 +1,8 @@
 <script src=""
 <script src=""
+<script src=""
 <script>
 
-const makeModel = () => {
-    const source = document.createElement("source");
-    source.src = ""
-    const model = document.createElement("model");
-    model.appendChild(source);
-    return model;
-}
-
-const bodyAvailability = async () => {
-    return new Promise(resolve => {
-        if (document.body)
-            resolve();
-        else
-            window.addEventListener("DOMContentLoaded", event => resolve());
-    });
-};
-
-const readyModel = async (test) => {
-    await bodyAvailability();
-    const model = document.body.appendChild(makeModel());
-    test.add_cleanup(() => model.remove());
-    await model.ready;
-    return model;
-};
-
-const epsilon = 0.001;
 const expectedCamera = { pitch: 10, yaw: 40, scale: 2 };
 
 test(() => {
@@ -57,9 +32,7 @@
     const model = await readyModel(test);
     await model.setCamera(expectedCamera);
     const actualCamera = await model.getCamera();
-    assert_approx_equals(actualCamera.pitch, expectedCamera.pitch, epsilon, "Camera has expected pitch");
-    assert_approx_equals(actualCamera.yaw, expectedCamera.yaw, epsilon, "Camera has expected yaw");
-    assert_approx_equals(actualCamera.scale, expectedCamera.scale, epsilon, "Camera has expected scale");
+    assert_cameras_are_equal(actualCamera, expectedCamera);
 }, "<model> can set the camera and read it back");
 
 promise_test(async test => {

Added: trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt (0 => 288728)


--- trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt	2022-01-28 07:02:29 UTC (rev 288728)
@@ -0,0 +1,4 @@
+
+PASS Dragging over a <model> has no effect on the camera when interactive is false
+PASS Dragging over a <model> affects the camera when interactive is true
+

Added: trunk/LayoutTests/model-element/model-element-interactive-dragging.html (0 => 288728)


--- trunk/LayoutTests/model-element/model-element-interactive-dragging.html	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-interactive-dragging.html	2022-01-28 07:02:29 UTC (rev 288728)
@@ -0,0 +1,61 @@
+<script src=""
+<script src=""
+<script src=""
+<style>
+
+model {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 400px;
+    height: 400px;
+}
+
+</style>
+<script>
+
+const dragModel = async (model) => {
+    const bounds = model.getBoundingClientRect();
+    const startPoint = new DOMPoint(
+        bounds.x + bounds.width / 2,
+        bounds.y + bounds.height / 2
+    );
+    const endPoint = new DOMPoint(
+        startPoint.x + bounds.width / 4,
+        startPoint.y + bounds.height / 4
+    );
+    return new Promise((resolve, reject) => {
+        if (!("eventSender" in window)) {
+            reject();
+            return;
+        }
+
+        eventSender.mouseMoveTo(startPoint.x, startPoint.y);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(endPoint.x, endPoint.y);
+        eventSender.mouseUp();
+        resolve();
+    });
+};
+
+promise_test(async test => {
+    const model = await readyModel(test);
+    model.interactive = false;
+    const cameraBeforeDrag = await model.getCamera();
+    await dragModel(model);
+    const cameraAfterDrag = await model.getCamera();
+    assert_cameras_are_equal(cameraAfterDrag, cameraBeforeDrag, "cameras before and after drag match");
+}, "Dragging over a <model> has no effect on the camera when interactive is false");
+
+promise_test(async test => {
+    const model = await readyModel(test);
+    model.interactive = true;
+    const cameraBeforeDrag = await model.getCamera();
+    await dragModel(model);
+    const cameraAfterDrag = await model.getCamera();
+    assert_cameras_are_not_equal(cameraAfterDrag, cameraBeforeDrag, "cameras before and after drag are different");
+}, "Dragging over a <model> affects the camera when interactive is true");
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/model-element/model-element-interactive-expected.txt (0 => 288728)


--- trunk/LayoutTests/model-element/model-element-interactive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-interactive-expected.txt	2022-01-28 07:02:29 UTC (rev 288728)
@@ -0,0 +1,6 @@
+
+PASS <model> has interactive property
+PASS <model> interactive property default to false
+PASS <model> interactive property reflects the interactive HTML attribute
+PASS <model> interactive HTML attribute reflects the interactive property
+

Added: trunk/LayoutTests/model-element/model-element-interactive.html (0 => 288728)


--- trunk/LayoutTests/model-element/model-element-interactive.html	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-interactive.html	2022-01-28 07:02:29 UTC (rev 288728)
@@ -0,0 +1,40 @@
+<script src=""
+<script src=""
+<script>
+
+test(() => {
+    const model = document.createElement("model");
+    assert_idl_attribute(model, "interactive", "interactive is defined");
+}, "<model> has interactive property");
+
+test(() => {
+    const model = document.createElement("model");
+    assert_false(model.interactive, "interactive is false");
+}, "<model> interactive property default to false");
+
+test(() => {
+    const model = document.createElement("model");
+
+    model.setAttribute("interactive", "");
+    assert_true(model.interactive, "interactive is true when the HTML attribute has no value");
+
+    model.setAttribute("interactive", "false");
+    assert_true(model.interactive, "interactive is true when the HTML attribute has a 'false' value");
+
+    model.removeAttribute("interactive");
+    assert_false(model.interactive, "interactive is false");
+}, "<model> interactive property reflects the interactive HTML attribute");
+
+test(() => {
+    const model = document.createElement("model");
+
+    model.interactive = true;
+    assert_true(model.hasAttribute("interactive"), "interactive HTML attribute is present when interactive is true");
+
+    model.interactive = false;
+    assert_false(model.hasAttribute("interactive"), "interactive HTML attribute is not present when interactive is false");
+}, "<model> interactive HTML attribute reflects the interactive property");
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/model-element/resources/model-utils.js (0 => 288728)


--- trunk/LayoutTests/model-element/resources/model-utils.js	                        (rev 0)
+++ trunk/LayoutTests/model-element/resources/model-utils.js	2022-01-28 07:02:29 UTC (rev 288728)
@@ -0,0 +1,40 @@
+
+const makeModel = () => {
+    const source = document.createElement("source");
+    source.src = ""
+    const model = document.createElement("model");
+    model.appendChild(source);
+    return model;
+}
+
+const bodyAvailability = async () => {
+    return new Promise(resolve => {
+        if (document.body)
+            resolve();
+        else
+            window.addEventListener("DOMContentLoaded", event => resolve());
+    });
+};
+
+const readyModel = async (test) => {
+    await bodyAvailability();
+    const model = document.body.appendChild(makeModel());
+    test.add_cleanup(() => model.remove());
+    await model.ready;
+    return model;
+};
+
+const epsilon = 0.001;
+
+const assert_cameras_are_equal = (actualCamera, expectedCamera, description) => {
+    assert_approx_equals(actualCamera.pitch, expectedCamera.pitch, epsilon, `${description}: camera has expected pitch`);
+    assert_approx_equals(actualCamera.yaw, expectedCamera.yaw, epsilon, `${description}: camera has expected yaw`);
+    assert_approx_equals(actualCamera.scale, expectedCamera.scale, epsilon, `${description}: camera has expected scale`);
+};
+
+const assert_cameras_are_not_equal = (actualCamera, expectedCamera, description) => {
+    const camerasMatch = Math.abs(actualCamera.pitch - expectedCamera.pitch) > epsilon &&
+                         Math.abs(actualCamera.yaw - expectedCamera.yaw) > epsilon &&
+                         Math.abs(actualCamera.scale - expectedCamera.scale) > epsilon;
+    assert_false(camerasMatch, description);
+};

Modified: trunk/LayoutTests/platform/ios/TestExpectations (288727 => 288728)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-01-28 07:02:29 UTC (rev 288728)
@@ -3419,6 +3419,7 @@
 
 # This test requires ARQL SPIs not yet available to OpenSource builds.
 model-element/model-element-camera.html [ Skip ]
+model-element/model-element-interactive-dragging.html [ Skip ]
 
 # These tests require the design system ui fonts to be installed.
 fast/text/design-system-ui-11.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (288727 => 288728)


--- trunk/LayoutTests/platform/mac/TestExpectations	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2022-01-28 07:02:29 UTC (rev 288728)
@@ -109,6 +109,7 @@
 
 # This test requires ARQL SPIs not yet available to OpenSource builds.
 model-element/model-element-camera.html [ Skip ]
+model-element/model-element-interactive-dragging.html [ Skip ]
 
 # Accessibility tests for notifications that don't exist or aren't needed on Mac OS X.
 accessibility/aria-checkbox-sends-notification.html

Modified: trunk/Source/WebCore/ChangeLog (288727 => 288728)


--- trunk/Source/WebCore/ChangeLog	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/ChangeLog	2022-01-28 07:02:29 UTC (rev 288728)
@@ -1,3 +1,44 @@
+2022-01-27  Antoine Quint  <grao...@webkit.org>
+
+        [Model] Allow disabling interaction
+        https://bugs.webkit.org/show_bug.cgi?id=227621
+        <rdar://problem/80079703>
+
+        Reviewed by Darin Adler.
+
+        We add support for the "interactive" IDL property and HTML attribute as discussed
+        in the <model> explainer at https://github.com/WebKit/explainers/tree/main/model.
+
+        If the "interactive" property is "true", then the HTML "interactive" attribute is
+        set on the element. If the property is "false", then the HTML attribute is absent.
+
+        Likewise, if the HTML attribute is present, the property returns "true". If the
+        HTML attribute is midding, the property returns "false".
+
+        Note that the value held by the HTML attribute is not taken into account, its mere
+        presence is all that is required.
+
+        Based on the value of the "interactive" property, we either disable or enable
+        interaction. On macOS, we check the property in HTMLModelElement::defaultEventHandler()
+        while on iOS, where dragging is performed entirely in the UI process, we use the
+        new ModelPlayer::setInteractionEnabled() method.
+
+        By default, interaction is disabled.
+
+        Tests: model-element/model-element-interactive-dragging.html
+               model-element/model-element-interactive.html
+
+        * Modules/model-element/HTMLModelElement.cpp:
+        (WebCore::HTMLModelElement::isInteractive const):
+        (WebCore::HTMLModelElement::attributeChanged):
+        (WebCore::HTMLModelElement::defaultEventHandler):
+        * Modules/model-element/HTMLModelElement.h:
+        * Modules/model-element/HTMLModelElement.idl:
+        * Modules/model-element/ModelPlayer.cpp:
+        (WebCore::ModelPlayer::setInteractionEnabled):
+        * Modules/model-element/ModelPlayer.h:
+        * html/HTMLAttributeNames.in:
+
 2022-01-27  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][a11y] Do not set the children count when serializing objects for the ATSPI cache

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp	2022-01-28 07:02:29 UTC (rev 288728)
@@ -334,8 +334,22 @@
     return supportsDragging();
 }
 
+bool HTMLModelElement::isInteractive() const
+{
+    return hasAttributeWithoutSynchronization(HTMLNames::interactiveAttr);
+}
+
+void HTMLModelElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason reason)
+{
+    HTMLElement::attributeChanged(name, oldValue, newValue, reason);
+    if (m_modelPlayer && name == HTMLNames::interactiveAttr)
+        m_modelPlayer->setInteractionEnabled(isInteractive());
+}
+
 void HTMLModelElement::defaultEventHandler(Event& event)
 {
+    HTMLElement::defaultEventHandler(event);
+
     if (!m_modelPlayer || !m_modelPlayer->supportsMouseInteraction())
         return;
 
@@ -349,7 +363,7 @@
     if (mouseEvent.button() != LeftButton)
         return;
 
-    if (type == eventNames().mousedownEvent && !m_isDragging && !event.defaultPrevented())
+    if (type == eventNames().mousedownEvent && !m_isDragging && !event.defaultPrevented() && isInteractive())
         dragDidStart(mouseEvent);
     else if (type == eventNames().mousemoveEvent && m_isDragging)
         dragDidChange(mouseEvent);

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-01-28 07:02:29 UTC (rev 288728)
@@ -119,6 +119,7 @@
 
     // DOM overrides.
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
+    void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) final;
 
     // Rendering overrides.
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
@@ -142,6 +143,8 @@
 
     void setAnimationIsPlaying(bool, DOMPromiseDeferred<void>&&);
 
+    bool isInteractive() const;
+
     URL m_sourceURL;
     CachedResourceHandle<CachedRawResource> m_resource;
     SharedBufferBuilder m_data;

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl	2022-01-28 07:02:29 UTC (rev 288728)
@@ -33,6 +33,8 @@
     readonly attribute boolean complete;
     readonly attribute Promise<HTMLModelElement> ready;
 
+    [Reflect] attribute boolean interactive;
+
     undefined enterFullscreen();
 
     [Conditional=ARKIT_INLINE_PREVIEW_CAMERA_TRANSFORM] Promise<HTMLModelElementCamera> getCamera();

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


--- trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp	2022-01-28 07:02:29 UTC (rev 288728)
@@ -40,4 +40,8 @@
     return true;
 }
 
+void ModelPlayer::setInteractionEnabled(bool)
+{
 }
+
+}

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


--- trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/Modules/model-element/ModelPlayer.h	2022-01-28 07:02:29 UTC (rev 288728)
@@ -48,6 +48,7 @@
     virtual void enterFullscreen() = 0;
     virtual bool supportsMouseInteraction();
     virtual bool supportsDragging();
+    virtual void setInteractionEnabled(bool);
     virtual void handleMouseDown(const LayoutPoint&, MonotonicTime) = 0;
     virtual void handleMouseMove(const LayoutPoint&, MonotonicTime) = 0;
     virtual void handleMouseUp(const LayoutPoint&, MonotonicTime) = 0;

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (288727 => 288728)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2022-01-28 07:02:29 UTC (rev 288728)
@@ -161,6 +161,7 @@
 inert
 inputmode
 integrity
+interactive
 is
 ismap
 itemid

Modified: trunk/Source/WebKit/ChangeLog (288727 => 288728)


--- trunk/Source/WebKit/ChangeLog	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/ChangeLog	2022-01-28 07:02:29 UTC (rev 288728)
@@ -1,5 +1,30 @@
 2022-01-27  Antoine Quint  <grao...@webkit.org>
 
+        [Model] Allow disabling interaction
+        https://bugs.webkit.org/show_bug.cgi?id=227621
+        <rdar://problem/80079703>
+
+        Reviewed by Darin Adler.
+
+        Override the new ModelPlayer::setInteractionEnabled() method for the iOS flavor
+        and send the value up to the UI process such that it may set the matching value
+        for UIView.userInteractionEnabled on the matching WKModelView.
+
+        * UIProcess/Cocoa/ModelElementControllerCocoa.mm:
+        (WebKit::ModelElementController::setInteractionEnabledForModelElement):
+        * UIProcess/ModelElementController.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::modelElementSetInteractionEnabled):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WKModelView.mm:
+        (-[WKModelView initWithModel:]):
+        * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h:
+        * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm:
+        (WebKit::ARKitInlinePreviewModelPlayerIOS::setInteractionEnabled):
+
+2022-01-27  Antoine Quint  <grao...@webkit.org>
+
         <model> should not be draggable on macOS
         https://bugs.webkit.org/show_bug.cgi?id=235697
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm	2022-01-28 07:02:29 UTC (rev 288728)
@@ -131,6 +131,12 @@
     }];
 }
 
+void ModelElementController::setInteractionEnabledForModelElement(ModelIdentifier modelIdentifier, bool isInteractionEnabled)
+{
+    if (auto *modelView = modelViewForModelIdentifier(modelIdentifier))
+        modelView.userInteractionEnabled = isInteractionEnabled;
+}
+
 #endif
 
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)

Modified: trunk/Source/WebKit/UIProcess/ModelElementController.h (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/ModelElementController.h	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/ModelElementController.h	2022-01-28 07:02:29 UTC (rev 288728)
@@ -67,6 +67,7 @@
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     void takeModelElementFullscreen(ModelIdentifier);
+    void setInteractionEnabledForModelElement(ModelIdentifier, bool);
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     void modelElementDidCreatePreview(URL, String, WebCore::FloatSize, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-01-28 07:02:29 UTC (rev 288728)
@@ -11003,6 +11003,11 @@
 {
     modelElementController()->takeModelElementFullscreen(modelIdentifier);
 }
+
+void WebPageProxy::modelElementSetInteractionEnabled(ModelIdentifier modelIdentifier, bool isInteractionEnabled)
+{
+    modelElementController()->setInteractionEnabledForModelElement(modelIdentifier, isInteractionEnabled);
+}
 #endif
 
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-01-28 07:02:29 UTC (rev 288728)
@@ -605,6 +605,7 @@
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     void takeModelElementFullscreen(ModelIdentifier);
+    void modelElementSetInteractionEnabled(ModelIdentifier, bool);
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     void modelElementDidCreatePreview(const URL&, const String&, const WebCore::FloatSize&, CompletionHandler<void(Expected<std::pair<String, uint32_t>, WebCore::ResourceError>)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2022-01-28 07:02:29 UTC (rev 288728)
@@ -585,6 +585,7 @@
 
 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
     TakeModelElementFullscreen(struct WebKit::ModelIdentifier modelIdentifier)
+    ModelElementSetInteractionEnabled(struct WebKit::ModelIdentifier modelIdentifier, bool isInteractionEnabled)
 #endif
 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC)
     ModelElementDidCreatePreview(URL url, String uuid, WebCore::FloatSize size) -> (Expected<std::pair<String, uint32_t>, WebCore::ResourceError> result) Async

Modified: trunk/Source/WebKit/UIProcess/ios/WKModelView.mm (288727 => 288728)


--- trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-01-28 07:02:29 UTC (rev 288728)
@@ -99,6 +99,7 @@
 
     _modelInteractionGestureRecognizer = adoptNS([[WKModelInteractionGestureRecognizer alloc] init]);
     [self addGestureRecognizer:_modelInteractionGestureRecognizer.get()];
+    self.userInteractionEnabled = NO;
 
     return self;
 }

Modified: trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h (288727 => 288728)


--- trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h	2022-01-28 07:02:29 UTC (rev 288728)
@@ -45,6 +45,7 @@
 
     // WebCore::ModelPlayer overrides.
     void enterFullscreen() override;
+    void setInteractionEnabled(bool) override;
     void handleMouseDown(const WebCore::LayoutPoint&, MonotonicTime) override;
     void handleMouseMove(const WebCore::LayoutPoint&, MonotonicTime) override;
     void handleMouseUp(const WebCore::LayoutPoint&, MonotonicTime) override;

Modified: trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm (288727 => 288728)


--- trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm	2022-01-28 07:01:55 UTC (rev 288727)
+++ trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm	2022-01-28 07:02:29 UTC (rev 288728)
@@ -71,6 +71,16 @@
         strongPage->send(Messages::WebPageProxy::TakeModelElementFullscreen(*modelIdentifier));
 }
 
+void ARKitInlinePreviewModelPlayerIOS::setInteractionEnabled(bool isInteractionEnabled)
+{
+    RefPtr strongPage = page();
+    if (!strongPage)
+        return;
+
+    if (auto modelIdentifier = this->modelIdentifier())
+        strongPage->send(Messages::WebPageProxy::ModelElementSetInteractionEnabled(*modelIdentifier, isInteractionEnabled));
+}
+
 void ARKitInlinePreviewModelPlayerIOS::handleMouseDown(const WebCore::LayoutPoint&, MonotonicTime)
 {
     ASSERT_NOT_REACHED();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to