Skip to content
Permalink
Browse files
Unreviewed, rolling out r226330.
https://bugs.webkit.org/show_bug.cgi?id=183152

incorrectly assumes enumeration callback happens once
(Requested by alexchristensen on #webkit).

Reverted changeset:

"Use BlockPtrs and lambdas instead of new/delete to pass
parameters to blocks in WebViewImpl::performDragOperation"
https://bugs.webkit.org/show_bug.cgi?id=180795
https://trac.webkit.org/changeset/226330

Canonical link: https://commits.webkit.org/198858@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229043 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed Feb 26, 2018
1 parent fc69fa6 commit 4cc7a1417f8e7108e3b6af219cbb90137f9a563c
Showing with 38 additions and 16 deletions.
  1. +15 −0 Source/WebKit/ChangeLog
  2. +23 −16 Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
@@ -1,3 +1,18 @@
2018-02-26 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r226330.
https://bugs.webkit.org/show_bug.cgi?id=183152

incorrectly assumes enumeration callback happens once
(Requested by alexchristensen on #webkit).

Reverted changeset:

"Use BlockPtrs and lambdas instead of new/delete to pass
parameters to blocks in WebViewImpl::performDragOperation"
https://bugs.webkit.org/show_bug.cgi?id=180795
https://trac.webkit.org/changeset/226330

2018-02-26 Ryosuke Niwa <rniwa@webkit.org>

Release assertion in WebPage::updatePreferences
@@ -3692,16 +3692,18 @@ static String commandNameForSelector(SEL selector)
{
WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window]));
WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));
WebCore::DragData *dragData = new WebCore::DragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));

NSArray *types = draggingInfo.draggingPasteboard.types;
SandboxExtension::Handle sandboxExtensionHandle;
SandboxExtension::HandleArray sandboxExtensionForUpload;

if ([types containsObject:WebCore::legacyFilenamesPasteboardType()]) {
NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:WebCore::legacyFilenamesPasteboardType()];
if (![files isKindOfClass:[NSArray class]])
if (![files isKindOfClass:[NSArray class]]) {
delete dragData;
return false;
}

Vector<String> fileNames;

@@ -3710,39 +3712,44 @@ static String commandNameForSelector(SEL selector)
m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
} else if (![types containsObject:PasteboardTypes::WebArchivePboardType] && [types containsObject:WebCore::legacyFilesPromisePasteboardType()]) {
NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:WebCore::legacyFilesPromisePasteboardType()];
if (![files isKindOfClass:[NSArray class]])
if (![files isKindOfClass:[NSArray class]]) {
delete dragData;
return false;
}
size_t fileCount = files.count;
Vector<String> fileNames;
Vector<String> *fileNames = new Vector<String>;
NSURL *dropLocation = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
String pasteboardName = draggingInfo.draggingPasteboard.name;
[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 {
[draggingInfo enumerateDraggingItemsWithOptions:0 forView:m_view.getAutoreleased() classes:@[[NSFilePromiseReceiver class]] searchOptions:@{ } usingBlock:^(NSDraggingItem * __nonnull draggingItem, NSInteger idx, BOOL * __nonnull stop) {
NSFilePromiseReceiver *item = draggingItem.item;
NSDictionary *options = @{ };

RetainPtr<NSOperationQueue> queue = adoptNS([NSOperationQueue new]);
[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 {
[item receivePromisedFilesAtDestination:dropLocation options:options operationQueue:queue.get() reader:^(NSURL * _Nonnull fileURL, NSError * _Nullable errorOrNil) {
if (errorOrNil)
return;

dispatch_async(dispatch_get_main_queue(), BlockPtr<void()>::fromCallable([this, path = retainPtr(fileURL.path), fileNames, fileCount, dragData = WTFMove(dragData), pasteboardName]() mutable {
fileNames.append(path.get());
if (fileNames.size() == fileCount) {
dispatch_async(dispatch_get_main_queue(), [this, path = RetainPtr<NSString>(fileURL.path), fileNames, fileCount, dragData, pasteboardName] {
fileNames->append(path.get());
if (fileNames->size() == fileCount) {
SandboxExtension::Handle sandboxExtensionHandle;
SandboxExtension::HandleArray sandboxExtensionForUpload;

m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
dragData.setFileNames(fileNames);
m_page->performDragOperation(dragData, pasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
m_page->createSandboxExtensionsIfNeeded(*fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
dragData->setFileNames(*fileNames);
m_page->performDragOperation(*dragData, pasteboardName, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
delete dragData;
delete fileNames;
}
}).get());
}).get()];
}).get()];
});
}];
}];

return true;
}

m_page->performDragOperation(dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
m_page->performDragOperation(*dragData, draggingInfo.draggingPasteboard.name, WTFMove(sandboxExtensionHandle), WTFMove(sandboxExtensionForUpload));
delete dragData;

return true;
}

0 comments on commit 4cc7a14

Please sign in to comment.