--- old/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp 2017-10-17 14:02:11.254769424 +0530 +++ new/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp 2017-10-17 14:02:10.534409425 +0530 @@ -107,10 +107,12 @@ (jstring)markup.toJavaString(env)); } -void jWriteImage(const Image& image) +void jWriteImage(const Image& image, const String& fileType) { - DEFINE_PB_STATIC_METHOD("writeImage", "(Lcom/sun/webkit/graphics/WCImageFrame;)V"); - CALL_PB_STATIC_VOID_METHOD(jobject(*const_cast(image).javaImage())); + DEFINE_PB_STATIC_METHOD("writeImage", "(Lcom/sun/webkit/graphics/WCImageFrame;Ljava/lang/String;)V"); + CALL_PB_STATIC_VOID_METHOD( + jobject(*const_cast(image).javaImage()), + (jstring)fileType.toJavaString(env)); } void jWriteURL(const String& url, const String& markup) @@ -324,13 +326,14 @@ // Write the bytes of the image to the file format writeImageToDataObject(m_dataObject, node, url); - + AtomicString imageURL = node.getAttribute(HTMLNames::srcAttr); + URL fullURL; if (!imageURL.isEmpty()) { - String fullURL = node.document().completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); + fullURL = node.document().completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); if (!fullURL.isEmpty()) { m_dataObject->setHTML( - imageToMarkup(fullURL, node), + imageToMarkup(fullURL.string(), node), node.document().url()); } } @@ -353,7 +356,15 @@ jWriteURL(url.string(), createMarkup(node)); } else { - jWriteImage(*image); + String lastPathComponent = fullURL.lastPathComponent(); + String extension; + size_t dotOffset = lastPathComponent.reverseFind('.'); + if (dotOffset != notFound) + extension = lastPathComponent.substring(dotOffset + 1); + else + extension = "png"; + + jWriteImage(*image, extension); } } }