Title: [291245] trunk
Revision
291245
Author
grao...@webkit.org
Date
2022-03-14 12:36:13 -0700 (Mon, 14 Mar 2022)

Log Message

[model] <model interactive> doesn't allow model to be rotated on iOS
https://bugs.webkit.org/show_bug.cgi?id=237831
rdar://89698247

Reviewed by Simon Fraser.

Source/WebCore:

A <model> element is *not* interactive by default and the "interactive" HTML attribute
must be set explicitly. We used to mirror this initial disabled state by explicitly
setting "userInteractionEnabled" to NO on WKModelView during its creation, and we would
update that property when HTMLModelElement::isInteractive() would change value.

However, in the case where the attribute was originally set, we would completely
disregard that value.

We now account for it when we create the GraphicsLayer for the <model> element, letting the
existing GraphicsLayer machinery to set the matching "userInteractionEnabled" property on
the WKModelView.

* Modules/model-element/HTMLModelElement.h:
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setContentsToModel):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setContentsToModel):
* platform/graphics/ca/GraphicsLayerCA.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):

Source/WebKit:

Remove the call to set userInteractionEnabled on the WKModelView when created. This property
is now set via the layer tree application code from the GraphicsLayer::userInteractionEnabled()
value.

* UIProcess/ios/WKModelView.mm:
(-[WKModelView initWithModel:]):

LayoutTests:

Add a test where the <model> element is added to the DOM with the "interactive"
HTML attribute already set.

* model-element/model-element-interactive-dragging-expected.txt:
* model-element/model-element-interactive-dragging.html:
* model-element/resources/model-utils.js:
(const.makeModel):
(const.readyModel.async test):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291244 => 291245)


--- trunk/LayoutTests/ChangeLog	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/LayoutTests/ChangeLog	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1,3 +1,20 @@
+2022-03-14  Antoine Quint  <grao...@webkit.org>
+
+        [model] <model interactive> doesn't allow model to be rotated on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=237831
+        rdar://89698247
+
+        Reviewed by Simon Fraser.
+
+        Add a test where the <model> element is added to the DOM with the "interactive"
+        HTML attribute already set.
+
+        * model-element/model-element-interactive-dragging-expected.txt:
+        * model-element/model-element-interactive-dragging.html:
+        * model-element/resources/model-utils.js:
+        (const.makeModel):
+        (const.readyModel.async test):
+
 2022-03-14  Oriol Brufau  <obru...@igalia.com>
 
         [css] Implement 'text-decoration' as a shorthand.

Modified: trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt (291244 => 291245)


--- trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/LayoutTests/model-element/model-element-interactive-dragging-expected.txt	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1,4 +1,5 @@
 
 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
+PASS Dragging over a <model> affects the camera when interactive is set to true using the HTML attribute as the element is created
 

Modified: trunk/LayoutTests/model-element/model-element-interactive-dragging.html (291244 => 291245)


--- trunk/LayoutTests/model-element/model-element-interactive-dragging.html	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/LayoutTests/model-element/model-element-interactive-dragging.html	2022-03-14 19:36:13 UTC (rev 291245)
@@ -56,6 +56,14 @@
     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");
 
+promise_test(async test => {
+    const model = await readyModel(test, { 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 set to true using the HTML attribute as the element is created");
+
 </script>
 </body>
 </html>

Modified: trunk/LayoutTests/model-element/resources/model-utils.js (291244 => 291245)


--- trunk/LayoutTests/model-element/resources/model-utils.js	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/LayoutTests/model-element/resources/model-utils.js	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1,8 +1,10 @@
 
-const makeModel = () => {
+const makeModel = (options = { interactive: false }) => {
     const source = document.createElement("source");
     source.src = ""
     const model = document.createElement("model");
+    if (options.interactive)
+        model.setAttribute("interactive", "");
     model.appendChild(source);
     return model;
 }
@@ -16,9 +18,9 @@
     });
 };
 
-const readyModel = async (test) => {
+const readyModel = async (test, options) => {
     await bodyAvailability();
-    const model = document.body.appendChild(makeModel());
+    const model = document.body.appendChild(makeModel(options));
     test.add_cleanup(() => model.remove());
     await model.ready;
     return model;

Modified: trunk/Source/WebCore/ChangeLog (291244 => 291245)


--- trunk/Source/WebCore/ChangeLog	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/ChangeLog	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1,3 +1,32 @@
+2022-03-14  Antoine Quint  <grao...@webkit.org>
+
+        [model] <model interactive> doesn't allow model to be rotated on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=237831
+        rdar://89698247
+
+        Reviewed by Simon Fraser.
+
+        A <model> element is *not* interactive by default and the "interactive" HTML attribute
+        must be set explicitly. We used to mirror this initial disabled state by explicitly
+        setting "userInteractionEnabled" to NO on WKModelView during its creation, and we would
+        update that property when HTMLModelElement::isInteractive() would change value.
+
+        However, in the case where the attribute was originally set, we would completely
+        disregard that value.
+
+        We now account for it when we create the GraphicsLayer for the <model> element, letting the
+        existing GraphicsLayer machinery to set the matching "userInteractionEnabled" property on
+        the WKModelView.
+
+        * Modules/model-element/HTMLModelElement.h:
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setContentsToModel):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setContentsToModel):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+
 2022-03-14  Oriol Brufau  <obru...@igalia.com>
 
         [css] Implement 'text-decoration' as a shorthand.

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2022-03-14 19:36:13 UTC (rev 291245)
@@ -101,6 +101,8 @@
     bool supportsDragging() const;
     bool isDraggableIgnoringAttributes() const final;
 
+    bool isInteractive() const;
+
 #if PLATFORM(COCOA)
     Vector<RetainPtr<id>> accessibilityChildren();
 #endif
@@ -146,8 +148,6 @@
 
     void setAnimationIsPlaying(bool, DOMPromiseDeferred<void>&&);
 
-    bool isInteractive() const;
-
     LayoutSize contentSize() const;
 
     URL m_sourceURL;

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (291244 => 291245)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2022-03-14 19:36:13 UTC (rev 291245)
@@ -525,7 +525,8 @@
     virtual void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) { }
     virtual void setContentsDisplayDelegate(RefPtr<GraphicsLayerContentsDisplayDelegate>&&, ContentsLayerPurpose);
 #if ENABLE(MODEL_ELEMENT)
-    virtual void setContentsToModel(RefPtr<Model>&&) { }
+    enum class ModelInteraction : uint8_t { Enabled, Disabled };
+    virtual void setContentsToModel(RefPtr<Model>&&, ModelInteraction) { }
     virtual PlatformLayerID contentsLayerIDForModel() const { return 0; }
 #endif
     virtual bool usesContentsLayer() const { return false; }

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (291244 => 291245)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1285,7 +1285,7 @@
 }
 
 #if ENABLE(MODEL_ELEMENT)
-void GraphicsLayerCA::setContentsToModel(RefPtr<Model>&& model)
+void GraphicsLayerCA::setContentsToModel(RefPtr<Model>&& model, ModelInteraction interactive)
 {
     if (model == m_contentsModel)
         return;
@@ -1302,6 +1302,7 @@
         m_contentsLayer->setName(MAKE_STATIC_STRING_IMPL("contents model"));
 #endif
 
+        m_contentsLayer->setUserInteractionEnabled(interactive == ModelInteraction::Enabled);
         m_contentsLayer->setAnchorPoint({ });
         m_contentsLayerPurpose = ContentsLayerPurpose::Model;
         contentsLayerChanged = true;

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (291244 => 291245)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2022-03-14 19:36:13 UTC (rev 291245)
@@ -154,7 +154,7 @@
 
     WEBCORE_EXPORT void setContentsToSolidColor(const Color&) override;
 #if ENABLE(MODEL_ELEMENT)
-    WEBCORE_EXPORT void setContentsToModel(RefPtr<Model>&&) override;
+    WEBCORE_EXPORT void setContentsToModel(RefPtr<Model>&&, ModelInteraction) override;
     WEBCORE_EXPORT PlatformLayerID contentsLayerIDForModel() const override;
 #endif
     WEBCORE_EXPORT void setContentsMinificationFilter(ScalingFilter) override;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (291244 => 291245)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1108,7 +1108,7 @@
         if (element->usesPlatformLayer())
             m_graphicsLayer->setContentsToPlatformLayer(element->platformLayer(), GraphicsLayer::ContentsLayerPurpose::Model);
         else if (auto model = element->model())
-            m_graphicsLayer->setContentsToModel(WTFMove(model));
+            m_graphicsLayer->setContentsToModel(WTFMove(model), element->isInteractive() ? GraphicsLayer::ModelInteraction::Enabled : GraphicsLayer::ModelInteraction::Disabled);
 
         layerConfigChanged = true;
     }

Modified: trunk/Source/WebKit/ChangeLog (291244 => 291245)


--- trunk/Source/WebKit/ChangeLog	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebKit/ChangeLog	2022-03-14 19:36:13 UTC (rev 291245)
@@ -1,3 +1,18 @@
+2022-03-14  Antoine Quint  <grao...@webkit.org>
+
+        [model] <model interactive> doesn't allow model to be rotated on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=237831
+        rdar://89698247
+
+        Reviewed by Simon Fraser.
+
+        Remove the call to set userInteractionEnabled on the WKModelView when created. This property
+        is now set via the layer tree application code from the GraphicsLayer::userInteractionEnabled()
+        value.
+
+        * UIProcess/ios/WKModelView.mm:
+        (-[WKModelView initWithModel:]):
+
 2022-03-14  Simon Fraser  <simon.fra...@apple.com>
 
         Do a single IPC for MarkSurfaceNonVolatile and SwapToValidFrontBuffer

Modified: trunk/Source/WebKit/UIProcess/ios/WKModelView.mm (291244 => 291245)


--- trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-03-14 19:18:11 UTC (rev 291244)
+++ trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-03-14 19:36:13 UTC (rev 291245)
@@ -99,7 +99,6 @@
 
     _modelInteractionGestureRecognizer = adoptNS([[WKModelInteractionGestureRecognizer alloc] init]);
     [self addGestureRecognizer:_modelInteractionGestureRecognizer.get()];
-    self.userInteractionEnabled = NO;
 
     return self;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to