WebKit Bugzilla
Attachment 348148 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]
Patch for landing
bug-188957-20180827090719.patch (text/plain), 6.65 KB, created by
Wenson Hsieh
on 2018-08-27 09:07:20 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-08-27 09:07:20 PDT
Size:
6.65 KB
patch
obsolete
>Subversion Revision: 235347 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 55f02363367dba45739ecd7bb21de33451688123..10e53740202e993caf2605cf1fb809bc93155997 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-08-27 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 Darin Adler. >+ >+ 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 Youenn Fablet <youenn@apple.com> > > Make IDBCursor::m_request a WeakPtr >diff --git a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >index 1c91351b73af47f971b9ce17434c8d56b45a40d4..6109c3815a075f3f913800808e380d2fcc8de1e1 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 63a875cc5802bbfc2d7b612758bcec2f7b7c1792..95bba0cc3494266c640d353ea55ae873d8e82ec5 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-27 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 Darin Adler. >+ >+ 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 Sam Weinig <sam@webkit.org> > > Using _WKRemoteObjectInterface with a protocol that inherits from a non-NSObject protocol crashes >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >index dd2687941f863632f115ff29c5fb297cd23039c8..3f1e7e6842e734134b8e40eb68b472db383ebf85 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"]; >@@ -1202,6 +1212,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:(__bridge WebResource *)mainResource.get() subresources:@[ (__bridge WebResource *)pngResource.get(), (__bridge WebResource *)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((__bridge TestWKWebView *)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(@[ ], @[ (__bridge _WKAttachment *)pngAttachment.get(), (__bridge _WKAttachment *)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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188957
:
348105
|
348113
| 348148