Title: [276219] trunk
Revision
276219
Author
[email protected]
Date
2021-04-17 20:49:07 -0700 (Sat, 17 Apr 2021)

Log Message

Remove PromisedAttachmentInfo::blobURL and adjacent code
https://bugs.webkit.org/show_bug.cgi?id=224720

Reviewed by Ryosuke Niwa.

Source/WebCore:

Remove this member of `PromisedAttachmentInfo`. See WebKit ChangeLog for more details.

* editing/Editor.cpp:
(WebCore::Editor::promisedAttachmentInfo):
* platform/PromisedAttachmentInfo.h:
(WebCore::PromisedAttachmentInfo::operator bool const):

Source/WebKit:

The `blobURL` member of `PromisedAttachmentInfo` was originally introduced to facilitate drag and drop support
for attachment elements in WebKit2, by writing blob URL data to temporary file paths on behalf of
`NSFilePromiseProvider` when starting a drag on attachment elements backed by blobs. However, this was
superceded by use of `NSFileWrapper` and the `_WKAttachment` SPI instead, such that we only support dragging
attachment elements if they correspond to API `Attachment` objects in the UI process. This means we can remove
this `blobURL`, along with the file name and content type members of the struct (which were only added to
support the ability to drag blob-backed attachments).

Code that utilized this member was originally introduced in <https://trac.webkit.org/r235202>, and was
subsequently removed in <https://trac.webkit.org/r240687>.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<PromisedAttachmentInfo>::encode):
(IPC::ArgumentCoder<PromisedAttachmentInfo>::decode):
* UIProcess/Cocoa/WebViewImpl.mm:
(-[WKPromisedAttachmentContext initWithIdentifier:fileName:]):
(WebKit::WebViewImpl::writeToURLForFilePromiseProvider):
(WebKit::WebViewImpl::startDrag):
(-[WKPromisedAttachmentContext initWithIdentifier:blobURL:fileName:]): Deleted.
(-[WKPromisedAttachmentContext blobURL]): Deleted.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _prepareToDragPromisedAttachment:]):

Tools:

Rebaseline a couple of iOS WKAttachment tests that are failing on recent versions of the iOS SDK. The content
type of text files that are inserted as attachments is now a MIME type rather than a UTI, which is still valid
since it is valid for the content type of an attachment to be either a MIME type or UTI.

* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276218 => 276219)


--- trunk/Source/WebCore/ChangeLog	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebCore/ChangeLog	2021-04-18 03:49:07 UTC (rev 276219)
@@ -1,3 +1,17 @@
+2021-04-17  Wenson Hsieh  <[email protected]>
+
+        Remove PromisedAttachmentInfo::blobURL and adjacent code
+        https://bugs.webkit.org/show_bug.cgi?id=224720
+
+        Reviewed by Ryosuke Niwa.
+
+        Remove this member of `PromisedAttachmentInfo`. See WebKit ChangeLog for more details.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::promisedAttachmentInfo):
+        * platform/PromisedAttachmentInfo.h:
+        (WebCore::PromisedAttachmentInfo::operator bool const):
+
 2021-04-17  Tim Nguyen  <[email protected]>
 
         Add support for inline-{start/end} values to float & clear properties

Modified: trunk/Source/WebCore/editing/Editor.cpp (276218 => 276219)


--- trunk/Source/WebCore/editing/Editor.cpp	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebCore/editing/Editor.cpp	2021-04-18 03:49:07 UTC (rev 276219)
@@ -4120,10 +4120,7 @@
     getPasteboardTypesAndDataForAttachment(element, additionalTypes, additionalData);
 #endif
 
-    if (auto file = makeRefPtr(attachment->file()))
-        return { file->url(), platformContentTypeForBlobType(file->type()), file->name(), { }, WTFMove(additionalTypes), WTFMove(additionalData) };
-
-    return { { }, { }, { }, attachment->uniqueIdentifier(), WTFMove(additionalTypes), WTFMove(additionalData) };
+    return { attachment->uniqueIdentifier(), WTFMove(additionalTypes), WTFMove(additionalData) };
 }
 
 void Editor::registerAttachmentIdentifier(const String& identifier, const String& contentType, const String& preferredFileName, Ref<SharedBuffer>&& data)

Modified: trunk/Source/WebCore/platform/PromisedAttachmentInfo.h (276218 => 276219)


--- trunk/Source/WebCore/platform/PromisedAttachmentInfo.h	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebCore/platform/PromisedAttachmentInfo.h	2021-04-18 03:49:07 UTC (rev 276219)
@@ -33,10 +33,6 @@
 class SharedBuffer;
 
 struct PromisedAttachmentInfo {
-    URL blobURL;
-    String contentType;
-    String fileName;
-
 #if ENABLE(ATTACHMENT_ELEMENT)
     String attachmentIdentifier;
 #endif
@@ -50,8 +46,7 @@
         if (!attachmentIdentifier.isEmpty())
             return true;
 #endif
-
-        return !contentType.isEmpty() && !blobURL.isEmpty();
+        return false;
     }
 };
 

Modified: trunk/Source/WebKit/ChangeLog (276218 => 276219)


--- trunk/Source/WebKit/ChangeLog	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebKit/ChangeLog	2021-04-18 03:49:07 UTC (rev 276219)
@@ -1,3 +1,33 @@
+2021-04-17  Wenson Hsieh  <[email protected]>
+
+        Remove PromisedAttachmentInfo::blobURL and adjacent code
+        https://bugs.webkit.org/show_bug.cgi?id=224720
+
+        Reviewed by Ryosuke Niwa.
+
+        The `blobURL` member of `PromisedAttachmentInfo` was originally introduced to facilitate drag and drop support
+        for attachment elements in WebKit2, by writing blob URL data to temporary file paths on behalf of
+        `NSFilePromiseProvider` when starting a drag on attachment elements backed by blobs. However, this was
+        superceded by use of `NSFileWrapper` and the `_WKAttachment` SPI instead, such that we only support dragging
+        attachment elements if they correspond to API `Attachment` objects in the UI process. This means we can remove
+        this `blobURL`, along with the file name and content type members of the struct (which were only added to
+        support the ability to drag blob-backed attachments).
+
+        Code that utilized this member was originally introduced in <https://trac.webkit.org/r235202>, and was
+        subsequently removed in <https://trac.webkit.org/r240687>.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<PromisedAttachmentInfo>::encode):
+        (IPC::ArgumentCoder<PromisedAttachmentInfo>::decode):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (-[WKPromisedAttachmentContext initWithIdentifier:fileName:]):
+        (WebKit::WebViewImpl::writeToURLForFilePromiseProvider):
+        (WebKit::WebViewImpl::startDrag):
+        (-[WKPromisedAttachmentContext initWithIdentifier:blobURL:fileName:]): Deleted.
+        (-[WKPromisedAttachmentContext blobURL]): Deleted.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _prepareToDragPromisedAttachment:]):
+
 2021-04-17  Chris Dumez  <[email protected]>
 
         Use WebProcess::existingGPUProcessConnection() whenever possible

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (276218 => 276219)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-04-18 03:49:07 UTC (rev 276219)
@@ -2882,9 +2882,6 @@
 
 void ArgumentCoder<PromisedAttachmentInfo>::encode(Encoder& encoder, const PromisedAttachmentInfo& info)
 {
-    encoder << info.blobURL;
-    encoder << info.contentType;
-    encoder << info.fileName;
 #if ENABLE(ATTACHMENT_ELEMENT)
     encoder << info.attachmentIdentifier;
 #endif
@@ -2893,15 +2890,6 @@
 
 bool ArgumentCoder<PromisedAttachmentInfo>::decode(Decoder& decoder, PromisedAttachmentInfo& info)
 {
-    if (!decoder.decode(info.blobURL))
-        return false;
-
-    if (!decoder.decode(info.contentType))
-        return false;
-
-    if (!decoder.decode(info.fileName))
-        return false;
-
 #if ENABLE(ATTACHMENT_ELEMENT)
     if (!decoder.decode(info.attachmentIdentifier))
         return false;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (276218 => 276219)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-04-18 03:49:07 UTC (rev 276219)
@@ -885,14 +885,12 @@
 
 @interface WKPromisedAttachmentContext : NSObject {
 @private
-    RetainPtr<NSURL> _blobURL;
     RetainPtr<NSString> _fileName;
     RetainPtr<NSString> _attachmentIdentifier;
 }
 
-- (instancetype)initWithIdentifier:(NSString *)identifier blobURL:(NSURL *)url fileName:(NSString *)fileName;
+- (instancetype)initWithIdentifier:(NSString *)identifier fileName:(NSString *)fileName;
 
-@property (nonatomic, readonly) NSURL *blobURL;
 @property (nonatomic, readonly) NSString *fileName;
 @property (nonatomic, readonly) NSString *attachmentIdentifier;
 
@@ -900,22 +898,16 @@
 
 @implementation WKPromisedAttachmentContext
 
-- (instancetype)initWithIdentifier:(NSString *)identifier blobURL:(NSURL *)blobURL fileName:(NSString *)fileName
+- (instancetype)initWithIdentifier:(NSString *)identifier fileName:(NSString *)fileName
 {
     if (!(self = [super init]))
         return nil;
 
-    _blobURL = blobURL;
     _fileName = fileName;
     _attachmentIdentifier = identifier;
     return self;
 }
 
-- (NSURL *)blobURL
-{
-    return _blobURL.get();
-}
-
 - (NSString *)fileName
 {
     return _fileName.get();
@@ -4234,12 +4226,6 @@
         return;
     }
 
-    URL blobURL { info.blobURL };
-    if (blobURL.isEmpty()) {
-        completionHandler(webKitUnknownError());
-        return;
-    }
-
     completionHandler(webKitUnknownError());
 }
 
@@ -4285,20 +4271,21 @@
     ALLOW_DEPRECATED_DECLARATIONS_END
 
     if (auto& info = item.promisedAttachmentInfo) {
-        NSString *utiType = info.contentType;
-        NSString *fileName = info.fileName;
-        if (auto attachment = m_page->attachmentForIdentifier(info.attachmentIdentifier)) {
-            utiType = attachment->utiType();
-            fileName = attachment->fileName();
+        auto attachment = m_page->attachmentForIdentifier(info.attachmentIdentifier);
+        if (!attachment) {
+            m_page->dragCancelled();
+            return;
         }
 
+        NSString *utiType = attachment->utiType();
         if (!utiType.length) {
             m_page->dragCancelled();
             return;
         }
 
+        NSString *fileName = attachment->fileName();
         auto provider = adoptNS([[NSFilePromiseProvider alloc] initWithFileType:utiType delegate:(id <NSFilePromiseProviderDelegate>)m_view.getAutoreleased()]);
-        auto context = adoptNS([[WKPromisedAttachmentContext alloc] initWithIdentifier:info.attachmentIdentifier blobURL:info.blobURL fileName:fileName]);
+        auto context = adoptNS([[WKPromisedAttachmentContext alloc] initWithIdentifier:info.attachmentIdentifier fileName:fileName]);
         [provider setUserInfo:context.get()];
         auto draggingItem = adoptNS([[NSDraggingItem alloc] initWithPasteboardWriter:provider.get()]);
         [draggingItem setDraggingFrame:NSMakeRect(clientDragLocation.x(), clientDragLocation.y() - size.height(), size.width(), size.height()) contents:dragNSImage.get()];

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (276218 => 276219)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-04-18 03:49:07 UTC (rev 276219)
@@ -8149,10 +8149,10 @@
     auto numberOfAdditionalTypes = info.additionalTypes.size();
     ASSERT(numberOfAdditionalTypes == info.additionalData.size());
 
-    RELEASE_LOG(DragAndDrop, "Drag session: %p preparing to drag blob: %s with attachment identifier: %s", session.get(), info.blobURL.string().utf8().data(), info.attachmentIdentifier.utf8().data());
+    RELEASE_LOG(DragAndDrop, "Drag session: %p preparing to drag with attachment identifier: %s", session.get(), info.attachmentIdentifier.utf8().data());
 
-    NSString *utiType = info.contentType;
-    NSString *fileName = info.fileName;
+    NSString *utiType = nil;
+    NSString *fileName = nil;
     if (auto attachment = _page->attachmentForIdentifier(info.attachmentIdentifier)) {
         utiType = attachment->utiType();
         fileName = attachment->fileName();

Modified: trunk/Tools/ChangeLog (276218 => 276219)


--- trunk/Tools/ChangeLog	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Tools/ChangeLog	2021-04-18 03:49:07 UTC (rev 276219)
@@ -1,3 +1,17 @@
+2021-04-17  Wenson Hsieh  <[email protected]>
+
+        Remove PromisedAttachmentInfo::blobURL and adjacent code
+        https://bugs.webkit.org/show_bug.cgi?id=224720
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline a couple of iOS WKAttachment tests that are failing on recent versions of the iOS SDK. The content
+        type of text files that are inserted as attachments is now a MIME type rather than a UTI, which is still valid
+        since it is valid for the content type of an attachment to be either a MIME type or UTI.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
+        (TestWebKitAPI::TEST):
+
 2021-04-17  Aakash Jain  <[email protected]>
 
         Do not configure Janitor to delete old logs in local testing mode

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm (276218 => 276219)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm	2021-04-18 03:40:56 UTC (rev 276218)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm	2021-04-18 03:49:07 UTC (rev 276219)
@@ -1896,7 +1896,8 @@
     EXPECT_WK_STREQ("hello.rtf", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('title')"]);
     EXPECT_WK_STREQ((__bridge NSString *)kUTTypeFlatRTFD, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"]);
     EXPECT_WK_STREQ("world.txt", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('title')"]);
-    EXPECT_WK_STREQ((__bridge NSString *)kUTTypeUTF8PlainText, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('type')"]);
+    auto contentType = [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('type')"];
+    EXPECT_TRUE([contentType isEqualToString:(__bridge NSString *)kUTTypeUTF8PlainText] || [contentType containsString:@"text/plain"]);
 }
 
 TEST(WKAttachmentTestsIOS, InsertDroppedZipArchiveAsAttachment)
@@ -1953,7 +1954,8 @@
     [webView expectElementTagsInOrder:@[ @"ATTACHMENT", @"A", @"ATTACHMENT" ]];
 
     EXPECT_WK_STREQ("first.txt", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('title')"]);
-    EXPECT_WK_STREQ((__bridge NSString *)kUTTypeUTF8PlainText, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"]);
+    auto contentType = [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"];
+    EXPECT_TRUE([contentType isEqualToString:(__bridge NSString *)kUTTypeUTF8PlainText] || [contentType containsString:@"text/plain"]);
     EXPECT_WK_STREQ([appleURL absoluteString], [webView valueOfAttribute:@"href" forQuerySelector:@"a"]);
     EXPECT_WK_STREQ("second.pdf", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('title')"]);
     EXPECT_WK_STREQ("application/pdf", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('type')"]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to