Get rid of [ConstructorParameters] extended attributes

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

Reviewed by Kentaro Hara.

Get rid of WebKit-specific [ConstructorParameters] IDL extended attribute. Instead,
[CustomConstructor] arguments are now explicitly specified, similarly to [Constructor]
arguments and the constructor object's "length" property is now automatically
computed for custom constructors as well.

This is less error-prone as the value is not hardcoded, more consistent with
[Constructor] extended attribute and gives more information about the custom constructor
in the IDL file. We also get rid of a WebKit-specific IDL attribute which is always
nice.

No new tests, already covered by fast/js/constructor-length.html.

* Modules/mediastream/MediaStream.idl:
* Modules/webaudio/AudioContext.idl:
* Modules/websockets/WebSocket.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorHelperMethods):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/IDLParser.pm:
(applyTypedefs):
(parseAttributeRest):
(copyExtendedAttributes):
(parseExtendedAttributeRest):
(applyExtendedAttributeList):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64ArrayConstructor::finishCreation):
* bindings/scripts/test/TestTypedArray.idl:
* dom/MutationObserver.idl:
* fileapi/Blob.idl:
* html/DOMFormData.idl:
* html/canvas/ArrayBuffer.idl:
* html/canvas/DataView.idl:
* page/WebKitPoint.idl:
* workers/SharedWorker.idl:
* workers/Worker.idl:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150292 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e042b63d
2013-05-17 Christophe Dumez <ch.dumez@sisa.samsung.com>
Get rid of [ConstructorParameters] extended attributes
https://bugs.webkit.org/show_bug.cgi?id=116308
Reviewed by Kentaro Hara.
Get rid of WebKit-specific [ConstructorParameters] IDL extended attribute. Instead,
[CustomConstructor] arguments are now explicitly specified, similarly to [Constructor]
arguments and the constructor object's "length" property is now automatically
computed for custom constructors as well.
This is less error-prone as the value is not hardcoded, more consistent with
[Constructor] extended attribute and gives more information about the custom constructor
in the IDL file. We also get rid of a WebKit-specific IDL attribute which is always
nice.
No new tests, already covered by fast/js/constructor-length.html.
* Modules/mediastream/MediaStream.idl:
* Modules/webaudio/AudioContext.idl:
* Modules/websockets/WebSocket.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorHelperMethods):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/IDLParser.pm:
(applyTypedefs):
(parseAttributeRest):
(copyExtendedAttributes):
(parseExtendedAttributeRest):
(applyExtendedAttributeList):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64ArrayConstructor::finishCreation):
* bindings/scripts/test/TestTypedArray.idl:
* dom/MutationObserver.idl:
* fileapi/Blob.idl:
* html/DOMFormData.idl:
* html/canvas/ArrayBuffer.idl:
* html/canvas/DataView.idl:
* page/WebKitPoint.idl:
* workers/SharedWorker.idl:
* workers/Worker.idl:
2013-05-17 Alexey Proskuryakov <ap@apple.com>
Text input is largely broken when there are subframes loading
......
......@@ -29,7 +29,6 @@
Constructor,
Constructor(MediaStream stream),
Constructor(MediaStreamTrack[] tracks),
ConstructorParameters=0,
CallWith=ScriptExecutionContext,
SkipVTableValidation
] interface MediaStream {
......
......@@ -28,7 +28,6 @@
Conditional=WEB_AUDIO,
ActiveDOMObject,
CustomConstructor,
ConstructorParameters=0,
EventTarget
] interface AudioContext {
// All rendered audio ultimately connects to destination, which represents the audio hardware.
......
......@@ -40,7 +40,6 @@
CallWith=ScriptExecutionContext,
EventTarget,
JSNoStaticTables,
ConstructorParameters=1
] interface WebSocket {
readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
readonly attribute DOMString url;
......
......@@ -4202,20 +4202,19 @@ sub GenerateConstructorHelperMethods
my $generatingNamedConstructor = shift;
my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
my $leastConstructorLength = $interface->extendedAttributes->{"ConstructorParameters"};
if (!defined $leastConstructorLength) {
if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
$leastConstructorLength = 1;
} elsif ($interface->extendedAttributes->{"Constructor"}) {
my @constructors = @{$interface->constructors};
$leastConstructorLength = 255;
foreach my $constructor (@constructors) {
my $constructorLength = GetFunctionLength($constructor);
$leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
}
} else {
$leastConstructorLength = 0;
my $leastConstructorLength = 0;
if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
$leastConstructorLength = 1;
} elsif ($interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"CustomConstructor"}) {
my @constructors = @{$interface->constructors};
my @customConstructors = @{$interface->customConstructors};
$leastConstructorLength = 255;
foreach my $constructor (@constructors, @customConstructors) {
my $constructorLength = GetFunctionLength($constructor);
$leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
}
} else {
$leastConstructorLength = 0;
}
if ($generatingNamedConstructor) {
......
......@@ -28,7 +28,6 @@ Clamp
Conditional=*
Constructor
ConstructorConditional=*
ConstructorParameters=*
ConstructorRaisesException
ConstructorTemplate=Event|TypedArray
Custom
......
......@@ -49,6 +49,7 @@ struct( domInterface => {
attributes => '@', # List of 'domAttribute'
extendedAttributes => '$', # Extended attributes
constructors => '@', # Constructors, list of 'domFunction'
customConstructors => '@', # Custom constructors, list of 'domFunction'
isException => '$', # Used for exception interfaces
isCallback => '$', # Used for callback interfaces
isPartial => '$', # Used for partial interfaces
......@@ -382,7 +383,7 @@ sub applyTypedefs
foreach my $attribute (@{$definition->attributes}) {
$self->applyTypedefsForSignature($attribute->signature);
}
foreach my $function (@{$definition->functions}, @{$definition->constructors}) {
foreach my $function (@{$definition->functions}, @{$definition->constructors}, @{$definition->customConstructors}) {
$self->applyTypedefsForSignature($function->signature);
foreach my $signature (@{$function->parameters}) {
$self->applyTypedefsForSignature($signature);
......@@ -1166,6 +1167,11 @@ sub parseAttributeRest
push(@{$newDataNode->setterExceptions}, @{$getRef->{"setraises"}});
}
$self->assertTokenValue($self->getToken(), ";", __LINE__);
# CustomConstructor may also be used on attributes.
if (defined $extendedAttributeList->{"CustomConstructors"}) {
delete $extendedAttributeList->{"CustomConstructors"};
$extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
}
$newDataNode->signature->extendedAttributes($extendedAttributeList);
return $newDataNode;
}
......@@ -1537,6 +1543,13 @@ sub copyExtendedAttributes
foreach my $constructor (@constructors) {
push(@{$extendedAttributeList->{"Constructors"}}, $constructor);
}
} elsif ($key eq "CustomConstructor") {
push(@{$extendedAttributeList->{"CustomConstructors"}}, $attr->{$key});
} elsif ($key eq "CustomConstructors") {
my @customConstructors = @{$attr->{$key}};
foreach my $customConstructor (@customConstructors) {
push(@{$extendedAttributeList->{"CustomConstructors"}}, $customConstructor);
}
} else {
$extendedAttributeList->{$key} = $attr->{$key};
}
......@@ -1623,7 +1636,7 @@ sub parseExtendedAttributeRest
return $attrs;
}
if ($name eq "Constructor") {
if ($name eq "Constructor" || $name eq "CustomConstructor") {
$attrs->{$name} = [];
} else {
$attrs->{$name} = "VALUE_IS_MISSING";
......@@ -2607,6 +2620,21 @@ sub applyExtendedAttributeList
$extendedAttributeList->{"NamedConstructor"} = $constructorName;
push(@{$interface->constructors}, $newDataNode);
}
if (defined $extendedAttributeList->{"CustomConstructors"}) {
my @customConstructorParams = @{$extendedAttributeList->{"CustomConstructors"}};
my $index = (@customConstructorParams == 1) ? 0 : 1;
foreach my $param (@customConstructorParams) {
my $customConstructor = domFunction->new();
$customConstructor->signature(domSignature->new());
$customConstructor->signature->name("CustomConstructor");
$customConstructor->signature->extendedAttributes($extendedAttributeList);
$customConstructor->parameters($param);
$customConstructor->{overloadedIndex} = $index++;
push(@{$interface->customConstructors}, $customConstructor);
}
delete $extendedAttributeList->{"CustomConstructors"};
$extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
}
$interface->extendedAttributes($extendedAttributeList);
}
......
......@@ -90,7 +90,7 @@ void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObjec
Base::finishCreation(exec->vm());
ASSERT(inherits(&s_info));
putDirect(exec->vm(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
putDirect(exec->vm(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
......
......@@ -26,7 +26,6 @@
[
ConstructorTemplate=TypedArray,
ConstructorParameters=123,
NumericIndexedGetter,
CustomIndexedSetter,
JSGenerateToNativeObject,
......
......@@ -29,8 +29,7 @@
*/
[
CustomConstructor,
ConstructorParameters=1,
CustomConstructor(MutationCallback callback),
CustomIsReachable,
ImplementationLacksVTable
] interface MutationObserver {
......
......@@ -32,7 +32,8 @@
GenerateIsReachable=Impl,
CustomToJSObject,
JSNoStaticTables,
CustomConstructor
CustomConstructor,
CustomConstructor(sequence<any> blobParts, optional BlobPropertyBag options)
] interface Blob {
readonly attribute unsigned long long size;
readonly attribute DOMString type;
......
......@@ -29,8 +29,7 @@
*/
[
CustomConstructor,
ConstructorParameters=1,
CustomConstructor(optional HTMLFormElement form),
JSGenerateToNativeObject,
JSGenerateToJSObject,
InterfaceName=FormData,
......
......@@ -25,8 +25,7 @@
[
GenerateIsReachable=Impl,
CustomConstructor,
ConstructorParameters=1,
CustomConstructor(unsigned long length),
JSNoStaticTables,
ImplementationNamespace=WTF,
ImplementationLacksVTable
......
......@@ -24,8 +24,7 @@
*/
[
CustomConstructor,
ConstructorParameters=1,
CustomConstructor(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long byteLength),
CustomToJSObject,
JSNoStaticTables
] interface DataView : ArrayBufferView {
......
......@@ -25,6 +25,7 @@
[
CustomConstructor,
CustomConstructor(float x, float y),
ImplementationLacksVTable
] interface WebKitPoint {
attribute float x;
......
......@@ -32,8 +32,7 @@
[
EnabledAtRuntime,
Conditional=SHARED_WORKERS,
CustomConstructor,
Constructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
CustomConstructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
CallWith=ScriptExecutionContext,
ConstructorRaisesException,
JSCustomMarkFunction,
......
......@@ -27,8 +27,7 @@
[
Conditional=WORKERS,
CustomConstructor,
Constructor(DOMString scriptUrl),
CustomConstructor(DOMString scriptUrl),
CallWith=ScriptExecutionContext,
ConstructorRaisesException,
JSGenerateToNativeObject,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment