Changeset 199103 in webkit


Ignore:
Timestamp:
Apr 6, 2016 10:33:57 AM (8 years ago)
Author:
Chris Dumez
Message:

[IDL] Extend support for [EnabledAtRuntime] attributes / operations to all global objects, not just Window
https://bugs.webkit.org/show_bug.cgi?id=156291

Reviewed by Alex Christensen.

Extend support for [EnabledAtRuntime] attributes / operations to all
global objects, not just Window. This is needed by the Fetch API which
is enabled at runtime and exposed on both Window and WorkerGlobalScope.

  • bindings/scripts/CodeGeneratorJS.pm:

(IsDOMGlobalObject):
(OperationShouldBeOnInstance):
(GenerateHeader):
(GeneratePropertiesHashTable):
(GenerateImplementation):

  • bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp: Added.

(WebKit::kit):
(WebKit::core):
(WebKit::wrapTestGlobalObject):
(webkit_dom_test_global_object_finalize):
(webkit_dom_test_global_object_set_property):
(webkit_dom_test_global_object_get_property):
(webkit_dom_test_global_object_constructor):
(webkit_dom_test_global_object_class_init):
(webkit_dom_test_global_object_init):
(webkit_dom_test_global_object_regular_operation):
(webkit_dom_test_global_object_enabled_at_runtime_operation):
(webkit_dom_test_global_object_get_regular_attribute):
(webkit_dom_test_global_object_set_regular_attribute):
(webkit_dom_test_global_object_get_enabled_at_runtime_attribute):
(webkit_dom_test_global_object_set_enabled_at_runtime_attribute):

  • bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h: Added.
  • bindings/scripts/test/GObject/WebKitDOMTestGlobalObjectPrivate.h: Added.
  • bindings/scripts/test/JS/JSTestGlobalObject.cpp: Added.

(WebCore::JSTestGlobalObjectConstructor::prototypeForStructure):
(WebCore::JSTestGlobalObjectConstructor::initializeProperties):
(WebCore::JSTestGlobalObjectPrototype::getOwnPropertySlot):
(WebCore::JSTestGlobalObject::JSTestGlobalObject):
(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::JSTestGlobalObject::destroy):
(WebCore::JSTestGlobalObject::getOwnPropertySlot):
(WebCore::jsTestGlobalObjectRegularAttribute):
(WebCore::jsTestGlobalObjectEnabledAtRuntimeAttribute):
(WebCore::jsTestGlobalObjectConstructor):
(WebCore::setJSTestGlobalObjectConstructor):
(WebCore::setJSTestGlobalObjectRegularAttribute):
(WebCore::setJSTestGlobalObjectEnabledAtRuntimeAttribute):
(WebCore::JSTestGlobalObject::getConstructor):
(WebCore::jsTestGlobalObjectInstanceFunctionRegularOperation):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation):
(WebCore::JSTestGlobalObjectOwner::isReachableFromOpaqueRoots):
(WebCore::JSTestGlobalObjectOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSTestGlobalObject::toWrapped):

  • bindings/scripts/test/JS/JSTestGlobalObject.h: Added.

(WebCore::JSTestGlobalObject::create):
(WebCore::JSTestGlobalObject::createStructure):
(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::JSTestGlobalObjectPrototype::create):
(WebCore::JSTestGlobalObjectPrototype::createStructure):
(WebCore::JSTestGlobalObjectPrototype::JSTestGlobalObjectPrototype):

  • bindings/scripts/test/ObjC/DOMTestGlobalObject.h: Added.
  • bindings/scripts/test/ObjC/DOMTestGlobalObject.mm: Added.

(-[DOMTestGlobalObject dealloc]):
(-[DOMTestGlobalObject regularAttribute]):
(-[DOMTestGlobalObject setRegularAttribute:]):
(-[DOMTestGlobalObject enabledAtRuntimeAttribute]):
(-[DOMTestGlobalObject setEnabledAtRuntimeAttribute:]):
(-[DOMTestGlobalObject regularOperation:]):
(-[DOMTestGlobalObject enabledAtRuntimeOperation:]):
(core):
(kit):

  • bindings/scripts/test/ObjC/DOMTestGlobalObjectInternal.h: Added.
  • bindings/scripts/test/TestGlobalObject.idl: Added.
Location:
trunk/Source/WebCore
Files:
9 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199102 r199103  
     12016-04-06  Chris Dumez  <cdumez@apple.com>
     2
     3        [IDL] Extend support for [EnabledAtRuntime] attributes / operations to all global objects, not just Window
     4        https://bugs.webkit.org/show_bug.cgi?id=156291
     5
     6        Reviewed by Alex Christensen.
     7
     8        Extend support for [EnabledAtRuntime] attributes / operations to all
     9        global objects, not just Window. This is needed by the Fetch API which
     10        is enabled at runtime and exposed on both Window and WorkerGlobalScope.
     11
     12        * bindings/scripts/CodeGeneratorJS.pm:
     13        (IsDOMGlobalObject):
     14        (OperationShouldBeOnInstance):
     15        (GenerateHeader):
     16        (GeneratePropertiesHashTable):
     17        (GenerateImplementation):
     18        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp: Added.
     19        (WebKit::kit):
     20        (WebKit::core):
     21        (WebKit::wrapTestGlobalObject):
     22        (webkit_dom_test_global_object_finalize):
     23        (webkit_dom_test_global_object_set_property):
     24        (webkit_dom_test_global_object_get_property):
     25        (webkit_dom_test_global_object_constructor):
     26        (webkit_dom_test_global_object_class_init):
     27        (webkit_dom_test_global_object_init):
     28        (webkit_dom_test_global_object_regular_operation):
     29        (webkit_dom_test_global_object_enabled_at_runtime_operation):
     30        (webkit_dom_test_global_object_get_regular_attribute):
     31        (webkit_dom_test_global_object_set_regular_attribute):
     32        (webkit_dom_test_global_object_get_enabled_at_runtime_attribute):
     33        (webkit_dom_test_global_object_set_enabled_at_runtime_attribute):
     34        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h: Added.
     35        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObjectPrivate.h: Added.
     36        * bindings/scripts/test/JS/JSTestGlobalObject.cpp: Added.
     37        (WebCore::JSTestGlobalObjectConstructor::prototypeForStructure):
     38        (WebCore::JSTestGlobalObjectConstructor::initializeProperties):
     39        (WebCore::JSTestGlobalObjectPrototype::getOwnPropertySlot):
     40        (WebCore::JSTestGlobalObject::JSTestGlobalObject):
     41        (WebCore::JSTestGlobalObject::finishCreation):
     42        (WebCore::JSTestGlobalObject::destroy):
     43        (WebCore::JSTestGlobalObject::getOwnPropertySlot):
     44        (WebCore::jsTestGlobalObjectRegularAttribute):
     45        (WebCore::jsTestGlobalObjectEnabledAtRuntimeAttribute):
     46        (WebCore::jsTestGlobalObjectConstructor):
     47        (WebCore::setJSTestGlobalObjectConstructor):
     48        (WebCore::setJSTestGlobalObjectRegularAttribute):
     49        (WebCore::setJSTestGlobalObjectEnabledAtRuntimeAttribute):
     50        (WebCore::JSTestGlobalObject::getConstructor):
     51        (WebCore::jsTestGlobalObjectInstanceFunctionRegularOperation):
     52        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1):
     53        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2):
     54        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation):
     55        (WebCore::JSTestGlobalObjectOwner::isReachableFromOpaqueRoots):
     56        (WebCore::JSTestGlobalObjectOwner::finalize):
     57        (WebCore::toJSNewlyCreated):
     58        (WebCore::toJS):
     59        (WebCore::JSTestGlobalObject::toWrapped):
     60        * bindings/scripts/test/JS/JSTestGlobalObject.h: Added.
     61        (WebCore::JSTestGlobalObject::create):
     62        (WebCore::JSTestGlobalObject::createStructure):
     63        (WebCore::JSTestGlobalObject::finishCreation):
     64        (WebCore::wrapperOwner):
     65        (WebCore::wrapperKey):
     66        (WebCore::toJS):
     67        (WebCore::JSTestGlobalObjectPrototype::create):
     68        (WebCore::JSTestGlobalObjectPrototype::createStructure):
     69        (WebCore::JSTestGlobalObjectPrototype::JSTestGlobalObjectPrototype):
     70        * bindings/scripts/test/ObjC/DOMTestGlobalObject.h: Added.
     71        * bindings/scripts/test/ObjC/DOMTestGlobalObject.mm: Added.
     72        (-[DOMTestGlobalObject dealloc]):
     73        (-[DOMTestGlobalObject regularAttribute]):
     74        (-[DOMTestGlobalObject setRegularAttribute:]):
     75        (-[DOMTestGlobalObject enabledAtRuntimeAttribute]):
     76        (-[DOMTestGlobalObject setEnabledAtRuntimeAttribute:]):
     77        (-[DOMTestGlobalObject regularOperation:]):
     78        (-[DOMTestGlobalObject enabledAtRuntimeOperation:]):
     79        (core):
     80        (kit):
     81        * bindings/scripts/test/ObjC/DOMTestGlobalObjectInternal.h: Added.
     82        * bindings/scripts/test/TestGlobalObject.idl: Added.
     83
    1842016-04-06  Brady Eidson  <beidson@apple.com>
    285
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r199096 r199103  
    379379{
    380380    my $interface = shift;
    381     return $interface->name eq "DOMWindow" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope");
     381    return $interface->name eq "DOMWindow" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope") || $interface->name eq "TestGlobalObject";
    382382}
    383383
     
    722722    my $function = shift;
    723723
    724     # FIXME: The bindings generator does not support putting runtime-enabled on the instance yet (except for Window).
    725     return 0 if $function->signature->extendedAttributes->{"EnabledAtRuntime"} && $interface->name ne "DOMWindow";
    726 
    727724    return 1 if IsDOMGlobalObject($interface);
     725
     726    # FIXME: The bindings generator does not support putting runtime-enabled on the instance yet (except for global objects).
     727    return 0 if $function->signature->extendedAttributes->{"EnabledAtRuntime"};
    728728
    729729    # [Unforgeable] operations should be on the instance.
     
    12481248    if ($interfaceName eq "DOMWindow") {
    12491249        push(@headerContent, "    $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&, JSDOMWindowShell*);\n");
    1250         push(@headerContent, "    void finishCreation(JSC::VM&, JSDOMWindowShell*);\n");
    12511250    } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
    12521251        push(@headerContent, "    $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&);\n");
     
    12601259        push(@headerContent, "        ASSERT(inherits(info()));\n");
    12611260        push(@headerContent, "    }\n\n");
     1261    }
     1262
     1263    if (IsDOMGlobalObject($interface)) {
     1264        if ($interfaceName eq "DOMWindow") {
     1265            push(@headerContent, "    void finishCreation(JSC::VM&, JSDOMWindowShell*);\n");
     1266        } else {
     1267            push(@headerContent, "    void finishCreation(JSC::VM&);\n");
     1268        }
    12621269    }
    12631270
     
    14121419        next if AttributeShouldBeOnInstance($interface, $attribute) != $isInstance;
    14131420
    1414         # DOMWindow adds RuntimeEnabled attributes after creation so do not add them to the static table.
    1415         if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) {
     1421        # Global objects add RuntimeEnabled attributes after creation so do not add them to the static table.
     1422        if (IsDOMGlobalObject($interface) && $attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) {
    14161423            $propertyCount -= 1;
    14171424            next;
     
    14491456        next if $function->signature->name eq "[Symbol.Iterator]";
    14501457
    1451         # DOMWindow adds RuntimeEnabled operations after creation so do not add them to the static table.
    1452         if ($interfaceName eq "DOMWindow" && $function->signature->extendedAttributes->{"EnabledAtRuntime"}) {
     1458        # Global objects add RuntimeEnabled operations after creation so do not add them to the static table.
     1459        if (IsDOMGlobalObject($interface) && $function->signature->extendedAttributes->{"EnabledAtRuntime"}) {
    14531460            $propertyCount -= 1;
    14541461            next;
     
    14731480        if ($function->signature->extendedAttributes->{"EnabledAtRuntime"}) {
    14741481            if ($isInstance) {
    1475                 die "We currently do not support [EnabledAtRuntime] operations on the instance.";
     1482                die "We currently do not support [EnabledAtRuntime] operations on the instance (except for global objects).";
    14761483            } else {
    14771484                push(@$runtimeEnabledFunctions, $function);
     
    21982205        push(@implContent, "{\n");
    21992206        push(@implContent, "}\n\n");
    2200 
    2201         push(@implContent, "void ${className}::finishCreation(VM& vm, JSDOMWindowShell* shell)\n");
    2202         push(@implContent, "{\n");
    2203         push(@implContent, "    Base::finishCreation(vm, shell);\n\n");
    2204         # Support for RuntimeEnabled attributes on DOMWindow.
    2205         foreach my $attribute (@{$interface->attributes}) {
    2206             next unless $attribute->signature->extendedAttributes->{"EnabledAtRuntime"};
    2207 
    2208             AddToImplIncludes("RuntimeEnabledFeatures.h");
    2209             my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
    2210             push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    2211             my $enable_function = GetRuntimeEnableFunctionName($attribute->signature);
    2212             my $attributeName = $attribute->signature->name;
    2213             push(@implContent, "    if (${enable_function}()) {\n");
    2214             my $getter = GetAttributeGetterName($interfaceName, $className, $interface, $attribute);
    2215             my $setter = IsReadonly($attribute) ? "nullptr" : GetAttributeSetterName($interfaceName, $className, $interface, $attribute);
    2216             push(@implContent, "        auto* customGetterSetter = CustomGetterSetter::create(vm, $getter, $setter);\n");
    2217             my $jscAttributes = GetJSCAttributesForAttribute($interface, $attribute);
    2218             push(@implContent, "        putDirectCustomAccessor(vm, vm.propertyNames->$attributeName, customGetterSetter, attributesForStructure($jscAttributes));\n");
    2219             push(@implContent, "    }\n");
    2220             push(@implContent, "#endif\n") if $conditionalString;
    2221         }
    2222         # Support for RuntimeEnabled operations on DOMWindow.
    2223         foreach my $function (@{$interface->functions}) {
    2224             next unless $function->signature->extendedAttributes->{"EnabledAtRuntime"};
    2225             next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
    2226 
    2227             AddToImplIncludes("RuntimeEnabledFeatures.h");
    2228             my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
    2229             push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    2230             my $enable_function = GetRuntimeEnableFunctionName($function->signature);
    2231             my $functionName = $function->signature->name;
    2232             my $implementationFunction = GetFunctionName($interface, $className, $function);
    2233             my $functionLength = GetFunctionLength($function);
    2234             my $jsAttributes = ComputeFunctionSpecial($interface, $function);
    2235             push(@implContent, "    if (${enable_function}())\n");
    2236             push(@implContent, "        putDirectNativeFunction(vm, this, vm.propertyNames->$functionName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n");
    2237             push(@implContent, "#endif\n") if $conditionalString;
    2238         }
    2239         push(@implContent, "}\n\n");
    22402207    } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
    22412208        AddIncludesForTypeInImpl($interfaceName);
     
    22542221    }
    22552222
    2256     unless (IsDOMGlobalObject($interface)) {
     2223    if (IsDOMGlobalObject($interface)) {
     2224        if ($interfaceName eq "DOMWindow") {
     2225            push(@implContent, "void ${className}::finishCreation(VM& vm, JSDOMWindowShell* shell)\n");
     2226            push(@implContent, "{\n");
     2227            push(@implContent, "    Base::finishCreation(vm, shell);\n\n");
     2228        } else {
     2229            push(@implContent, "void ${className}::finishCreation(VM& vm)\n");
     2230            push(@implContent, "{\n");
     2231            push(@implContent, "    Base::finishCreation(vm);\n\n");
     2232        }
     2233        # Support for RuntimeEnabled attributes on global objects.
     2234        foreach my $attribute (@{$interface->attributes}) {
     2235            next unless $attribute->signature->extendedAttributes->{"EnabledAtRuntime"};
     2236
     2237            AddToImplIncludes("RuntimeEnabledFeatures.h");
     2238            my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
     2239            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
     2240            my $enable_function = GetRuntimeEnableFunctionName($attribute->signature);
     2241            my $attributeName = $attribute->signature->name;
     2242            push(@implContent, "    if (${enable_function}()) {\n");
     2243            my $getter = GetAttributeGetterName($interfaceName, $className, $interface, $attribute);
     2244            my $setter = IsReadonly($attribute) ? "nullptr" : GetAttributeSetterName($interfaceName, $className, $interface, $attribute);
     2245            push(@implContent, "        auto* customGetterSetter = CustomGetterSetter::create(vm, $getter, $setter);\n");
     2246            my $jscAttributes = GetJSCAttributesForAttribute($interface, $attribute);
     2247            push(@implContent, "        putDirectCustomAccessor(vm, vm.propertyNames->$attributeName, customGetterSetter, attributesForStructure($jscAttributes));\n");
     2248            push(@implContent, "    }\n");
     2249            push(@implContent, "#endif\n") if $conditionalString;
     2250        }
     2251        # Support for RuntimeEnabled operations on global objects.
     2252        foreach my $function (@{$interface->functions}) {
     2253            next unless $function->signature->extendedAttributes->{"EnabledAtRuntime"};
     2254            next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
     2255
     2256            AddToImplIncludes("RuntimeEnabledFeatures.h");
     2257            my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
     2258            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
     2259            my $enable_function = GetRuntimeEnableFunctionName($function->signature);
     2260            my $functionName = $function->signature->name;
     2261            my $implementationFunction = GetFunctionName($interface, $className, $function);
     2262            my $functionLength = GetFunctionLength($function);
     2263            my $jsAttributes = ComputeFunctionSpecial($interface, $function);
     2264            push(@implContent, "    if (${enable_function}())\n");
     2265            push(@implContent, "        putDirectNativeFunction(vm, this, vm.propertyNames->$functionName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n");
     2266            push(@implContent, "#endif\n") if $conditionalString;
     2267        }
     2268        push(@implContent, "}\n\n");
     2269    } else {
    22572270        push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n");
    22582271        push(@implContent, "{\n");
Note: See TracChangeset for help on using the changeset viewer.