WebKit Bugzilla
Attachment 348113 Details for
Bug 188957
: [Attachment Support] [WK2] Images copied from Mail message view paste with the wrong file name in compose
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Rebase on trunk
bug-188957-20180826195741.patch (text/plain), 6.64 KB, created by
Wenson Hsieh
on 2018-08-26 19:57:42 PDT
(
hide
)
Description:
Rebase on trunk
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-08-26 19:57:42 PDT
Size:
6.64 KB
patch
obsolete
>Subversion Revision: 235347 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9327f997ad87517c73e6987dc1eaf0f649b48e19..5c85e22448c0c813d3cd9e1c73d9557f0143f53f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-08-26 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Attachment Support] [WK2] Images copied from Mail message view paste with the wrong file name in compose >+ https://bugs.webkit.org/show_bug.cgi?id=188957 >+ <rdar://problem/43737715> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow the alt attribute of a pasted image element to determine the name of an image attachment, rather than >+ using the source URL's last path component first. This is because in some clients, such as Mail, the source of >+ the image element is some nondescript UUID, and the alt text contains the real name of the image. >+ >+ Test: WKAttachmentTests.PasteWebArchiveContainingImages >+ >+ * editing/cocoa/WebContentReaderCocoa.mm: >+ (WebCore::replaceRichContentWithAttachments): >+ > 2018-08-26 Wenson Hsieh <wenson_hsieh@apple.com> > > [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory >diff --git a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >index c883a2369ad36f7012cbc486cfad0bc02b04c43c..e8850843019b176890da6065fa5f00434c46785d 100644 >--- a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >+++ b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >@@ -286,7 +286,9 @@ static void replaceRichContentWithAttachments(Frame& frame, DocumentFragment& fr > if (resource == urlToResourceMap.end()) > continue; > >- auto name = URLParser { resourceURLString }.result().lastPathComponent(); >+ auto name = image.attributeWithoutSynchronization(HTMLNames::altAttr); >+ if (name.isEmpty()) >+ name = URLParser { resourceURLString }.result().lastPathComponent(); > if (name.isEmpty()) > name = AtomicString("media"); > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index ff8d82ef053e732a34846787c1586878a7454dec..5c2dbc0694cde6731ae0cf3189a9d71cd18802cf 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-26 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Attachment Support] [WK2] Images copied from Mail message view paste with the wrong file name in compose >+ https://bugs.webkit.org/show_bug.cgi?id=188957 >+ <rdar://problem/43737715> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a new API test to verify that pasting a web archive containing several image elements with alt attributes >+ generates _WKAttachments whose names reflect those alt attributes. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: >+ (testGIFFileURL): >+ (testGIFData): >+ (TestWebKitAPI::TEST): >+ > 2018-08-26 Wenson Hsieh <wenson_hsieh@apple.com> > > [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >index 1fe0e2c26aa4f1c7df85ad679d1a7958a6ecdc8b..bd2fc5f546780cbbc7066c55d04f37eb8ac32db9 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >@@ -32,7 +32,7 @@ > #import "WKWebViewConfigurationExtras.h" > #import <WebKit/WKPreferencesRefPrivate.h> > #import <WebKit/WKWebViewPrivate.h> >-#import <WebKit/WebKit.h> >+#import <WebKit/WebArchive.h> > #import <WebKit/WebKitPrivate.h> > #import <wtf/RetainPtr.h> > >@@ -193,6 +193,16 @@ static NSData *testImageData() > return [NSData dataWithContentsOfURL:testImageFileURL()]; > } > >+static NSURL *testGIFFileURL() >+{ >+ return [[NSBundle mainBundle] URLForResource:@"apple" withExtension:@"gif" subdirectory:@"TestWebKitAPI.resources"]; >+} >+ >+static NSData *testGIFData() >+{ >+ return [NSData dataWithContentsOfURL:testGIFFileURL()]; >+} >+ > static NSURL *testPDFFileURL() > { > return [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]; >@@ -1314,6 +1324,46 @@ TEST(WKAttachmentTests, MoveAttachmentElementAsIconByDragging) > [simulator endDataTransfer]; > } > >+TEST(WKAttachmentTests, PasteWebArchiveContainingImages) >+{ >+ NSData *markupData = [@"<img src='1.png' alt='foo'><div><br></div><img src='2.gif' alt='bar'>" dataUsingEncoding:NSUTF8StringEncoding]; >+ >+ auto mainResource = adoptNS([[WebResource alloc] initWithData:markupData URL:[NSURL URLWithString:@"foo.html"] MIMEType:@"text/html" textEncodingName:@"utf-8" frameName:nil]); >+ auto pngResource = adoptNS([[WebResource alloc] initWithData:testImageData() URL:[NSURL URLWithString:@"1.png"] MIMEType:@"image/png" textEncodingName:nil frameName:nil]); >+ auto gifResource = adoptNS([[WebResource alloc] initWithData:testGIFData() URL:[NSURL URLWithString:@"2.gif"] MIMEType:@"image/gif" textEncodingName:nil frameName:nil]); >+ auto archive = adoptNS([[WebArchive alloc] initWithMainResource:mainResource.get() subresources:@[ pngResource.get(), gifResource.get() ] subframeArchives:@[ ]]); >+ >+#if PLATFORM(MAC) >+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; >+ [pasteboard declareTypes:@[WebArchivePboardType] owner:nil]; >+ [pasteboard setData:[archive data] forType:WebArchivePboardType]; >+#else >+ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; >+ [pasteboard setData:[archive data] forPasteboardType:WebArchivePboardType]; >+#endif >+ >+ RetainPtr<_WKAttachment> gifAttachment; >+ RetainPtr<_WKAttachment> pngAttachment; >+ auto webView = webViewForTestingAttachments(); >+ >+ ObserveAttachmentUpdatesForScope observer(webView.get()); >+ [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; >+ [webView expectElementCount:2 tagName:@"IMG"]; >+ >+ for (_WKAttachment *attachment in observer.observer().inserted) { >+ if ([attachment.info.contentType isEqualToString:@"image/png"]) >+ pngAttachment = attachment; >+ else if ([attachment.info.contentType isEqualToString:@"image/gif"]) >+ gifAttachment = attachment; >+ } >+ >+ EXPECT_WK_STREQ("foo", [pngAttachment info].name); >+ EXPECT_WK_STREQ("bar", [gifAttachment info].name); >+ [pngAttachment expectRequestedDataToBe:testImageData()]; >+ [gifAttachment expectRequestedDataToBe:testGIFData()]; >+ observer.expectAttachmentUpdates(@[ ], @[ pngAttachment.get(), gifAttachment.get() ]); >+} >+ > #pragma mark - Platform-specific tests > > #if PLATFORM(MAC)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
darin
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188957
:
348105
| 348113 |
348148