Changeset 150292 in webkit


Ignore:
Timestamp:
May 17, 2013 1:05:51 PM (11 years ago)
Author:
Christophe Dumez
Message:

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:
Location:
trunk/Source/WebCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150291 r150292  
     12013-05-17  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        Get rid of [ConstructorParameters] extended attributes
     4        https://bugs.webkit.org/show_bug.cgi?id=116308
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Get rid of WebKit-specific [ConstructorParameters] IDL extended attribute. Instead,
     9        [CustomConstructor] arguments are now explicitly specified, similarly to [Constructor]
     10        arguments and the constructor object's "length" property is now automatically
     11        computed for custom constructors as well.
     12
     13        This is less error-prone as the value is not hardcoded, more consistent with
     14        [Constructor] extended attribute and gives more information about the custom constructor
     15        in the IDL file. We also get rid of a WebKit-specific IDL attribute which is always
     16        nice.
     17
     18        No new tests, already covered by fast/js/constructor-length.html.
     19
     20        * Modules/mediastream/MediaStream.idl:
     21        * Modules/webaudio/AudioContext.idl:
     22        * Modules/websockets/WebSocket.idl:
     23        * bindings/scripts/CodeGeneratorJS.pm:
     24        (GenerateConstructorHelperMethods):
     25        * bindings/scripts/IDLAttributes.txt:
     26        * bindings/scripts/IDLParser.pm:
     27        (applyTypedefs):
     28        (parseAttributeRest):
     29        (copyExtendedAttributes):
     30        (parseExtendedAttributeRest):
     31        (applyExtendedAttributeList):
     32        * bindings/scripts/test/JS/JSFloat64Array.cpp:
     33        (WebCore::JSFloat64ArrayConstructor::finishCreation):
     34        * bindings/scripts/test/TestTypedArray.idl:
     35        * dom/MutationObserver.idl:
     36        * fileapi/Blob.idl:
     37        * html/DOMFormData.idl:
     38        * html/canvas/ArrayBuffer.idl:
     39        * html/canvas/DataView.idl:
     40        * page/WebKitPoint.idl:
     41        * workers/SharedWorker.idl:
     42        * workers/Worker.idl:
     43
    1442013-05-17  Alexey Proskuryakov  <ap@apple.com>
    245
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.idl

    r149796 r150292  
    3030    Constructor(MediaStream stream),
    3131    Constructor(MediaStreamTrack[] tracks),
    32     ConstructorParameters=0,
    3332    CallWith=ScriptExecutionContext,
    3433    SkipVTableValidation
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.idl

    r149796 r150292  
    2929    ActiveDOMObject,
    3030    CustomConstructor,
    31     ConstructorParameters=0,
    3231    EventTarget
    3332] interface AudioContext {
  • trunk/Source/WebCore/Modules/websockets/WebSocket.idl

    r150276 r150292  
    4141    EventTarget,
    4242    JSNoStaticTables,
    43     ConstructorParameters=1
    4443] interface WebSocket {
    4544    readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r150283 r150292  
    42034203
    42044204    my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
    4205     my $leastConstructorLength = $interface->extendedAttributes->{"ConstructorParameters"};
    4206     if (!defined $leastConstructorLength) {
    4207         if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
    4208             $leastConstructorLength = 1;
    4209         } elsif ($interface->extendedAttributes->{"Constructor"}) {
    4210             my @constructors = @{$interface->constructors};
    4211             $leastConstructorLength = 255;
    4212             foreach my $constructor (@constructors) {
    4213                 my $constructorLength = GetFunctionLength($constructor);
    4214                 $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
    4215             }
    4216         } else {
    4217             $leastConstructorLength = 0;
    4218         }
     4205    my $leastConstructorLength = 0;
     4206    if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
     4207        $leastConstructorLength = 1;
     4208    } elsif ($interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"CustomConstructor"}) {
     4209        my @constructors = @{$interface->constructors};
     4210        my @customConstructors = @{$interface->customConstructors};
     4211        $leastConstructorLength = 255;
     4212        foreach my $constructor (@constructors, @customConstructors) {
     4213            my $constructorLength = GetFunctionLength($constructor);
     4214            $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
     4215        }
     4216    } else {
     4217        $leastConstructorLength = 0;
    42194218    }
    42204219
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r150276 r150292  
    2929Constructor
    3030ConstructorConditional=*
    31 ConstructorParameters=*
    3231ConstructorRaisesException
    3332ConstructorTemplate=Event|TypedArray
  • trunk/Source/WebCore/bindings/scripts/IDLParser.pm

    r149796 r150292  
    5050    extendedAttributes => '$', # Extended attributes
    5151    constructors => '@', # Constructors, list of 'domFunction'
     52    customConstructors => '@', # Custom constructors, list of 'domFunction'
    5253    isException => '$', # Used for exception interfaces
    5354    isCallback => '$', # Used for callback interfaces
     
    383384                $self->applyTypedefsForSignature($attribute->signature);
    384385            }
    385             foreach my $function (@{$definition->functions}, @{$definition->constructors}) {
     386            foreach my $function (@{$definition->functions}, @{$definition->constructors}, @{$definition->customConstructors}) {
    386387                $self->applyTypedefsForSignature($function->signature);
    387388                foreach my $signature (@{$function->parameters}) {
     
    11671168        }
    11681169        $self->assertTokenValue($self->getToken(), ";", __LINE__);
     1170        # CustomConstructor may also be used on attributes.
     1171        if (defined $extendedAttributeList->{"CustomConstructors"}) {
     1172            delete $extendedAttributeList->{"CustomConstructors"};
     1173            $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
     1174        }
    11691175        $newDataNode->signature->extendedAttributes($extendedAttributeList);
    11701176        return $newDataNode;
     
    15381544                push(@{$extendedAttributeList->{"Constructors"}}, $constructor);
    15391545            }
     1546        } elsif ($key eq "CustomConstructor") {
     1547            push(@{$extendedAttributeList->{"CustomConstructors"}}, $attr->{$key});
     1548        } elsif ($key eq "CustomConstructors") {
     1549           my @customConstructors = @{$attr->{$key}};
     1550            foreach my $customConstructor (@customConstructors) {
     1551                push(@{$extendedAttributeList->{"CustomConstructors"}}, $customConstructor);
     1552            }
    15401553        } else {
    15411554            $extendedAttributeList->{$key} = $attr->{$key};
     
    16241637    }
    16251638
    1626     if ($name eq "Constructor") {
     1639    if ($name eq "Constructor" || $name eq "CustomConstructor") {
    16271640        $attrs->{$name} = [];
    16281641    } else {
     
    26082621        push(@{$interface->constructors}, $newDataNode);
    26092622    }
     2623    if (defined $extendedAttributeList->{"CustomConstructors"}) {
     2624        my @customConstructorParams = @{$extendedAttributeList->{"CustomConstructors"}};
     2625        my $index = (@customConstructorParams == 1) ? 0 : 1;
     2626        foreach my $param (@customConstructorParams) {
     2627            my $customConstructor = domFunction->new();
     2628            $customConstructor->signature(domSignature->new());
     2629            $customConstructor->signature->name("CustomConstructor");
     2630            $customConstructor->signature->extendedAttributes($extendedAttributeList);
     2631            $customConstructor->parameters($param);
     2632            $customConstructor->{overloadedIndex} = $index++;
     2633            push(@{$interface->customConstructors}, $customConstructor);
     2634        }
     2635        delete $extendedAttributeList->{"CustomConstructors"};
     2636        $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
     2637    }
    26102638    $interface->extendedAttributes($extendedAttributeList);
    26112639}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp

    r148696 r150292  
    9191    ASSERT(inherits(&s_info));
    9292    putDirect(exec->vm(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
    93     putDirect(exec->vm(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
     93    putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
    9494}
    9595
  • trunk/Source/WebCore/bindings/scripts/test/TestTypedArray.idl

    r149368 r150292  
    2727[
    2828    ConstructorTemplate=TypedArray,
    29     ConstructorParameters=123,
    3029    NumericIndexedGetter,
    3130    CustomIndexedSetter,
  • trunk/Source/WebCore/dom/MutationObserver.idl

    r149368 r150292  
    3030
    3131[
    32     CustomConstructor,
    33     ConstructorParameters=1,
     32    CustomConstructor(MutationCallback callback),
    3433    CustomIsReachable,
    3534    ImplementationLacksVTable
  • trunk/Source/WebCore/fileapi/Blob.idl

    r149368 r150292  
    3333    CustomToJSObject,
    3434    JSNoStaticTables,
    35     CustomConstructor
     35    CustomConstructor,
     36    CustomConstructor(sequence<any> blobParts, optional BlobPropertyBag options)
    3637] interface Blob {
    3738    readonly attribute unsigned long long size;
  • trunk/Source/WebCore/html/DOMFormData.idl

    r149368 r150292  
    3030
    3131[
    32     CustomConstructor,
    33     ConstructorParameters=1,
     32    CustomConstructor(optional HTMLFormElement form),
    3433    JSGenerateToNativeObject,
    3534    JSGenerateToJSObject,
  • trunk/Source/WebCore/html/canvas/ArrayBuffer.idl

    r149368 r150292  
    2626[
    2727    GenerateIsReachable=Impl,
    28     CustomConstructor,
    29     ConstructorParameters=1,
     28    CustomConstructor(unsigned long length),
    3029    JSNoStaticTables,
    3130    ImplementationNamespace=WTF,
  • trunk/Source/WebCore/html/canvas/DataView.idl

    r149368 r150292  
    2525
    2626[
    27     CustomConstructor,
    28     ConstructorParameters=1,
     27    CustomConstructor(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long byteLength),
    2928    CustomToJSObject,
    3029    JSNoStaticTables
  • trunk/Source/WebCore/page/WebKitPoint.idl

    r148997 r150292  
    2626[
    2727    CustomConstructor,
     28    CustomConstructor(float x, float y),
    2829    ImplementationLacksVTable
    2930] interface WebKitPoint {
  • trunk/Source/WebCore/workers/SharedWorker.idl

    r150276 r150292  
    3333    EnabledAtRuntime,
    3434    Conditional=SHARED_WORKERS,
    35     CustomConstructor,
    36     Constructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
     35    CustomConstructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
    3736    CallWith=ScriptExecutionContext,
    3837    ConstructorRaisesException,
  • trunk/Source/WebCore/workers/Worker.idl

    r149368 r150292  
    2828[
    2929    Conditional=WORKERS,
    30     CustomConstructor,
    31     Constructor(DOMString scriptUrl),
     30    CustomConstructor(DOMString scriptUrl),
    3231    CallWith=ScriptExecutionContext,
    3332    ConstructorRaisesException,
Note: See TracChangeset for help on using the changeset viewer.