Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (152167 => 152168)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-06-28 15:58:03 UTC (rev 152167)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-06-28 16:01:32 UTC (rev 152168)
@@ -347,6 +347,12 @@
return $interface->extendedAttributes->{"CustomIsReachable"};
}
+sub IsDOMGlobalObject
+{
+ my $interface = shift;
+ return $interface->name eq "DOMWindow" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope");
+}
+
sub GenerateGetOwnPropertySlotBody
{
my ($interface, $interfaceName, $className, $hasAttributes, $inlined) = @_;
@@ -723,7 +729,7 @@
$headerIncludes{"$interfaceName.h"} = 1;
} else {
# Implementation class forward declaration
- if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ if (IsDOMGlobalObject($interface)) {
AddClassForwardIfNeeded($interfaceName) unless $svgPropertyOrListPropertyType;
}
}
@@ -745,7 +751,7 @@
push(@headerContent, " vm.heap.addFinalizer(ptr, destroy);\n");
push(@headerContent, " return ptr;\n");
push(@headerContent, " }\n\n");
- } elsif ($interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
push(@headerContent, " static $className* create(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<$implType> impl)\n");
push(@headerContent, " {\n");
push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(vm.heap)) ${className}(vm, structure, impl);\n");
@@ -772,12 +778,12 @@
push(@headerContent, " }\n\n");
}
- if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ if (IsDOMGlobalObject($interface)) {
push(@headerContent, " static const bool needsDestruction = false;\n\n");
}
# Prototype
- push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($interface->extendedAttributes->{"ExtendsDOMGlobalObject"});
+ push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless IsDOMGlobalObject($interface);
$headerTrailingIncludes{"${className}Custom.h"} = 1 if $interface->extendedAttributes->{"JSCustomHeader"};
@@ -851,7 +857,7 @@
}
push(@headerContent, " static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n");
push(@headerContent, " {\n");
- if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ if (IsDOMGlobalObject($interface)) {
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);\n");
} else {
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n");
@@ -995,7 +1001,7 @@
# Constructor
if ($interfaceName eq "DOMWindow") {
push(@headerContent, " $className(JSC::VM&, JSC::Structure*, PassRefPtr<$implType>, JSDOMWindowShell*);\n");
- } elsif ($interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
push(@headerContent, " $className(JSC::VM&, JSC::Structure*, PassRefPtr<$implType>);\n");
} else {
push(@headerContent, " $className(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<$implType>);\n");
@@ -1097,7 +1103,7 @@
push(@headerContent, "class ${className}Prototype : public JSC::JSNonFinalObject {\n");
push(@headerContent, "public:\n");
push(@headerContent, " typedef JSC::JSNonFinalObject Base;\n");
- if ($interfaceName ne "DOMWindow" && !$interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ unless (IsDOMGlobalObject($interface)) {
push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n");
}
@@ -1781,7 +1787,7 @@
} else {
push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, &${className}PrototypeTable, 0, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
}
- if ($interfaceName ne "DOMWindow" && !$interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ unless (IsDOMGlobalObject($interface)) {
push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec, JSGlobalObject* globalObject)\n");
push(@implContent, "{\n");
push(@implContent, " return getDOMPrototype<${className}>(exec, globalObject);\n");
@@ -1867,7 +1873,7 @@
push(@implContent, " : $parentClassName(vm, structure, impl, shell)\n");
push(@implContent, "{\n");
push(@implContent, "}\n\n");
- } elsif ($interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
AddIncludesForTypeInImpl($interfaceName);
push(@implContent, "${className}::$className(VM& vm, Structure* structure, PassRefPtr<$implType> impl)\n");
push(@implContent, " : $parentClassName(vm, structure, impl)\n");
@@ -1897,7 +1903,7 @@
push(@implContent, "}\n\n");
}
- if (!$interface->extendedAttributes->{"ExtendsDOMGlobalObject"}) {
+ unless (IsDOMGlobalObject($interface)) {
push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n");
push(@implContent, "{\n");
if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") {
@@ -2070,7 +2076,7 @@
push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n");
push(@implContent, " if (EventListener* listener = impl->$implGetterFunctionName()) {\n");
push(@implContent, " if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
- if ($interfaceName eq "Document" || $interfaceName eq "WorkerGlobalScope" || $interfaceName eq "SharedWorkerGlobalScope" || $interfaceName eq "DedicatedWorkerGlobalScope") {
+ if ($interfaceName eq "Document" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(impl))\n");
} else {
push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n");
@@ -2521,7 +2527,7 @@
push(@implContent, " $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThisObject(exec));\n");
push(@implContent, " if (!castedThis)\n");
push(@implContent, " return throwVMTypeError(exec);\n");
- } elsif ($interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
push(@implContent, " $className* castedThis = to${className}(exec->hostThisValue().toThisObject(exec));\n");
push(@implContent, " if (!castedThis)\n");
push(@implContent, " return throwVMTypeError(exec);\n");
@@ -4304,7 +4310,7 @@
push(@$outputArray, "void ${constructorClassName}::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)\n");
push(@$outputArray, "{\n");
- if ($interfaceName eq "DOMWindow" || $interface->extendedAttributes->{"IsWorkerGlobalScope"}) {
+ if (IsDOMGlobalObject($interface)) {
push(@$outputArray, " Base::finishCreation(exec->vm());\n");
push(@$outputArray, " ASSERT(inherits(&s_info));\n");
push(@$outputArray, " putDirect(exec->vm(), exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n");