Changeset 217584 in webkit


Ignore:
Timestamp:
May 30, 2017 4:40:33 PM (7 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: images dragged from Inspector to Desktop are named "Unknown.png"
https://bugs.webkit.org/show_bug.cgi?id=141515
<rdar://problem/9251308>

Reviewed by Wenson Hsieh.

Source/WebCore:

  • html/HTMLAttributeNames.in:

Source/WebInspectorUI:

  • UserInterface/Views/ImageResourceContentView.js:

(WebInspector.ImageResourceContentView.prototype.contentAvailable):
Set a non-standard "filename" attribute to provide a suggested filename
for this <img> containing data: or blob: content.

Source/WebKit2:

In Web Inspector these images are <img src="..."> with data: or blob:
content. In these cases we have the image data but the URL does not
provide a useful name. In fact the name "Unknown.png" comes from
-[NSURLResponse suggestedFilename] for this URL / content.

To start, improve this situation for drags in Web Inspector pages.
If the image element being dragged has a filename attribute use that
as the suggested filename for the drag.

  • WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:

(WebKit::WebDragClient::declareAndWriteDragImage):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r217583 r217584  
     12017-05-30  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: images dragged from Inspector to Desktop are named "Unknown.png"
     4        https://bugs.webkit.org/show_bug.cgi?id=141515
     5        <rdar://problem/9251308>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * html/HTMLAttributeNames.in:
     10
    1112017-05-30  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r216347 r217584  
    118118expanded
    119119face
     120filename
    120121focused
    121122for
  • trunk/Source/WebInspectorUI/ChangeLog

    r217544 r217584  
     12017-05-30  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: images dragged from Inspector to Desktop are named "Unknown.png"
     4        https://bugs.webkit.org/show_bug.cgi?id=141515
     5        <rdar://problem/9251308>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UserInterface/Views/ImageResourceContentView.js:
     10        (WebInspector.ImageResourceContentView.prototype.contentAvailable):
     11        Set a non-standard "filename" attribute to provide a suggested filename
     12        for this <img> containing data: or blob: content.
     13
    1142017-05-30  Fujii Hironori  <Hironori.Fujii@sony.com>
    215
  • trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js

    r216138 r217584  
    5353        this._imageElement.addEventListener("load", function() { URL.revokeObjectURL(objectURL); });
    5454        this._imageElement.src = objectURL;
     55        this._imageElement.setAttribute("filename", this.resource.urlComponents.lastPathComponent || "");
    5556
    5657        this.element.appendChild(this._imageElement);
  • trunk/Source/WebKit2/ChangeLog

    r217580 r217584  
     12017-05-30  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: images dragged from Inspector to Desktop are named "Unknown.png"
     4        https://bugs.webkit.org/show_bug.cgi?id=141515
     5        <rdar://problem/9251308>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        In Web Inspector these images are <img src="..."> with data: or blob:
     10        content. In these cases we have the image data but the URL does not
     11        provide a useful name. In fact the name "Unknown.png" comes from
     12        -[NSURLResponse suggestedFilename] for this URL / content.
     13
     14        To start, improve this situation for drags in Web Inspector pages.
     15        If the image element being dragged has a filename attribute use that
     16        as the suggested filename for the drag.
     17
     18        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
     19        (WebKit::WebDragClient::declareAndWriteDragImage):
     20
    1212017-05-30  Ryosuke Niwa  <rniwa@webkit.org>
    222
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

    r216810 r217584  
    174174        archiveSharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::Protection::ReadOnly);
    175175    }
    176     m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
     176
     177    String filename = String([response suggestedFilename]);
     178    if (m_page->isInspectorPage()) {
     179        String downloadFilename = ResourceResponseBase::sanitizeSuggestedFilename(element.attributeWithoutSynchronization(HTMLNames::filenameAttr));
     180        if (!downloadFilename.isEmpty())
     181            filename = downloadFilename;
     182    }
     183
     184    m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, filename, extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
    177185}
    178186
Note: See TracChangeset for help on using the changeset viewer.