Title: [283563] trunk
Revision
283563
Author
[email protected]
Date
2021-10-05 11:40:31 -0700 (Tue, 05 Oct 2021)

Log Message

<model> should be draggable, similar to <img>
https://bugs.webkit.org/show_bug.cgi?id=229246

Reviewed by Wenson Hsieh.

Source/WebCore:

* page/DragActions.h:
(WebCore::anyDragSourceAction):
* page/DragController.cpp:
(WebCore::DragController::draggableElement const):
(WebCore::DragController::startDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::dragHysteresisExceeded const):
Make <model> draggable, vending a PasteboardImage with the model data and correct MIME type.
We currently make a DragImage from a node snapshot, but later will want a richer DragImage.

Source/WebKit:

* UIProcess/ios/DragDropInteractionState.mm:
(WebKit::shouldUseDragImageToCreatePreviewForDragSource):
For now, use the Web-Content-process-painted node-snapshot DragImage for the targeted preview on iOS.

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(kit):
Do nothing for <model> drags in legacy WebKit.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/cube.usdz: Added.
* TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
(-[ModelLoadingMessageHandler userContentController:didReceiveScriptMessage:]):
(TestWebKitAPI::TEST):
Add a test that ensures that dragging a <model> works.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283562 => 283563)


--- trunk/Source/WebCore/ChangeLog	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebCore/ChangeLog	2021-10-05 18:40:31 UTC (rev 283563)
@@ -1,3 +1,20 @@
+2021-10-05  Tim Horton  <[email protected]>
+
+        <model> should be draggable, similar to <img>
+        https://bugs.webkit.org/show_bug.cgi?id=229246
+
+        Reviewed by Wenson Hsieh.
+
+        * page/DragActions.h:
+        (WebCore::anyDragSourceAction):
+        * page/DragController.cpp:
+        (WebCore::DragController::draggableElement const):
+        (WebCore::DragController::startDrag):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::dragHysteresisExceeded const):
+        Make <model> draggable, vending a PasteboardImage with the model data and correct MIME type.
+        We currently make a DragImage from a node snapshot, but later will want a richer DragImage.
+
 2021-10-05  Gabriel Nava Marino  <[email protected]>
 
         Unsupported blending of mixed length types leads to nullptr deref when accessing m_value.calc in CSSPrimitiveValue::primitiveType()

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


--- trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h	2021-10-05 18:40:31 UTC (rev 283563)
@@ -73,6 +73,8 @@
 
     void enterFullscreen();
 
+    bool isDraggableIgnoringAttributes() const final { return true; }
+
 private:
     HTMLModelElement(const QualifiedName&, Document&);
 

Modified: trunk/Source/WebCore/page/DragActions.h (283562 => 283563)


--- trunk/Source/WebCore/page/DragActions.h	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebCore/page/DragActions.h	2021-10-05 18:40:31 UTC (rev 283563)
@@ -46,16 +46,19 @@
 
 // See WebDragSourceAction.
 enum class DragSourceAction : uint8_t {
-    DHTML      = 1,
-    Image      = 2,
-    Link       = 4,
-    Selection  = 8,
+    DHTML      = 1 << 0,
+    Image      = 1 << 1,
+    Link       = 1 << 2,
+    Selection  = 1 << 3,
 #if ENABLE(ATTACHMENT_ELEMENT)
-    Attachment = 16,
+    Attachment = 1 << 4,
 #endif
 #if ENABLE(INPUT_TYPE_COLOR)
-    Color      = 32,
+    Color      = 1 << 5,
 #endif
+#if ENABLE(MODEL_ELEMENT)
+    Model      = 1 << 6,
+#endif
 };
 
 constexpr OptionSet<DragSourceAction> anyDragSourceAction()
@@ -71,6 +74,9 @@
 #if ENABLE(INPUT_TYPE_COLOR)
         , DragSourceAction::Color
 #endif
+#if ENABLE(MODEL_ELEMENT)
+        , DragSourceAction::Model
+#endif
     };
 }
 
@@ -144,6 +150,9 @@
 #if ENABLE(INPUT_TYPE_COLOR)
         , WebCore::DragSourceAction::Color
 #endif
+#if ENABLE(MODEL_ELEMENT)
+        , WebCore::DragSourceAction::Model
+#endif
     >;
 };
 

Modified: trunk/Source/WebCore/page/DragController.cpp (283562 => 283563)


--- trunk/Source/WebCore/page/DragController.cpp	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebCore/page/DragController.cpp	2021-10-05 18:40:31 UTC (rev 283563)
@@ -58,6 +58,7 @@
 #include "HTMLAttachmentElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLModelElement.h"
 #include "HTMLParserIdioms.h"
 #include "HTMLPlugInElement.h"
 #include "HitTestRequest.h"
@@ -64,6 +65,7 @@
 #include "HitTestResult.h"
 #include "Image.h"
 #include "ImageOrientation.h"
+#include "Model.h"
 #include "MoveSelectionCommand.h"
 #include "Page.h"
 #include "Pasteboard.h"
@@ -752,6 +754,15 @@
     return cachedImage && !cachedImage->errorOccurred() && cachedImage->imageForRenderer(renderer);
 }
 
+#if ENABLE(MODEL_ELEMENT)
+
+static bool modelElementIsDraggable(const HTMLModelElement& modelElement)
+{
+    return !!modelElement.model();
+}
+
+#endif
+
 #if ENABLE(ATTACHMENT_ELEMENT)
 
 static RefPtr<HTMLAttachmentElement> enclosingAttachmentElement(Element& element)
@@ -824,6 +835,12 @@
                 return element;
             }
 #endif
+#if ENABLE(MODEL_ELEMENT)
+            if (m_dragSourceAction.contains(DragSourceAction::Model) && is<HTMLModelElement>(*element) && modelElementIsDraggable(downcast<HTMLModelElement>(*element))) {
+                state.type.add(DragSourceAction::Model);
+                return element;
+            }
+#endif
         }
     }
 
@@ -1239,6 +1256,27 @@
     }
 #endif
 
+#if ENABLE(MODEL_ELEMENT)
+    bool isModel = is<HTMLModelElement>(state.source);
+    if (isModel && m_dragSourceAction.contains(DragSourceAction::Model)) {
+        auto& modelElement = downcast<HTMLModelElement>(*state.source);
+        dragImage = DragImage { createDragImageForNode(src, modelElement) };
+
+        PasteboardImage pasteboardImage;
+        pasteboardImage.suggestedName = modelElement.currentSrc().lastPathComponent().toString();
+        pasteboardImage.resourceMIMEType = modelElement.model()->mimeType();
+        pasteboardImage.resourceData = modelElement.model()->data();
+        dataTransfer.pasteboard().write(pasteboardImage);
+
+        dragImageOffset = IntPoint { dragImageSize(dragImage.get()) };
+        dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOffset, false);
+
+        client().willPerformDragSourceAction(DragSourceAction::Model, dragOrigin, dataTransfer);
+        doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { });
+        return true;
+    }
+#endif
+
     if (state.type == DragSourceAction::DHTML && dragImage) {
         ASSERT(m_dragSourceAction.contains(DragSourceAction::DHTML));
         client().willPerformDragSourceAction(DragSourceAction::DHTML, dragOrigin, dataTransfer);

Modified: trunk/Source/WebCore/page/EventHandler.cpp (283562 => 283563)


--- trunk/Source/WebCore/page/EventHandler.cpp	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2021-10-05 18:40:31 UTC (rev 283563)
@@ -3886,6 +3886,9 @@
 #if ENABLE(ATTACHMENT_ELEMENT)
         case DragSourceAction::Attachment:
 #endif
+#if ENABLE(MODEL_ELEMENT)
+        case DragSourceAction::Model:
+#endif
             threshold = ImageDragHysteresis;
             break;
         case DragSourceAction::Link:

Modified: trunk/Source/WebKit/ChangeLog (283562 => 283563)


--- trunk/Source/WebKit/ChangeLog	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebKit/ChangeLog	2021-10-05 18:40:31 UTC (rev 283563)
@@ -1,5 +1,16 @@
 2021-10-05  Tim Horton  <[email protected]>
 
+        <model> should be draggable, similar to <img>
+        https://bugs.webkit.org/show_bug.cgi?id=229246
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/ios/DragDropInteractionState.mm:
+        (WebKit::shouldUseDragImageToCreatePreviewForDragSource):
+        For now, use the Web-Content-process-painted node-snapshot DragImage for the targeted preview on iOS.
+
+2021-10-05  Tim Horton  <[email protected]>
+
         Add an alternate style for form controls, and implement it for checkboxes and radio buttons
         https://bugs.webkit.org/show_bug.cgi?id=231160
 

Modified: trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm (283562 => 283563)


--- trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm	2021-10-05 18:40:31 UTC (rev 283563)
@@ -103,6 +103,11 @@
         return true;
 #endif
 
+#if ENABLE(MODEL_ELEMENT)
+    if (source.action.contains(DragSourceAction::Model))
+        return true;
+#endif
+
     return source.action.containsAny({ DragSourceAction::DHTML, DragSourceAction::Image });
 }
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (283562 => 283563)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-05 18:40:31 UTC (rev 283563)
@@ -1,3 +1,14 @@
+2021-10-05  Tim Horton  <[email protected]>
+
+        <model> should be draggable, similar to <img>
+        https://bugs.webkit.org/show_bug.cgi?id=229246
+
+        Reviewed by Wenson Hsieh.
+
+        * WebView/WebView.mm:
+        (kit):
+        Do nothing for <model> drags in legacy WebKit.
+
 2021-10-03  David Kilzer  <[email protected]>
 
         WTF::RetainPtr<> allows assignment of two pointer types that are not assignable

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (283562 => 283563)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2021-10-05 18:40:31 UTC (rev 283563)
@@ -719,6 +719,10 @@
     case WebCore::DragSourceAction::Color:
         break;
 #endif
+#if ENABLE(MODEL_ELEMENT)
+    case WebCore::DragSourceAction::Model:
+        break;
+#endif
     }
 
     ASSERT_NOT_REACHED();

Modified: trunk/Tools/ChangeLog (283562 => 283563)


--- trunk/Tools/ChangeLog	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Tools/ChangeLog	2021-10-05 18:40:31 UTC (rev 283563)
@@ -1,3 +1,17 @@
+2021-10-05  Tim Horton  <[email protected]>
+
+        <model> should be draggable, similar to <img>
+        https://bugs.webkit.org/show_bug.cgi?id=229246
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/cube.usdz: Added.
+        * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
+        (-[ModelLoadingMessageHandler userContentController:didReceiveScriptMessage:]):
+        (TestWebKitAPI::TEST):
+        Add a test that ensures that dragging a <model> works.
+
 2021-10-05  Alex Christensen  <[email protected]>
 
         Implement missing functions in PrivateClickMeasurementDaemonClient

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (283562 => 283563)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-10-05 18:40:31 UTC (rev 283563)
@@ -175,6 +175,7 @@
 		2DC9451724D8AC0200430376 /* WebThreadLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC9451624D8AC0200430376 /* WebThreadLock.mm */; };
 		2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
 		2DD87145265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DD87144265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp */; };
+		2DDD4DA4270B8B3500659A61 /* cube.usdz in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DDD4DA3270B8B3300659A61 /* cube.usdz */; };
 		2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */; };
 		2DE71B001D49C3ED00904094 /* blinking-div.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DE71AFF1D49C2F000904094 /* blinking-div.html */; };
 		2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DFF7B6C1DA487AF00814614 /* SnapshotStore.mm */; };
@@ -1459,6 +1460,7 @@
 				9B62630C1F8C25C8007EE29B /* copy-url.html in Copy Resources */,
 				7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */,
 				4995A6F025E8772000E5F0A9 /* csp-document-uri-report.html in Copy Resources */,
+				2DDD4DA4270B8B3500659A61 /* cube.usdz in Copy Resources */,
 				F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */,
 				290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */,
 				1CF59AE521E6977D006E37EC /* dark-mode.html in Copy Resources */,
@@ -1986,6 +1988,7 @@
 		2DD7D3A9178205D00026E1E3 /* ResizeReversePaginatedWebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeReversePaginatedWebView.cpp; sourceTree = "<group>"; };
 		2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; };
 		2DD87144265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BifurcatedGraphicsContextTestsCG.cpp; path = cg/BifurcatedGraphicsContextTestsCG.cpp; sourceTree = "<group>"; };
+		2DDD4DA3270B8B3300659A61 /* cube.usdz */ = {isa = PBXFileReference; lastKnownFileType = file.usdz; path = cube.usdz; sourceTree = "<group>"; };
 		2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnimatedResize.mm; sourceTree = "<group>"; };
 		2DE71AFF1D49C2F000904094 /* blinking-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "blinking-div.html"; sourceTree = "<group>"; };
 		2DFF7B6C1DA487AF00814614 /* SnapshotStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SnapshotStore.mm; sourceTree = "<group>"; };
@@ -4628,6 +4631,7 @@
 				1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
 				9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */,
 				5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */,
+				2DDD4DA3270B8B3300659A61 /* cube.usdz */,
 				290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
 				118153432208B7AC00B2CCD2 /* deferred-script-load.html */,
 				118153452208B7E500B2CCD2 /* deferred-script.js */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/cube.usdz (0 => 283563)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/cube.usdz	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/cube.usdz	2021-10-05 18:40:31 UTC (rev 283563)
@@ -0,0 +1,17 @@
+PK
+����������i|\x95Rn54
+����
+��������untitled.imported.usdc\x86������������������PXR-USDC��������������B��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
+@��������������������������������������������
+@���������������������������������������������������������������������������������������������������������������������������������������������� ������!������"������������#��������������������$������%��������������������&��������������������'��������������������)������'������*������+������,��������������������(��������������������)������'��������������������������������������������������������������������������������������������$��������������0����������������\xF0������UEUUQUUPU+\xED\xF3\xFC+\xF7	\xFE\xFD\xFA	\xF7\xF3\xF9+\xEF\xFD\xFD\xFC\xF3\xEF\xCD\xCCL?\xCD\xCCL?\xCD\xCCL?����������������������������������	��������������������������������������������\x80\xBF������������\x80?������\x80����\x80?��������������\x80������������\x80\xBF������\x80��������������������\x80\xBF����\x80?��������������\x80��������������������\x80?������������\x80?������\x80����\x80?��������������\x80������������\x80\xBF������\x80����������������
 ����\x80?����\x80?��������������\x80����\x80\xBF��������������\x80��������������������\x80\xBF������������\x80?������\x80����\x80\xBF��������������\x80������������\x80\xBF������\x80��������������������\x80\xBF����\x80\xBF��������������\x80��������������������\x80?������������\x80?������\x80����\x80\xBF��������������\x80������������\x80\xBF������\x80��������������������\x80?����������������������������������������������������������������������\x80?����\x80?����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80?����\x
 80?����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80?����\x80?����\x80?����\x80?����\x80?����\x80?����\x80?����\x80?����\x80?����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80?����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80?����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?����\x80\xBF����\x80\xBF����\x80?������������������ ?������?���� ?������?���� ?������?����\xC0>������?����\xC0>������?����\xC0>������?���� ?����@?���� ?����@?���� ?����@?����\xC0>����@?����\xC0>����@?����\xC0>����@?���� ?����\x80>���� ?����\x80>����`?������?����\xC0>����\x80>������>������?����\xC0>����\x80>�
 ��� ?������������ ?����\x80?����`?����@?����\xC0>��������������>����@?����\xC0>����\x80?	\x92\xF7>oz\xAC>f\xB6U\xBE\xB7\xCDG?2"->`\x81A?Z\x8B\xBE\x9E)?������@\x81o@��������O\xD5@������\x80\xB4@������@N@��������\x8E\x9D@������\xE0V\x
 F0\xBF��������������������������@��������������\xAB������������M��������������\xF3\xAE��upAxis��Y��primChildren��untitled��defaultPrim��metersPerUnit��customLayerData��creator��usdzconvert preview 0.62��specifier��typeName��Xform��assetInfo��name��kind��component��Materials��Geom��properties��m��\xF4#:binding��Scope��Cube��Light��Camera��xformOp:translate��TOrder+��A:oriq��\xA1esh��points\xC0vars:st��norm\x87��\xF8faceVertexIndice��0Cou7��\xF5subdivisionScheme��doubleSided\xD2��]C.%er��0surf��0Sha\xA0��\x83outputs:������\xA1info:id��in��\xB0diffuseColo����\x84metallic$��\xF4roughness��bool��variability\x8C��\xF2��int[]��token��UsdP\xC2S\x91�� ��c^��\xF33f��float��targetPaths@3f[]C��\xC1erpolation��v+p��connec��0��a/��7@ord2<��\xA3none��quatf3\xA03��token[]����������������������	������������������9��������������A����������������R$������U��\xF1UTEQ��\xF4\xF8\xF8\xF8\xF0��\xF0	\xF8#\xDC��\xDC\xDC\xDC����\xD6��\xD2\x
 DC��\xDC��\xDC��\xDC5�������������� ����0@X��A��)����\xB1@����\x80?����	@d����P����*@��A��@\x80��1����1@\x9C��3)��\xAC����1@\xB8��3)��\xCC����1@\xE0
 ��@)��	��0)��$��D��@����(��0��L��X��- ����#��,��3@0��h��2\x80\xA0��#\xA01��2��3��\xE0 ��3��4����\xC1��@\xCD\xCC\xCC>����@\xEC ��3"��\xF9��6!��1@A3\x808�� 0	��3"��=��:��A��@P��3\x80;��xi3\x80<��=�� @	��3��P��>��A��@`��3��x��?��\x80\x90��������\x80s��������������~����������������\xF0l��������EUTTUUPTUEQUUAUUQUUTEU��\xFB\xF5\xF3\xF2	\xF0\xEF\xEC\xEA\xFB\xEC\xE8\xE5\xE3\xE2\xFB\xE0!\xDE#\xDC#\xDB\xDA+\xD9(\xD6\xE1\xD5+\xD4-\xD2/\xFB\xD0\xFB\xCF2\xCD2\xCC5\xCA5\xC98\xE2\xC7#��������������#��������������%����������������\xF0������UAUAAD��\xE3\xE9\xE4\xF2	\xFB-����������������\xF0������UQQQEEUU��\xCD\xFF0\xC7\xF5\xFF\xFC9\xCE\xFF+\xB1\xFF\xFF\xFF��L\xAF��$����������������\xF0��������QQ@EU@T\xFF\xF2\xFC\xFE\xF7\xFE\xFE\xFA\xFE\xFA\xFE\xFD\xFE#������������������������������\xE0������������������������&��������
 ��������\xF0������UUUAP��\xFC��\xFE������������������\xF0����������@��@������\xFF\xFB\xF9��������������TOKENS��������������������\xA0������������e������������STRINGS����������������������������
 ����������������FIELDS��������������������������������\x8E������������FIELDSETS��������������\xAB	������������\x8E��������������PATHS����������������������9
+������������\x9E��������������SPECS����������������������\xD7
+������������k��������������PK����
+����������i|\x95Rn54
+����
+������������������������������������untitled.imported.usdc\x86������������������PK������������P������J��������
\ No newline at end of file

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (283562 => 283563)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm	2021-10-05 18:26:52 UTC (rev 283562)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm	2021-10-05 18:40:31 UTC (rev 283563)
@@ -31,6 +31,7 @@
 #import "DragAndDropSimulator.h"
 #import "NSItemProviderAdditions.h"
 #import "PlatformUtilities.h"
+#import "TestURLSchemeHandler.h"
 #import "TestWKWebView.h"
 #import "UIKitSPI.h"
 #import "WKWebViewConfigurationExtras.h"
@@ -43,6 +44,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WebItemProviderPasteboard.h>
+#import <WebKit/_WKExperimentalFeature.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <wtf/Seconds.h>
 #import <wtf/SoftLinking.h>
@@ -92,6 +94,21 @@
 
 @end
 
+@interface ModelLoadingMessageHandler : NSObject <WKScriptMessageHandler>
+
+@property (nonatomic) BOOL didLoadModel;
+
+@end
+
+@implementation ModelLoadingMessageHandler
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    EXPECT_WK_STREQ(@"READY", [message body]);
+    _didLoadModel = true;
+}
+@end
+
+
 static void loadTestPageAndEnsureInputSession(DragAndDropSimulator *simulator, NSString *testPageName)
 {
     TestWKWebView *webView = [simulator webView];
@@ -2156,6 +2173,42 @@
     EXPECT_WK_STREQ("one.foo.png (image/png)\ntwo.foo.PNG (image/png)", [webView stringByEvaluatingJavaScript:@"output.innerText"]);
 }
 
+TEST(DragAndDropTests, CanStartDragOnModel)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) {
+        if ([feature.key isEqualToString:@"ModelElementEnabled"])
+            [[configuration preferences] _setEnabled:YES forFeature:feature];
+    }
+
+    // FIXME: Remove this after <rdar://problem/83863149> is fixed.
+    // It should not be necessary to use WKURLSchemeHandler here, but CFNetwork does not correctly identify USDZ files.
+    auto handler = adoptNS([TestURLSchemeHandler new]);
+    RetainPtr<NSData> modelData = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"cube" withExtension:@"usdz" subdirectory:@"TestWebKitAPI.resources"]];
+    [handler setStartURLSchemeTaskHandler:^(WKWebView *, id<WKURLSchemeTask> task) {
+        NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"model/vnd.usdz+zip" expectedContentLength:[modelData length] textEncodingName:nil] autorelease];
+        [task didReceiveResponse:response];
+        [task didReceiveData:modelData.get()];
+        [task didFinish];
+    }];
+
+    auto messageHandler = adoptNS([[ModelLoadingMessageHandler alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"modelLoading"];
+    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"model"];
+    
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]);
+    [webView synchronouslyLoadHTMLString:@"<model><source src=''></model><script>document.getElementsByTagName('model')[0].ready.then(() => { window.webkit.messageHandlers.modelLoading.postMessage('READY') });</script>"];
+
+    while (![messageHandler didLoadModel])
+        Util::spinRunLoop();
+
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
+    [simulator runFrom:CGPointMake(20, 20) to:CGPointMake(100, 100)];
+
+    NSArray *registeredTypes = [[simulator sourceItemProviders].firstObject registeredTypeIdentifiers];
+    EXPECT_WK_STREQ("com.pixar.universal-scene-description-mobile", [registeredTypes firstObject]);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to