Diff
Modified: trunk/LayoutTests/ChangeLog (264285 => 264286)
--- trunk/LayoutTests/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/LayoutTests/ChangeLog 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,3 +1,26 @@
+2020-07-12 Said Abou-Hallawa <[email protected]>
+
+ [macOS]: A HEIF image, selected from the OpenPanel, should be converted to an accepted MIME type
+ https://bugs.webkit.org/show_bug.cgi?id=213347
+ <rdar://problem/57258464>
+
+ Reviewed by Darin Adler.
+
+ Ensure the HEIF image is converted to an accepted MIME type when it is
+ selected from the OpenPanel and the 'accept' attribute of the <input>
+ does allow the HEIF MIME type.
+
+ No need to test this functionality on WK1 since the image transcoding
+ should happen in the UI process.
+
+ * TestExpectations:
+ * fast/forms/file/entries-api/image-no-transcode-open-panel-expected.txt: Added.
+ * fast/forms/file/entries-api/image-no-transcode-open-panel.html: Added.
+ * fast/forms/file/entries-api/image-transcode-open-panel-expected.txt: Added.
+ * fast/forms/file/entries-api/image-transcode-open-panel.html: Added.
+ * fast/forms/file/entries-api/resources/images/green-400x400.heic: Added.
+ * platform/mac-wk2/TestExpectations:
+
2020-07-12 Zalan Bujtas <[email protected]>
[LFC][BFC][Min-Max width] Regular block level box resets the horizontal stacking
Modified: trunk/LayoutTests/TestExpectations (264285 => 264286)
--- trunk/LayoutTests/TestExpectations 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/LayoutTests/TestExpectations 2020-07-12 21:20:19 UTC (rev 264286)
@@ -906,6 +906,8 @@
# testRunner.terminateNetworkProcess() only works in WebKit2
fast/files/blob-network-process-crash.html [ Skip ]
+fast/forms/file/entries-api/image-transcode-open-panel.html [ Skip ]
+fast/forms/file/entries-api/image-no-transcode-open-panel.html [ Skip ]
# This test is currently only relevant on mac-wk2
fast/canvas/webgl/context-update-on-display-configuration.html [ Skip ]
Added: trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel-expected.txt (0 => 264286)
--- trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel-expected.txt 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,16 @@
+OPEN FILE PANEL
+Tests a HEIC image, chosen via the file picker which accepts HEIC, will not be converted to any supported MIME type.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS fileList.length is 1
+PASS file.type is "image/heic"
+PASS file.size is non-zero.
+Image could not be loaded.
+PASS img.width is not 400
+PASS img.height is not 400
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel.html (0 => 264286)
--- trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/entries-api/image-no-transcode-open-panel.html 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+</head>
+<body>
+ <input type="file" accept="IMAGE/HEIC" _onchange_="changed(event)"></input>
+ <script>
+ description("Tests a HEIC image, chosen via the file picker which accepts HEIC, will not be converted to any supported MIME type.");
+ jsTestIsAsync = true;
+
+ function runTest()
+ {
+ testRunner.setOpenPanelFiles(['resources/images/green-400x400.heic']);
+
+ inputElement = document.getElementsByTagName('input')[0];
+ UIHelper.activateAt(inputElement.offsetLeft + inputElement.offsetWidth / 2,
+ inputElement.offsetTop + inputElement.offsetHeight / 2);
+ }
+
+ function changed(event)
+ {
+ fileList = event.target.files;
+ shouldBe("fileList.length", "1");
+
+ file = fileList[0];
+ shouldBeEqualToString("file.type", "image/heic");
+ shouldBeNonZero("file.size");
+
+ img = document.createElement("img");
+ document.body.appendChild(img);
+
+ var reader = new FileReader();
+ reader._onload_ = () => {
+ img._onload_ = () => {
+ debug("Image was loaded.");
+ shouldBe("img.width", "400");
+ shouldBe("img.height", "400");
+ finishJSTest();
+ };
+ img._onerror_ = () => {
+ debug("Image could not be loaded.");
+ shouldNotBe("img.width", "400");
+ shouldNotBe("img.height", "400");
+ finishJSTest();
+ };
+ img.src = ""
+ };
+ reader.readAsDataURL(file);
+ }
+ runTest();
+ </script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel-expected.txt (0 => 264286)
--- trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel-expected.txt 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,16 @@
+OPEN FILE PANEL
+Tests a HEIC image, chosen via the file picker which accepts PNG, will be converted to a PNG image.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS fileList.length is 1
+PASS file.type is "image/png"
+PASS file.size is non-zero.
+Image was loaded.
+PASS img.width is 400
+PASS img.height is 400
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel.html (0 => 264286)
--- trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/entries-api/image-transcode-open-panel.html 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+</head>
+<body>
+ <input type="file" accept=".png" _onchange_="changed(event)"></input>
+ <script>
+ description("Tests a HEIC image, chosen via the file picker which accepts PNG, will be converted to a PNG image.");
+ jsTestIsAsync = true;
+
+ function runTest()
+ {
+ testRunner.setOpenPanelFiles(['resources/images/green-400x400.heic']);
+
+ inputElement = document.getElementsByTagName('input')[0];
+ UIHelper.activateAt(inputElement.offsetLeft + inputElement.offsetWidth / 2,
+ inputElement.offsetTop + inputElement.offsetHeight / 2);
+ }
+
+ function changed(event)
+ {
+ fileList = event.target.files;
+ shouldBe("fileList.length", "1");
+
+ file = fileList[0];
+ shouldBeEqualToString("file.type", "image/png");
+ shouldBeNonZero("file.size");
+
+ img = document.createElement("img");
+ document.body.appendChild(img);
+
+ var reader = new FileReader();
+ reader._onload_ = () => {
+ img._onload_ = () => {
+ debug("Image was loaded.");
+ shouldBe("img.width", "400");
+ shouldBe("img.height", "400");
+ finishJSTest();
+ };
+ img._onerror_ = () => {
+ debug("Image could not be loaded.");
+ shouldNotBe("img.width", "400");
+ shouldNotBe("img.height", "400");
+ finishJSTest();
+ };
+ img.src = ""
+ };
+ reader.readAsDataURL(file);
+ }
+ runTest();
+ </script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/entries-api/resources/images/green-400x400.heic (0 => 264286)
--- trunk/LayoutTests/fast/forms/file/entries-api/resources/images/green-400x400.heic (rev 0)
+++ trunk/LayoutTests/fast/forms/file/entries-api/resources/images/green-400x400.heic 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1 @@
+������ftypheic��������heicmif1����\xABmeta��������������"hdlr����������������pict����������������������������������$dinf������dref��������������������url ������������pitm����������������8iinf����������������infe������������hvc1��������infe����������Exif��������iref��������������cdsc������������\xCDiprp������\xAEipco������yhvcC`������\xB0����������?\xF0��\xFC\xFD\xF8\xF8����\xA0����@\xFF\xFF`������\xB0����������?, \xA1����#B`������\xB0����������?\xA0\x88E\x9C\xB9$JIq7\xA4\xA2����D\xC0aL\xE9$ID\x91*@������ispe������������\x90����\x90������ irot��������pixi��������������ipma����������������\x81\x83������,iloc��������D����������������W������o������������\xD3������\x84������mdat������������������Exif����MM��*����������������������>��������������F(��������������\x87i��������������N��������������H������������H��������\x92\x86��������������`��������ASCII������Created with
GIMP��������k&\xAD\x9C\xBEzԔ@\xC1 \xFD\xBB\xFFн\xCF\xF4W|ZSQ\xC2Y\xAC\xA0/\x8C/��X\xE81\xA3\xE7\xA7J\x80\xC0\xB0o������Հ\x93��\x81`��������\x98\x87������������\xB4������������0����������Z����������\xA8
\ No newline at end of file
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (264285 => 264286)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2020-07-12 21:20:19 UTC (rev 264286)
@@ -87,6 +87,9 @@
fast/animation/request-animation-frame-in-two-pages.html [ Pass ]
+fast/forms/file/entries-api/image-transcode-open-panel.html [ Pass ]
+fast/forms/file/entries-api/image-no-transcode-open-panel.html [ Pass ]
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific directories.
#//////////////////////////////////////////////////////////////////////////////////////////
Modified: trunk/Source/WTF/ChangeLog (264285 => 264286)
--- trunk/Source/WTF/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/ChangeLog 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,3 +1,25 @@
+2020-07-12 Said Abou-Hallawa <[email protected]>
+
+ [macOS]: A HEIF image, selected from the OpenPanel, should be converted to an accepted MIME type
+ https://bugs.webkit.org/show_bug.cgi?id=213347
+ <rdar://problem/57258464>
+
+ Reviewed by Darin Adler.
+
+ Allow a suffix to be included in the temporary file name. The goal is to
+ make it possible to create temporary image files with valid extensions.
+
+ * wtf/FileSystem.h:
+ (WTF::FileSystemImpl::openTemporaryFile):
+ * wtf/cocoa/FileSystemCocoa.mm:
+ (WTF::FileSystemImpl::openTemporaryFile):
+ * wtf/glib/FileSystemGlib.cpp:
+ (WTF::FileSystemImpl::openTemporaryFile):
+ * wtf/posix/FileSystemPOSIX.cpp:
+ (WTF::FileSystemImpl::openTemporaryFile):
+ * wtf/win/FileSystemWin.cpp:
+ (WTF::FileSystemImpl::openTemporaryFile):
+
2020-07-12 Rob Buis <[email protected]>
Improve IPv6 detection when setting host/hostname
Modified: trunk/Source/WTF/wtf/FileSystem.h (264285 => 264286)
--- trunk/Source/WTF/wtf/FileSystem.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/wtf/FileSystem.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -145,7 +145,7 @@
inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
// Prefix is what the filename should be prefixed with, not the full path.
-WTF_EXPORT_PRIVATE String openTemporaryFile(const String& prefix, PlatformFileHandle&);
+WTF_EXPORT_PRIVATE String openTemporaryFile(const String& prefix, PlatformFileHandle&, const String& suffix = { });
WTF_EXPORT_PRIVATE PlatformFileHandle openFile(const String& path, FileOpenMode, FileAccessPermission = FileAccessPermission::All, bool failIfFileExists = false);
WTF_EXPORT_PRIVATE void closeFile(PlatformFileHandle&);
// Returns the resulting offset from the beginning of the file if successful, -1 otherwise.
Modified: trunk/Source/WTF/wtf/cocoa/FileSystemCocoa.mm (264285 => 264286)
--- trunk/Source/WTF/wtf/cocoa/FileSystemCocoa.mm 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/wtf/cocoa/FileSystemCocoa.mm 2020-07-12 21:20:19 UTC (rev 264286)
@@ -93,7 +93,7 @@
return NSHomeDirectory();
}
-String openTemporaryFile(const String& prefix, PlatformFileHandle& platformFileHandle)
+String openTemporaryFile(const String& prefix, PlatformFileHandle& platformFileHandle, const String& suffix)
{
platformFileHandle = invalidPlatformFileHandle;
@@ -110,12 +110,16 @@
temporaryFilePath.append('/');
// Append the file name.
- CString prefixUtf8 = prefix.utf8();
- temporaryFilePath.append(prefixUtf8.data(), prefixUtf8.length());
+ CString prefixUTF8 = prefix.utf8();
+ temporaryFilePath.append(prefixUTF8.data(), prefixUTF8.length());
temporaryFilePath.append("XXXXXX", 6);
+
+ // Append the file name suffix.
+ CString suffixUTF8 = suffix.utf8();
+ temporaryFilePath.append(suffixUTF8.data(), suffixUTF8.length());
temporaryFilePath.append('\0');
- platformFileHandle = mkstemp(temporaryFilePath.data());
+ platformFileHandle = mkstemps(temporaryFilePath.data(), suffixUTF8.length());
if (platformFileHandle == invalidPlatformFileHandle)
return String();
Modified: trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp (264285 => 264286)
--- trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -326,8 +326,11 @@
return entries;
}
-String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
+String openTemporaryFile(const String& prefix, PlatformFileHandle& handle, const String& suffix)
{
+ // FIXME: Suffix is not supported, but OK for now since the code using it is macOS-port-only.
+ ASSERT_UNUSED(suffix, suffix.isEmpty());
+
GUniquePtr<gchar> filename(g_strdup_printf("%s%s", prefix.utf8().data(), createCanonicalUUIDString().utf8().data()));
GUniquePtr<gchar> tempPath(g_build_filename(g_get_tmp_dir(), filename.get(), nullptr));
GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(tempPath.get()));
Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (264285 => 264286)
--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -442,8 +442,11 @@
return false;
}
-String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
+String openTemporaryFile(const String& prefix, PlatformFileHandle& handle, const String& suffix)
{
+ // FIXME: Suffix is not supported, but OK for now since the code using it is macOS-port-only.
+ ASSERT_UNUSED(suffix, suffix.isEmpty());
+
char buffer[PATH_MAX];
const char* tmpDir = getenv("TMPDIR");
Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (264285 => 264286)
--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -404,8 +404,11 @@
return proposedPath;
}
-String openTemporaryFile(const String&, PlatformFileHandle& handle)
+String openTemporaryFile(const String&, PlatformFileHandle& handle, const String& suffix)
{
+ // FIXME: Suffix is not supported, but OK for now since the code using it is macOS-port-only.
+ ASSERT_UNUSED(suffix, suffix.isEmpty());
+
handle = INVALID_HANDLE_VALUE;
String proposedPath = generateTemporaryPath([&handle](const String& proposedPath) {
Modified: trunk/Source/WebCore/ChangeLog (264285 => 264286)
--- trunk/Source/WebCore/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebCore/ChangeLog 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,3 +1,23 @@
+2020-07-12 Said Abou-Hallawa <[email protected]>
+
+ [macOS]: A HEIF image, selected from the OpenPanel, should be converted to an accepted MIME type
+ https://bugs.webkit.org/show_bug.cgi?id=213347
+ <rdar://problem/57258464>
+
+ Reviewed by Darin Adler.
+
+ Tests: fast/forms/file/entries-api/image-no-transcode-open-panel.html
+ fast/forms/file/entries-api/image-transcode-open-panel.html
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::allowedMIMETypes):
+ Make sure this function returns lowercase MIME types.
+
+ * platform/MIMETypeRegistry.h:
+ * platform/graphics/NativeImage.h:
+ * platform/graphics/cg/NativeImageCG.cpp:
+ (WebCore::drawNativeImage):
+
2020-07-12 Sam Weinig <[email protected]>
Tidy up color usage in accessibility code
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (264285 => 264286)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -814,13 +814,13 @@
Vector<String> allowedMIMETypes;
for (auto& mimeType : mimeTypes)
- allowedMIMETypes.appendIfNotContains(mimeType);
+ allowedMIMETypes.appendIfNotContains(mimeType.convertToASCIILowercase());
for (auto& extension : extensions) {
auto mimeType = MIMETypeRegistry::mimeTypeForExtension(trimmedExtension(extension));
if (mimeType.isEmpty())
continue;
- allowedMIMETypes.appendIfNotContains(mimeType);
+ allowedMIMETypes.appendIfNotContains(mimeType.convertToASCIILowercase());
}
return allowedMIMETypes;
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (264285 => 264286)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -59,7 +59,7 @@
WEBCORE_EXPORT static String preferredExtensionForMIMEType(const String& type);
WEBCORE_EXPORT static String mediaMIMETypeForExtension(const String& extension);
- static String mimeTypeForPath(const String& path);
+ WEBCORE_EXPORT static String mimeTypeForPath(const String& path);
static std::unique_ptr<MIMETypeRegistryThreadGlobalData> createMIMETypeRegistryThreadGlobalData();
Modified: trunk/Source/WebCore/platform/graphics/NativeImage.h (264285 => 264286)
--- trunk/Source/WebCore/platform/graphics/NativeImage.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -66,6 +66,8 @@
Color nativeImageSinglePixelSolidColor(const NativeImagePtr&);
void drawNativeImage(const NativeImagePtr&, GraphicsContext&, const FloatRect&, const FloatRect&, const IntSize&, const ImagePaintingOptions&);
+WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&, GraphicsContext&, float scaleFactor, const IntPoint& destination, const IntRect& source);
+
void clearNativeImageSubimages(const NativeImagePtr&);
class NativeImageHandle {
Modified: trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp (264285 => 264286)
--- trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -84,6 +84,25 @@
context.drawNativeImage(image, subsampledImageSize, destRect, adjustedSrcRect, options);
}
+void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, float scaleFactor, const IntPoint& destination, const IntRect& source)
+{
+ CGContextRef cgContext = context.platformContext();
+ CGContextSaveGState(cgContext);
+
+ CGContextClipToRect(cgContext, CGRectMake(destination.x(), destination.y(), source.width(), source.height()));
+ CGContextScaleCTM(cgContext, 1, -1);
+
+ CGFloat imageHeight = CGImageGetHeight(image.get()) / scaleFactor;
+ CGFloat imageWidth = CGImageGetWidth(image.get()) / scaleFactor;
+
+ CGFloat destX = destination.x() - source.x();
+ CGFloat destY = -imageHeight - destination.y() + source.y();
+
+ CGContextDrawImage(cgContext, CGRectMake(destX, destY, imageWidth, imageHeight), image.get());
+
+ CGContextRestoreGState(cgContext);
+}
+
void clearNativeImageSubimages(const NativeImagePtr& image)
{
#if CACHE_SUBIMAGES
Modified: trunk/Source/WebKit/ChangeLog (264285 => 264286)
--- trunk/Source/WebKit/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/ChangeLog 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,3 +1,52 @@
+2020-07-12 Said Abou-Hallawa <[email protected]>
+
+ [macOS]: A HEIF image, selected from the OpenPanel, should be converted to an accepted MIME type
+ https://bugs.webkit.org/show_bug.cgi?id=213347
+ <rdar://problem/57258464>
+
+ Reviewed by Darin Adler.
+
+ Transcode the images given the list of the selected file and the allowed
+ MIME types. Only selected files whose MIME types do not exist in the allowed
+ MIME types will be transcoded. Right now, this only will apply to the HEIF
+ images on macOS.
+
+ * Platform/ImageUtilities.h: Renamed from Source/WebKit/Platform/cg/CGUtilities.h.
+ * Platform/Logging.h:
+ * Platform/cg/CGUtilities.cpp: Removed.
+ * Platform/cg/ImageUtilitiesCG.cpp: Added.
+ (WebKit::transcodeImage):
+ (WebKit::findImagesForTranscoding):
+ (WebKit::transcodeImages):
+ Implement a function that transcodes images among a set of files given
+ the allowedMIMETypes. The destination MIME type of these images is the
+ first MIME type in the allowedMIMETypes which CG supports encoding to.
+
+ * Shared/cg/ShareableBitmapCG.cpp:
+ (WebKit::ShareableBitmap::paint):
+ Call drawNativeImage() after renaming paintImage() to drawNativeImage().
+
+ * SourcesCocoa.txt:
+
+ * UIProcess/API/C/WKOpenPanelParametersRef.cpp:
+ (WKOpenPanelParametersCopyAllowedMIMETypes):
+ * UIProcess/API/C/WKOpenPanelParametersRef.h:
+ * UIProcess/API/C/WKOpenPanelResultListener.cpp:
+ (WKOpenPanelResultListenerChooseFiles):
+ * UIProcess/API/C/WKOpenPanelResultListener.h:
+ Transfer the list of the allowed MIME types from the OpenPanel to the
+ file chooser listener.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::m_transcodingQueue):
+ (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithImageTranscoding):
+ Transcode the images in a work queue so the UI process is not blocked.
+ Once the transcoding finishes, the message will be sent to the WebPage.
+
+ (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
+ * UIProcess/WebPageProxy.h:
+ * WebKit.xcodeproj/project.pbxproj:
+
2020-07-12 Darin Adler <[email protected]>
REGRESSION (r261152): 9 blocks of critical sandboxing code disabled because they are guarded with HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN)
Copied: trunk/Source/WebKit/Platform/ImageUtilities.h (from rev 264285, trunk/Source/WebKit/Platform/cg/CGUtilities.cpp) (0 => 264286)
--- trunk/Source/WebKit/Platform/ImageUtilities.h (rev 0)
+++ trunk/Source/WebKit/Platform/ImageUtilities.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+// Given a list of files' 'paths' and 'allowedMIMETypes', the function returns a list
+// of strings whose size is the same as the size of 'paths' and its entries are all
+// null strings except the ones whose MIME types are not in 'allowedMIMETypes'.
+Vector<String> findImagesForTranscoding(const Vector<String>& paths, const Vector<String>& allowedMIMETypes);
+
+// Given a list of images' 'paths', this function transcodes these images to a new
+// format whose UTI is destinationUTI. The result of the transcoding will be written
+// to temporary files whose extensions are 'destinationExtension'. It returns a list
+// of paths to the result temporary files. If an entry in 'paths' is null or an error
+// happens while transcoding, a null string will be added to the returned list.
+Vector<String> transcodeImages(const Vector<String>& paths, const String& destinationUTI, const String& destinationExtension);
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/Platform/Logging.h (264285 => 264286)
--- trunk/Source/WebKit/Platform/Logging.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/Platform/Logging.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -57,6 +57,7 @@
M(IPC) \
M(ITPDebug) \
M(IconDatabase) \
+ M(Images) \
M(IncrementalPDF) \
M(IncrementalPDFVerbose) \
M(IndexedDB) \
Deleted: trunk/Source/WebKit/Platform/cg/CGUtilities.cpp (264285 => 264286)
--- trunk/Source/WebKit/Platform/cg/CGUtilities.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/Platform/cg/CGUtilities.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CGUtilities.h"
-
-namespace WebKit {
-
-void paintImage(CGContextRef context, CGImageRef image, CGFloat scaleFactor, CGPoint destination, CGRect source)
-{
- CGContextSaveGState(context);
-
- CGContextClipToRect(context, CGRectMake(destination.x, destination.y, source.size.width, source.size.height));
- CGContextScaleCTM(context, 1, -1);
-
- CGFloat imageHeight = CGImageGetHeight(image) / scaleFactor;
- CGFloat imageWidth = CGImageGetWidth(image) / scaleFactor;
-
- CGFloat destX = destination.x - source.origin.x;
- CGFloat destY = -imageHeight - destination.y + source.origin.y;
-
- CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image);
-
- CGContextRestoreGState(context);
-}
-
-} // namespace WebKit
Deleted: trunk/Source/WebKit/Platform/cg/CGUtilities.h (264285 => 264286)
--- trunk/Source/WebKit/Platform/cg/CGUtilities.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/Platform/cg/CGUtilities.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CGUtilities_h
-#define CGUtilities_h
-
-namespace WebKit {
-
-void paintImage(CGContextRef, CGImageRef, CGFloat scaleFactor, CGPoint destination, CGRect source);
-
-} // namespace WebKit
-
-#endif // CGUtilities_h
Added: trunk/Source/WebKit/Platform/cg/ImageUtilitiesCG.cpp (0 => 264286)
--- trunk/Source/WebKit/Platform/cg/ImageUtilitiesCG.cpp (rev 0)
+++ trunk/Source/WebKit/Platform/cg/ImageUtilitiesCG.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageUtilities.h"
+
+#include "Logging.h"
+#include <ImageIO/ImageIO.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <wtf/FileSystem.h>
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+static String transcodeImage(const String& path, const String& destinationUTI, const String& destinationExtension)
+{
+ auto sourceURL = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.createCFString().get(), kCFURLPOSIXPathStyle, false));
+ auto source = adoptCF(CGImageSourceCreateWithURL(sourceURL.get(), nullptr));
+ if (!source)
+ return nullString();
+
+ auto sourceUTI = String(CGImageSourceGetType(source.get()));
+ if (sourceUTI == destinationUTI)
+ return nullString();
+
+ // It is important to add the appropriate file extension to the temporary file path.
+ // The File object depends solely on the extension to know the MIME type of the file.
+ auto suffix = makeString('.', destinationExtension);
+
+ FileSystem::PlatformFileHandle destinationFileHandle;
+ String destinationPath = FileSystem::openTemporaryFile("tempImage"_s, destinationFileHandle, suffix);
+ if (destinationFileHandle == FileSystem::invalidPlatformFileHandle) {
+ RELEASE_LOG_ERROR(Images, "transcodeImage: Destination image could not be created: %s %s\n", path.utf8().data(), destinationUTI.utf8().data());
+ return nullString();
+ }
+
+ CGDataConsumerCallbacks callbacks = {
+ [](void* info, const void* buffer, size_t count) -> size_t {
+ auto handle = *static_cast<FileSystem::PlatformFileHandle*>(info);
+ return FileSystem::writeToFile(handle, static_cast<const char*>(buffer), count);
+ },
+ nullptr
+ };
+
+ auto consumer = adoptCF(CGDataConsumerCreate(&destinationFileHandle, &callbacks));
+ auto destination = adoptCF(CGImageDestinationCreateWithDataConsumer(consumer.get(), destinationUTI.createCFString().get(), 1, nullptr));
+
+ CGImageDestinationAddImageFromSource(destination.get(), source.get(), 0, nullptr);
+
+ if (!CGImageDestinationFinalize(destination.get())) {
+ RELEASE_LOG_ERROR(Images, "transcodeImage: Image transcoding fails: %s %s\n", path.utf8().data(), destinationUTI.utf8().data());
+ FileSystem::closeFile(destinationFileHandle);
+ FileSystem::deleteFile(destinationPath);
+ return nullString();
+ }
+
+ FileSystem::closeFile(destinationFileHandle);
+ return destinationPath;
+}
+
+Vector<String> findImagesForTranscoding(const Vector<String>& paths, const Vector<String>& allowedMIMETypes)
+{
+ Vector<String> transcodingPaths;
+ transcodingPaths.reserveInitialCapacity(paths.size());
+
+ bool needsTranscoding = false;
+
+ for (auto& path : paths) {
+ // Append a path of the image which needs transcoding. Otherwise append a null string.
+ if (!allowedMIMETypes.contains(WebCore::MIMETypeRegistry::mimeTypeForPath(path))) {
+ transcodingPaths.uncheckedAppend(path);
+ needsTranscoding = true;
+ } else
+ transcodingPaths.uncheckedAppend(nullString());
+ }
+
+ // If none of the files needs image transcoding, return an empty Vector.
+ return needsTranscoding ? transcodingPaths : Vector<String>();
+}
+
+Vector<String> transcodeImages(const Vector<String>& paths, const String& destinationUTI, const String& destinationExtension)
+{
+ ASSERT(!destinationUTI.isNull());
+ ASSERT(!destinationExtension.isNull());
+
+ Vector<String> transcodedPaths;
+ transcodedPaths.reserveInitialCapacity(paths.size());
+
+ for (auto& path : paths) {
+ // Append the transcoded path if the image needs transcoding. Otherwise append a null string.
+ if (!path.isNull())
+ transcodedPaths.uncheckedAppend(transcodeImage(path, destinationUTI, destinationExtension));
+ else
+ transcodedPaths.uncheckedAppend(nullString());
+ }
+
+ return transcodedPaths;
+}
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (264285 => 264286)
--- trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -29,11 +29,11 @@
#include <WebCore/BitmapImage.h>
#include <WebCore/GraphicsContextCG.h>
#include <WebCore/ImageBufferUtilitiesCG.h>
+#include <WebCore/NativeImage.h>
#include <WebCore/PlatformScreen.h>
#include <pal/spi/cg/CoreGraphicsSPI.h>
#include <pal/spi/cocoa/IOSurfaceSPI.h>
#include <wtf/RetainPtr.h>
-#include "CGUtilities.h"
namespace WebKit {
using namespace WebCore;
@@ -106,12 +106,12 @@
void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& destination, const IntRect& source)
{
- paintImage(context.platformContext(), makeCGImageCopy().get(), 1, destination, source);
+ drawNativeImage(makeCGImageCopy(), context, 1, destination, source);
}
void ShareableBitmap::paint(WebCore::GraphicsContext& context, float scaleFactor, const IntPoint& destination, const IntRect& source)
{
- paintImage(context.platformContext(), makeCGImageCopy().get(), scaleFactor, destination, source);
+ drawNativeImage(makeCGImageCopy(), context, scaleFactor, destination, source);
}
RetainPtr<CGImageRef> ShareableBitmap::makeCGImageCopy()
Modified: trunk/Source/WebKit/SourcesCocoa.txt (264285 => 264286)
--- trunk/Source/WebKit/SourcesCocoa.txt 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2020-07-12 21:20:19 UTC (rev 264286)
@@ -65,7 +65,7 @@
Platform/cf/ModuleCF.cpp
-Platform/cg/CGUtilities.cpp
+Platform/cg/ImageUtilitiesCG.cpp
Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
Platform/classifier/ResourceLoadStatisticsClassifier.cpp
Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -58,6 +58,11 @@
return toAPI(&toImpl(parametersRef)->acceptFileExtensions().leakRef());
}
+WKArrayRef WKOpenPanelParametersCopyAllowedMIMETypes(WKOpenPanelParametersRef parametersRef)
+{
+ return toAPI(&toImpl(parametersRef)->allowedMIMETypes().leakRef());
+}
+
// Deprecated.
WKStringRef WKOpenPanelParametersCopyCapture(WKOpenPanelParametersRef)
{
Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -45,6 +45,8 @@
WK_EXPORT WKArrayRef WKOpenPanelParametersCopyAcceptedMIMETypes(WKOpenPanelParametersRef parameters);
WK_EXPORT WKArrayRef WKOpenPanelParametersCopyAcceptedFileExtensions(WKOpenPanelParametersRef parameters);
+WK_EXPORT WKArrayRef WKOpenPanelParametersCopyAllowedMIMETypes(WKOpenPanelParametersRef parameters);
+
/* DEPRECATED - Please use WKOpenPanelParametersGetCaptureEnabled() instead. */
WK_EXPORT WKStringRef WKOpenPanelParametersCopyCapture(WKOpenPanelParametersRef parameters);
Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.cpp (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -63,9 +63,9 @@
}
#endif
-void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
+void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef, WKArrayRef allowedMimeTypesRef)
{
- toImpl(listenerRef)->chooseFiles(filePathsFromFileURLs(*toImpl(fileURLsRef)));
+ toImpl(listenerRef)->chooseFiles(filePathsFromFileURLs(*toImpl(fileURLsRef)), toImpl(allowedMimeTypesRef)->toStringVector());
}
void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.h (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelResultListener.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -35,7 +35,7 @@
WK_EXPORT WKTypeID WKOpenPanelResultListenerGetTypeID(void);
WK_EXPORT void WKOpenPanelResultListenerChooseMediaFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef, WKStringRef displayString, WKDataRef iconImageDataRef);
-WK_EXPORT void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listener, WKArrayRef fileURLs);
+WK_EXPORT void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listener, WKArrayRef fileURLs, WKArrayRef allowedMimeTypesRef);
WK_EXPORT void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listener);
#ifdef __cplusplus
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -215,6 +215,11 @@
#include <wtf/cocoa/Entitlements.h>
#endif
+#if PLATFORM(MAC)
+#include "ImageUtilities.h"
+#include <WebCore/UTIUtilities.h>
+#endif
+
#if HAVE(TOUCH_BAR)
#include "TouchBarMenuData.h"
#include "TouchBarMenuItemData.h"
@@ -488,6 +493,9 @@
, m_ignoresAppBoundDomains(m_configuration->ignoresAppBoundDomains())
, m_limitsNavigationsToAppBoundDomains(m_configuration->limitsNavigationsToAppBoundDomains())
#endif
+#if PLATFORM(MAC)
+ , m_transcodingQueue(WorkQueue::create("com.apple.WebKit.ImageTranscoding"))
+#endif
{
RELEASE_LOG_IF_ALLOWED(Loading, "constructor:");
@@ -6652,18 +6660,59 @@
}
#endif
-void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs, const Vector<String>&)
+bool WebPageProxy::didChooseFilesForOpenPanelWithImageTranscoding(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes)
{
+#if PLATFORM(MAC)
+ auto transcodingMIMEType = WebCore::MIMETypeRegistry::preferredImageMIMETypeForEncoding(allowedMIMETypes, { });
+ if (transcodingMIMEType.isNull())
+ return false;
+
+ auto transcodingURLs = findImagesForTranscoding(fileURLs, allowedMIMETypes);
+ if (transcodingURLs.isEmpty())
+ return false;
+
+ auto transcodingUTI = WebCore::UTIFromMIMEType(transcodingMIMEType);
+ auto transcodingExtension = WebCore::MIMETypeRegistry::preferredExtensionForMIMEType(transcodingMIMEType);
+
+ m_transcodingQueue->dispatch([this, protectedThis = makeRef(*this), fileURLs = fileURLs.isolatedCopy(), transcodingURLs = transcodingURLs.isolatedCopy(), transcodingUTI = transcodingUTI.isolatedCopy(), transcodingExtension = transcodingExtension.isolatedCopy()]() mutable {
+ ASSERT(!RunLoop::isMain());
+
+ auto transcodedURLs = transcodeImages(transcodingURLs, transcodingUTI, transcodingExtension);
+ ASSERT(transcodingURLs.size() == transcodedURLs.size());
+
+ RunLoop::main().dispatch([this, protectedThis = WTFMove(protectedThis), fileURLs = fileURLs.isolatedCopy(), transcodedURLs = transcodedURLs.isolatedCopy()]() {
+#if ENABLE(SANDBOX_EXTENSIONS)
+ Vector<String> sandboxExtensionFiles;
+ for (size_t i = 0, size = fileURLs.size(); i < size; ++i)
+ sandboxExtensionFiles.append(!transcodedURLs[i].isNull() ? transcodedURLs[i] : fileURLs[i]);
+ auto sandboxExtensionHandles = SandboxExtension::createReadOnlyHandlesForFiles("WebPageProxy::didChooseFilesForOpenPanel"_s, sandboxExtensionFiles);
+ send(Messages::WebPage::ExtendSandboxForFilesFromOpenPanel(WTFMove(sandboxExtensionHandles)));
+#endif
+ send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs, transcodedURLs));
+ });
+ });
+
+ return true;
+#else
+ UNUSED_PARAM(fileURLs);
+ UNUSED_PARAM(allowedMIMETypes);
+ return false;
+#endif
+}
+
+void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes)
+{
if (!hasRunningProcess())
return;
+ if (!didChooseFilesForOpenPanelWithImageTranscoding(fileURLs, allowedMIMETypes)) {
#if ENABLE(SANDBOX_EXTENSIONS)
- auto sandboxExtensionHandles = SandboxExtension::createReadOnlyHandlesForFiles("WebPageProxy::didChooseFilesForOpenPanel"_s, fileURLs);
- send(Messages::WebPage::ExtendSandboxForFilesFromOpenPanel(WTFMove(sandboxExtensionHandles)));
+ auto sandboxExtensionHandles = SandboxExtension::createReadOnlyHandlesForFiles("WebPageProxy::didChooseFilesForOpenPanel"_s, fileURLs);
+ send(Messages::WebPage::ExtendSandboxForFilesFromOpenPanel(WTFMove(sandboxExtensionHandles)));
#endif
+ send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs, { }));
+ }
- send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs, { }));
-
m_openPanelResultListener->invalidate();
m_openPanelResultListener = nullptr;
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (264285 => 264286)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1924,6 +1924,7 @@
void didChangeViewportProperties(const WebCore::ViewportAttributes&);
void pageDidScroll();
void runOpenPanel(WebCore::FrameIdentifier, FrameInfoData&&, const WebCore::FileChooserSettings&);
+ bool didChooseFilesForOpenPanelWithImageTranscoding(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes);
void showShareSheet(const WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&);
void printFrame(WebCore::FrameIdentifier, CompletionHandler<void()>&&);
void exceededDatabaseQuota(WebCore::FrameIdentifier, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuotaDelayedReply&&);
@@ -2841,6 +2842,9 @@
bool m_userScriptsNotified { false };
bool m_limitsNavigationsToAppBoundDomains { false };
bool m_hasExecutedAppBoundBehaviorBeforeNavigation { false };
+#if PLATFORM(MAC)
+ Ref<WorkQueue> m_transcodingQueue;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (264285 => 264286)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-07-12 21:20:19 UTC (rev 264286)
@@ -290,7 +290,7 @@
1A9FBA8D13FF04E600DEED67 /* PluginComplexTextInputState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */; };
1AA13212191D5924009C1489 /* WKNavigationResponsePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA13211191D5924009C1489 /* WKNavigationResponsePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
1AA20D5118AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA20D5018AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */; };
+ 1AA2E51D12E4C05E00BC4966 /* ImageUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E51B12E4C05E00BC4966 /* ImageUtilities.h */; };
1AA2E56718D77508003814BD /* WKWebProcessBundleParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E56518D77508003814BD /* WKWebProcessBundleParameters.h */; };
1AA3D75C1651B44F008713D0 /* RemoteLayerTreeHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA3D75A1651B44F008713D0 /* RemoteLayerTreeHost.h */; };
1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA417C912C00CCA002BE67B /* TextChecker.h */; };
@@ -2516,8 +2516,8 @@
1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
1AA1CD06100FA1BA0078DEBC /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
1AA20D5018AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationDelegatePrivate.h; sourceTree = "<group>"; };
- 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUtilities.h; sourceTree = "<group>"; };
- 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUtilities.cpp; sourceTree = "<group>"; };
+ 1AA2E51B12E4C05E00BC4966 /* ImageUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageUtilities.h; sourceTree = "<group>"; };
+ 1AA2E51C12E4C05E00BC4966 /* ImageUtilitiesCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageUtilitiesCG.cpp; sourceTree = "<group>"; };
1AA2E56418D77508003814BD /* WKWebProcessBundleParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessBundleParameters.mm; sourceTree = "<group>"; };
1AA2E56518D77508003814BD /* WKWebProcessBundleParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessBundleParameters.h; sourceTree = "<group>"; };
1AA3D7591651B44F008713D0 /* RemoteLayerTreeHost.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeHost.mm; sourceTree = "<group>"; };
@@ -5966,8 +5966,7 @@
1AA2E51A12E4C05600BC4966 /* cg */ = {
isa = PBXGroup;
children = (
- 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */,
- 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */,
+ 1AA2E51C12E4C05E00BC4966 /* ImageUtilitiesCG.cpp */,
);
path = cg;
sourceTree = "<group>";
@@ -9604,6 +9603,7 @@
51B15A7D138439B200321AD8 /* unix */,
ECA680D31E6904B500731D20 /* ExtraPrivateSymbolsForTAPI.h */,
ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */,
+ 1AA2E51B12E4C05E00BC4966 /* ImageUtilities.h */,
51A7F2F4125BF8D4008AEB1D /* Logging.cpp */,
51A7F2F2125BF820008AEB1D /* Logging.h */,
0FDCD7F61D47E92A009F08BC /* LogInitialization.h */,
@@ -10791,7 +10791,6 @@
41897ED81F415D8A0016FA42 /* CacheStorageEngine.h in Headers */,
41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */,
41897EDA1F415D8A0016FA42 /* CacheStorageEngineConnection.h in Headers */,
- 1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */,
57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */,
F4FE0A3B24632B60002631E1 /* CocoaColor.h in Headers */,
4482734724528F6000A95493 /* CocoaImage.h in Headers */,
@@ -10870,6 +10869,7 @@
51C0C9741DDD76000032CAD3 /* IconLoadingDelegate.h in Headers */,
51E351CB180F2CCC00E53BE9 /* IDBUtilities.h in Headers */,
BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */,
+ 1AA2E51D12E4C05E00BC4966 /* ImageUtilities.h in Headers */,
1A1EC69E1872092100B951F0 /* ImportanceAssertion.h in Headers */,
BC204EE311C83E98008F3375 /* InjectedBundle.h in Headers */,
BCEE7DC5128B645D009827DA /* InjectedBundleClient.h in Headers */,
Modified: trunk/Tools/ChangeLog (264285 => 264286)
--- trunk/Tools/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Tools/ChangeLog 2020-07-12 21:20:19 UTC (rev 264286)
@@ -1,3 +1,14 @@
+2020-07-12 Said Abou-Hallawa <[email protected]>
+
+ [macOS]: A HEIF image, selected from the OpenPanel, should be converted to an accepted MIME type
+ https://bugs.webkit.org/show_bug.cgi?id=213347
+ <rdar://problem/57258464>
+
+ Reviewed by Darin Adler.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::runOpenPanel):
+
2020-07-11 Sam Weinig <[email protected]> and Yusuke Suzuki <[email protected]>
Relanding "Make hasher work with tuple-like classes"
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (264285 => 264286)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2020-07-12 20:13:59 UTC (rev 264285)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2020-07-12 21:20:19 UTC (rev 264286)
@@ -223,12 +223,14 @@
}
#endif
+ WKArrayRef allowedMimeTypes = WKOpenPanelParametersCopyAllowedMIMETypes(parameters);
+
if (WKOpenPanelParametersGetAllowsMultipleFiles(parameters)) {
- WKOpenPanelResultListenerChooseFiles(resultListenerRef, fileURLs);
+ WKOpenPanelResultListenerChooseFiles(resultListenerRef, fileURLs, allowedMimeTypes);
return;
}
- WKOpenPanelResultListenerChooseFiles(resultListenerRef, adoptWK(WKArrayCreate(&firstItem, 1)).get());
+ WKOpenPanelResultListenerChooseFiles(resultListenerRef, adoptWK(WKArrayCreate(&firstItem, 1)).get(), allowedMimeTypes);
}
void TestController::runModal(WKPageRef page, const void* clientInfo)