JDK-8187928 : [WebView] Images copied from clipboard not written in source file format
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-09-25
  • Updated: 2017-11-08
  • Resolved: 2017-11-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8
10Fixed 8u172Fixed
Related Reports
Relates :  
Description
Scenario 1:
1. Open https://www.w3schools.com/html/html_images.asp in FX WebView
2. Right Click on the JPG image. Context Menu pops up. Select "Copy Image to Clipboard"
3. Paste the image in file explorer

Scenario 2:
1. Open https://www.w3schools.com/html/html_images.asp in FX WebView
2. Click on the GIF image,drag it to the file explorer and drop

Expected Result:
Scenario 1: Image should be written as <filename>.jpg
Scenaior 2: Image should be dropped as <filename>.gif

Actual Result:
In both the scenarios, the image is written as .png file.
Comments
Changeset: 9f43fb83e989 Author: mbilla Date: 2017-11-06 19:10 +0530 URL: http://hg.openjdk.java.net/openjfx/10-dev/rt/rev/9f43fb83e989
06-11-2017

+1
06-11-2017

+1
06-11-2017

+1
06-11-2017

Thanks [~arajkumar] Updated webrev: http://cr.openjdk.java.net/~rkamath/8187928/Approach2/webrev.01/
06-11-2017

lgtm with a nit: @Override protected String getFilenameExtension() { - /// retrieve image format from reader - return ".img"; + return fileNameExtension; I guess you need to prepend a "." here. (return "." + fileNameExtension;)
06-11-2017

Based on [~arajkumar] suggestions, have used different approach to solve this issue. Brief: The file extension is updated in WCImage while image decoding. While writing to clipboard this data is utilized from WCImage directly instead of passing arguments through JNI. Request you all to please review the below webrev http://cr.openjdk.java.net/~rkamath/8187928/Approach2/webrev.00/
06-11-2017

Is it possible to get image url from DragController object using draggingImageURL() method instead of modifying to get the same?
02-11-2017

+1
02-11-2017

+1 looks good to me
02-11-2017

Thanks [~ghb]. Please have a look at http://cr.openjdk.java.net/~ghb/rkamath/8187928/webrev.01/ 1. Renamed to fileExtension at all places 2. Checking only for isEmpty() now 3. Done 4. It is only extension. Renamed accordingly. Updated copyright year as well. And yes, manual test case has already been added as part of JDK-8188111
27-10-2017

Some of minor nit, rest of the logic looks good. Will review once again with updated webrev with below RC. I believe you will have a manual test for this fix as well. 1. writeImage(..., String fileExt), startDrag(..., String imageFileExt) same goes to most of its decedents , keep one name across all other places (either fileExt or imageFileExt or any better one). 2. if (imageURL.isNull() || imageURL.isEmpty()) --> isEmpty() will internally check for isNull() as well, Please check String isNull and isEmpty() 3. You can avoid "DragClientJava.cpp: 216 String extension;" by directly assigning to member m_fileExt. 4. void jWriteImage(..., const String& fileType) : if the fileType is a mime value then this is fine, if its extension, do have fileExt or imageFileExt.
27-10-2017

WebRev for review: http://cr.openjdk.java.net/~ghb/rkamath/8187928/webrev.00/
19-10-2017

The patch to write in source format is ready. However, when testing found this issue: If an alt attribute is present on image and we do a drag to the file explorer, a shortcut file is written with the alternate text as its reference. This is windows specific and happens with previous version of FX too. Checking this issue further. UPDATE: The issue was with Windows Clipboard misbehaving. The shortcut url and file type both are written to the Clipboard. But for some reason , Windows was not reflecting the file type. After a restart of system, clipboard started reflecting the same.
19-10-2017