Don't load inline data when requesting info for an attachment element backed by a...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jan 2018 01:13:28 +0000 (01:13 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jan 2018 01:13:28 +0000 (01:13 +0000)
commitbeda809b12b06f4ee2cadec9fa4d0156617f1341
tree78512a87b76f84d39afa65e6cf1fc1505ba2a5a8
parent76c414855f907f0560a4a81e00f30e58e4184cca
Don't load inline data when requesting info for an attachment element backed by a file path
https://bugs.webkit.org/show_bug.cgi?id=181550

Source/WebCore:

Reviewed by Tim Horton.

When requesting data for an attachment element that is backed by a file path, we currently trigger a load in the
web process to fetch contents of the attachment data as inline data in the AttachmentInfo. This is unnecessary,
since the file path of the attachment element must have come from the UI process anyways, so it is sufficient to
simply send the file path to the UI process and have the UI process read the contents of the path as a memory-
mapped NSData.

This patch lets HTMLAttachmentElement skip over resource loading codepaths when creating an AttachmentInfo for
the client, and also teaches _WKAttachment to read a AttachmentInfo's filepath as memory-mapped data if a file
path is present, and no inline data was specified.

Covered by existing API tests.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::requestInfo):

Source/WebKit:

Reviewed by Tim Horton

See WebCore/ChangeLog for more information.

* UIProcess/API/Cocoa/_WKAttachment.mm:
(-[_WKAttachmentInfo initWithInfo:]):
(-[_WKAttachmentInfo fileLoadingError]):
(-[_WKAttachment requestInfo:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226824 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttachmentElement.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm