Changeset 181760 in webkit
- Timestamp:
- Mar 19, 2015 2:59:23 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181749 r181760 1 2015-03-19 Enrica Casucci <enrica@apple.com> 2 3 <attachment> should put URLs on the pasteboard so that Finder can accept drops. 4 https://bugs.webkit.org/show_bug.cgi?id=142801 5 rdar://problem/19982527 6 7 Reviewed by Tim Horton. 8 9 * editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt: Added. 10 * editing/pasteboard/drag-and-drop-attachment-contenteditable.html: Added. 11 * platform/mac-wk2/TestExpectations: Skipping new test on WK2 since it uses eventSender. 12 1 13 2015-03-19 Dean Jackson <dino@apple.com> 2 14 … … 123 135 * fast/repaint/multiple-backgrounds-style-change.html: Added. 124 136 137 >>>>>>> .r181712 125 138 2015-03-18 Marcos Chavarría Teijeiro <chavarria1991@gmail.com> 126 139 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r181684 r181760 24 24 editing/pasteboard/drag-and-drop-inputimage-contenteditable.html 25 25 editing/pasteboard/drag-and-drop-objectimage-contenteditable.html 26 editing/pasteboard/drag-and-drop-attachment-contenteditable.html 26 27 editing/pasteboard/drag-drop-dead-frame.html 27 28 editing/pasteboard/drag-drop-input-textarea.html -
trunk/Source/WebCore/ChangeLog
r181757 r181760 1 2015-03-19 Enrica Casucci <enrica@apple.com> 2 3 <attachment> should put URLs on the pasteboard so that Finder can accept drops. 4 https://bugs.webkit.org/show_bug.cgi?id=142801 5 rdar://problem/19982527 6 7 Reviewed by Tim Horton. 8 9 Test: editing/pasteboard/drag-and-drop-attachment-contenteditable.html 10 11 This patch adds all the necessary support to write attachment elements into 12 the pasteboard, including the promised type. 13 14 * WebCore.xcodeproj/project.pbxproj: 15 * page/DragActions.h: 16 * page/DragClient.h: 17 (WebCore::DragClient::declareAndWriteAttachment): 18 * page/DragController.cpp: 19 (WebCore::DragController::draggableElement): 20 (WebCore::DragController::startDrag): 21 * page/DragController.h: 22 (WebCore::DragController::draggingAttachmentURL): 23 * page/EventHandler.cpp: 24 (WebCore::EventHandler::dragHysteresisExceeded): 25 (WebCore::EventHandler::handleDrag): 26 * page/mac/DragControllerMac.mm: 27 (WebCore::DragController::declareAndWriteAttachment): 28 * page/win/DragControllerWin.cpp: 29 (WebCore::DragController::declareAndWriteAttachment): 30 * platform/URL.cpp: 31 (WebCore::URL::fileURLWithFileSystemPath): 32 * platform/URL.h: 33 * rendering/HitTestResult.cpp: 34 (WebCore::HitTestResult::absoluteAttachmentURL): 35 * rendering/HitTestResult.h: 36 1 37 2015-03-19 Chris Dumez <cdumez@apple.com> 2 38 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r181726 r181760 2528 2528 7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; }; 2529 2529 7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; }; 2530 7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; };2530 7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2531 2531 7CDEEE1E197610D700E352CD /* ViewStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2532 2532 7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */; }; -
trunk/Source/WebCore/page/DragActions.h
r165676 r181760 47 47 DragSourceActionLink = 4, 48 48 DragSourceActionSelection = 8, 49 #if ENABLE(ATTACHMENT_ELEMENT) 50 DragSourceActionAttachment = 16, 51 #endif 49 52 DragSourceActionAny = UINT_MAX 50 53 } DragSourceAction; -
trunk/Source/WebCore/page/DragClient.h
r166965 r181760 56 56 // This is not abstract as that would require another #if PLATFORM(COCOA) for the SVGImage client empty implentation. 57 57 virtual void declareAndWriteDragImage(const String&, Element&, const URL&, const String&, Frame*) { } 58 #if ENABLE(ATTACHMENT_ELEMENT) 59 virtual void declareAndWriteAttachment(const String&, Element&, const URL&, const String&, Frame*) { } 60 #endif 58 61 #endif 59 62 -
trunk/Source/WebCore/page/DragController.cpp
r181115 r181760 50 50 #include "FrameView.h" 51 51 #include "HTMLAnchorElement.h" 52 #include "HTMLAttachmentElement.h" 52 53 #include "HTMLImageElement.h" 53 54 #include "HTMLInputElement.h" … … 624 625 if (!startElement) 625 626 return nullptr; 627 #if ENABLE(ATTACHMENT_ELEMENT) 628 // Unlike image elements, attachment elements are immediately selected upon mouse down, 629 // but for those elements we still want to use the single element drag behavior as long as 630 // the element is the only content of the selection. 631 const VisibleSelection& selection = sourceFrame->selection().selection(); 632 if (selection.isRange() && is<HTMLAttachmentElement>(selection.start().anchorNode()) && selection.start().anchorNode() == selection.end().anchorNode()) 633 state.type = DragSourceActionNone; 634 #endif 626 635 627 636 for (auto renderer = startElement->renderer(); renderer; renderer = renderer->parent()) { … … 650 659 return element; 651 660 } 661 #if ENABLE(ATTACHMENT_ELEMENT) 662 if ((m_dragSourceAction & DragSourceActionAttachment) 663 && is<HTMLAttachmentElement>(*element) 664 && downcast<HTMLAttachmentElement>(*element).file()) { 665 state.type = static_cast<DragSourceAction>(state.type | DragSourceActionAttachment); 666 return element; 667 } 668 #endif 652 669 } 653 670 } … … 739 756 URL linkURL = hitTestResult.absoluteLinkURL(); 740 757 URL imageURL = hitTestResult.absoluteImageURL(); 758 #if ENABLE(ATTACHMENT_ELEMENT) 759 URL attachmentURL = hitTestResult.absoluteAttachmentURL(); 760 m_draggingAttachmentURL = URL(); 761 #endif 741 762 742 763 IntPoint mouseDraggedPoint = src.view()->windowToContents(dragEvent.position()); … … 854 875 } 855 876 doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, dataTransfer, src, true); 877 #if ENABLE(ATTACHMENT_ELEMENT) 878 } else if (!attachmentURL.isEmpty() && (m_dragSourceAction & DragSourceActionAttachment)) { 879 if (!dataTransfer.pasteboard().hasData()) { 880 m_draggingAttachmentURL = attachmentURL; 881 selectElement(element); 882 declareAndWriteAttachment(dataTransfer, element, attachmentURL); 883 } 884 885 m_client.willPerformDragSourceAction(DragSourceActionAttachment, dragOrigin, dataTransfer); 886 887 if (!dragImage) { 888 dragImage = dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha); 889 dragLoc = dragLocForSelectionDrag(src); 890 m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y()); 891 } 892 doSystemDrag(dragImage, dragLoc, dragOrigin, dataTransfer, src, false); 893 #endif 856 894 } else if (state.type == DragSourceActionDHTML) { 857 895 if (dragImage) { -
trunk/Source/WebCore/page/DragController.h
r181115 r181760 74 74 DragOperation sourceDragOperation() const { return m_sourceDragOperation; } 75 75 const URL& draggingImageURL() const { return m_draggingImageURL; } 76 #if ENABLE(ATTACHMENT_ELEMENT) 77 const URL& draggingAttachmentURL() const { return m_draggingAttachmentURL; } 78 #endif 76 79 void setDragOffset(const IntPoint& offset) { m_dragOffset = offset; } 77 80 const IntPoint& dragOffset() const { return m_dragOffset; } … … 115 118 void cleanupAfterSystemDrag(); 116 119 void declareAndWriteDragImage(DataTransfer&, Element&, const URL&, const String& label); 117 120 #if ENABLE(ATTACHMENT_ELEMENT) 121 void declareAndWriteAttachment(DataTransfer&, Element&, const URL&); 122 #endif 118 123 Page& m_page; 119 124 DragClient& m_client; … … 131 136 IntPoint m_dragOffset; 132 137 URL m_draggingImageURL; 138 #if ENABLE(ATTACHMENT_ELEMENT) 139 URL m_draggingAttachmentURL; 140 #endif 133 141 }; 134 142 -
trunk/Source/WebCore/page/EventHandler.cpp
r181687 r181760 3309 3309 break; 3310 3310 case DragSourceActionImage: 3311 #if ENABLE(ATTACHMENT_ELEMENT) 3312 case DragSourceActionAttachment: 3313 #endif 3311 3314 threshold = ImageDragHysteresis; 3312 3315 break; … … 3431 3434 ASSERT((dragState().type & ~DragSourceActionSelection) == DragSourceActionDHTML 3432 3435 || (dragState().type & ~DragSourceActionSelection) == DragSourceActionImage 3436 #if ENABLE(ATTACHMENT_ELEMENT) 3437 || (dragState().type & ~DragSourceActionSelection) == DragSourceActionAttachment 3438 #endif 3433 3439 || (dragState().type & ~DragSourceActionSelection) == DragSourceActionLink); 3434 3440 dragState().type = DragSourceActionSelection; -
trunk/Source/WebCore/page/mac/DragControllerMac.mm
r174314 r181760 37 37 #import "EditorClient.h" 38 38 #import "Element.h" 39 #import "File.h" 39 40 #import "FrameView.h" 41 #import "HTMLAttachmentElement.h" 40 42 #import "MainFrame.h" 41 43 #import "Page.h" … … 88 90 } 89 91 92 #if ENABLE(ATTACHMENT_ELEMENT) 93 void DragController::declareAndWriteAttachment(DataTransfer& dataTransfer, Element& element, const URL& url) 94 { 95 const HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(element); 96 m_client.declareAndWriteAttachment(dataTransfer.pasteboard().name(), element, url, attachment.file()->path(), element.document().frame()); 97 } 98 #endif 99 90 100 void DragController::declareAndWriteDragImage(DataTransfer& dataTransfer, Element& element, const URL& url, const String& label) 91 101 { -
trunk/Source/WebCore/page/win/DragControllerWin.cpp
r174314 r181760 70 70 } 71 71 72 #if ENABLE(ATTACHMENT_ELEMENT) 73 void DragController::declareAndWriteAttachment(DataTransfer&, Element&, const URL&) 74 { 75 } 76 #endif 77 72 78 void DragController::declareAndWriteDragImage(DataTransfer& dataTransfer, Element& element, const URL& url, const String& label) 73 79 { -
trunk/Source/WebCore/platform/URL.cpp
r179933 r181760 2120 2120 } 2121 2121 2122 } 2122 URL URL::fileURLWithFileSystemPath(const String& filePath) 2123 { 2124 return URL(URL(), "file:///" + filePath); 2125 } 2126 2127 } -
trunk/Source/WebCore/platform/URL.h
r180301 r181760 74 74 75 75 static URL fakeURLWithRelativePart(const String&); 76 static URL fileURLWithFileSystemPath(const String&); 76 77 77 78 String strippedForUseAsReferrer() const; -
trunk/Source/WebCore/rendering/HitTestResult.cpp
r176999 r181760 26 26 #include "DocumentMarkerController.h" 27 27 #include "Editor.h" 28 #include "File.h" 28 29 #include "Frame.h" 29 30 #include "FrameSelection.h" … … 31 32 #include "HTMLAnchorElement.h" 32 33 #include "HTMLAreaElement.h" 34 #include "HTMLAttachmentElement.h" 33 35 #include "HTMLAudioElement.h" 34 36 #include "HTMLImageElement.h" … … 311 313 } 312 314 315 #if ENABLE(ATTACHMENT_ELEMENT) 316 URL HitTestResult::absoluteAttachmentURL() const 317 { 318 if (!m_innerNonSharedNode) 319 return URL(); 320 321 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isAttachment())) 322 return URL(); 323 324 if (!is<HTMLAttachmentElement>(*m_innerNonSharedNode)) 325 return URL(); 326 File* attachmentFile = downcast<HTMLAttachmentElement>(*m_innerNonSharedNode).file(); 327 if (!attachmentFile) 328 return URL(); 329 330 return URL::fileURLWithFileSystemPath(attachmentFile->path()); 331 } 332 #endif 333 313 334 URL HitTestResult::absoluteImageURL() const 314 335 { -
trunk/Source/WebCore/rendering/HitTestResult.h
r179861 r181760 107 107 WEBCORE_EXPORT URL absoluteMediaURL() const; 108 108 WEBCORE_EXPORT URL absoluteLinkURL() const; 109 #if ENABLE(ATTACHMENT_ELEMENT) 110 WEBCORE_EXPORT URL absoluteAttachmentURL() const; 111 #endif 109 112 WEBCORE_EXPORT String textContent() const; 110 113 WEBCORE_EXPORT bool isLiveLink() const; -
trunk/Source/WebKit/mac/ChangeLog
r181753 r181760 1 2015-03-19 Enrica Casucci <enrica@apple.com> 2 3 <attachment> should put URLs on the pasteboard so that Finder can accept drops. 4 https://bugs.webkit.org/show_bug.cgi?id=142801 5 rdar://problem/19982527 6 7 Reviewed by Tim Horton. 8 9 This patch adds all the necessary support to write attachment elements into 10 the pasteboard, including the promised type in WK1. 11 12 * Misc/WebNSPasteboardExtras.mm: 13 (-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]): 14 * WebCoreSupport/WebDragClient.h: 15 * WebCoreSupport/WebDragClient.mm: 16 (WebDragClient::declareAndWriteAttachment): 17 * WebView/WebHTMLView.mm: 18 (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]): 19 * WebView/WebUIDelegate.h: 20 1 21 2015-03-19 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm
r174676 r181760 43 43 #import <WebCore/Image.h> 44 44 #import <WebCore/MIMETypeRegistry.h> 45 #import <WebCore/RenderAttachment.h> 45 46 #import <WebCore/RenderImage.h> 46 47 #import <WebKitLegacy/DOMExtensions.h> … … 272 273 273 274 NSString *extension = @""; 275 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); 274 276 if (auto* renderer = core(element)->renderer()) { 275 277 if (is<RenderImage>(*renderer)) { … … 278 280 if (![extension length]) 279 281 return nullptr; 282 [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImageIncludingArchive:(archive != nil)]]; 283 [self declareTypes:types.get() owner:source]; 280 284 } 281 285 } 282 } 283 284 NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; 285 [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImageIncludingArchive:(archive != nil)]]; 286 [self declareTypes:types owner:source]; 287 [self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types source:source]; 288 [types release]; 286 #if ENABLE(ATTACHMENT_ELEMENT) 287 else if (is<RenderAttachment>(*renderer)) { 288 extension = URL.pathExtension; 289 [types addObjectsFromArray:[NSPasteboard _web_dragTypesForURL]]; 290 [self declareTypes:types.get() owner:source]; 291 RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]); 292 [paths.get() addObject:title]; 293 [self setPropertyList:paths.get() forType:NSFilenamesPboardType]; 294 } 295 #endif 296 } 297 298 [self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types.get() source:source]; 289 299 290 300 NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h
r166965 r181760 40 40 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::DataTransfer&, WebCore::Frame&, bool linkDrag) override; 41 41 virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) override; 42 #if ENABLE(ATTACHMENT_ELEMENT) 43 virtual void declareAndWriteAttachment(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String& path, WebCore::Frame*) override; 44 #endif 42 45 private: 43 46 WebView* m_webView; -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
r167403 r181760 128 128 { 129 129 ASSERT(pasteboardName); 130 WebHTMLView *source = getTopHTMLView(frame); 131 WebArchive *archive = [kit(&element) webArchive]; 130 [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:title archive:[kit(&element) webArchive] source:getTopHTMLView(frame)]; 131 } 132 133 #if ENABLE(ATTACHMENT_ELEMENT) 134 void WebDragClient::declareAndWriteAttachment(const String& pasteboardName, Element& element, const URL& url, const String& path, WebCore::Frame* frame) 135 { 136 ASSERT(pasteboardName); 132 137 133 [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title: title archive:archive source:source];138 [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:path archive:nil source:getTopHTMLView(frame)]; 134 139 } 140 #endif 135 141 136 142 void WebDragClient::dragControllerDestroyed() -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r181679 r181760 3963 3963 { 3964 3964 NSFileWrapper *wrapper = nil; 3965 NSURL *dragging ImageURL = nil;3965 NSURL *draggingElementURL = nil; 3966 3966 3967 3967 if (WebCore::CachedImage* tiffResource = [self promisedDragTIFFDataSource]) { 3968 3968 if (auto* buffer = tiffResource->resourceBuffer()) { 3969 3969 NSURLResponse *response = tiffResource->response().nsURLResponse(); 3970 dragging ImageURL = [response URL];3970 draggingElementURL = [response URL]; 3971 3971 wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:buffer->createNSData().get()] autorelease]; 3972 3972 NSString* filename = [response suggestedFilename]; … … 3989 3989 3990 3990 const URL& imageURL = page->dragController().draggingImageURL(); 3991 ASSERT(!imageURL.isEmpty()); 3992 draggingImageURL = imageURL; 3993 3994 wrapper = [[self _dataSource] _fileWrapperForURL:draggingImageURL]; 3991 if (!imageURL.isEmpty()) 3992 draggingElementURL = imageURL; 3993 #if ENABLE(ATTACHMENT_ELEMENT) 3994 else 3995 draggingElementURL = page->dragController().draggingAttachmentURL(); 3996 #endif 3997 3998 wrapper = [[self _dataSource] _fileWrapperForURL:draggingElementURL]; 3995 3999 } 3996 4000 … … 4006 4010 LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToURL:options:originalContentsURL:error:]"); 4007 4011 4008 if (dragging ImageURL)4009 [[NSFileManager defaultManager] _webkit_setMetadataURL:[dragging ImageURL absoluteString] referrer:nil atPath:path];4012 if (draggingElementURL) 4013 [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingElementURL absoluteString] referrer:nil atPath:path]; 4010 4014 4011 4015 return [NSArray arrayWithObject:[path lastPathComponent]]; -
trunk/Source/WebKit/mac/WebView/WebUIDelegate.h
r179183 r181760 113 113 WebDragSourceActionLink = 4, 114 114 WebDragSourceActionSelection = 8, 115 WebDragSourceActionAttachment = 16, 115 116 WebDragSourceActionAny = UINT_MAX 116 117 }; -
trunk/Source/WebKit2/ChangeLog
r181756 r181760 1 2015-03-19 Enrica Casucci <enrica@apple.com> 2 3 <attachment> should put URLs on the pasteboard so that Finder can accept drops. 4 https://bugs.webkit.org/show_bug.cgi?id=142801 5 rdar://problem/19982527 6 7 Reviewed by Tim Horton. 8 9 This patch adds all the necessary support to write attachment elements into 10 the pasteboard, including the promised type in WK2. 11 12 * UIProcess/API/mac/WKView.mm: 13 (-[WKView _setPromisedDataForImage:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]): 14 (-[WKView _setPromisedDataForAttachment:withExtension:withTitle:withURL:withVisibleURL:forPasteboard:]): 15 (-[WKView namesOfPromisedFilesDroppedAtDestination:]): 16 (-[WKView _setPromisedData:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]): Deleted. 17 * UIProcess/API/mac/WKViewInternal.h: 18 * UIProcess/PageClient.h: 19 * UIProcess/WebPageProxy.h: 20 * UIProcess/WebPageProxy.messages.in: 21 * UIProcess/mac/PageClientImpl.h: 22 * UIProcess/mac/PageClientImpl.mm: 23 (WebKit::PageClientImpl::setPromisedDataForImage): 24 (WebKit::PageClientImpl::setPromisedDataForAttachment): 25 (WebKit::PageClientImpl::setPromisedData): Deleted. 26 * UIProcess/mac/WebPageProxyMac.mm: 27 (WebKit::WebPageProxy::setPromisedDataForImage): 28 (WebKit::WebPageProxy::setPromisedDataForAttachment): 29 (WebKit::WebPageProxy::setPromisedData): Deleted. 30 * WebProcess/WebCoreSupport/WebDragClient.h: 31 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 32 (WebKit::WebDragClient::declareAndWriteAttachment): 33 (WebKit::WebDragClient::declareAndWriteDragImage): 34 1 35 2015-03-19 Anders Carlsson <andersca@apple.com> 2 36 -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r181705 r181760 3380 3380 } 3381 3381 3382 - (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName 3383 3384 { 3385 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName]; 3386 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); 3387 3388 [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; 3389 [pasteboard declareTypes:types.get() owner:self]; 3382 - (void)_setFileAndURLTypes:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSPasteboard *)pasteboard 3383 { 3390 3384 if (!matchesExtensionOrEquivalent(filename, extension)) 3391 3385 filename = [[filename stringByAppendingString:@"."] stringByAppendingString:extension]; 3392 3386 3393 3387 [pasteboard setString:visibleUrl forType:NSStringPboardType]; 3394 3388 [pasteboard setString:visibleUrl forType:PasteboardTypes::WebURLPboardType]; … … 3396 3390 [pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:visibleUrl], [NSArray arrayWithObject:title], nil] forType:PasteboardTypes::WebURLsWithTitlesPboardType]; 3397 3391 [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType]; 3392 _data->_promisedFilename = filename; 3393 _data->_promisedURL = url; 3394 } 3395 3396 - (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName 3397 3398 { 3399 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName]; 3400 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); 3401 3402 [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; 3403 [pasteboard declareTypes:types.get() owner:self]; 3404 [self _setFileAndURLTypes:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboard]; 3398 3405 3399 3406 if (archiveBuffer) … … 3401 3408 3402 3409 _data->_promisedImage = image; 3403 _data->_promisedFilename = filename; 3404 _data->_promisedURL = url; 3405 } 3410 } 3411 3412 #if ENABLE(ATTACHMENT_ELEMENT) 3413 - (void)_setPromisedDataForAttachment:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSString *)pasteboardName 3414 3415 { 3416 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName]; 3417 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); 3418 [types addObjectsFromArray:PasteboardTypes::forURL()]; 3419 [pasteboard declareTypes:types.get() owner:self]; 3420 [self _setFileAndURLTypes:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboard]; 3421 3422 RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]); 3423 [paths addObject:title]; 3424 [pasteboard setPropertyList:paths.get() forType:NSFilenamesPboardType]; 3425 3426 _data->_promisedImage = nullptr; 3427 } 3428 #endif 3406 3429 3407 3430 - (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard … … 3468 3491 data = _data->_promisedImage->data()->createNSData(); 3469 3492 wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:data.get()]); 3493 } else 3494 wrapper = adoptNS([[NSFileWrapper alloc] initWithURL:[NSURL URLWithString:_data->_promisedURL] options:NSFileWrapperReadingImmediate error:nil]); 3495 3496 if (wrapper) 3470 3497 [wrapper setPreferredFilename:_data->_promisedFilename]; 3471 } 3472 3473 if (!wrapper) { 3498 else { 3474 3499 LOG_ERROR("Failed to create image file."); 3475 3500 return nil; -
trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
r180465 r181760 102 102 103 103 - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; 104 - (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName; 104 - (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName; 105 #if ENABLE(ATTACHMENT_ELEMENT) 106 - (void)_setPromisedDataForAttachment:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSString *)pasteboardName; 107 #endif 105 108 - (void)_updateSecureInputState; 106 109 - (void)_resetSecureInputState; -
trunk/Source/WebKit2/UIProcess/PageClient.h
r181423 r181760 192 192 193 193 #if USE(APPKIT) 194 virtual void setPromisedData (const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,194 virtual void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, 195 195 const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) = 0; 196 #if ENABLE(ATTACHMENT_ELEMENT) 197 virtual void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, 198 const String& url, const String& visibleUrl) = 0; 199 200 #endif 196 201 #endif 197 202 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r181660 r181760 770 770 #if PLATFORM(COCOA) 771 771 void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag); 772 void setPromisedData (const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,772 void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension, 773 773 const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize); 774 #if ENABLE(ATTACHMENT_ELEMENT) 775 void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL); 776 #endif 774 777 #endif 775 778 #if PLATFORM(GTK) -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r181423 r181760 298 298 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT) 299 299 SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag) 300 SetPromisedData(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize) 300 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize) 301 #if ENABLE(ATTACHMENT_ELEMENT) 302 SetPromisedDataForAttachment(String pasteboardName, String filename, String extension, String title, String url, String visibleURL) 303 #endif 301 304 #endif 302 305 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h
r181442 r181760 95 95 virtual bool executeSavedCommandBySelector(const String& selector) override; 96 96 virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override; 97 virtual void setPromisedData (const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,97 virtual void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, 98 98 const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) override; 99 #if ENABLE(ATTACHMENT_ELEMENT) 100 virtual void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl) override; 101 #endif 99 102 virtual void updateSecureInputState() override; 100 103 virtual void resetSecureInputState() override; -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r181442 r181760 408 408 } 409 409 410 void PageClientImpl::setPromisedData (const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer)410 void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer) 411 411 { 412 412 RefPtr<Image> image = BitmapImage::create(); 413 413 image->setData(imageBuffer.get(), true); 414 [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName]; 415 } 414 [m_wkView _setPromisedDataForImage:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName]; 415 } 416 417 #if ENABLE(ATTACHMENT_ELEMENT) 418 void PageClientImpl::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl) 419 { 420 [m_wkView _setPromisedDataForAttachment:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboardName]; 421 } 422 #endif 416 423 417 424 void PageClientImpl::updateSecureInputState() -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r180768 r181760 61 61 62 62 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process().connection()) 63 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection()) 63 64 64 65 using namespace WebCore; … … 408 409 } 409 410 410 void WebPageProxy::setPromisedData (const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,411 void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension, 411 412 const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize) 412 413 { 414 MESSAGE_CHECK_URL(url); 415 MESSAGE_CHECK_URL(visibleURL); 413 416 RefPtr<SharedMemory> sharedMemoryImage = SharedMemory::create(imageHandle, SharedMemory::ReadOnly); 414 417 RefPtr<SharedBuffer> imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), imageSize); … … 419 422 archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), archiveSize); 420 423 } 421 m_pageClient.setPromisedData(pasteboardName, imageBuffer, filename, extension, title, url, visibleURL, archiveBuffer); 422 } 424 m_pageClient.setPromisedDataForImage(pasteboardName, imageBuffer, filename, extension, title, url, visibleURL, archiveBuffer); 425 } 426 427 #if ENABLE(ATTACHMENT_ELEMENT) 428 void WebPageProxy::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL) 429 { 430 MESSAGE_CHECK_URL(url); 431 MESSAGE_CHECK_URL(visibleURL); 432 m_pageClient.setPromisedDataForAttachment(pasteboardName, filename, extension, title, url, visibleURL); 433 } 434 #endif 423 435 #endif 424 436 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
r166965 r181760 52 52 #if PLATFORM(COCOA) 53 53 virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) override; 54 #if ENABLE(ATTACHMENT_ELEMENT) 55 virtual void declareAndWriteAttachment(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String& path, WebCore::Frame*) override; 56 #endif 54 57 #endif 55 58 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r176687 r181760 98 98 } 99 99 100 #if ENABLE(ATTACHMENT_ELEMENT) 101 void WebDragClient::declareAndWriteAttachment(const String& pasteboardName, Element& element, const URL& url, const String& path, WebCore::Frame* frame) 102 { 103 ASSERT(pasteboardName == String(NSDragPboard)); 104 105 NSURL* nsURL = (NSURL *)url; 106 m_page->send(Messages::WebPageProxy::SetPromisedDataForAttachment(pasteboardName, String(nsURL.lastPathComponent), String(nsURL.pathExtension), path, String(nsURL.absoluteString), userVisibleString(nsURL))); 107 } 108 #endif 109 100 110 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*) 101 111 { … … 144 154 archiveSharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly); 145 155 } 146 m_page->send(Messages::WebPageProxy::SetPromisedData (pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));156 m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize)); 147 157 } 148 158
Note: See TracChangeset
for help on using the changeset viewer.