Skip to content
Permalink
Browse files
[Web IDL] Specify default values for optional parameters of TypedArra…
…y types

https://bugs.webkit.org/show_bug.cgi?id=157017

Reviewed by Darin Adler.

Specify default values for optional parameters of TypedArray types and let
the bindings generator use WTF::Optional<> for the ones that do not have a
default value.

* bindings/scripts/CodeGeneratorJS.pm:
(CanUseWTFOptionalForParameter): Deleted.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::webkitGenerateKeyRequest):
(WebCore::HTMLMediaElement::webkitAddKey):
(WebCore::HTMLMediaElement::webkitCancelKeyRequest): Deleted.
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:


Canonical link: https://commits.webkit.org/175143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 26, 2016
1 parent a3c9bdb commit db88f47128a728c180d836bcfb164cba1d8e189f
@@ -1,3 +1,23 @@
2016-04-26 Chris Dumez <cdumez@apple.com>

[Web IDL] Specify default values for optional parameters of TypedArray types
https://bugs.webkit.org/show_bug.cgi?id=157017

Reviewed by Darin Adler.

Specify default values for optional parameters of TypedArray types and let
the bindings generator use WTF::Optional<> for the ones that do not have a
default value.

* bindings/scripts/CodeGeneratorJS.pm:
(CanUseWTFOptionalForParameter): Deleted.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::webkitGenerateKeyRequest):
(WebCore::HTMLMediaElement::webkitAddKey):
(WebCore::HTMLMediaElement::webkitCancelKeyRequest): Deleted.
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:

2016-04-26 Chris Dumez <cdumez@apple.com>

[Web IDL] Specify default values for optional parameters of type 'long' / 'unrestricted double'
@@ -3381,7 +3381,6 @@ sub CanUseWTFOptionalForParameter
return 0 if $parameter->isVariadic;
return 0 if $codeGenerator->IsCallbackInterface($type);
return 0 if $codeGenerator->IsEnumType($type);
return 0 if $codeGenerator->IsTypedArrayType($type);
return 0 if $codeGenerator->IsWrapperType($type);
return 0 if $type eq "DOMString";
return 0 if $type eq "Dictionary";
@@ -3114,7 +3114,7 @@ void HTMLMediaElement::closeMediaSource()
#endif

#if ENABLE(ENCRYPTED_MEDIA)
void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionCode& ec)
void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, RefPtr<Uint8Array>&& initData, ExceptionCode& ec)
{
#if ENABLE(ENCRYPTED_MEDIA_V2)
static bool firstTime = true;
@@ -3134,7 +3134,7 @@ void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
return;
}

const unsigned char* initDataPointer = 0;
const unsigned char* initDataPointer = nullptr;
unsigned initDataLength = 0;
if (initData) {
initDataPointer = initData->data();
@@ -3145,11 +3145,6 @@ void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
ec = exceptionCodeForMediaKeyException(result);
}

void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, ExceptionCode& ec)
{
webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), ec);
}

void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionCode& ec)
{
#if ENABLE(ENCRYPTED_MEDIA_V2)
@@ -3180,7 +3175,7 @@ void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
return;
}

const unsigned char* initDataPointer = 0;
const unsigned char* initDataPointer = nullptr;
unsigned initDataLength = 0;
if (initData) {
initDataPointer = initData->data();
@@ -3191,11 +3186,6 @@ void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ec = exceptionCodeForMediaKeyException(result);
}

void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionCode& ec)
{
webkitAddKey(keySystem, key, Uint8Array::create(0), String(), ec);
}

void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const String& sessionId, ExceptionCode& ec)
{
if (keySystem.isEmpty()) {
@@ -234,10 +234,8 @@ class HTMLMediaElement
#endif

#if ENABLE(ENCRYPTED_MEDIA)
void webkitGenerateKeyRequest(const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionCode&);
void webkitGenerateKeyRequest(const String& keySystem, ExceptionCode&);
void webkitGenerateKeyRequest(const String& keySystem, RefPtr<Uint8Array>&& initData, ExceptionCode&);
void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionCode&);
void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionCode&);
void webkitCancelKeyRequest(const String& keySystem, const String& sessionId, ExceptionCode&);
#endif

@@ -98,8 +98,8 @@
#endif

#if (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT) && (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C)
[Conditional=ENCRYPTED_MEDIA, RaisesException] void webkitGenerateKeyRequest(DOMString? keySystem, optional Uint8Array initData);
[Conditional=ENCRYPTED_MEDIA, RaisesException] void webkitAddKey(DOMString? keySystem, Uint8Array key, optional Uint8Array initData, optional DOMString sessionId = null);
[Conditional=ENCRYPTED_MEDIA, RaisesException] void webkitGenerateKeyRequest(DOMString? keySystem, optional Uint8Array initData = null);
[Conditional=ENCRYPTED_MEDIA, RaisesException] void webkitAddKey(DOMString? keySystem, Uint8Array key, optional Uint8Array initData = null, optional DOMString sessionId = null);
[Conditional=ENCRYPTED_MEDIA, RaisesException] void webkitCancelKeyRequest(DOMString? keySystem, optional DOMString sessionId = null);

[Conditional=ENCRYPTED_MEDIA_V2, ImplementedAs=keys] readonly attribute MediaKeys webkitKeys;

0 comments on commit db88f47

Please sign in to comment.