Changeset 226330 in webkit
- Timestamp:
- Jan 2, 2018, 12:02:50 PM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r226327 r226330 1 2018-01-02 Alex Christensen <achristensen@webkit.org> 2 3 Use BlockPtrs and lambdas instead of new/delete to pass parameters to blocks in WebViewImpl::performDragOperation 4 https://bugs.webkit.org/show_bug.cgi?id=180795 5 6 Reviewed by Brent Fulgham. 7 8 * UIProcess/Cocoa/WebViewImpl.mm: 9 (WebKit::WebViewImpl::performDragOperation): 10 1 11 2018-01-02 Michael Catanzaro <mcatanzaro@igalia.com> 2 12 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r226312 r226330 3691 3691 WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]); 3692 3692 WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window])); 3693 WebCore::DragData *dragData = new WebCore::DragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));3693 WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo)); 3694 3694 3695 3695 NSArray *types = draggingInfo.draggingPasteboard.types; … … 3699 3699 if ([types containsObject:WebCore::legacyFilenamesPasteboardType()]) { 3700 3700 NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:WebCore::legacyFilenamesPasteboardType()]; 3701 if (![files isKindOfClass:[NSArray class]]) { 3702 delete dragData; 3701 if (![files isKindOfClass:[NSArray class]]) 3703 3702 return false; 3704 }3705 3703 3706 3704 Vector<String> fileNames; … … 3713 3711 else if (![types containsObject:PasteboardTypes::WebArchivePboardType] && [types containsObject:WebCore::legacyFilesPromisePasteboardType()]) { 3714 3712 NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:WebCore::legacyFilesPromisePasteboardType()]; 3715 if (![files isKindOfClass:[NSArray class]]) { 3716 delete dragData; 3713 if (![files isKindOfClass:[NSArray class]]) 3717 3714 return false; 3718 }3719 3715 size_t fileCount = files.count; 3720 Vector<String> *fileNames = new Vector<String>;3716 Vector<String> fileNames; 3721 3717 NSURL *dropLocation = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; 3722 3718 String pasteboardName = draggingInfo.draggingPasteboard.name; 3723 [draggingInfo enumerateDraggingItemsWithOptions:0 forView:m_view.getAutoreleased() classes:@[[NSFilePromiseReceiver class]] searchOptions:@{ } usingBlock: ^(NSDraggingItem * __nonnull draggingItem, NSInteger idx, BOOL * __nonnull stop){3719 [draggingInfo enumerateDraggingItemsWithOptions:0 forView:m_view.getAutoreleased() classes:@[[NSFilePromiseReceiver class]] searchOptions:@{ } usingBlock:BlockPtr<void (NSDraggingItem *, NSInteger, BOOL *)>::fromCallable([this, fileNames = WTFMove(fileNames), dropLocation = retainPtr(dropLocation), fileCount, dragData = WTFMove(dragData), pasteboardName](NSDraggingItem * __nonnull draggingItem, NSInteger idx, BOOL * __nonnull stop) mutable { 3724 3720 NSFilePromiseReceiver *item = draggingItem.item; 3725 3721 NSDictionary *options = @{ }; 3726 3722 3727 3723 RetainPtr<NSOperationQueue> queue = adoptNS([NSOperationQueue new]); 3728 [item receivePromisedFilesAtDestination:dropLocation options:options operationQueue:queue.get() reader:^(NSURL * _Nonnull fileURL, NSError * _Nullable errorOrNil){3724 [item receivePromisedFilesAtDestination:dropLocation.get() options:options operationQueue:queue.get() reader:BlockPtr<void(NSURL *, NSError *)>::fromCallable([this, fileNames = WTFMove(fileNames), fileCount, dragData = WTFMove(dragData), pasteboardName](NSURL * _Nonnull fileURL, NSError * _Nullable errorOrNil) mutable { 3729 3725 if (errorOrNil) 3730 3726 return; 3731 3727 3732 dispatch_async(dispatch_get_main_queue(), [this, path = RetainPtr<NSString>(fileURL.path), fileNames, fileCount, dragData, pasteboardName]{3733 fileNames ->append(path.get());3734 if (fileNames ->size() == fileCount) {3728 dispatch_async(dispatch_get_main_queue(), BlockPtr<void()>::fromCallable([this, path = retainPtr(fileURL.path), fileNames, fileCount, dragData = WTFMove(dragData), pasteboardName]() mutable { 3729 fileNames.append(path.get()); 3730 if (fileNames.size() == fileCount) { 3735 3731 SandboxExtension::Handle sandboxExtensionHandle; 3736 3732 SandboxExtension::HandleArray sandboxExtensionForUpload; 3737 3733 3738 m_page->createSandboxExtensionsIfNeeded(*fileNames, sandboxExtensionHandle, sandboxExtensionForUpload); 3739 dragData->setFileNames(*fileNames); 3740 m_page->performDragOperation(*dragData, pasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 3741 delete dragData; 3742 delete fileNames; 3734 m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload); 3735 dragData.setFileNames(fileNames); 3736 m_page->performDragOperation(dragData, pasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 3743 3737 } 3744 }) ;3745 } ];3746 } ];3738 }).get()); 3739 }).get()]; 3740 }).get()]; 3747 3741 3748 3742 return true; … … 3750 3744 #endif 3751 3745 3752 m_page->performDragOperation(*dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 3753 delete dragData; 3746 m_page->performDragOperation(dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload)); 3754 3747 3755 3748 return true;
Note:
See TracChangeset
for help on using the changeset viewer.