Changeset 288728 in webkit
- Timestamp:
- Jan 27, 2022 11:02:29 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 20 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/model-element/model-element-camera.html (modified) (2 diffs)
-
LayoutTests/model-element/model-element-interactive-dragging-expected.txt (added)
-
LayoutTests/model-element/model-element-interactive-dragging.html (added)
-
LayoutTests/model-element/model-element-interactive-expected.txt (added)
-
LayoutTests/model-element/model-element-interactive.html (added)
-
LayoutTests/model-element/resources/model-utils.js (added)
-
LayoutTests/platform/ios/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/mac/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/model-element/HTMLModelElement.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/model-element/HTMLModelElement.h (modified) (2 diffs)
-
Source/WebCore/Modules/model-element/HTMLModelElement.idl (modified) (1 diff)
-
Source/WebCore/Modules/model-element/ModelPlayer.cpp (modified) (1 diff)
-
Source/WebCore/Modules/model-element/ModelPlayer.h (modified) (1 diff)
-
Source/WebCore/html/HTMLAttributeNames.in (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/ModelElementController.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/WKModelView.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h (modified) (1 diff)
-
Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r288707 r288728 1 2022-01-27 Antoine Quint <graouts@webkit.org> 2 3 [Model] Allow disabling interaction 4 https://bugs.webkit.org/show_bug.cgi?id=227621 5 <rdar://problem/80079703> 6 7 Reviewed by Darin Adler. 8 9 Add two new tests: 10 11 - model-element/model-element-interactive.html tests the "interactive" IDL property 12 and the "interactive" HTML attribute, 13 - model-element/model-element-interactive-dragging.html tests that the "interactive" 14 IDL property correctly disables setting the camera by dragging when "false", and allows 15 it when "true". 16 17 We also refactor some code previously found in model-element/model-element-camera.html 18 to now be in the shared model-element/resources/model-utils.js to ease writing <model> 19 tests. 20 21 * model-element/model-element-camera.html: 22 * model-element/model-element-interactive-dragging-expected.txt: Added. 23 * model-element/model-element-interactive-dragging.html: Added. 24 * model-element/model-element-interactive-expected.txt: Added. 25 * model-element/model-element-interactive.html: Added. 26 * model-element/resources/model-utils.js: Added. 27 (const.makeModel): 28 (const.bodyAvailability.async return): 29 (const.bodyAvailability): 30 (const.readyModel.async test): 31 (const.assert_cameras_are_equal): 32 (const.assert_cameras_are_not_equal): 33 * platform/ios/TestExpectations: 34 * platform/mac/TestExpectations: 35 1 36 2022-01-27 Chris Dumez <cdumez@apple.com> 2 37 -
trunk/LayoutTests/model-element/model-element-camera.html
r288440 r288728 1 1 <script src="../resources/testharness.js"></script> 2 2 <script src="../resources/testharnessreport.js"></script> 3 <script src="resources/model-utils.js"></script> 3 4 <script> 4 5 5 const makeModel = () => {6 const source = document.createElement("source");7 source.src = "resources/cube.usdz";8 const model = document.createElement("model");9 model.appendChild(source);10 return model;11 }12 13 const bodyAvailability = async () => {14 return new Promise(resolve => {15 if (document.body)16 resolve();17 else18 window.addEventListener("DOMContentLoaded", event => resolve());19 });20 };21 22 const readyModel = async (test) => {23 await bodyAvailability();24 const model = document.body.appendChild(makeModel());25 test.add_cleanup(() => model.remove());26 await model.ready;27 return model;28 };29 30 const epsilon = 0.001;31 6 const expectedCamera = { pitch: 10, yaw: 40, scale: 2 }; 32 7 … … 58 33 await model.setCamera(expectedCamera); 59 34 const actualCamera = await model.getCamera(); 60 assert_approx_equals(actualCamera.pitch, expectedCamera.pitch, epsilon, "Camera has expected pitch"); 61 assert_approx_equals(actualCamera.yaw, expectedCamera.yaw, epsilon, "Camera has expected yaw"); 62 assert_approx_equals(actualCamera.scale, expectedCamera.scale, epsilon, "Camera has expected scale"); 35 assert_cameras_are_equal(actualCamera, expectedCamera); 63 36 }, "<model> can set the camera and read it back"); 64 37 -
trunk/LayoutTests/platform/ios/TestExpectations
r288697 r288728 3420 3420 # This test requires ARQL SPIs not yet available to OpenSource builds. 3421 3421 model-element/model-element-camera.html [ Skip ] 3422 model-element/model-element-interactive-dragging.html [ Skip ] 3422 3423 3423 3424 # These tests require the design system ui fonts to be installed. -
trunk/LayoutTests/platform/mac/TestExpectations
r288655 r288728 110 110 # This test requires ARQL SPIs not yet available to OpenSource builds. 111 111 model-element/model-element-camera.html [ Skip ] 112 model-element/model-element-interactive-dragging.html [ Skip ] 112 113 113 114 # Accessibility tests for notifications that don't exist or aren't needed on Mac OS X. -
trunk/Source/WebCore/ChangeLog
r288726 r288728 1 2022-01-27 Antoine Quint <graouts@webkit.org> 2 3 [Model] Allow disabling interaction 4 https://bugs.webkit.org/show_bug.cgi?id=227621 5 <rdar://problem/80079703> 6 7 Reviewed by Darin Adler. 8 9 We add support for the "interactive" IDL property and HTML attribute as discussed 10 in the <model> explainer at https://github.com/WebKit/explainers/tree/main/model. 11 12 If the "interactive" property is "true", then the HTML "interactive" attribute is 13 set on the element. If the property is "false", then the HTML attribute is absent. 14 15 Likewise, if the HTML attribute is present, the property returns "true". If the 16 HTML attribute is midding, the property returns "false". 17 18 Note that the value held by the HTML attribute is not taken into account, its mere 19 presence is all that is required. 20 21 Based on the value of the "interactive" property, we either disable or enable 22 interaction. On macOS, we check the property in HTMLModelElement::defaultEventHandler() 23 while on iOS, where dragging is performed entirely in the UI process, we use the 24 new ModelPlayer::setInteractionEnabled() method. 25 26 By default, interaction is disabled. 27 28 Tests: model-element/model-element-interactive-dragging.html 29 model-element/model-element-interactive.html 30 31 * Modules/model-element/HTMLModelElement.cpp: 32 (WebCore::HTMLModelElement::isInteractive const): 33 (WebCore::HTMLModelElement::attributeChanged): 34 (WebCore::HTMLModelElement::defaultEventHandler): 35 * Modules/model-element/HTMLModelElement.h: 36 * Modules/model-element/HTMLModelElement.idl: 37 * Modules/model-element/ModelPlayer.cpp: 38 (WebCore::ModelPlayer::setInteractionEnabled): 39 * Modules/model-element/ModelPlayer.h: 40 * html/HTMLAttributeNames.in: 41 1 42 2022-01-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 43 -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp
r288723 r288728 335 335 } 336 336 337 bool HTMLModelElement::isInteractive() const 338 { 339 return hasAttributeWithoutSynchronization(HTMLNames::interactiveAttr); 340 } 341 342 void HTMLModelElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason reason) 343 { 344 HTMLElement::attributeChanged(name, oldValue, newValue, reason); 345 if (m_modelPlayer && name == HTMLNames::interactiveAttr) 346 m_modelPlayer->setInteractionEnabled(isInteractive()); 347 } 348 337 349 void HTMLModelElement::defaultEventHandler(Event& event) 338 350 { 351 HTMLElement::defaultEventHandler(event); 352 339 353 if (!m_modelPlayer || !m_modelPlayer->supportsMouseInteraction()) 340 354 return; … … 350 364 return; 351 365 352 if (type == eventNames().mousedownEvent && !m_isDragging && !event.defaultPrevented() )366 if (type == eventNames().mousedownEvent && !m_isDragging && !event.defaultPrevented() && isInteractive()) 353 367 dragDidStart(mouseEvent); 354 368 else if (type == eventNames().mousemoveEvent && m_isDragging) -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h
r288723 r288728 120 120 // DOM overrides. 121 121 void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final; 122 void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) final; 122 123 123 124 // Rendering overrides. … … 143 144 void setAnimationIsPlaying(bool, DOMPromiseDeferred<void>&&); 144 145 146 bool isInteractive() const; 147 145 148 URL m_sourceURL; 146 149 CachedResourceHandle<CachedRawResource> m_resource; -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl
r288424 r288728 34 34 readonly attribute Promise<HTMLModelElement> ready; 35 35 36 [Reflect] attribute boolean interactive; 37 36 38 undefined enterFullscreen(); 37 39 -
trunk/Source/WebCore/Modules/model-element/ModelPlayer.cpp
r288723 r288728 41 41 } 42 42 43 void ModelPlayer::setInteractionEnabled(bool) 44 { 43 45 } 46 47 } -
trunk/Source/WebCore/Modules/model-element/ModelPlayer.h
r288723 r288728 49 49 virtual bool supportsMouseInteraction(); 50 50 virtual bool supportsDragging(); 51 virtual void setInteractionEnabled(bool); 51 52 virtual void handleMouseDown(const LayoutPoint&, MonotonicTime) = 0; 52 53 virtual void handleMouseMove(const LayoutPoint&, MonotonicTime) = 0; -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r287019 r288728 162 162 inputmode 163 163 integrity 164 interactive 164 165 is 165 166 ismap -
trunk/Source/WebKit/ChangeLog
r288723 r288728 1 2022-01-27 Antoine Quint <graouts@webkit.org> 2 3 [Model] Allow disabling interaction 4 https://bugs.webkit.org/show_bug.cgi?id=227621 5 <rdar://problem/80079703> 6 7 Reviewed by Darin Adler. 8 9 Override the new ModelPlayer::setInteractionEnabled() method for the iOS flavor 10 and send the value up to the UI process such that it may set the matching value 11 for UIView.userInteractionEnabled on the matching WKModelView. 12 13 * UIProcess/Cocoa/ModelElementControllerCocoa.mm: 14 (WebKit::ModelElementController::setInteractionEnabledForModelElement): 15 * UIProcess/ModelElementController.h: 16 * UIProcess/WebPageProxy.cpp: 17 (WebKit::WebPageProxy::modelElementSetInteractionEnabled): 18 * UIProcess/WebPageProxy.h: 19 * UIProcess/WebPageProxy.messages.in: 20 * UIProcess/ios/WKModelView.mm: 21 (-[WKModelView initWithModel:]): 22 * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h: 23 * WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm: 24 (WebKit::ARKitInlinePreviewModelPlayerIOS::setInteractionEnabled): 25 1 26 2022-01-27 Antoine Quint <graouts@webkit.org> 2 27 -
trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm
r288610 r288728 132 132 } 133 133 134 void ModelElementController::setInteractionEnabledForModelElement(ModelIdentifier modelIdentifier, bool isInteractionEnabled) 135 { 136 if (auto *modelView = modelViewForModelIdentifier(modelIdentifier)) 137 modelView.userInteractionEnabled = isInteractionEnabled; 138 } 139 134 140 #endif 135 141 -
trunk/Source/WebKit/UIProcess/ModelElementController.h
r286317 r288728 68 68 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) 69 69 void takeModelElementFullscreen(ModelIdentifier); 70 void setInteractionEnabledForModelElement(ModelIdentifier, bool); 70 71 #endif 71 72 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r288610 r288728 11004 11004 modelElementController()->takeModelElementFullscreen(modelIdentifier); 11005 11005 } 11006 11007 void WebPageProxy::modelElementSetInteractionEnabled(ModelIdentifier modelIdentifier, bool isInteractionEnabled) 11008 { 11009 modelElementController()->setInteractionEnabledForModelElement(modelIdentifier, isInteractionEnabled); 11010 } 11006 11011 #endif 11007 11012 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r288679 r288728 606 606 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) 607 607 void takeModelElementFullscreen(ModelIdentifier); 608 void modelElementSetInteractionEnabled(ModelIdentifier, bool); 608 609 #endif 609 610 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r288610 r288728 586 586 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) 587 587 TakeModelElementFullscreen(struct WebKit::ModelIdentifier modelIdentifier) 588 ModelElementSetInteractionEnabled(struct WebKit::ModelIdentifier modelIdentifier, bool isInteractionEnabled) 588 589 #endif 589 590 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC) -
trunk/Source/WebKit/UIProcess/ios/WKModelView.mm
r286317 r288728 100 100 _modelInteractionGestureRecognizer = adoptNS([[WKModelInteractionGestureRecognizer alloc] init]); 101 101 [self addGestureRecognizer:_modelInteractionGestureRecognizer.get()]; 102 self.userInteractionEnabled = NO; 102 103 103 104 return self; -
trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.h
r288694 r288728 46 46 // WebCore::ModelPlayer overrides. 47 47 void enterFullscreen() override; 48 void setInteractionEnabled(bool) override; 48 49 void handleMouseDown(const WebCore::LayoutPoint&, MonotonicTime) override; 49 50 void handleMouseMove(const WebCore::LayoutPoint&, MonotonicTime) override; -
trunk/Source/WebKit/WebProcess/Model/ios/ARKitInlinePreviewModelPlayerIOS.mm
r288694 r288728 72 72 } 73 73 74 void ARKitInlinePreviewModelPlayerIOS::setInteractionEnabled(bool isInteractionEnabled) 75 { 76 RefPtr strongPage = page(); 77 if (!strongPage) 78 return; 79 80 if (auto modelIdentifier = this->modelIdentifier()) 81 strongPage->send(Messages::WebPageProxy::ModelElementSetInteractionEnabled(*modelIdentifier, isInteractionEnabled)); 82 } 83 74 84 void ARKitInlinePreviewModelPlayerIOS::handleMouseDown(const WebCore::LayoutPoint&, MonotonicTime) 75 85 {
Note: See TracChangeset
for help on using the changeset viewer.