Title: [217584] trunk/Source
Revision
217584
Author
joep...@webkit.org
Date
2017-05-30 16:40:33 -0700 (Tue, 30 May 2017)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (217583 => 217584)


--- trunk/Source/WebCore/ChangeLog	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebCore/ChangeLog	2017-05-30 23:40:33 UTC (rev 217584)
@@ -1,3 +1,13 @@
+2017-05-30  Joseph Pecoraro  <pecor...@apple.com>
+
+        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.
+
+        * html/HTMLAttributeNames.in:
+
 2017-05-30  Youenn Fablet  <you...@apple.com>
 
         Add support for Certificate and IceCandidatePair stats

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (217583 => 217584)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-05-30 23:40:33 UTC (rev 217584)
@@ -117,6 +117,7 @@
 event
 expanded
 face
+filename
 focused
 for
 form

Modified: trunk/Source/WebInspectorUI/ChangeLog (217583 => 217584)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-05-30 23:40:33 UTC (rev 217584)
@@ -1,3 +1,16 @@
+2017-05-30  Joseph Pecoraro  <pecor...@apple.com>
+
+        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.
+
+        * 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.
+
 2017-05-30  Fujii Hironori  <hironori.fu...@sony.com>
 
         [GTK] Web Inspector: Add DOM breakpoint image for GTK+

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js (217583 => 217584)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js	2017-05-30 23:40:33 UTC (rev 217584)
@@ -52,6 +52,7 @@
         this._imageElement = document.createElement("img");
         this._imageElement.addEventListener("load", function() { URL.revokeObjectURL(objectURL); });
         this._imageElement.src = ""
+        this._imageElement.setAttribute("filename", this.resource.urlComponents.lastPathComponent || "");
 
         this.element.appendChild(this._imageElement);
     }

Modified: trunk/Source/WebKit2/ChangeLog (217583 => 217584)


--- trunk/Source/WebKit2/ChangeLog	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-30 23:40:33 UTC (rev 217584)
@@ -1,3 +1,23 @@
+2017-05-30  Joseph Pecoraro  <pecor...@apple.com>
+
+        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.
+
+        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):
+
 2017-05-30  Ryosuke Niwa  <rn...@webkit.org>
 
         Only include DataDetectorsUI headers in iOS

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (217583 => 217584)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-05-30 23:32:00 UTC (rev 217583)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-05-30 23:40:33 UTC (rev 217584)
@@ -173,7 +173,15 @@
         memcpy(archiveSharedMemoryBuffer->data(), archiveBuffer->data(), archiveSize);
         archiveSharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::Protection::ReadOnly);
     }
-    m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
+
+    String filename = String([response suggestedFilename]);
+    if (m_page->isInspectorPage()) {
+        String downloadFilename = ResourceResponseBase::sanitizeSuggestedFilename(element.attributeWithoutSynchronization(HTMLNames::filenameAttr));
+        if (!downloadFilename.isEmpty())
+            filename = downloadFilename;
+    }
+
+    m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, filename, extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to