+2017-08-02 Sam Weinig <sam@webkit.org>
+
+ [WebIDL] Simplify [EnabledBySettings] extended attribute code to not require passing a global object to finishCreation
+ https://bugs.webkit.org/show_bug.cgi?id=175087
+
+ Reviewed by Chris Dumez.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation):
+ (GeneratePrototypeDeclaration):
+ Remove unnecessary passing of the global object to finishCreation for [EnabledBySettings].
+
+ * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
+ * bindings/scripts/test/JS/JSTestNode.cpp:
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ Update tests.
+
2017-08-02 Andy Estes <aestes@apple.com>
REGRESSION (r207155): Unable to switch sheets when previewing Numbers '09 spreadsheets
|| $interface->extendedAttributes->{SecureContext};
}
-sub NeedsSettingsCheckForPrototypeProperty
-{
- my $interface = shift;
-
- foreach my $operation (@{$interface->operations}) {
- next if OperationShouldBeOnInstance($interface, $operation);
-
- return 1 if $operation->extendedAttributes->{EnabledBySetting};
- }
-
- foreach my $attribute (@{$interface->attributes}) {
- next if AttributeShouldBeOnInstance($interface, $attribute);
- return 1 if $attribute->extendedAttributes->{EnabledBySetting};
- }
-
- return 0;
-}
-
# https://heycam.github.io/webidl/#es-operations
sub OperationShouldBeOnInstance
{
}
if (PrototypeHasStaticPropertyTable($interface) && !IsGlobalOrPrimaryGlobalInterface($interface)) {
- my $needsGlobalObjectInFinishCreation = NeedsSettingsCheckForPrototypeProperty($interface);
-
- if ($needsGlobalObjectInFinishCreation) {
- push(@implContent, "void ${className}Prototype::finishCreation(VM& vm, JSDOMGlobalObject& globalObject)\n");
- } else {
- push(@implContent, "void ${className}Prototype::finishCreation(VM& vm)\n");
- }
+ push(@implContent, "void ${className}Prototype::finishCreation(VM& vm)\n");
push(@implContent, "{\n");
push(@implContent, " Base::finishCreation(vm);\n");
push(@implContent, " reifyStaticProperties(vm, ${className}::info(), ${className}PrototypeTableValues, *this);\n");
push(@implContent, " if (!${runtimeEnableConditionalString}) {\n");
push(@implContent, " auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>(\"$name\"), strlen(\"$name\"));\n");
push(@implContent, " VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);\n");
- push(@implContent, " JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);\n");
+ push(@implContent, " JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);\n");
push(@implContent, " }\n");
push(@implContent, "#endif\n") if $conditionalString;
}
push(@settingsEnabledProperties, @settingsEnabledAttributes);
if (scalar(@settingsEnabledProperties)) {
AddToImplIncludes("Settings.h");
- push(@implContent, " auto* context = globalObject.scriptExecutionContext();\n");
+ push(@implContent, " auto* context = jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext();\n");
push(@implContent, " ASSERT(!context || context->isDocument());\n");
foreach my $operationOrAttribute (@settingsEnabledProperties) {
push(@implContent, " if (!context || !downcast<Document>(*context).settings().${enableFunction}()) {\n");
push(@implContent, " auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>(\"$name\"), strlen(\"$name\"));\n");
push(@implContent, " VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);\n");
- push(@implContent, " JSObject::deleteProperty(this, globalObject.globalExec(), propertyName);\n");
+ push(@implContent, " JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);\n");
push(@implContent, " }\n");
push(@implContent, "#endif\n") if $conditionalString;
push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), DontEnum);\n");
} else {
AddToImplIncludes("<runtime/ArrayPrototype.h>");
- push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, this->globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), DontEnum);\n");
+ push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), DontEnum);\n");
}
}
push(@implContent, " addValueIterableMethods(*globalObject(), *this);\n") if $interface->iterable and !IsKeyValueIterableInterface($interface);
my $prototypeClassName = "${className}Prototype";
- my $needsGlobalObjectInFinishCreation = NeedsSettingsCheckForPrototypeProperty($interface);
-
my %structureFlags = ();
push(@$outputArray, "class ${prototypeClassName} : public JSC::JSNonFinalObject {\n");
push(@$outputArray, "public:\n");
push(@$outputArray, " static ${prototypeClassName}* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)\n");
push(@$outputArray, " {\n");
push(@$outputArray, " ${className}Prototype* ptr = new (NotNull, JSC::allocateCell<${className}Prototype>(vm.heap)) ${className}Prototype(vm, globalObject, structure);\n");
-
- if ($needsGlobalObjectInFinishCreation) {
- push(@$outputArray, " ptr->finishCreation(vm, *globalObject);\n");
- } else {
- push(@$outputArray, " ptr->finishCreation(vm);\n");
- }
-
+ push(@$outputArray, " ptr->finishCreation(vm);\n");
push(@$outputArray, " return ptr;\n");
push(@$outputArray, " }\n\n");
$structureFlags{"JSC::HasStaticPropertyTable"} = 1;
} else {
push(@$outputArray, "\n");
- if ($needsGlobalObjectInFinishCreation) {
- push(@$outputArray, " void finishCreation(JSC::VM&, JSDOMGlobalObject&);\n");
- } else {
- push(@$outputArray, " void finishCreation(JSC::VM&);\n");
- }
+ push(@$outputArray, " void finishCreation(JSC::VM&);\n");
}
}
if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("aSecretAttribute"), strlen("aSecretAttribute"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
}
if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#if ENABLE(TEST_FEATURE)
if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("entries"), strlen("entries"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("keys"), strlen("keys"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("values"), strlen("values"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("forEach"), strlen("forEach"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), DontEnum);
}
static JSTestObjPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
{
JSTestObjPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestObjPrototype>(vm.heap)) JSTestObjPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, *globalObject);
+ ptr->finishCreation(vm);
return ptr;
}
{
}
- void finishCreation(JSC::VM&, JSDOMGlobalObject&);
+ void finishCreation(JSC::VM&);
};
using JSTestObjConstructor = JSDOMConstructor<JSTestObj>;
const ClassInfo JSTestObjPrototype::s_info = { "TestObjectPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestObjPrototype) };
-void JSTestObjPrototype::finishCreation(VM& vm, JSDOMGlobalObject& globalObject)
+void JSTestObjPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestObj::info(), JSTestObjPrototypeTableValues, *this);
if (!RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledAtRuntimeOperation"), strlen("enabledAtRuntimeOperation"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
if (!(worldForDOMObject(this).someWorld() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledInSpecificWorldWhenRuntimeFeatureEnabled"), strlen("enabledInSpecificWorldWhenRuntimeFeatureEnabled"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!worldForDOMObject(this).someWorld()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("worldSpecificMethod"), strlen("worldSpecificMethod"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#if ENABLE(TEST_FEATURE)
if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
#if ENABLE(TEST_FEATURE)
if (!(RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled() && RuntimeEnabledFeatures::sharedFeatures().testFeature1Enabled())) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledAtRuntimeAttribute"), strlen("enabledAtRuntimeAttribute"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, this->globalObject()->globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
- auto* context = globalObject.scriptExecutionContext();
+ auto* context = jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext();
ASSERT(!context || context->isDocument());
#if ENABLE(TEST_FEATURE)
if (!context || !downcast<Document>(*context).settings().testSettingEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledBySettingOperation"), strlen("enabledBySettingOperation"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, globalObject.globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
#if ENABLE(TEST_FEATURE)
if (!context || !downcast<Document>(*context).settings().testSettingEnabled()) {
auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledBySettingAttribute"), strlen("enabledBySettingAttribute"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
- JSObject::deleteProperty(this, globalObject.globalExec(), propertyName);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().privateMethodPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsTestObjPrototypeFunctionPrivateMethod), ReadOnly | DontEnum);
putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateMethodPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsTestObjPrototypeFunctionPublicAndPrivateMethod), ReadOnly | DontEnum);
- putDirect(vm, vm.propertyNames->iteratorSymbol, this->globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), DontEnum);
+ putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), DontEnum);
addValueIterableMethods(*globalObject(), *this);
JSObject& unscopables = *constructEmptyObject(globalObject()->globalExec(), globalObject()->nullPrototypeObjectStructure());
unscopables.putDirect(vm, Identifier::fromString(&vm, "voidMethod"), jsBoolean(true));