Changeset 283563 in webkit
- Timestamp:
- Oct 5, 2021 11:40:31 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/model-element/HTMLModelElement.h (modified) (1 diff)
-
Source/WebCore/page/DragActions.h (modified) (3 diffs)
-
Source/WebCore/page/DragController.cpp (modified) (5 diffs)
-
Source/WebCore/page/EventHandler.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/DragDropInteractionState.mm (modified) (1 diff)
-
Source/WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/mac/WebView/WebView.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKit/cube.usdz (added)
-
Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r283562 r283563 1 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 3 <model> should be draggable, similar to <img> 4 https://bugs.webkit.org/show_bug.cgi?id=229246 5 6 Reviewed by Wenson Hsieh. 7 8 * page/DragActions.h: 9 (WebCore::anyDragSourceAction): 10 * page/DragController.cpp: 11 (WebCore::DragController::draggableElement const): 12 (WebCore::DragController::startDrag): 13 * page/EventHandler.cpp: 14 (WebCore::EventHandler::dragHysteresisExceeded const): 15 Make <model> draggable, vending a PasteboardImage with the model data and correct MIME type. 16 We currently make a DragImage from a node snapshot, but later will want a richer DragImage. 17 1 18 2021-10-05 Gabriel Nava Marino <gnavamarino@apple.com> 2 19 -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h
r282567 r283563 74 74 void enterFullscreen(); 75 75 76 bool isDraggableIgnoringAttributes() const final { return true; } 77 76 78 private: 77 79 HTMLModelElement(const QualifiedName&, Document&); -
trunk/Source/WebCore/page/DragActions.h
r263178 r283563 47 47 // See WebDragSourceAction. 48 48 enum class DragSourceAction : uint8_t { 49 DHTML = 1 ,50 Image = 2,51 Link = 4,52 Selection = 8,49 DHTML = 1 << 0, 50 Image = 1 << 1, 51 Link = 1 << 2, 52 Selection = 1 << 3, 53 53 #if ENABLE(ATTACHMENT_ELEMENT) 54 Attachment = 1 6,54 Attachment = 1 << 4, 55 55 #endif 56 56 #if ENABLE(INPUT_TYPE_COLOR) 57 Color = 32, 57 Color = 1 << 5, 58 #endif 59 #if ENABLE(MODEL_ELEMENT) 60 Model = 1 << 6, 58 61 #endif 59 62 }; … … 71 74 #if ENABLE(INPUT_TYPE_COLOR) 72 75 , DragSourceAction::Color 76 #endif 77 #if ENABLE(MODEL_ELEMENT) 78 , DragSourceAction::Model 73 79 #endif 74 80 }; … … 145 151 , WebCore::DragSourceAction::Color 146 152 #endif 153 #if ENABLE(MODEL_ELEMENT) 154 , WebCore::DragSourceAction::Model 155 #endif 147 156 >; 148 157 }; -
trunk/Source/WebCore/page/DragController.cpp
r282799 r283563 59 59 #include "HTMLImageElement.h" 60 60 #include "HTMLInputElement.h" 61 #include "HTMLModelElement.h" 61 62 #include "HTMLParserIdioms.h" 62 63 #include "HTMLPlugInElement.h" … … 65 66 #include "Image.h" 66 67 #include "ImageOrientation.h" 68 #include "Model.h" 67 69 #include "MoveSelectionCommand.h" 68 70 #include "Page.h" … … 753 755 } 754 756 757 #if ENABLE(MODEL_ELEMENT) 758 759 static bool modelElementIsDraggable(const HTMLModelElement& modelElement) 760 { 761 return !!modelElement.model(); 762 } 763 764 #endif 765 755 766 #if ENABLE(ATTACHMENT_ELEMENT) 756 767 … … 825 836 } 826 837 #endif 838 #if ENABLE(MODEL_ELEMENT) 839 if (m_dragSourceAction.contains(DragSourceAction::Model) && is<HTMLModelElement>(*element) && modelElementIsDraggable(downcast<HTMLModelElement>(*element))) { 840 state.type.add(DragSourceAction::Model); 841 return element; 842 } 843 #endif 827 844 } 828 845 } … … 1235 1252 1236 1253 client().willPerformDragSourceAction(DragSourceAction::Color, dragOrigin, dataTransfer); 1254 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { }); 1255 return true; 1256 } 1257 #endif 1258 1259 #if ENABLE(MODEL_ELEMENT) 1260 bool isModel = is<HTMLModelElement>(state.source); 1261 if (isModel && m_dragSourceAction.contains(DragSourceAction::Model)) { 1262 auto& modelElement = downcast<HTMLModelElement>(*state.source); 1263 dragImage = DragImage { createDragImageForNode(src, modelElement) }; 1264 1265 PasteboardImage pasteboardImage; 1266 pasteboardImage.suggestedName = modelElement.currentSrc().lastPathComponent().toString(); 1267 pasteboardImage.resourceMIMEType = modelElement.model()->mimeType(); 1268 pasteboardImage.resourceData = modelElement.model()->data(); 1269 dataTransfer.pasteboard().write(pasteboardImage); 1270 1271 dragImageOffset = IntPoint { dragImageSize(dragImage.get()) }; 1272 dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOffset, false); 1273 1274 client().willPerformDragSourceAction(DragSourceAction::Model, dragOrigin, dataTransfer); 1237 1275 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { }); 1238 1276 return true; -
trunk/Source/WebCore/page/EventHandler.cpp
r283335 r283563 3887 3887 case DragSourceAction::Attachment: 3888 3888 #endif 3889 #if ENABLE(MODEL_ELEMENT) 3890 case DragSourceAction::Model: 3891 #endif 3889 3892 threshold = ImageDragHysteresis; 3890 3893 break; -
trunk/Source/WebKit/ChangeLog
r283560 r283563 1 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 3 <model> should be draggable, similar to <img> 4 https://bugs.webkit.org/show_bug.cgi?id=229246 5 6 Reviewed by Wenson Hsieh. 7 8 * UIProcess/ios/DragDropInteractionState.mm: 9 (WebKit::shouldUseDragImageToCreatePreviewForDragSource): 10 For now, use the Web-Content-process-painted node-snapshot DragImage for the targeted preview on iOS. 11 1 12 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 13 -
trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm
r278253 r283563 104 104 #endif 105 105 106 #if ENABLE(MODEL_ELEMENT) 107 if (source.action.contains(DragSourceAction::Model)) 108 return true; 109 #endif 110 106 111 return source.action.containsAny({ DragSourceAction::DHTML, DragSourceAction::Image }); 107 112 } -
trunk/Source/WebKitLegacy/mac/ChangeLog
r283476 r283563 1 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 3 <model> should be draggable, similar to <img> 4 https://bugs.webkit.org/show_bug.cgi?id=229246 5 6 Reviewed by Wenson Hsieh. 7 8 * WebView/WebView.mm: 9 (kit): 10 Do nothing for <model> drags in legacy WebKit. 11 1 12 2021-10-03 David Kilzer <ddkilzer@apple.com> 2 13 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r282848 r283563 720 720 break; 721 721 #endif 722 #if ENABLE(MODEL_ELEMENT) 723 case WebCore::DragSourceAction::Model: 724 break; 725 #endif 722 726 } 723 727 -
trunk/Tools/ChangeLog
r283559 r283563 1 2021-10-05 Tim Horton <timothy_horton@apple.com> 2 3 <model> should be draggable, similar to <img> 4 https://bugs.webkit.org/show_bug.cgi?id=229246 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKit/cube.usdz: Added. 10 * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: 11 (-[ModelLoadingMessageHandler userContentController:didReceiveScriptMessage:]): 12 (TestWebKitAPI::TEST): 13 Add a test that ensures that dragging a <model> works. 14 1 15 2021-10-05 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r283553 r283563 176 176 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; }; 177 177 2DD87145265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DD87144265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp */; }; 178 2DDD4DA4270B8B3500659A61 /* cube.usdz in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DDD4DA3270B8B3300659A61 /* cube.usdz */; }; 178 179 2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */; }; 179 180 2DE71B001D49C3ED00904094 /* blinking-div.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DE71AFF1D49C2F000904094 /* blinking-div.html */; }; … … 1460 1461 7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */, 1461 1462 4995A6F025E8772000E5F0A9 /* csp-document-uri-report.html in Copy Resources */, 1463 2DDD4DA4270B8B3500659A61 /* cube.usdz in Copy Resources */, 1462 1464 F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */, 1463 1465 290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */, … … 1987 1989 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; }; 1988 1990 2DD87144265F23B4005F997C /* BifurcatedGraphicsContextTestsCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BifurcatedGraphicsContextTestsCG.cpp; path = cg/BifurcatedGraphicsContextTestsCG.cpp; sourceTree = "<group>"; }; 1991 2DDD4DA3270B8B3300659A61 /* cube.usdz */ = {isa = PBXFileReference; lastKnownFileType = file.usdz; path = cube.usdz; sourceTree = "<group>"; }; 1989 1992 2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnimatedResize.mm; sourceTree = "<group>"; }; 1990 1993 2DE71AFF1D49C2F000904094 /* blinking-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "blinking-div.html"; sourceTree = "<group>"; }; … … 4629 4632 9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */, 4630 4633 5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */, 4634 2DDD4DA3270B8B3300659A61 /* cube.usdz */, 4631 4635 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */, 4632 4636 118153432208B7AC00B2CCD2 /* deferred-script-load.html */, -
trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm
r273308 r283563 32 32 #import "NSItemProviderAdditions.h" 33 33 #import "PlatformUtilities.h" 34 #import "TestURLSchemeHandler.h" 34 35 #import "TestWKWebView.h" 35 36 #import "UIKitSPI.h" … … 44 45 #import <WebKit/WKWebViewConfigurationPrivate.h> 45 46 #import <WebKit/WebItemProviderPasteboard.h> 47 #import <WebKit/_WKExperimentalFeature.h> 46 48 #import <WebKit/_WKProcessPoolConfiguration.h> 47 49 #import <wtf/Seconds.h> … … 92 94 93 95 @end 96 97 @interface ModelLoadingMessageHandler : NSObject <WKScriptMessageHandler> 98 99 @property (nonatomic) BOOL didLoadModel; 100 101 @end 102 103 @implementation ModelLoadingMessageHandler 104 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message 105 { 106 EXPECT_WK_STREQ(@"READY", [message body]); 107 _didLoadModel = true; 108 } 109 @end 110 94 111 95 112 static void loadTestPageAndEnsureInputSession(DragAndDropSimulator *simulator, NSString *testPageName) … … 2157 2174 } 2158 2175 2176 TEST(DragAndDropTests, CanStartDragOnModel) 2177 { 2178 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 2179 for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) { 2180 if ([feature.key isEqualToString:@"ModelElementEnabled"]) 2181 [[configuration preferences] _setEnabled:YES forFeature:feature]; 2182 } 2183 2184 // FIXME: Remove this after <rdar://problem/83863149> is fixed. 2185 // It should not be necessary to use WKURLSchemeHandler here, but CFNetwork does not correctly identify USDZ files. 2186 auto handler = adoptNS([TestURLSchemeHandler new]); 2187 RetainPtr<NSData> modelData = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"cube" withExtension:@"usdz" subdirectory:@"TestWebKitAPI.resources"]]; 2188 [handler setStartURLSchemeTaskHandler:^(WKWebView *, id<WKURLSchemeTask> task) { 2189 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"model/vnd.usdz+zip" expectedContentLength:[modelData length] textEncodingName:nil] autorelease]; 2190 [task didReceiveResponse:response]; 2191 [task didReceiveData:modelData.get()]; 2192 [task didFinish]; 2193 }]; 2194 2195 auto messageHandler = adoptNS([[ModelLoadingMessageHandler alloc] init]); 2196 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"modelLoading"]; 2197 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"model"]; 2198 2199 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]); 2200 [webView synchronouslyLoadHTMLString:@"<model><source src='model://cube.usdz'></model><script>document.getElementsByTagName('model')[0].ready.then(() => { window.webkit.messageHandlers.modelLoading.postMessage('READY') });</script>"]; 2201 2202 while (![messageHandler didLoadModel]) 2203 Util::spinRunLoop(); 2204 2205 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); 2206 [simulator runFrom:CGPointMake(20, 20) to:CGPointMake(100, 100)]; 2207 2208 NSArray *registeredTypes = [[simulator sourceItemProviders].firstObject registeredTypeIdentifiers]; 2209 EXPECT_WK_STREQ("com.pixar.universal-scene-description-mobile", [registeredTypes firstObject]); 2210 } 2211 2159 2212 } // namespace TestWebKitAPI 2160 2213
Note: See TracChangeset
for help on using the changeset viewer.