⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276219 in webkit


Ignore:
Timestamp:
Apr 17, 2021, 8:49:07 PM (5 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276216 r276219  
     12021-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove PromisedAttachmentInfo::blobURL and adjacent code
     4        https://bugs.webkit.org/show_bug.cgi?id=224720
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Remove this member of `PromisedAttachmentInfo`. See WebKit ChangeLog for more details.
     9
     10        * editing/Editor.cpp:
     11        (WebCore::Editor::promisedAttachmentInfo):
     12        * platform/PromisedAttachmentInfo.h:
     13        (WebCore::PromisedAttachmentInfo::operator bool const):
     14
    1152021-04-17  Tim Nguyen  <ntim@apple.com>
    216
  • trunk/Source/WebCore/editing/Editor.cpp

    r276191 r276219  
    41214121#endif
    41224122
    4123     if (auto file = makeRefPtr(attachment->file()))
    4124         return { file->url(), platformContentTypeForBlobType(file->type()), file->name(), { }, WTFMove(additionalTypes), WTFMove(additionalData) };
    4125 
    4126     return { { }, { }, { }, attachment->uniqueIdentifier(), WTFMove(additionalTypes), WTFMove(additionalData) };
     4123    return { attachment->uniqueIdentifier(), WTFMove(additionalTypes), WTFMove(additionalData) };
    41274124}
    41284125
  • trunk/Source/WebCore/platform/PromisedAttachmentInfo.h

    r238771 r276219  
    3434
    3535struct PromisedAttachmentInfo {
    36     URL blobURL;
    37     String contentType;
    38     String fileName;
    39 
    4036#if ENABLE(ATTACHMENT_ELEMENT)
    4137    String attachmentIdentifier;
     
    5147            return true;
    5248#endif
    53 
    54         return !contentType.isEmpty() && !blobURL.isEmpty();
     49        return false;
    5550    }
    5651};
  • trunk/Source/WebKit/ChangeLog

    r276218 r276219  
     12021-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove PromisedAttachmentInfo::blobURL and adjacent code
     4        https://bugs.webkit.org/show_bug.cgi?id=224720
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        The `blobURL` member of `PromisedAttachmentInfo` was originally introduced to facilitate drag and drop support
     9        for attachment elements in WebKit2, by writing blob URL data to temporary file paths on behalf of
     10        `NSFilePromiseProvider` when starting a drag on attachment elements backed by blobs. However, this was
     11        superceded by use of `NSFileWrapper` and the `_WKAttachment` SPI instead, such that we only support dragging
     12        attachment elements if they correspond to API `Attachment` objects in the UI process. This means we can remove
     13        this `blobURL`, along with the file name and content type members of the struct (which were only added to
     14        support the ability to drag blob-backed attachments).
     15
     16        Code that utilized this member was originally introduced in <https://trac.webkit.org/r235202>, and was
     17        subsequently removed in <https://trac.webkit.org/r240687>.
     18
     19        * Shared/WebCoreArgumentCoders.cpp:
     20        (IPC::ArgumentCoder<PromisedAttachmentInfo>::encode):
     21        (IPC::ArgumentCoder<PromisedAttachmentInfo>::decode):
     22        * UIProcess/Cocoa/WebViewImpl.mm:
     23        (-[WKPromisedAttachmentContext initWithIdentifier:fileName:]):
     24        (WebKit::WebViewImpl::writeToURLForFilePromiseProvider):
     25        (WebKit::WebViewImpl::startDrag):
     26        (-[WKPromisedAttachmentContext initWithIdentifier:blobURL:fileName:]): Deleted.
     27        (-[WKPromisedAttachmentContext blobURL]): Deleted.
     28        * UIProcess/ios/WKContentViewInteraction.mm:
     29        (-[WKContentView _prepareToDragPromisedAttachment:]):
     30
    1312021-04-17  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r276177 r276219  
    28832883void ArgumentCoder<PromisedAttachmentInfo>::encode(Encoder& encoder, const PromisedAttachmentInfo& info)
    28842884{
    2885     encoder << info.blobURL;
    2886     encoder << info.contentType;
    2887     encoder << info.fileName;
    28882885#if ENABLE(ATTACHMENT_ELEMENT)
    28892886    encoder << info.attachmentIdentifier;
     
    28942891bool ArgumentCoder<PromisedAttachmentInfo>::decode(Decoder& decoder, PromisedAttachmentInfo& info)
    28952892{
    2896     if (!decoder.decode(info.blobURL))
    2897         return false;
    2898 
    2899     if (!decoder.decode(info.contentType))
    2900         return false;
    2901 
    2902     if (!decoder.decode(info.fileName))
    2903         return false;
    2904 
    29052893#if ENABLE(ATTACHMENT_ELEMENT)
    29062894    if (!decoder.decode(info.attachmentIdentifier))
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r275913 r276219  
    886886@interface WKPromisedAttachmentContext : NSObject {
    887887@private
    888     RetainPtr<NSURL> _blobURL;
    889888    RetainPtr<NSString> _fileName;
    890889    RetainPtr<NSString> _attachmentIdentifier;
    891890}
    892891
    893 - (instancetype)initWithIdentifier:(NSString *)identifier blobURL:(NSURL *)url fileName:(NSString *)fileName;
    894 
    895 @property (nonatomic, readonly) NSURL *blobURL;
     892- (instancetype)initWithIdentifier:(NSString *)identifier fileName:(NSString *)fileName;
     893
    896894@property (nonatomic, readonly) NSString *fileName;
    897895@property (nonatomic, readonly) NSString *attachmentIdentifier;
     
    901899@implementation WKPromisedAttachmentContext
    902900
    903 - (instancetype)initWithIdentifier:(NSString *)identifier blobURL:(NSURL *)blobURL fileName:(NSString *)fileName
     901- (instancetype)initWithIdentifier:(NSString *)identifier fileName:(NSString *)fileName
    904902{
    905903    if (!(self = [super init]))
    906904        return nil;
    907905
    908     _blobURL = blobURL;
    909906    _fileName = fileName;
    910907    _attachmentIdentifier = identifier;
    911908    return self;
    912 }
    913 
    914 - (NSURL *)blobURL
    915 {
    916     return _blobURL.get();
    917909}
    918910
     
    42354227    }
    42364228
    4237     URL blobURL { info.blobURL };
    4238     if (blobURL.isEmpty()) {
    4239         completionHandler(webKitUnknownError());
    4240         return;
    4241     }
    4242 
    42434229    completionHandler(webKitUnknownError());
    42444230}
     
    42864272
    42874273    if (auto& info = item.promisedAttachmentInfo) {
    4288         NSString *utiType = info.contentType;
    4289         NSString *fileName = info.fileName;
    4290         if (auto attachment = m_page->attachmentForIdentifier(info.attachmentIdentifier)) {
    4291             utiType = attachment->utiType();
    4292             fileName = attachment->fileName();
     4274        auto attachment = m_page->attachmentForIdentifier(info.attachmentIdentifier);
     4275        if (!attachment) {
     4276            m_page->dragCancelled();
     4277            return;
    42934278        }
    42944279
     4280        NSString *utiType = attachment->utiType();
    42954281        if (!utiType.length) {
    42964282            m_page->dragCancelled();
     
    42984284        }
    42994285
     4286        NSString *fileName = attachment->fileName();
    43004287        auto provider = adoptNS([[NSFilePromiseProvider alloc] initWithFileType:utiType delegate:(id <NSFilePromiseProviderDelegate>)m_view.getAutoreleased()]);
    4301         auto context = adoptNS([[WKPromisedAttachmentContext alloc] initWithIdentifier:info.attachmentIdentifier blobURL:info.blobURL fileName:fileName]);
     4288        auto context = adoptNS([[WKPromisedAttachmentContext alloc] initWithIdentifier:info.attachmentIdentifier fileName:fileName]);
    43024289        [provider setUserInfo:context.get()];
    43034290        auto draggingItem = adoptNS([[NSDraggingItem alloc] initWithPasteboardWriter:provider.get()]);
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r275980 r276219  
    81508150    ASSERT(numberOfAdditionalTypes == info.additionalData.size());
    81518151
    8152     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());
    8153 
    8154     NSString *utiType = info.contentType;
    8155     NSString *fileName = info.fileName;
     8152    RELEASE_LOG(DragAndDrop, "Drag session: %p preparing to drag with attachment identifier: %s", session.get(), info.attachmentIdentifier.utf8().data());
     8153
     8154    NSString *utiType = nil;
     8155    NSString *fileName = nil;
    81568156    if (auto attachment = _page->attachmentForIdentifier(info.attachmentIdentifier)) {
    81578157        utiType = attachment->utiType();
  • trunk/Tools/ChangeLog

    r276199 r276219  
     12021-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove PromisedAttachmentInfo::blobURL and adjacent code
     4        https://bugs.webkit.org/show_bug.cgi?id=224720
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Rebaseline a couple of iOS WKAttachment tests that are failing on recent versions of the iOS SDK. The content
     9        type of text files that are inserted as attachments is now a MIME type rather than a UTI, which is still valid
     10        since it is valid for the content type of an attachment to be either a MIME type or UTI.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152021-04-17  Aakash Jain  <aakash_jain@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

    r273194 r276219  
    18971897    EXPECT_WK_STREQ((__bridge NSString *)kUTTypeFlatRTFD, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"]);
    18981898    EXPECT_WK_STREQ("world.txt", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('title')"]);
    1899     EXPECT_WK_STREQ((__bridge NSString *)kUTTypeUTF8PlainText, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('type')"]);
     1899    auto contentType = [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('type')"];
     1900    EXPECT_TRUE([contentType isEqualToString:(__bridge NSString *)kUTTypeUTF8PlainText] || [contentType containsString:@"text/plain"]);
    19001901}
    19011902
     
    19541955
    19551956    EXPECT_WK_STREQ("first.txt", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('title')"]);
    1956     EXPECT_WK_STREQ((__bridge NSString *)kUTTypeUTF8PlainText, [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"]);
     1957    auto contentType = [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].getAttribute('type')"];
     1958    EXPECT_TRUE([contentType isEqualToString:(__bridge NSString *)kUTTypeUTF8PlainText] || [contentType containsString:@"text/plain"]);
    19571959    EXPECT_WK_STREQ([appleURL absoluteString], [webView valueOfAttribute:@"href" forQuerySelector:@"a"]);
    19581960    EXPECT_WK_STREQ("second.pdf", [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].getAttribute('title')"]);
Note: See TracChangeset for help on using the changeset viewer.