Changeset 199103 in webkit
- Timestamp:
- Apr 6, 2016 10:33:57 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199102 r199103 1 2016-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 1 84 2016-04-06 Brady Eidson <beidson@apple.com> 2 85 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r199096 r199103 379 379 { 380 380 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"; 382 382 } 383 383 … … 722 722 my $function = shift; 723 723 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 727 724 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"}; 728 728 729 729 # [Unforgeable] operations should be on the instance. … … 1248 1248 if ($interfaceName eq "DOMWindow") { 1249 1249 push(@headerContent, " $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&, JSDOMWindowShell*);\n"); 1250 push(@headerContent, " void finishCreation(JSC::VM&, JSDOMWindowShell*);\n");1251 1250 } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) { 1252 1251 push(@headerContent, " $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&);\n"); … … 1260 1259 push(@headerContent, " ASSERT(inherits(info()));\n"); 1261 1260 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 } 1262 1269 } 1263 1270 … … 1412 1419 next if AttributeShouldBeOnInstance($interface, $attribute) != $isInstance; 1413 1420 1414 # DOMWindow addsRuntimeEnabled 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"}) { 1416 1423 $propertyCount -= 1; 1417 1424 next; … … 1449 1456 next if $function->signature->name eq "[Symbol.Iterator]"; 1450 1457 1451 # DOMWindow addsRuntimeEnabled 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"}) { 1453 1460 $propertyCount -= 1; 1454 1461 next; … … 1473 1480 if ($function->signature->extendedAttributes->{"EnabledAtRuntime"}) { 1474 1481 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)."; 1476 1483 } else { 1477 1484 push(@$runtimeEnabledFunctions, $function); … … 2198 2205 push(@implContent, "{\n"); 2199 2206 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");2240 2207 } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) { 2241 2208 AddIncludesForTypeInImpl($interfaceName); … … 2254 2221 } 2255 2222 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 { 2257 2270 push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n"); 2258 2271 push(@implContent, "{\n");
Note: See TracChangeset
for help on using the changeset viewer.