diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/bindings/scripts')
5 files changed, 353 insertions, 326 deletions
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm index fe145f4ec..341c60798 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm @@ -40,7 +40,7 @@ my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1 "float" => 1, "double" => 1, "boolean" => 1, "void" => 1); -my %podTypeHash = ("RGBColor" => 1, "SVGNumber" => 1, "SVGTransform" => 1); +my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1); my %podTypesWithWritablePropertiesHash = ("SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGRect" => 1); my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm index 7e80a17a6..6641305a3 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm @@ -596,9 +596,15 @@ sub GenerateCPPAttribute # FIXME: CHECK EXCEPTION AND DO SOMETHING WITH IT - my $setterCall = " impl${implementationClassWithoutNamespace}()->${setterName}(" . join(", ", @setterParams) . ");\n"; - - push(@setterImplementation, $setterCall); + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $CPPImplementationWebCoreIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); + push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->setAttribute(WebCore::HTMLNames::${contentAttributeName}Attr, " . join(", ", @setterParams) . ");\n"); + } else { + push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->${setterName}(" . join(", ", @setterParams) . ");\n"); + } push(@setterImplementation, " return S_OK;\n"); push(@setterImplementation, "}\n\n"); @@ -611,7 +617,17 @@ sub GenerateCPPAttribute push(@getterImplementation, " if (!result)\n"); push(@getterImplementation, " return E_POINTER;\n\n"); - my $implementationGetter = "impl${implementationClassWithoutNamespace}()->" . $codeGenerator->WK_lcfirst($attributeName) . "(" . ($hasGetterException ? "ec" : ""). ")"; + my $implementationGetter; + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $implementationGetter = "impl${implementationClassWithoutNamespace}()->${getAttributeFunctionName}(WebCore::HTMLNames::${contentAttributeName}Attr)"; + } else { + $implementationGetter = "impl${implementationClassWithoutNamespace}()->" . $codeGenerator->WK_lcfirst($attributeName) . "(" . ($hasGetterException ? "ec" : ""). ")"; + } push(@getterImplementation, " WebCore::ExceptionCode ec = 0;\n") if $hasGetterException; diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm index dbcfffffe..26cf3f596 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -119,7 +119,15 @@ sub GetParentClassName my $dataNode = shift; return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"}; - return "DOMObject" if @{$dataNode->parents} eq 0; + if (@{$dataNode->parents} eq 0) { + # FIXME: SVG types requiring a context() pointer do not have enough + # space to hold a globalObject pointer as well w/o hitting the CELL_SIZE limit. + # This could be fixed by moving context() into the various impl() classes. + # Until then, we special case these SVG bindings and allow them to return + # the wrong prototypes and constructors during x-frame access. See bug 27088. + return "DOMObjectWithSVGContext" if IsSVGTypeNeedingContextParameter($dataNode->name); + return "DOMObjectWithGlobalPointer"; + } return "JS" . $codeGenerator->StripModule($dataNode->parents(0)); } @@ -165,7 +173,7 @@ sub AddIncludesForType # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type) - or $type eq "DOMString" or $type eq "DOMObject" or $type eq "RGBColor" or $type eq "Array") { + or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") { } elsif ($type =~ /SVGPathSeg/) { $joinedName = $type; $joinedName =~ s/Abs|Rel//; @@ -219,11 +227,13 @@ sub IsSVGTypeNeedingContextParameter { my $implClassName = shift; - if ($implClassName =~ /SVG/ and not $implClassName =~ /Element/) { - return 1 unless $implClassName =~ /SVGPaint/ or $implClassName =~ /SVGColor/ or $implClassName =~ /SVGDocument/; + return 0 unless $implClassName =~ /SVG/; + return 0 if $implClassName =~ /Element/; + my @noContextNeeded = ("SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent"); + foreach (@noContextNeeded) { + return 0 if $implClassName eq $_; } - - return 0; + return 1; } sub HashValueForClassAndName @@ -358,6 +368,7 @@ sub GenerateHeader my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $needsSVGContext = IsSVGTypeNeedingContextParameter($interfaceName); # - Add default header template @headerContentHeader = split("\r", $headerTemplate); @@ -375,7 +386,8 @@ sub GenerateHeader if ($hasParent) { $headerIncludes{"$parentClassName.h"} = 1; } else { - $headerIncludes{"JSDOMBinding.h"} = 1; + $headerIncludes{"DOMObjectWithSVGContext.h"} = $needsSVGContext; + $headerIncludes{"JSDOMBinding.h"} = !$needsSVGContext; $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1; $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1; } @@ -420,10 +432,12 @@ sub GenerateHeader # Constructor if ($interfaceName eq "DOMWindow") { push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>, JSDOMWindowShell*);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>, SVGElement* context);\n"); + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>, SVGElement* context);\n"); } else { - push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>);\n"); + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>);\n"); } # Destructor @@ -520,7 +534,7 @@ sub GenerateHeader push(@headerContent, " virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupSetter"}; # Constructor object getter - push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"}; + push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"}; my $numCustomFunctions = 0; my $numCustomAttributes = 0; @@ -569,23 +583,11 @@ sub GenerateHeader } if (!$hasParent) { - if ($podType) { - push(@headerContent, " JSSVGPODTypeWrapper<$podType>* impl() const { return m_impl.get(); }\n"); - push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<SVGElement> m_context;\n"); - push(@headerContent, " RefPtr<JSSVGPODTypeWrapper<$podType> > m_impl;\n"); - } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n"); - push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<SVGElement> m_context;\n"); - push(@headerContent, " RefPtr<$implClassName > m_impl;\n"); - } else { - push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<$implClassName> m_impl;\n"); - } + # Extra space after JSSVGPODTypeWrapper<> to make RefPtr<Wrapper<> > compile. + my $implType = $podType ? "JSSVGPODTypeWrapper<$podType> " : $implClassName; + push(@headerContent, " $implType* impl() const { return m_impl.get(); }\n\n"); + push(@headerContent, "private:\n"); + push(@headerContent, " RefPtr<$implType> m_impl;\n"); } elsif ($dataNode->extendedAttributes->{"GenerateNativeConverter"}) { push(@headerContent, " $implClassName* impl() const\n"); push(@headerContent, " {\n"); @@ -623,11 +625,11 @@ sub GenerateHeader if (!$hasParent || $dataNode->extendedAttributes->{"GenerateToJS"} || $dataNode->extendedAttributes->{"CustomToJS"}) { if ($podType) { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSSVGPODTypeWrapper<$podType>*, SVGElement* context);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSSVGPODTypeWrapper<$podType>*, SVGElement* context);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, $implType*, SVGElement* context);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*, SVGElement* context);\n"); } else { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, $implType*);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*);\n"); } } if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) { @@ -640,7 +642,7 @@ sub GenerateHeader } } if ($interfaceName eq "Node" or $interfaceName eq "Element" or $interfaceName eq "Text" or $interfaceName eq "CDATASection") { - push(@headerContent, "JSC::JSValue toJSNewlyCreated(JSC::ExecState*, $interfaceName*);\n"); + push(@headerContent, "JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, $interfaceName*);\n"); } push(@headerContent, "\n"); @@ -651,7 +653,7 @@ sub GenerateHeader push(@headerContent, "public:\n"); if ($interfaceName eq "DOMWindow") { push(@headerContent, " void* operator new(size_t);\n"); - } elsif ($interfaceName eq "WorkerContext") { + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { push(@headerContent, " void* operator new(size_t, JSC::JSGlobalData*);\n"); } else { push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); @@ -901,7 +903,7 @@ sub GenerateImplementation push(@implContent, "{\n"); push(@implContent, " return JSDOMWindow::commonJSGlobalData()->heap.allocate(size);\n"); push(@implContent, "}\n\n"); - } elsif ($interfaceName eq "WorkerContext") { + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { push(@implContent, "void* ${className}Prototype::operator new(size_t size, JSGlobalData* globalData)\n"); push(@implContent, "{\n"); push(@implContent, " return globalData->heap.allocate(size);\n"); @@ -980,22 +982,18 @@ sub GenerateImplementation AddIncludesForType("JSDOMWindowShell"); push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl, JSDOMWindowShell* shell)\n"); push(@implContent, " : $parentClassName(structure, impl, shell)\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + AddIncludesForType($interfaceName); + push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl)\n"); + push(@implContent, " : $parentClassName(structure, impl)\n"); } else { - my $contextArg = ""; - if ($needsSVGContext) { - if ($hasParent && !$parentNeedsSVGContext) { - $contextArg = ", SVGElement*"; - } else { - $contextArg = ", SVGElement* context"; - } - } - push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl$contextArg)\n"); + my $contextArg = $needsSVGContext ? ", SVGElement* context" : ""; + push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl$contextArg)\n"); if ($hasParent) { - push(@implContent, " : $parentClassName(structure, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n"); + push(@implContent, " : $parentClassName(structure, globalObject, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n"); } else { - push(@implContent, " : $parentClassName(structure)\n"); - push(@implContent, " , m_context(context)\n") if $needsSVGContext; - push(@implContent, " , m_impl(impl)\n"); + push(@implContent, " : $parentClassName(structure, globalObject" . ($needsSVGContext ? ", context" : "") . ")\n"); + push(@implContent, " , m_impl(impl)\n"); } } push(@implContent, "{\n"); @@ -1096,6 +1094,7 @@ sub GenerateImplementation push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n"); push(@implContent, "{\n"); + push(@implContent, " ${className}* castedThis = static_cast<$className*>(asObject(slot.slotBase()));\n"); my $implClassNameForValueConversion = ""; if (!$podType and ($codeGenerator->IsSVGAnimatedType($implClassName) or $attribute->type !~ /^readonly/)) { @@ -1105,25 +1104,25 @@ sub GenerateImplementation if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurityOnGet"}) { - push(@implContent, " if (!static_cast<$className*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); push(@implContent, " return jsUndefined();\n"); } if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) { - push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->$implGetterFunctionName(exec);\n"); + push(@implContent, " return castedThis->$implGetterFunctionName(exec);\n"); } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { $implIncludes{"JSDOMBinding.h"} = 1; - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { $implIncludes{"Document.h"} = 1; $implIncludes{"JSDOMBinding.h"} = 1; - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); } elsif ($type eq "EventListener") { $implIncludes{"EventListener.h"} = 1; push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); push(@implContent, " if (EventListener* listener = imp->$implGetterFunctionName()) {\n"); push(@implContent, " if (JSObject* jsFunction = listener->jsFunction())\n"); push(@implContent, " return jsFunction;\n"); @@ -1132,19 +1131,20 @@ sub GenerateImplementation } elsif ($attribute->signature->type =~ /Constructor$/) { my $constructorType = $codeGenerator->StripModule($attribute->signature->type); $constructorType =~ s/Constructor$//; - push(@implContent, " UNUSED_PARAM(slot);\n"); - push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n"); + # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object + # Once DOMObjects have a back-pointer to the globalObject we can pass castedThis->globalObject() + push(@implContent, " return JS" . $constructorType . "::getConstructor(exec, castedThis);\n"); } elsif (!@{$attribute->getterExceptions}) { push(@implContent, " UNUSED_PARAM(exec);\n"); if ($podType) { - push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $podType imp(*castedThis->impl());\n"); if ($podType eq "float") { # Special case for JSSVGNumber - push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "castedThis") . ";\n"); } else { - push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "castedThis") . ";\n"); } } else { - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); my $value; my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; @@ -1156,23 +1156,22 @@ sub GenerateImplementation } else { $value = "imp->$implGetterFunctionName()"; } - my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $value, "static_cast<$className*>(asObject(slot.slotBase()))"); + my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $value, "castedThis"); if ($codeGenerator->IsSVGAnimatedType($type)) { push(@implContent, " RefPtr<$type> obj = $jsType;\n"); - push(@implContent, " return toJS(exec, obj.get(), imp);\n"); + push(@implContent, " return toJS(exec, castedThis->globalObject(), obj.get(), imp);\n"); } else { push(@implContent, " return $jsType;\n"); } } } else { - push(@implContent, " ExceptionCode ec = 0;\n"); - + push(@implContent, " ExceptionCode ec = 0;\n"); if ($podType) { - push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " $podType imp(*castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "castedThis") . ";\n"); } else { - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "castedThis") . ";\n"); } push(@implContent, " setDOMException(exec, ec);\n"); @@ -1193,7 +1192,15 @@ sub GenerateImplementation push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n"); push(@implContent, "{\n"); - push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->getConstructor(exec);\n"); + if (IsSVGTypeNeedingContextParameter($interfaceName)) { + # FIXME: SVG bindings with a context pointer have no space to store a globalObject + # so we use deprecatedGlobalObjectForPrototype instead. + push(@implContent, " UNUSED_PARAM(slot);\n"); + push(@implContent, " return ${className}::getConstructor(exec, deprecatedGlobalObjectForPrototype(exec));\n"); + } else { + push(@implContent, " ${className}* domObject = static_cast<$className*>(asObject(slot.slotBase()));\n"); + push(@implContent, " return ${className}::getConstructor(exec, domObject->globalObject());\n"); + } push(@implContent, "}\n"); } } @@ -1338,8 +1345,8 @@ sub GenerateImplementation } if ($dataNode->extendedAttributes->{"GenerateConstructor"}) { - push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec)\n{\n"); - push(@implContent, " return getDOMConstructor<${className}Constructor>(exec);\n"); + push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n"); + push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n"); push(@implContent, "}\n\n"); } @@ -1361,6 +1368,10 @@ sub GenerateImplementation push(@implContent, " $className* castedThisObj = toJSDOMWindow(thisValue.toThisObject(exec));\n"); push(@implContent, " if (!castedThisObj)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@implContent, " $className* castedThisObj = to${className}(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " return throwError(exec, TypeError);\n"); } else { push(@implContent, " if (!thisValue.isObject(&${className}::s_info))\n"); push(@implContent, " return throwError(exec, TypeError);\n"); @@ -1488,7 +1499,7 @@ sub GenerateImplementation $implIncludes{"KURL.h"} = 1; push(@implContent, " return jsStringOrNull(exec, thisObj->impl()->item(slot.index()));\n"); } else { - push(@implContent, " return toJS(exec, static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n"); + push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n"); } push(@implContent, "}\n"); if ($interfaceName eq "HTMLCollection") { @@ -1499,20 +1510,20 @@ sub GenerateImplementation if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !$dataNode->extendedAttributes->{"CustomToJS"}) { if ($podType) { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSSVGPODTypeWrapper<$podType>* object, SVGElement* context)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, JSSVGPODTypeWrapper<$podType>* object, SVGElement* context)\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, $implType* object, SVGElement* context)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object, SVGElement* context)\n"); } else { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, $implType* object)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n"); } push(@implContent, "{\n"); if ($podType) { - push(@implContent, " return getDOMObjectWrapper<$className, JSSVGPODTypeWrapper<$podType> >(exec, object, context);\n"); + push(@implContent, " return getDOMObjectWrapper<$className, JSSVGPODTypeWrapper<$podType> >(exec, globalObject, object, context);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, " return getDOMObjectWrapper<$className>(exec, object, context);\n"); + push(@implContent, " return getDOMObjectWrapper<$className>(exec, globalObject, object, context);\n"); } else { - push(@implContent, " return getDOMObjectWrapper<$className>(exec, object);\n"); + push(@implContent, " return getDOMObjectWrapper<$className>(exec, globalObject, object);\n"); } push(@implContent, "}\n"); } @@ -1688,11 +1699,9 @@ sub NativeToJSValue $implIncludes{"<runtime/JSString.h>"} = 1; return "jsString(exec, $value)"; } - - if ($type eq "RGBColor") { - $implIncludes{"JS$type.h"} = 1; - return "getJSRGBColor(exec, $value)"; - } + + # Some SVG bindings don't have space to store a globalObject pointer, for those, we use the deprecatedGlobalObjectForPrototype hack for now. + my $globalObject = IsSVGTypeNeedingContextParameter($implClassName) ? "deprecatedGlobalObjectForPrototype(exec)" : "$thisValue->globalObject()"; if ($codeGenerator->IsPodType($type)) { $implIncludes{"JS$type.h"} = 1; @@ -1711,24 +1720,25 @@ sub NativeToJSValue and $codeGenerator->IsPodTypeWithWriteableProperties($type) and not defined $signature->extendedAttributes->{"Immutable"}) { if ($codeGenerator->IsPodType($implClassName)) { - return "toJS(exec, JSSVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($value, $thisValue->impl()).get(), $thisValue->context())"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($value, $thisValue->impl()).get(), $thisValue->context())"; } else { - return "toJS(exec, JSSVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter).get(), imp)"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter).get(), imp)"; } } if ($implClassNameForValueConversion eq "") { - if (IsSVGTypeNeedingContextParameter($implClassName)) { - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), castedThisObj->context())" if $inFunctionCall eq 1; + # SVGZoomEvent has no context() pointer, and is also not an SVGElement. + # This is not a problem, because SVGZoomEvent has no read/write properties. + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), 0)" if $implClassName eq "SVGZoomEvent"; - # Special case: SVGZoomEvent - it doesn't have a context, but it's no problem, as there are no readwrite props - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), 0)" if $implClassName eq "SVGZoomEvent"; - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), $thisValue->context())"; + if (IsSVGTypeNeedingContextParameter($implClassName)) { + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), castedThisObj->context())" if $inFunctionCall; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), $thisValue->context())"; } else { - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), imp)"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), imp)"; } } else { # These classes, always have a m_context pointer! - return "toJS(exec, JSSVGDynamicPODTypeWrapperCache<$nativeType, $implClassNameForValueConversion>::lookupOrCreateWrapper(imp, &${implClassNameForValueConversion}::$getter, &${implClassNameForValueConversion}::$setter).get(), $thisValue->context())"; + return "toJS(exec, $globalObject, JSSVGDynamicPODTypeWrapperCache<$nativeType, $implClassNameForValueConversion>::lookupOrCreateWrapper(imp, &${implClassNameForValueConversion}::$getter, &${implClassNameForValueConversion}::$setter).get(), $thisValue->context())"; } } @@ -1761,18 +1771,15 @@ sub NativeToJSValue return $value if $codeGenerator->IsSVGAnimatedType($type); if (IsSVGTypeNeedingContextParameter($type)) { - if (IsSVGTypeNeedingContextParameter($implClassName)) { - return "toJS(exec, WTF::getPtr($value), $thisValue->context())"; - } else { - return "toJS(exec, WTF::getPtr($value), imp)"; - } + my $contextPtr = IsSVGTypeNeedingContextParameter($implClassName) ? "$thisValue->context()" : "imp"; + return "toJS(exec, $globalObject, WTF::getPtr($value), $contextPtr)"; } if ($signature->extendedAttributes->{"ReturnsNew"}) { - return "toJSNewlyCreated(exec, WTF::getPtr($value))"; + return "toJSNewlyCreated(exec, $globalObject, WTF::getPtr($value))"; } - return "toJS(exec, WTF::getPtr($value))"; + return "toJS(exec, $globalObject, WTF::getPtr($value))"; } sub ceilingToPowerOf2 @@ -2023,14 +2030,15 @@ sub constructorFor my $interfaceName = shift; my $visibleClassName = shift; my $canConstruct = shift; + my $constructorClassName = "${className}Constructor"; my $implContent = << "EOF"; -class ${className}Constructor : public DOMObject { +class ${constructorClassName} : public DOMConstructorObject { public: - ${className}Constructor(ExecState* exec) - : DOMObject(${className}Constructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) + ${constructorClassName}(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), None); } virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual const ClassInfo* classInfo() const { return &s_info; } @@ -2044,13 +2052,13 @@ EOF if ($canConstruct) { $implContent .= << "EOF"; - static JSObject* construct(ExecState* exec, JSObject*, const ArgList&) + static JSObject* construct${interfaceName}(ExecState* exec, JSObject* constructor, const ArgList&) { - return asObject(toJS(exec, ${interfaceName}::create())); + return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create())); } virtual ConstructType getConstructData(ConstructData& constructData) { - constructData.native.function = construct; + constructData.native.function = construct${interfaceName}; return ConstructTypeHost; } EOF @@ -2059,16 +2067,16 @@ EOF $implContent .= << "EOF"; }; -const ClassInfo ${className}Constructor::s_info = { "${visibleClassName}Constructor", 0, &${className}ConstructorTable, 0 }; +const ClassInfo ${constructorClassName}::s_info = { "${visibleClassName}Constructor", 0, &${constructorClassName}Table, 0 }; -bool ${className}Constructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +bool ${constructorClassName}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<${className}Constructor, DOMObject>(exec, &${className}ConstructorTable, this, propertyName, slot); + return getStaticValueSlot<${constructorClassName}, DOMObject>(exec, &${constructorClassName}Table, this, propertyName, slot); } EOF - $implJSCInclude{"JSNumberCell.h"} = 1; + $implJSCInclude{"JSNumberCell.h"} = 1; # FIXME: What is this for? return $implContent; } diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 10628b464..d46d88a72 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -515,15 +515,17 @@ sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); - return if $codeGenerator->IsNonPointerType($type) or IsNativeObjCType($type); + return if $codeGenerator->IsNonPointerType($type); - if ($codeGenerator->IsStringType($type)) { - $implIncludes{"KURL.h"} = 1; + if (IsNativeObjCType($type)) { + if ($type eq "Color") { + $implIncludes{"ColorMac.h"} = 1; + } return; } - if ($type eq "RGBColor") { - $implIncludes{"DOMRGBColorInternal.h"} = 1; + if ($codeGenerator->IsStringType($type)) { + $implIncludes{"KURL.h"} = 1; return; } @@ -924,8 +926,6 @@ sub GenerateHeader if ($codeGenerator->IsSVGAnimatedType($interfaceName)) { push(@internalHeaderContent, "#import <WebCore/SVGAnimatedTemplate.h>\n\n"); - } elsif ($interfaceName eq "RGBColor") { - push(@internalHeaderContent, "#import <WebCore/Color.h>\n\n"); } else { push(@internalHeaderContent, "namespace WebCore {\n"); $startedNamespace = 1; @@ -1198,6 +1198,9 @@ sub GenerateImplementation } elsif (IsProtocolType($idlType) and $idlType ne "EventTarget") { $getterContentHead = "kit($getterContentHead"; $getterContentTail .= ")"; + } elsif ($idlType eq "Color") { + $getterContentHead = "WebCore::nsColor($getterContentHead"; + $getterContentTail .= ")"; } elsif (ConversionNeeded($attribute->signature->type)) { $getterContentHead = "kit(WTF::getPtr($getterContentHead"; $getterContentTail .= "))"; diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm index cdadf8178..862649fb1 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -113,7 +113,6 @@ sub WK_lcfirst sub IsPodType { my $type = shift; - return 0 if $type eq "RGBColor"; return $codeGenerator->IsPodType($type); } @@ -243,6 +242,18 @@ sub GetImplementationFileName return "${iface}.h"; } +# If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if. +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } else { + return ""; + } +} + sub GenerateHeader { my $object = shift; @@ -257,17 +268,12 @@ sub GenerateHeader $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template @headerContent = split("\r", $headerTemplate); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@headerContent, "\n#if ${conditionalString}\n\n"); - } - + push(@headerContent, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "\n#ifndef $className" . "_H"); push(@headerContent, "\n#define $className" . "_H\n\n"); @@ -310,7 +316,7 @@ END push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_H\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; } @@ -422,17 +428,12 @@ END if ($classIndex eq "DOMWINDOW") { push(@implContentDecls, <<END); DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder()); - Frame* frame = window->frame(); - if (frame) { - // Get the proxy corresponding to the DOMWindow if possible to - // make sure that the constructor function is constructed in the - // context of the DOMWindow and not in the context of the caller. - return V8Proxy::retrieve(frame)->getConstructor(type); - } + // Get the proxy corresponding to the DOMWindow if possible to + // make sure that the constructor function is constructed in the + // context of the DOMWindow and not in the context of the caller. + return V8DOMWrapper::getConstructor(type, window); END - } - - if ($classIndex eq "WORKERCONTEXT") { + } elsif ($classIndex eq "DEDICATEDWORKERCONTEXT" or $classIndex eq "WORKERCONTEXT") { $implIncludes{"WorkerContextExecutionProxy.h"} = 1; push(@implContentDecls, <<END); return WorkerContextExecutionProxy::retrieve()->GetConstructor(type); @@ -547,54 +548,60 @@ END my $getterString; if ($getterStringUsesImp) { - $getterString = "imp->$getterFunc("; - $getterString .= "ec" if $useExceptions; - $getterString .= ")"; - if (IsRefPtrType($returnType)) { - $implIncludes{"wtf/GetPtr.h"} = 1; - $getterString = "WTF::getPtr(" . $getterString . ")"; - } - if ($nativeType eq "int" and - $attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $getterString .= ".toInt()"; - } + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $getterString = "imp->$getAttributeFunctionName(HTMLNames::${contentAttributeName}Attr"; } else { - $getterString = "imp_instance"; + $getterString = "imp->$getterFunc("; } - if ($nativeType eq "String") { - $getterString = "toString($getterString)"; + $getterString .= "ec" if $useExceptions; + $getterString .= ")"; + if ($nativeType eq "int" and $attribute->signature->extendedAttributes->{"ConvertFromString"}) { + $getterString .= ".toInt()"; } + } else { + $getterString = "imp_instance"; + } - my $result; - my $wrapper; + if ($nativeType eq "String") { + $getterString = "toString($getterString)"; + } - if ($attrIsPodType) { - $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; + my $result; + my $wrapper; + + if ($attrIsPodType) { + $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; - my $getter = $getterString; - $getter =~ s/imp->//; - $getter =~ s/\(\)//; - my $setter = "set" . WK_ucfirst($getter); + my $getter = $getterString; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + my $setter = "set" . WK_ucfirst($getter); - my $implClassIsAnimatedType = $codeGenerator->IsSVGAnimatedType($implClassName); - if (not $implClassIsAnimatedType - and $codeGenerator->IsPodTypeWithWriteableProperties($attrType) - and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { + my $implClassIsAnimatedType = $codeGenerator->IsSVGAnimatedType($implClassName); + if (not $implClassIsAnimatedType and $codeGenerator->IsPodTypeWithWriteableProperties($attrType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { if (IsPodType($implClassName)) { - $wrapper = "new V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>($getterString, imp_wrapper)"; + my $wrapper = "V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($getterString, imp_wrapper)"; + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName> > wrapper = $wrapper;\n"); } else { - $wrapper = "new V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + my $wrapper = "V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName> > wrapper = $wrapper;\n"); } } else { if ($implClassIsAnimatedType) { - $wrapper = "V8SVGDynamicPODTypeWrapperCache<$nativeType, $implClassName>::lookupOrCreateWrapper(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + my $wrapper = "V8SVGDynamicPODTypeWrapperCache<$nativeType, $implClassName>::lookupOrCreateWrapper(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + push(@implContentDecls, " RefPtr<V8SVGPODTypeWrapper<" . $nativeType . "> > wrapper = $wrapper;\n"); } else { - $wrapper = GenerateSVGStaticPodTypeWrapper($returnType, $getterString); + my $wrapper = GenerateSVGStaticPodTypeWrapper($returnType, $getterString); + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapper<" . $nativeType . "> > wrapper = $wrapper;\n"); } } - push(@implContentDecls, " void* wrapper = $wrapper;\n"); - } elsif ($nativeType ne "RGBColor") { + } else { push(@implContentDecls, " $nativeType v = "); push(@implContentDecls, "$getterString;\n"); @@ -604,28 +611,22 @@ END } $result = "v"; - if (IsRefPtrType($returnType)) { - $result = "WTF::getPtr(" . $result . ")"; - } - } else { - # Special case: RGBColor is noncopyable - $result = $getterString; } - if (IsSVGTypeNeedingContextParameter($attrType) && !$skipContext) { my $resultObject = $result; if ($attrIsPodType) { $resultObject = "wrapper"; } - + $resultObject = "WTF::getPtr(" . $resultObject . ")"; push(@implContentDecls, GenerateSVGContextAssignment($implClassName, $resultObject, " ")); } if ($attrIsPodType) { my $classIndex = uc($attrType); - push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper);\n"); + push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"); } else { + $result .= ".release()" if (IsRefPtrType($attrType)); push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); } @@ -718,7 +719,16 @@ END if ($implClassName eq "double") { push(@implContentDecls, " *imp = $result;\n"); } else { - push(@implContentDecls, " imp->set" . WK_ucfirst($attrName) . "(" . $result); + my $implSetterFunctionName = WK_ucfirst($attrName); + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); + push(@implContentDecls, " imp->setAttribute(HTMLNames::${contentAttributeName}Attr, $result"); + } else { + push(@implContentDecls, " imp->set$implSetterFunctionName(" . $result); + } push(@implContentDecls, ", ec") if $useExceptions; push(@implContentDecls, ");\n"); } @@ -800,7 +810,7 @@ sub GenerateFunctionCallback push(@implContentDecls, " $nativeClassName* imp = &imp_instance;\n"); } else { push(@implContentDecls, <<END); - v8::Handle<v8::Value> holder = args.Holder(); + v8::Handle<v8::Object> holder = args.Holder(); END HolderToNative($dataNode, $implClassName, $classIndex); } @@ -892,134 +902,138 @@ sub GenerateBatchedAttributeData $accessControl = "v8::ALL_CAN_WRITE"; } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) { $accessControl = "v8::ALL_CAN_READ"; - if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) { - $accessControl .= "|v8::ALL_CAN_WRITE"; + if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) { + $accessControl .= "|v8::ALL_CAN_WRITE"; + } } - } - if ($attrExt->{"V8DisallowShadowing"}) { - $accessControl .= "|v8::PROHIBITS_OVERWRITING"; - } - $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; - - my $customAccessor = - $attrExt->{"Custom"} || - $attrExt->{"CustomSetter"} || - $attrExt->{"CustomGetter"} || - $attrExt->{"V8Custom"} || - $attrExt->{"V8CustomSetter"} || - $attrExt->{"V8CustomGetter"} || - ""; - if ($customAccessor eq 1) { - # use the naming convension, interface + (capitalize) attr name - $customAccessor = $interfaceName . WK_ucfirst($attrName); - } - - my $getter; - my $setter; - my $propAttr = "v8::None"; - my $hasCustomSetter = 0; - - # Check attributes. - if ($attrExt->{"DontEnum"}) { - $propAttr .= "|v8::DontEnum"; - } - if ($attrExt->{"V8DisallowShadowing"}) { - $propAttr .= "|v8::DontDelete"; - } - - my $on_proto = "0 /* on instance */"; - my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */"; - - # Constructor - if ($attribute->signature->type =~ /Constructor$/) { - my $constructorType = $codeGenerator->StripModule($attribute->signature->type); - $constructorType =~ s/Constructor$//; - my $constructorIndex = uc($constructorType); - $data = "V8ClassIndex::${constructorIndex}"; - $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; - $setter = "0"; - $propAttr = "v8::ReadOnly"; - - # EventListeners - } elsif ($attribute->signature->type eq "EventListener") { - if ($interfaceName eq "DOMWindow") { - $getter = "V8Custom::v8DOMWindowEventHandlerAccessorGetter"; - $setter = "V8Custom::v8DOMWindowEventHandlerAccessorSetter"; - } elsif ($interfaceName eq "Element" || $interfaceName eq "Document" || $interfaceName eq "HTMLBodyElement" || $interfaceName eq "SVGElementInstance" || $interfaceName eq "HTMLFrameSetElement") { - $getter = "V8Custom::v8ElementEventHandlerAccessorGetter"; - $setter = "V8Custom::v8ElementEventHandlerAccessorSetter"; - } else { + if ($attrExt->{"V8DisallowShadowing"}) { + $accessControl .= "|v8::PROHIBITS_OVERWRITING"; + } + $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; + + my $customAccessor = + $attrExt->{"Custom"} || + $attrExt->{"CustomSetter"} || + $attrExt->{"CustomGetter"} || + $attrExt->{"V8Custom"} || + $attrExt->{"V8CustomSetter"} || + $attrExt->{"V8CustomGetter"} || + ""; + if ($customAccessor eq 1) { + # use the naming convension, interface + (capitalize) attr name + $customAccessor = $interfaceName . WK_ucfirst($attrName); + } + + my $getter; + my $setter; + my $propAttr = "v8::None"; + my $hasCustomSetter = 0; + + # Check attributes. + if ($attrExt->{"DontEnum"}) { + $propAttr .= "|v8::DontEnum"; + } + if ($attrExt->{"V8DisallowShadowing"}) { + $propAttr .= "|v8::DontDelete"; + } + + my $on_proto = "0 /* on instance */"; + my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */"; + + # Constructor + if ($attribute->signature->type =~ /Constructor$/) { + my $constructorType = $codeGenerator->StripModule($attribute->signature->type); + $constructorType =~ s/Constructor$//; + my $constructorIndex = uc($constructorType); + $data = "V8ClassIndex::${constructorIndex}"; + $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; + $setter = "0"; + $propAttr = "v8::ReadOnly"; + + # EventListeners + } elsif ($attribute->signature->type eq "EventListener") { + if ($interfaceName eq "DOMWindow") { + $getter = "V8Custom::v8DOMWindowEventHandlerAccessorGetter"; + $setter = "V8Custom::v8DOMWindowEventHandlerAccessorSetter"; + } elsif ($interfaceName eq "Element" || $interfaceName eq "Document" || $interfaceName eq "HTMLBodyElement" || $interfaceName eq "SVGElementInstance" || $interfaceName eq "HTMLFrameSetElement") { + $getter = "V8Custom::v8ElementEventHandlerAccessorGetter"; + $setter = "V8Custom::v8ElementEventHandlerAccessorSetter"; + } else { + $getter = "V8Custom::v8${customAccessor}AccessorGetter"; + if ($interfaceName eq "WorkerContext" and $attrName eq "self") { + $setter = "0"; + $propAttr = "v8::ReadOnly"; + } else { + $setter = "V8Custom::v8${customAccessor}AccessorSetter"; + } + } + + # Custom Getter and Setter + } elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { $getter = "V8Custom::v8${customAccessor}AccessorGetter"; if ($interfaceName eq "WorkerContext" and $attrName eq "self") { $setter = "0"; $propAttr = "v8::ReadOnly"; } else { + $hasCustomSetter = 1; $setter = "V8Custom::v8${customAccessor}AccessorSetter"; } - } - # Custom Getter and Setter - } elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - if ($interfaceName eq "WorkerContext" and $attrName eq "self") { - $setter = "0"; - $propAttr = "v8::ReadOnly"; - } else { + # Custom Setter + } elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) { $hasCustomSetter = 1; + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; $setter = "V8Custom::v8${customAccessor}AccessorSetter"; + + # Custom Getter + } elsif ($attrExt->{"CustomGetter"}) { + $getter = "V8Custom::v8${customAccessor}AccessorGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; + + # Replaceable + } elsif ($attrExt->{"Replaceable"}) { + # Replaceable accessor is put on instance template with ReadOnly attribute. + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "0"; + + # Mark to avoid duplicate v8::ReadOnly flags in output. + $hasCustomSetter = 1; + + # Handle the special case of window.top being marked upstream as Replaceable. + # FIXME: Investigate why [Replaceable] is not marked as ReadOnly + # upstream and reach parity. + if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { + $propAttr .= "|v8::ReadOnly"; + } + + # Normal + } else { + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; } - # Custom Setter - } elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) { - $hasCustomSetter = 1; - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "V8Custom::v8${customAccessor}AccessorSetter"; - - # Custom Getter - } elsif ($attrExt->{"CustomGetter"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - - # Replaceable - } elsif ($attrExt->{"Replaceable"}) { - # Replaceable accessor is put on instance template with ReadOnly attribute. - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "0"; - - # Mark to avoid duplicate v8::ReadOnly flags in output. - $hasCustomSetter = 1; - - # Handle the special case of window.top being marked upstream as Replaceable. - # FIXME: Investigate why [Replaceable] is not marked as ReadOnly - # upstream and reach parity. - if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { + if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { + $setter = "0"; $propAttr .= "|v8::ReadOnly"; } - # Normal - } else { - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - } - - if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { - $setter = "0"; - $propAttr .= "|v8::ReadOnly"; - } + # Read only attributes + if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) { + $setter = "0"; + } - # Read only attributes - if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) { - $setter = "0"; - } + # An accessor can be installed on the proto + if ($attrExt->{"v8OnProto"}) { + $on_proto = "1 /* on proto */"; + } - # An accessor can be installed on the proto - if ($attrExt->{"v8OnProto"}) { - $on_proto = "1 /* on proto */"; - } + my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . + "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; + + my $conditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . - "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; - push(@implContent, <<END); + push(@implContent, <<END); // $commentInfo { "$attrName", $getter, @@ -1029,6 +1043,7 @@ sub GenerateBatchedAttributeData static_cast<v8::PropertyAttribute>($propAttr), $on_proto }, END + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } } @@ -1043,7 +1058,7 @@ sub GenerateImplementation my $classIndex = uc($codeGenerator->StripModule($interfaceName)); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $conditionalString = GenerateConditionalString($dataNode); @allParents = $codeGenerator->FindParentsRecursively($dataNode); @@ -1056,11 +1071,7 @@ sub GenerateImplementation "#include \"V8Binding.h\"\n\n" . "#undef LOG\n\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implFixedHeader, "\n#if ${conditionalString}\n\n"); - } + push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; if ($className =~ /^V8SVGAnimated/) { AddIncludesForSVGAnimatedType($interfaceName); @@ -1376,7 +1387,7 @@ END } // namespace WebCore END - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } @@ -1466,13 +1477,6 @@ sub GenerateFunctionCallString() } $functionString .= ")"; - if ((IsRefPtrType($returnType) || $returnsListItemPodType) && !$nodeToReturn) { - # We don't use getPtr when $nodeToReturn because that situation is - # special-cased below to return a bool. - $implIncludes{"wtf/GetPtr.h"} = 1; - $functionString = "WTF::getPtr(" . $functionString . ")"; - } - if ($nodeToReturn) { # Special case for insertBefore, replaceChild, removeChild and # appendChild functions from Node. @@ -1502,18 +1506,14 @@ sub GenerateFunctionCallString() } my $return = "result"; - if (IsRefPtrType($returnType) || $returnsListItemPodType) { - $implIncludes{"wtf/GetPtr.h"} = 1; - $return = "WTF::getPtr(" . $return . ")"; - } # If the return type is a POD type, separate out the wrapper generation if ($returnsListItemPodType) { - $result .= $indent . "V8SVGPODTypeWrapper<" . $nativeReturnType . ">* wrapper = new "; - $result .= "V8SVGPODTypeWrapperCreatorForList<" . $nativeReturnType . ">($return, imp->associatedAttributeName());\n"; + $result .= $indent . "RefPtr<V8SVGPODTypeWrapper<" . $nativeReturnType . "> > wrapper = "; + $result .= "V8SVGPODTypeWrapperCreatorForList<" . $nativeReturnType . ">::create($return, imp->associatedAttributeName());\n"; $return = "wrapper"; } elsif ($returnsPodType) { - $result .= $indent . "V8SVGPODTypeWrapper<" . $nativeReturnType . ">* wrapper = "; + $result .= $indent . "RefPtr<V8SVGPODTypeWrapper<" . $nativeReturnType . "> > wrapper = "; $result .= GenerateSVGStaticPodTypeWrapper($returnType, $return) . ";\n"; $return = "wrapper"; } @@ -1521,7 +1521,7 @@ sub GenerateFunctionCallString() my $generatedSVGContextRetrieval = 0; # If the return type needs an SVG context, output it if (IsSVGTypeNeedingContextParameter($returnType)) { - $result .= GenerateSVGContextAssignment($implClassName, $return, $indent); + $result .= GenerateSVGContextAssignment($implClassName, $return . ".get()", $indent); $generatedSVGContextRetrieval = 1; } @@ -1547,8 +1547,9 @@ sub GenerateFunctionCallString() if ($returnsPodType) { my $classIndex = uc($returnType); - $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper);\n"; + $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"; } else { + $return .= ".release()" if (IsRefPtrType($returnType)); $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; } @@ -1688,7 +1689,6 @@ sub GetNativeType return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; return "DOMTimeStamp" if $type eq "DOMTimeStamp"; return "unsigned" if $type eq "unsigned int"; - return "unsigned" if $type eq "RGBColor"; return "Node*" if $type eq "EventTarget" and $isParameter; return "String" if $type eq "DOMUserData"; # FIXME: Temporary hack? @@ -1828,7 +1828,7 @@ sub JSValueToNative $implIncludes{"V8Node.h"} = 1; # EventTarget is not in DOM hierarchy, but all Nodes are EventTarget. - return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>($value) : 0"; + return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast($value)) : 0"; } AddIncludesForType($type); @@ -1839,7 +1839,7 @@ sub JSValueToNative # Perform type checks on the parameter, if it is expected Node type, # return NULL. - return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<${type}>($value) : 0"; + return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<${type}>(v8::Handle<v8::Object>::Cast($value)) : 0"; } else { # TODO: Temporary to avoid Window name conflict. my $classIndex = uc($type); @@ -1858,7 +1858,7 @@ sub JSValueToNative # Perform type checks on the parameter, if it is expected Node type, # return NULL. - return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertToNativeObject<${implClassName}>(V8ClassIndex::${classIndex}, $value) : 0"; + return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertToNativeObject<${implClassName}>(V8ClassIndex::${classIndex}, v8::Handle<v8::Object>::Cast($value)) : 0"; } } @@ -2028,13 +2028,12 @@ sub ReturnNativeToJSValue return "return V8DOMWrapper::convertEventListenerToV8Object($value)"; } - if ($type eq "RGBColor") { - my $construct = "RefPtr<RGBColor> rgbcolor = RGBColor::create($value);\n"; - my $convert = "V8DOMWrapper::convertToV8Object(V8ClassIndex::RGBCOLOR, WTF::getPtr(rgbcolor))"; - return $construct . $indent . "return " . $convert; + if ($type eq "DedicatedWorkerContext" or $type eq "WorkerContext") { + $implIncludes{"WorkerContextExecutionProxy.h"} = 1; + return "return WorkerContextExecutionProxy::WorkerContextToV8Object($value)"; } - if ($type eq "WorkerContext" or $type eq "WorkerLocation" or $type eq "WorkerNavigator") { + if ($type eq "WorkerLocation" or $type eq "WorkerNavigator") { $implIncludes{"WorkerContextExecutionProxy.h"} = 1; my $classIndex = uc($type); @@ -2044,6 +2043,7 @@ sub ReturnNativeToJSValue else { $implIncludes{"wtf/RefCounted.h"} = 1; $implIncludes{"wtf/RefPtr.h"} = 1; + $implIncludes{"wtf/GetPtr.h"} = 1; my $classIndex = uc($type); if (IsPodType($type)) { @@ -2062,7 +2062,7 @@ sub GenerateSVGStaticPodTypeWrapper { $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; my $nativeType = GetNativeType($type); - return "new V8SVGStaticPODTypeWrapper<$nativeType>($value)"; + return "V8SVGStaticPODTypeWrapper<$nativeType>::create($value)"; } # Internal helper @@ -2122,7 +2122,7 @@ sub GenerateSVGContextAssignment my $indent = shift; $result = GenerateSVGContextRetrieval($srcType, $indent); - $result .= $indent . "V8Proxy::setSVGContext($value, context);\n"; + $result .= $indent . "V8Proxy::setSVGContext($value, context);\n"; return $result; } |