Title: [229043] trunk/Source/WebKit
Revision
229043
Author
[email protected]
Date
2018-02-26 15:20:22 -0800 (Mon, 26 Feb 2018)

Log Message

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (229042 => 229043)


--- trunk/Source/WebKit/ChangeLog	2018-02-26 21:38:39 UTC (rev 229042)
+++ trunk/Source/WebKit/ChangeLog	2018-02-26 23:20:22 UTC (rev 229043)
@@ -1,3 +1,18 @@
+2018-02-26  Commit Queue  <[email protected]>
+
+        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  <[email protected]>
 
         Release assertion in WebPage::updatePreferences

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (229042 => 229043)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-02-26 21:38:39 UTC (rev 229042)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-02-26 23:20:22 UTC (rev 229043)
@@ -3692,7 +3692,7 @@
 {
     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;
@@ -3700,8 +3700,10 @@
 
     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 @@
         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;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to