Title: [245636] trunk
Revision
245636
Author
jer.no...@apple.com
Date
2019-05-22 12:10:05 -0700 (Wed, 22 May 2019)

Log Message

Hide MediaCapabilities.encodingInfo() when the platform does not support it.
https://bugs.webkit.org/show_bug.cgi?id=197476

Reviewed by Eric Carlson.

Source/WebCore:

Test: platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html

Add a new IDL attribute, CustomEnabled, which allows non Settings-based enabling of attributes and objects.

* Modules/mediacapabilities/MediaCapabilities.idl:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSMediaCapabilitiesCustom.h: Copied from Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl.
(WebCore::JSMediaCapabilitiesEncodingInfoIsEnabled):
* bindings/scripts/CodeGeneratorJS.pm:
(NeedsRuntimeCheck):
(GenerateRuntimeEnableConditionalString):
* bindings/scripts/IDLAttributes.json:
* bindings/scripts/preprocess-idls.pl:
(GenerateConstructorAttributes):
* platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
(WebCore::MediaEngineConfigurationFactory::hasDecodingConfigurationFactory):
(WebCore::MediaEngineConfigurationFactory::hasEncodingConfigurationFactory):
* platform/mediacapabilities/MediaEngineConfigurationFactory.h:

LayoutTests:

* platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt: Added.
* platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html: Added.
* platform/ios/media/mediacapabilities/mediacapabilities-types-expected.txt: Added.
* platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt: Added.
* platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html: Added.
* platform/mac/media/mediacapabilities/mediacapabilities-types-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245635 => 245636)


--- trunk/LayoutTests/ChangeLog	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/LayoutTests/ChangeLog	2019-05-22 19:10:05 UTC (rev 245636)
@@ -1,3 +1,17 @@
+2019-05-22  Jer Noble  <jer.no...@apple.com>
+
+        Hide MediaCapabilities.encodingInfo() when the platform does not support it.
+        https://bugs.webkit.org/show_bug.cgi?id=197476
+
+        Reviewed by Eric Carlson.
+
+        * platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt: Added.
+        * platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html: Added.
+        * platform/ios/media/mediacapabilities/mediacapabilities-types-expected.txt: Added.
+        * platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt: Added.
+        * platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html: Added.
+        * platform/mac/media/mediacapabilities/mediacapabilities-types-expected.txt: Added.
+
 2019-05-22  Youenn Fablet  <you...@apple.com>
 
         Implement Feature policy self/none/* parsing

Added: trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt (0 => 245636)


--- trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,11 @@
+Test that MediaCapabilities.prototype.encodingInfo is missing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof navigator.mediaCapabilities.encodingInfo is "undefined"
+PASS typeof MediaCapabilities.prototype.encodingInfo is "undefined"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html (0 => 245636)


--- trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>mediacapabilities-encodingInfo-empty</title>
+	<script src=""
+	<script>
+
+	</script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test that MediaCapabilities.prototype.encodingInfo is missing.');
+shouldBe('typeof navigator.mediaCapabilities.encodingInfo', '"undefined"');
+shouldBe('typeof MediaCapabilities.prototype.encodingInfo', '"undefined"');
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-types-expected.txt (0 => 245636)


--- trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-types-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/media/mediacapabilities/mediacapabilities-types-expected.txt	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,87 @@
+Test basic dictionary and enum types of Media Capabilities API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'media-source' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/0" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+FAIL () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record' });
+    } should not throw exception. Threw exception TypeError: navigator.mediaCapabilities.encodingInfo is not a function. (In 'navigator.mediaCapabilities.encodingInfo({ type: 'record' })', 'navigator.mediaCapabilities.encodingInfo' is undefined).
+FAIL () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } });
+    } should not throw exception. Threw exception TypeError: navigator.mediaCapabilities.encodingInfo is not a function. (In 'navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } })', 'navigator.mediaCapabilities.encodingInfo' is undefined).
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/-1" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt (0 => 245636)


--- trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined-expected.txt	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,11 @@
+Test that MediaCapabilities.prototype.encodingInfo is missing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof navigator.mediaCapabilities.encodingInfo is "undefined"
+PASS typeof MediaCapabilities.prototype.encodingInfo is "undefined"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html (0 => 245636)


--- trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>mediacapabilities-encodingInfo-empty</title>
+	<script src=""
+	<script>
+
+	</script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test that MediaCapabilities.prototype.encodingInfo is missing.');
+shouldBe('typeof navigator.mediaCapabilities.encodingInfo', '"undefined"');
+shouldBe('typeof MediaCapabilities.prototype.encodingInfo', '"undefined"');
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-types-expected.txt (0 => 245636)


--- trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-types-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/media/mediacapabilities/mediacapabilities-types-expected.txt	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,87 @@
+Test basic dictionary and enum types of Media Capabilities API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'media-source' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/0" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+FAIL () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record' });
+    } should not throw exception. Threw exception TypeError: navigator.mediaCapabilities.encodingInfo is not a function. (In 'navigator.mediaCapabilities.encodingInfo({ type: 'record' })', 'navigator.mediaCapabilities.encodingInfo' is undefined).
+FAIL () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } });
+    } should not throw exception. Threw exception TypeError: navigator.mediaCapabilities.encodingInfo is not a function. (In 'navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } })', 'navigator.mediaCapabilities.encodingInfo' is undefined).
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/-1" } });
+    } rejected promise  with TypeError: The provided value is non-finite.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/Source/WebCore/ChangeLog (245635 => 245636)


--- trunk/Source/WebCore/ChangeLog	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/ChangeLog	2019-05-22 19:10:05 UTC (rev 245636)
@@ -1,3 +1,29 @@
+2019-05-22  Jer Noble  <jer.no...@apple.com>
+
+        Hide MediaCapabilities.encodingInfo() when the platform does not support it.
+        https://bugs.webkit.org/show_bug.cgi?id=197476
+
+        Reviewed by Eric Carlson.
+
+        Test: platform/mac/media/mediacapabilities/mediacapabilities-encodingInfo-undefined.html
+
+        Add a new IDL attribute, CustomEnabled, which allows non Settings-based enabling of attributes and objects.
+
+        * Modules/mediacapabilities/MediaCapabilities.idl:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSMediaCapabilitiesCustom.h: Copied from Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl.
+        (WebCore::JSMediaCapabilitiesEncodingInfoIsEnabled):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (NeedsRuntimeCheck):
+        (GenerateRuntimeEnableConditionalString):
+        * bindings/scripts/IDLAttributes.json:
+        * bindings/scripts/preprocess-idls.pl:
+        (GenerateConstructorAttributes):
+        * platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
+        (WebCore::MediaEngineConfigurationFactory::hasDecodingConfigurationFactory):
+        (WebCore::MediaEngineConfigurationFactory::hasEncodingConfigurationFactory):
+        * platform/mediacapabilities/MediaEngineConfigurationFactory.h:
+
 2019-05-22  Youenn Fablet  <you...@apple.com>
 
         Implement Feature policy self/none/* parsing

Modified: trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl (245635 => 245636)


--- trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl	2019-05-22 19:10:05 UTC (rev 245636)
@@ -25,9 +25,10 @@
 
 [
     EnabledBySetting=MediaCapabilities,
-    ImplementationLacksVTable
+    ImplementationLacksVTable,
+    JSCustomHeader
 ]
 interface MediaCapabilities {
-  [CallWith=Document] Promise<MediaCapabilitiesDecodingInfo> decodingInfo(MediaDecodingConfiguration configuration);
-  Promise<MediaCapabilitiesEncodingInfo> encodingInfo(MediaEncodingConfiguration configuration);
+  [CustomEnabled, CallWith=Document] Promise<MediaCapabilitiesDecodingInfo> decodingInfo(MediaDecodingConfiguration configuration);
+  [CustomEnabled] Promise<MediaCapabilitiesEncodingInfo> encodingInfo(MediaEncodingConfiguration configuration);
 };

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (245635 => 245636)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-05-22 19:10:05 UTC (rev 245636)
@@ -13439,6 +13439,7 @@
 		CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; };
 		CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; };
 		CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; };
+		CD0320152279F5BF00DD9F0B /* JSMediaCapabilitiesCustom.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSMediaCapabilitiesCustom.h; sourceTree = "<group>"; };
 		CD063F801E23FA8900812BE3 /* InitDataRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitDataRegistry.cpp; sourceTree = "<group>"; };
 		CD063F811E23FA8900812BE3 /* InitDataRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitDataRegistry.h; sourceTree = "<group>"; };
 		CD0C8B582141C8CA0062F59D /* MediaCapabilitiesInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaCapabilitiesInfo.h; sourceTree = "<group>"; };
@@ -20626,6 +20627,7 @@
 				51E269321DD3BC43006B6A58 /* JSIDBTransactionCustom.cpp */,
 				A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */,
 				77C13F042165658A002D9C5F /* JSIntersectionObserverEntryCustom.cpp */,
+				CD0320152279F5BF00DD9F0B /* JSMediaCapabilitiesCustom.h */,
 				AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */,
 				415CDAF61E6CE0D3004F11EE /* JSMediaStreamTrackCustom.cpp */,
 				E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */,

Copied: trunk/Source/WebCore/bindings/js/JSMediaCapabilitiesCustom.h (from rev 245635, trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl) (0 => 245636)


--- trunk/Source/WebCore/bindings/js/JSMediaCapabilitiesCustom.h	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSMediaCapabilitiesCustom.h	2019-05-22 19:10:05 UTC (rev 245636)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 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
+
+#include "MediaEngineConfigurationFactory.h"
+
+namespace WebCore {
+
+ALWAYS_INLINE bool JSMediaCapabilitiesEncodingInfoIsEnabled()
+{
+    return MediaEngineConfigurationFactory::hasEncodingConfigurationFactory();
+}
+
+ALWAYS_INLINE bool JSMediaCapabilitiesDecodingInfoIsEnabled()
+{
+    return MediaEngineConfigurationFactory::hasDecodingConfigurationFactory();
+}
+
+}

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (245635 => 245636)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-05-22 19:10:05 UTC (rev 245636)
@@ -1710,7 +1710,8 @@
         || $context->extendedAttributes->{EnabledBySetting}
         || $context->extendedAttributes->{DisabledByQuirk}
         || $context->extendedAttributes->{SecureContext}
-        || $context->extendedAttributes->{ContextHasServiceWorkerScheme};
+        || $context->extendedAttributes->{ContextHasServiceWorkerScheme}
+        || $context->extendedAttributes->{CustomEnabled};
 }
 
 # https://heycam.github.io/webidl/#es-operations
@@ -3745,6 +3746,13 @@
         }
     }
 
+    if ($context->extendedAttributes->{CustomEnabled}) {
+        assert("CustomEnabled can only be used by interfaces only exposed to the Window") if $interface->extendedAttributes->{Exposed} && $interface->extendedAttributes->{Exposed} ne "Window";
+
+        my $className = "JS" . $interface->type->name;
+        push(@conjuncts, "${className}" . $codeGenerator->WK_ucfirst($context->name) . "IsEnabled()");
+    }
+
     if ($context->extendedAttributes->{DisabledByQuirk}) {
         assert("Must specify value for DisabledByQuirk.") if $context->extendedAttributes->{DisabledByQuirk} eq "VALUE_IS_MISSING";
 

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (245635 => 245636)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-05-22 19:10:05 UTC (rev 245636)
@@ -154,6 +154,9 @@
         "CustomToStringName": {
             "contextsAllowed": ["interface"]
         },
+        "CustomEnabled": {
+            "contextsAllowed": ["interface", "dictionary", "enum", "attribute", "operation", "constant", "iterable"]
+        },
         "DOMJIT": {
             "contextsAllowed": ["interface", "attribute", "operation"],
             "values": ["", "ReadDOM", "Getter"]

Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (245635 => 245636)


--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2019-05-22 19:10:05 UTC (rev 245636)
@@ -283,7 +283,7 @@
     foreach my $attributeName (sort keys %{$extendedAttributes}) {
       next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledForWorld"
         || $attributeName eq "EnabledBySetting" || $attributeName eq "SecureContext" || $attributeName eq "PrivateIdentifier"
-        || $attributeName eq "PublicIdentifier" || $attributeName eq "DisabledByQuirk" || $attributeName eq "EnabledByQuirk" || $attributeName eq "EnabledForContext");
+        || $attributeName eq "PublicIdentifier" || $attributeName eq "DisabledByQuirk" || $attributeName eq "EnabledByQuirk" || $attributeName eq "EnabledForContext" || $attributeName eq "CustomEnabled");
       my $extendedAttribute = $attributeName;
       $extendedAttribute .= "=" . $extendedAttributes->{$attributeName} unless $extendedAttributes->{$attributeName} eq "VALUE_IS_MISSING";
       push(@extendedAttributesList, $extendedAttribute);

Modified: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp (245635 => 245636)


--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp	2019-05-22 19:10:05 UTC (rev 245636)
@@ -33,6 +33,7 @@
 #include "MediaDecodingConfiguration.h"
 #include "MediaEncodingConfiguration.h"
 #include "MediaEngineConfigurationFactoryMock.h"
+#include <wtf/Algorithms.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Vector.h>
 
@@ -71,6 +72,16 @@
     return factories;
 }
 
+bool MediaEngineConfigurationFactory::hasDecodingConfigurationFactory()
+{
+    return mockEnabled() || WTF::anyOf(factories(), [] (auto& factory) { return factory.createDecodingConfiguration; });
+}
+
+bool MediaEngineConfigurationFactory::hasEncodingConfigurationFactory()
+{
+    return mockEnabled() || WTF::anyOf(factories(), [] (auto& factory) { return factory.createEncodingConfiguration; });
+}
+
 void MediaEngineConfigurationFactory::createDecodingConfiguration(MediaDecodingConfiguration&& config, MediaEngineConfigurationFactory::DecodingConfigurationCallback&& callback)
 {
     if (mockEnabled()) {

Modified: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h (245635 => 245636)


--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h	2019-05-22 19:09:30 UTC (rev 245635)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h	2019-05-22 19:10:05 UTC (rev 245636)
@@ -41,6 +41,9 @@
     using DecodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesDecodingInfo&&)>;
     using EncodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesEncodingInfo&&)>;
 
+    static bool hasDecodingConfigurationFactory();
+    static bool hasEncodingConfigurationFactory();
+
     static void createDecodingConfiguration(MediaDecodingConfiguration&&, DecodingConfigurationCallback&&);
     static void createEncodingConfiguration(MediaEncodingConfiguration&&, EncodingConfigurationCallback&&);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to