Diff
Modified: trunk/Source/WebCore/ChangeLog (238014 => 238015)
--- trunk/Source/WebCore/ChangeLog 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/ChangeLog 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1,3 +1,46 @@
+2018-11-08 Said Abou-Hallawa <[email protected]>
+
+ Add an SPI to allow WebView clients to add additional supported image formats
+ https://bugs.webkit.org/show_bug.cgi?id=190454
+
+ Reviewed by Simon Fraser.
+
+ Add an SPI to allow additional supported image formats in WebView. These
+ additional formats can be set in the WKWebViewConfiguration as an NSArray
+ of NStrings. Each string represents an image source type aka UTI.
+
+ The ImageSourceType in the functions' names will be replaced by ImageType.
+ ImageType in this context is the image UTI (Uniform Type Identifier).
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::supportedImageMIMETypes):
+ (WebCore::MIMETypeRegistry::additionalSupportedImageMIMETypes):
+ (WebCore::supportedImageMIMETypesForEncoding):
+ (WebCore::MIMETypeRegistry::isSupportedImageMIMEType):
+ * platform/MIMETypeRegistry.h:
+ * platform/graphics/cg/ImageDecoderCG.cpp:
+ (WebCore::ImageDecoderCG::filenameExtension const):
+ (WebCore::ImageDecoderCG::encodedDataStatus const):
+ * platform/graphics/cg/ImageSourceCG.h:
+ * platform/graphics/cg/ImageSourceCGMac.mm:
+ (WebCore::MIMETypeForImageType):
+ (WebCore::preferredExtensionForImageType):
+ (WebCore::MIMETypeForImageSourceType): Deleted.
+ (WebCore::preferredExtensionForImageSourceType): Deleted.
+ * platform/graphics/cg/ImageSourceCGWin.cpp:
+ (WebCore::MIMETypeForImageType):
+ (WebCore::preferredExtensionForImageType):
+ (WebCore::MIMETypeForImageSourceType): Deleted.
+ (WebCore::preferredExtensionForImageSourceType): Deleted.
+ * platform/graphics/cg/UTIRegistry.cpp:
+ (WebCore::defaultSupportedImageTypes):
+ (WebCore::additionalSupportedImageTypes):
+ (WebCore::setAdditionalSupportedImageTypes):
+ (WebCore::isSupportedImageType):
+ (WebCore::supportedDefaultImageSourceTypes): Deleted.
+ (WebCore::isSupportImageSourceType): Deleted.
+ * platform/graphics/cg/UTIRegistry.h:
+
2018-11-08 Megan Gardner <[email protected]>
Adopt Reveal Framework to replace Lookup
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (238014 => 238015)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -133,11 +133,11 @@
#if USE(CG)
#ifndef NDEBUG
- // Esnure supportedImageMIMETypes() is in sync with supportedDefaultImageSourceTypes().
+ // Esnure supportedImageMIMETypes() is in sync with defaultSupportedImageTypes().
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
- for (auto& imageSourceType : supportedDefaultImageSourceTypes()) {
- auto mimeType = MIMETypeForImageSourceType(imageSourceType);
+ for (auto& imageType : defaultSupportedImageTypes()) {
+ auto mimeType = MIMETypeForImageType(imageType);
ASSERT_IMPLIES(!mimeType.isEmpty(), supportedImageMIMETypes.get().contains(mimeType));
}
});
@@ -146,6 +146,12 @@
return supportedImageMIMETypes;
}
+HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::additionalSupportedImageMIMETypes()
+{
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> additionalSupportedImageMIMETypes;
+ return additionalSupportedImageMIMETypes;
+}
+
static const HashSet<String, ASCIICaseInsensitiveHash>& supportedImageMIMETypesForEncoding()
{
#if PLATFORM(COCOA)
@@ -155,7 +161,7 @@
CFIndex count = CFArrayGetCount(supportedTypes.get());
for (CFIndex i = 0; i < count; i++) {
CFStringRef supportedType = reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i));
- String mimeType = MIMETypeForImageSourceType(supportedType);
+ String mimeType = MIMETypeForImageType(supportedType);
if (!mimeType.isEmpty())
supportedImageMIMETypesForEncoding.add(mimeType);
}
@@ -433,7 +439,8 @@
{
if (mimeType.isEmpty())
return false;
- return supportedImageMIMETypes().contains(getNormalizedMIMEType(mimeType));
+ String normalizedMIMEType = getNormalizedMIMEType(mimeType);
+ return supportedImageMIMETypes().contains(normalizedMIMEType) || additionalSupportedImageMIMETypes().contains(normalizedMIMEType);
}
bool MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType(const String& mimeType)
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (238014 => 238015)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -106,6 +106,7 @@
// FIXME: Would be nice to find a way to avoid exposing these sets, even worse exposing non-const references.
WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedImageMIMETypes();
+ static HashSet<String, ASCIICaseInsensitiveHash>& additionalSupportedImageMIMETypes();
WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& supportedNonImageMIMETypes();
WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedMediaMIMETypes();
WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& pdfMIMETypes();
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -176,7 +176,7 @@
String ImageDecoderCG::filenameExtension() const
{
- return WebCore::preferredExtensionForImageSourceType(uti());
+ return WebCore::preferredExtensionForImageType(uti());
}
EncodedDataStatus ImageDecoderCG::encodedDataStatus() const
@@ -199,7 +199,7 @@
return EncodedDataStatus::Error;
case kCGImageStatusIncomplete: {
- if (!isSupportImageSourceType(uti))
+ if (!isSupportedImageType(uti))
return EncodedDataStatus::Error;
RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
@@ -213,7 +213,7 @@
}
case kCGImageStatusComplete:
- if (!isSupportImageSourceType(uti))
+ if (!isSupportedImageType(uti))
return EncodedDataStatus::Error;
return EncodedDataStatus::Complete;
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.h (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -30,9 +30,9 @@
namespace WebCore {
-String preferredExtensionForImageSourceType(const String& type);
+String preferredExtensionForImageType(const String& type);
-String MIMETypeForImageSourceType(const String& type);
+String MIMETypeForImageType(const String& type);
#if !PLATFORM(COCOA)
size_t sharedBufferGetBytesAtPosition(void* info, void* buffer, off_t position, size_t count);
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGMac.mm (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGMac.mm 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGMac.mm 2018-11-09 03:23:17 UTC (rev 238015)
@@ -36,12 +36,12 @@
namespace WebCore {
-String MIMETypeForImageSourceType(const String& uti)
+String MIMETypeForImageType(const String& uti)
{
return MIMETypeFromUTI(uti);
}
-String preferredExtensionForImageSourceType(const String& uti)
+String preferredExtensionForImageType(const String& uti)
{
return adoptCF(UTTypeCopyPreferredTagWithClass(uti.createCFString().get(), kUTTagClassFilenameExtension)).get();
}
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGWin.cpp (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGWin.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCGWin.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -32,7 +32,7 @@
namespace WebCore {
-String MIMETypeForImageSourceType(const String& type)
+String MIMETypeForImageType(const String& type)
{
String mimeType;
// FIXME: This approach of taking a UTI like public.type and giving back
@@ -44,7 +44,7 @@
return mimeType;
}
-String preferredExtensionForImageSourceType(const String& type)
+String preferredExtensionForImageType(const String& type)
{
if (type.isNull())
return String();
Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,6 +28,9 @@
#if USE(CG)
+#include "ImageSourceCG.h"
+#include "MIMETypeRegistry.h"
+
#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
#include <ImageIO/ImageIO.h>
@@ -38,10 +41,10 @@
namespace WebCore {
-const HashSet<String>& supportedDefaultImageSourceTypes()
+const HashSet<String>& defaultSupportedImageTypes()
{
// CG at least supports the following standard image types:
- static NeverDestroyed<HashSet<String>> supportedDefaultImageSourceTypes = std::initializer_list<String> {
+ static NeverDestroyed<HashSet<String>> defaultSupportedImageTypes = std::initializer_list<String> {
"com.compuserve.gif",
"com.microsoft.bmp",
"com.microsoft.cur",
@@ -57,23 +60,42 @@
// Make sure that CG supports them.
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
- RetainPtr<CFArrayRef> systemImageSourceTypes = adoptCF(CGImageSourceCopyTypeIdentifiers());
- CFIndex count = CFArrayGetCount(systemImageSourceTypes.get());
- for (auto& imageSourceType : supportedDefaultImageSourceTypes.get()) {
- RetainPtr<CFStringRef> string = imageSourceType.createCFString();
- ASSERT(CFArrayContainsValue(systemImageSourceTypes.get(), CFRangeMake(0, count), string.get()));
+ RetainPtr<CFArrayRef> systemImageTypes = adoptCF(CGImageSourceCopyTypeIdentifiers());
+ CFIndex count = CFArrayGetCount(systemImageTypes.get());
+ for (auto& imageType : defaultSupportedImageTypes.get()) {
+ RetainPtr<CFStringRef> string = imageType.createCFString();
+ ASSERT(CFArrayContainsValue(systemImageTypes.get(), CFRangeMake(0, count), string.get()));
}
});
#endif
- return supportedDefaultImageSourceTypes;
+ return defaultSupportedImageTypes;
}
-bool isSupportImageSourceType(const String& imageSourceType)
+HashSet<String>& additionalSupportedImageTypes()
{
- return !imageSourceType.isEmpty() && supportedDefaultImageSourceTypes().contains(imageSourceType);
+ static NeverDestroyed<HashSet<String>> additionalSupportedImageTypes;
+ return additionalSupportedImageTypes;
}
+void setAdditionalSupportedImageTypes(const Vector<String>& imageTypes)
+{
+ MIMETypeRegistry::additionalSupportedImageMIMETypes().clear();
+ for (const auto& imageType : imageTypes) {
+ additionalSupportedImageTypes().add(imageType);
+ auto mimeType = MIMETypeForImageType(imageType);
+ if (!mimeType.isEmpty())
+ MIMETypeRegistry::additionalSupportedImageMIMETypes().add(mimeType);
+ }
}
+bool isSupportedImageType(const String& imageType)
+{
+ if (imageType.isEmpty())
+ return false;
+ return defaultSupportedImageTypes().contains(imageType) || additionalSupportedImageTypes().contains(imageType);
+}
+
+}
+
#endif
Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h (238014 => 238015)
--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,9 @@
namespace WebCore {
-const HashSet<String>& supportedDefaultImageSourceTypes();
-bool isSupportImageSourceType(const String&);
+const HashSet<String>& defaultSupportedImageTypes();
+HashSet<String>& additionalSupportedImageTypes();
+WEBCORE_EXPORT void setAdditionalSupportedImageTypes(const Vector<String>&);
+bool isSupportedImageType(const String&);
}
Modified: trunk/Source/WebKit/ChangeLog (238014 => 238015)
--- trunk/Source/WebKit/ChangeLog 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/ChangeLog 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1,3 +1,51 @@
+2018-11-08 Said Abou-Hallawa <[email protected]>
+
+ Add an SPI to allow WebView clients to add additional supported image formats
+ https://bugs.webkit.org/show_bug.cgi?id=190454
+
+ Reviewed by Simon Fraser.
+
+ * Platform/mac/StringUtilities.h:
+ * Platform/mac/StringUtilities.mm:
+ (WebKit::webCoreStringVectorFromNSStringArray):
+ A helper function which converts an NSArray of NSStrings to a Vector of
+ WTFString.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ Handle encoding and decoding the AdditionalSupportedImageTypes which will
+ allow transferring it from the UI process to the web process.
+
+ * UIProcess/API/APIPageConfiguration.h:
+ (API::PageConfiguration::additionalSupportedImageTypes const):
+ (API::PageConfiguration::setAdditionalSupportedImageTypes):
+ Store the AdditionalSupportedImageTypes in the APIPageConfiguration
+ which is used when creating the WebPageProxy in the UIPorcess.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+ (-[WKWebViewConfiguration copyWithZone:]):
+ (-[WKWebViewConfiguration _additionalSupportedImageTypes]):
+ (-[WKWebViewConfiguration _setAdditionalSupportedImageTypes:]):
+ * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+ Setter/Getter for the AdditionalSupportedImageTypes.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ Copy the AdditionalSupportedImageTypes from APIPageConfiguration to
+ WebPageCreationParameters.
+
+ * UIProcess/WebPageProxy.h:
+ Delete unimplemented function.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::m_shouldAttachDrawingAreaOnPageTransition):
+ Copy the AdditionalSupportedImageTypes from WebPageCreationParameters to
+ WebCore.
+
2018-11-08 Megan Gardner <[email protected]>
Adopt Reveal Framework to replace Lookup
Modified: trunk/Source/WebKit/Platform/mac/StringUtilities.h (238014 => 238015)
--- trunk/Source/WebKit/Platform/mac/StringUtilities.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/Platform/mac/StringUtilities.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -37,6 +37,8 @@
NSString *nsStringFromWebCoreString(const String&);
NSString *formattedPhoneNumberString(NSString *originalPhoneNumber);
+Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *);
+
#endif // defined(__OBJC__)
}
Modified: trunk/Source/WebKit/Platform/mac/StringUtilities.mm (238014 => 238015)
--- trunk/Source/WebKit/Platform/mac/StringUtilities.mm 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/Platform/mac/StringUtilities.mm 2018-11-09 03:23:17 UTC (rev 238015)
@@ -82,4 +82,15 @@
#endif // ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
+Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *nsStringArray)
+{
+ Vector<String> stringVector;
+ stringVector.reserveInitialCapacity([nsStringArray count]);
+
+ for (NSString *nsString in nsStringArray)
+ stringVector.uncheckedAppend(nsString);
+
+ return stringVector;
}
+
+}
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (238014 => 238015)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -97,6 +97,7 @@
#endif
#if PLATFORM(COCOA)
encoder << smartInsertDeleteEnabled;
+ encoder << additionalSupportedImageTypes;
#endif
encoder << appleMailPaginationQuirkEnabled;
encoder << appleMailLinesClampEnabled;
@@ -272,6 +273,8 @@
#if PLATFORM(COCOA)
if (!decoder.decode(parameters.smartInsertDeleteEnabled))
return std::nullopt;
+ if (!decoder.decode(parameters.additionalSupportedImageTypes))
+ return std::nullopt;
#endif
if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (238014 => 238015)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -154,6 +154,7 @@
#endif
#if PLATFORM(COCOA)
bool smartInsertDeleteEnabled;
+ Vector<String> additionalSupportedImageTypes;
#endif
bool appleMailPaginationQuirkEnabled;
bool appleMailLinesClampEnabled;
Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -110,6 +110,11 @@
const WTF::String& overrideContentSecurityPolicy() const { return m_overrideContentSecurityPolicy; }
void setOverrideContentSecurityPolicy(const WTF::String& overrideContentSecurityPolicy) { m_overrideContentSecurityPolicy = overrideContentSecurityPolicy; }
+#if PLATFORM(COCOA)
+ const WTF::Vector<WTF::String>& additionalSupportedImageTypes() const { return m_additionalSupportedImageTypes; }
+ void setAdditionalSupportedImageTypes(WTF::Vector<WTF::String>&& additionalSupportedImageTypes) { m_additionalSupportedImageTypes = WTFMove(additionalSupportedImageTypes); }
+#endif
+
#if ENABLE(APPLICATION_MANIFEST)
ApplicationManifest* applicationManifest() const;
void setApplicationManifest(ApplicationManifest*);
@@ -146,6 +151,10 @@
WTF::String m_overrideContentSecurityPolicy;
+#if PLATFORM(COCOA)
+ WTF::Vector<WTF::String> m_additionalSupportedImageTypes;
+#endif
+
#if ENABLE(APPLICATION_MANIFEST)
RefPtr<ApplicationManifest> m_applicationManifest;
#endif
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-11-09 03:23:17 UTC (rev 238015)
@@ -46,6 +46,7 @@
#import "RemoteLayerTreeTransaction.h"
#import "RemoteObjectRegistry.h"
#import "RemoteObjectRegistryMessages.h"
+#import "StringUtilities.h"
#import "UIDelegate.h"
#import "UserMediaProcessManager.h"
#import "VersionChecks.h"
@@ -569,6 +570,8 @@
pageConfiguration->setPageGroup(WebKit::WebPageGroup::create(configuration._groupIdentifier).ptr());
}
+ pageConfiguration->setAdditionalSupportedImageTypes(WebKit::webCoreStringVectorFromNSStringArray([_configuration _additionalSupportedImageTypes]));
+
pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::suppressesIncrementalRenderingKey(), WebKit::WebPreferencesStore::Value(!![_configuration suppressesIncrementalRendering]));
pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldRespectImageOrientationKey(), WebKit::WebPreferencesStore::Value(!![_configuration _respectsImageOrientation]));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2018-11-09 03:23:17 UTC (rev 238015)
@@ -161,6 +161,7 @@
BOOL _drawsBackground;
RetainPtr<NSString> _mediaContentTypesRequiringHardwareSupport;
+ RetainPtr<NSArray<NSString *>> _additionalSupportedImageTypes;
}
- (instancetype)init
@@ -394,6 +395,7 @@
configuration->_needsStorageAccessFromFileURLsQuirk = self->_needsStorageAccessFromFileURLsQuirk;
configuration->_mediaContentTypesRequiringHardwareSupport = adoptNS([self._mediaContentTypesRequiringHardwareSupport copyWithZone:zone]);
+ configuration->_additionalSupportedImageTypes = adoptNS([self->_additionalSupportedImageTypes copyWithZone:zone]);
configuration->_legacyEncryptedMediaAPIEnabled = self->_legacyEncryptedMediaAPIEnabled;
configuration->_allowMediaContentTypesRequiringHardwareSupportAsFallback = self->_allowMediaContentTypesRequiringHardwareSupportAsFallback;
@@ -990,6 +992,16 @@
_mediaContentTypesRequiringHardwareSupport = adoptNS([mediaContentTypesRequiringHardwareSupport copy]);
}
+- (NSArray<NSString *> *)_additionalSupportedImageTypes
+{
+ return _additionalSupportedImageTypes.get();
+}
+
+- (void)_setAdditionalSupportedImageTypes:(NSArray<NSString *> *)additionalSupportedImageTypes
+{
+ _additionalSupportedImageTypes = adoptNS([additionalSupportedImageTypes copy]);
+}
+
- (void)_setLegacyEncryptedMediaAPIEnabled:(BOOL)enabled
{
_legacyEncryptedMediaAPIEnabled = enabled;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -102,6 +102,9 @@
@property (nonatomic, setter=_setLegacyEncryptedMediaAPIEnabled:) BOOL _legacyEncryptedMediaAPIEnabled WK_API_AVAILABLE(macosx(10.13), ios(11.0));
@property (nonatomic, setter=_setAllowMediaContentTypesRequiringHardwareSupportAsFallback:) BOOL _allowMediaContentTypesRequiringHardwareSupportAsFallback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
+// The input of this SPI is an array of image UTI (Uniform Type Identifier).
+@property (nonatomic, copy, setter=_setAdditionalSupportedImageTypes:) NSArray<NSString *> *_additionalSupportedImageTypes WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
@end
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -6415,6 +6415,7 @@
#if PLATFORM(COCOA)
parameters.smartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
+ parameters.additionalSupportedImageTypes = m_configuration->additionalSupportedImageTypes();
#endif
parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
parameters.userInterfaceLayoutDirection = pageClient().userInterfaceLayoutDirection();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (238014 => 238015)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1360,10 +1360,6 @@
WebCore::IntRect syncRootViewToScreen(const WebCore::IntRect& viewRect);
-#if PLATFORM(COCOA)
- Vector<String> mediaMIMETypes();
-#endif
-
#if ENABLE(DATALIST_ELEMENT)
void didSelectOption(const String&);
void didCloseSuggestions();
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (238014 => 238015)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-11-09 03:23:17 UTC (rev 238015)
@@ -246,6 +246,7 @@
#include "VideoFullscreenManager.h"
#include "WKStringCF.h"
#include <WebCore/LegacyWebArchive.h>
+#include <WebCore/UTIRegistry.h>
#include <wtf/MachSendRight.h>
#endif
@@ -595,6 +596,7 @@
#if PLATFORM(COCOA)
m_page->settings().setContentDispositionAttachmentSandboxEnabled(true);
setSmartInsertDeleteEnabled(parameters.smartInsertDeleteEnabled);
+ WebCore::setAdditionalSupportedImageTypes(parameters.additionalSupportedImageTypes);
#endif
#if ENABLE(SERVICE_WORKER)
Modified: trunk/Tools/ChangeLog (238014 => 238015)
--- trunk/Tools/ChangeLog 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Tools/ChangeLog 2018-11-09 03:23:17 UTC (rev 238015)
@@ -1,3 +1,20 @@
+2018-11-08 Said Abou-Hallawa <[email protected]>
+
+onal supported image formats
+ https://bugs.webkit.org/show_bug.cgi?id=190454
+
+ Reviewed by Simon Fraser.
+
+ Test opening a TGA image in WebView which is not allowed by default. The
+ TGA format will be allowed through WKWebViewConfiguration.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/100x100-red.tga: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/AdditionalSupportedImageTypes.mm: Added.
+ (runTest):
+ (TEST):
+
2018-11-08 Jiewen Tan <[email protected]>
Unreviewed, a proper build fix for r237983
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (238014 => 238015)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2018-11-09 03:23:17 UTC (rev 238015)
@@ -242,6 +242,9 @@
53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */; };
55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */; };
5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */; };
+ 55A817FC218100E00004A39A /* AdditionalSupportedImageTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */; };
+ 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55A817FE218101DF0004A39A /* 100x100-red.tga */; };
+ 55A81800218102210004A39A /* 400x400-green.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55A817FD218101DF0004A39A /* 400x400-green.png */; };
5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */; };
5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */; };
5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
@@ -952,7 +955,9 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */,
1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
+ 55A81800218102210004A39A /* 400x400-green.png in Copy Resources */,
379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */,
@@ -1559,6 +1564,9 @@
53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PriorityQueue.cpp; sourceTree = "<group>"; };
55226A2E1EB969B600C36AD0 /* large-red-square-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-red-square-image.html"; sourceTree = "<group>"; };
5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronizedFixedQueue.cpp; sourceTree = "<group>"; };
+ 55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AdditionalSupportedImageTypes.mm; sourceTree = "<group>"; };
+ 55A817FD218101DF0004A39A /* 400x400-green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "400x400-green.png"; sourceTree = "<group>"; };
+ 55A817FE218101DF0004A39A /* 100x100-red.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = "100x100-red.tga"; sourceTree = "<group>"; };
5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL.html; sourceTree = "<group>"; };
5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURLFrame.html; sourceTree = "<group>"; };
5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
@@ -2335,6 +2343,7 @@
37E7DD631EA06FF2009B396D /* AdditionalReadAccessAllowedURLs.mm */,
37E7DD661EA071F3009B396D /* AdditionalReadAccessAllowedURLsPlugin.mm */,
37E7DD651EA0715B009B396D /* AdditionalReadAccessAllowedURLsProtocol.h */,
+ 55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */,
A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
63F668201F97C3AA0032EE51 /* ApplicationManifest.mm */,
@@ -2680,6 +2689,8 @@
A16F66B81C40E9E100BD4D24 /* Resources */ = {
isa = PBXGroup;
children = (
+ 55A817FE218101DF0004A39A /* 100x100-red.tga */,
+ 55A817FD218101DF0004A39A /* 400x400-green.png */,
C25CCA0C1E5140E50026CB8A /* AllAhem.svg */,
F4A9202E1FEE34C800F59590 /* apple-data-url.html */,
F47D30EB1ED28619000482E1 /* apple.gif */,
@@ -3608,7 +3619,7 @@
};
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */;
compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
+ developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -3746,6 +3757,7 @@
9BD5111C1FE8E11600D2B630 /* AccessingPastedImage.mm in Sources */,
F45B63FE1F19D410009D38B9 /* ActionSheetTests.mm in Sources */,
37E7DD641EA06FF2009B396D /* AdditionalReadAccessAllowedURLs.mm in Sources */,
+ 55A817FC218100E00004A39A /* AdditionalSupportedImageTypes.mm in Sources */,
7A909A7D1D877480007E10F8 /* AffineTransform.cpp in Sources */,
A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */,
2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/100x100-red.tga (0 => 238015)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/100x100-red.tga (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/100x100-red.tga 2018-11-09 03:23:17 UTC (rev 238015)
@@ -0,0 +1,2 @@
+����
+������������������d��d�� (\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xF
F\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\x
E3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF\xE3����\xFF\xFF
\ No newline at end of file
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png
(Binary files differ)
Index: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png
===================================================================
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png 2018-11-09 01:59:10 UTC (rev 238014)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png 2018-11-09 03:23:17 UTC (rev 238015)
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/400x400-green.png
___________________________________________________________________
Added: svn:mime-type
+image/png
\ No newline at end of property
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalSupportedImageTypes.mm (0 => 238015)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalSupportedImageTypes.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalSupportedImageTypes.mm 2018-11-09 03:23:17 UTC (rev 238015)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#import "config.h"
+#import <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED && PLATFORM(COCOA)
+
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static void runTest(NSArray<NSString *> *additionalSupportedImageTypes, NSString *imageURL, NSString *imageExtension, CGFloat imageWidth)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [configuration _setAdditionalSupportedImageTypes:additionalSupportedImageTypes];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:imageURL withExtension:imageExtension subdirectory:@"TestWebKitAPI.resources"];
+ [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+ [webView _test_waitForDidFinishNavigation];
+
+ __block bool isDone = false;
+ [webView _doAfterNextPresentationUpdate:^{
+ [webView evaluateJavaScript:@"[document.querySelector('img').width]" completionHandler:^(id value, NSError *error) {
+ CGFloat width = [[value objectAtIndex:0] floatValue];
+ EXPECT_EQ(width, imageWidth);
+ isDone = true;
+ }];
+ }];
+ TestWebKitAPI::Util::run(&isDone);
+}
+
+TEST(WebKit, AddSupportedImageType)
+{
+ runTest(@[@"public.png"], @"400x400-green", @"png", 400);
+}
+
+TEST(WebKit, AddSupportedAndBogusImageTypes)
+{
+ runTest(@[@"public.png", @"public.bogus"], @"400x400-green", @"png", 400);
+}
+
+TEST(WebKit, AddSupportedAndBogusImageTypesTwice)
+{
+ runTest(@[@"public.png", @"public.bogus", @"public.png", @"public.bogus"], @"400x400-green", @"png", 400);
+}
+
+TEST(WebKit, AddUnsupportedImageType)
+{
+ runTest(@[@"com.truevision.tga-image"], @"100x100-red", @"tga", 100);
+}
+
+TEST(WebKit, AddUnsupportedAndBogusImageTypes)
+{
+ runTest(@[@"com.truevision.tga-image", @"public.bogus"], @"100x100-red", @"tga", 100);
+}
+
+TEST(WebKit, AddUnsupportedAndBogusImageTypesTwice)
+{
+ runTest(@[@"com.truevision.tga-image", @"public.bogus", @"com.truevision.tga-image", @"public.bogus"], @"100x100-red", @"tga", 100);
+}
+
+#endif