Title: [134492] branches/safari-536.28-branch/Source/WebCore
Revision
134492
Author
[email protected]
Date
2012-11-13 15:06:44 -0800 (Tue, 13 Nov 2012)

Log Message

Merged r123433.  <rdar://problem/12516346>

Modified Paths

Diff

Modified: branches/safari-536.28-branch/Source/WebCore/ChangeLog (134491 => 134492)


--- branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-13 22:55:04 UTC (rev 134491)
+++ branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-13 23:06:44 UTC (rev 134492)
@@ -1,5 +1,40 @@
 2012-11-13  Lucas Forschler  <[email protected]>
 
+        Merge r123433
+
+    2012-07-24  Kentaro Hara  <[email protected]>
+
+            [JSC] REGRESSION(r122912): CodeGeneratorJS.pm should not
+            implicitly assume ScriptExecutionContext for static attributes
+            https://bugs.webkit.org/show_bug.cgi?id=91924
+
+            Reviewed by Adam Barth.
+
+            r122912 implemented static attributes in CodeGeneratorJS.pm.
+            However, the generated code assumes that static attributes
+            always require ScriptExecutionContext, which is wrong.
+            If we need a ScriptExecutionContext, we should specify
+            [CallWith=ScriptExecutionContext].
+
+            This patch fixes CodeGeneratorJS.pm so that static attributes
+            do not assume ScriptExecutionContext. This fix aligns with
+            the fix in CodeGeneratorV8.pm in r123308.
+
+            Test: bindings/scripts/test/TestObj.idl
+
+            * bindings/scripts/CodeGeneratorJS.pm:
+            (GenerateImplementation):
+            * bindings/scripts/test/JS/JSTestInterface.cpp:
+            (WebCore::jsTestInterfaceConstructorSupplementalStaticReadOnlyAttr):
+            (WebCore::jsTestInterfaceConstructorSupplementalStaticAttr):
+            (WebCore::setJSTestInterfaceConstructorSupplementalStaticAttr):
+            * bindings/scripts/test/JS/JSTestObj.cpp:
+            (WebCore::jsTestObjConstructorStaticReadOnlyIntAttr):
+            (WebCore::jsTestObjConstructorStaticStringAttr):
+            (WebCore::setJSTestObjConstructorStaticStringAttr):
+
+2012-11-13  Lucas Forschler  <[email protected]>
+
         Merge r122912
 
     2012-07-17  Jon Lee  <[email protected]>
@@ -207476,3 +207511,4 @@
 .
 .
 .
+.

Modified: branches/safari-536.28-branch/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (134491 => 134492)


--- branches/safari-536.28-branch/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-11-13 22:55:04 UTC (rev 134491)
+++ branches/safari-536.28-branch/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-11-13 23:06:44 UTC (rev 134492)
@@ -1725,119 +1725,115 @@
                 push(@implContent, ", const Identifier&)\n");
                 push(@implContent, "{\n");
 
-                if ($attribute->isStatic) {
-                    push(@implContent, "    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n");
-                    push(@implContent, "    if (!scriptContext)\n");
-                    push(@implContent, "        return jsUndefined();\n");
-                    push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "${implClassName}::$implGetterFunctionName(scriptContext)", "") . ";\n");
-                    push(@implContent, "    return result;\n");
-                } else {
+                if (!$attribute->isStatic) {
                     push(@implContent, "    ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n");
+                }
 
-                    if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
-                        $needsMarkChildren = 1;
+                if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
+                    $needsMarkChildren = 1;
+                }
+
+                if ($dataNode->extendedAttributes->{"CheckSecurity"} &&
+                    !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} &&
+                    !$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) {
+                    push(@implContent, "    if (!castedThis->allowsAccessFrom(exec))\n");
+                    push(@implContent, "        return jsUndefined();\n");
+                }
+
+                if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) {
+                    push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
+                } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) {
+                    $implIncludes{"JSDOMBinding.h"} = 1;
+                    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
+                    push(@implContent, "    return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n");
+                } elsif ($type eq "EventListener") {
+                    $implIncludes{"EventListener.h"} = 1;
+                    push(@implContent, "    UNUSED_PARAM(exec);\n");
+                    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
+                    push(@implContent, "    if (EventListener* listener = impl->$implGetterFunctionName()) {\n");
+                    push(@implContent, "        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
+                    if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") {
+                        push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl))\n");
+                    } else {
+                        push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n");
                     }
+                    push(@implContent, "                return jsFunction;\n");
+                    push(@implContent, "        }\n");
+                    push(@implContent, "    }\n");
+                    push(@implContent, "    return jsNull();\n");
+                } elsif ($attribute->signature->type =~ /Constructor$/) {
+                    my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
+                    $constructorType =~ s/Constructor$//;
+                    # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object
+                    # Once JSDOMWrappers 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 !$attribute->signature->extendedAttributes->{"CallWith"};
 
-                    if ($dataNode->extendedAttributes->{"CheckSecurity"} &&
-                            !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} &&
-                            !$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) {
-                        push(@implContent, "    if (!castedThis->allowsAccessFrom(exec))\n");
-                        push(@implContent, "        return jsUndefined();\n");
+                    my $cacheIndex = 0;
+                    if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
+                        $cacheIndex = $currentCachedAttribute;
+                        $currentCachedAttribute++;
+                        push(@implContent, "    if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n");
+                        push(@implContent, "        return cachedValue;\n");
                     }
 
-                    if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) {
-                        push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
-                    } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) {
-                        $implIncludes{"JSDOMBinding.h"} = 1;
-                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
-                        push(@implContent, "    return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n");
-                    } elsif ($type eq "EventListener") {
-                        $implIncludes{"EventListener.h"} = 1;
-                        push(@implContent, "    UNUSED_PARAM(exec);\n");
-                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
-                        push(@implContent, "    if (EventListener* listener = impl->$implGetterFunctionName()) {\n");
-                        push(@implContent, "        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
-                        if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") {
-                            push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl))\n");
+                    my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()");
+
+                    if ($svgListPropertyType) {
+                        push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
+                    } elsif ($svgPropertyOrListPropertyType) {
+                        push(@implContent, "    $svgPropertyOrListPropertyType& impl = castedThis->impl()->propertyReference();\n");
+                        if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
+                            push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl", "castedThis") . ";\n");
                         } else {
-                            push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n");
-                        }
-                        push(@implContent, "                return jsFunction;\n");
-                        push(@implContent, "        }\n");
-                        push(@implContent, "    }\n");
-                        push(@implContent, "    return jsNull();\n");
-                    } elsif ($attribute->signature->type =~ /Constructor$/) {
-                        my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
-                        $constructorType =~ s/Constructor$//;
-                        # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object
-                        # Once JSDOMWrappers 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 !$attribute->signature->extendedAttributes->{"CallWith"};
+                            push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
 
-                        my $cacheIndex = 0;
-                        if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
-                            $cacheIndex = $currentCachedAttribute;
-                            $currentCachedAttribute++;
-                            push(@implContent, "    if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n");
-                            push(@implContent, "        return cachedValue;\n");
                         }
-
-                        my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()");
-
-                        if ($svgListPropertyType) {
-                            push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
-                        } elsif ($svgPropertyOrListPropertyType) {
-                            push(@implContent, "    $svgPropertyOrListPropertyType& impl = castedThis->impl()->propertyReference();\n");
-                            if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
-                                push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl", "castedThis") . ";\n");
-                            } else {
-                                push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
-
-                            }
+                    } else {
+                        my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
+                        if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
+                            my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
+                            $implIncludes{"${implementedBy}.h"} = 1;
+                            $functionName = "${implementedBy}::${functionName}";
+                            unshift(@arguments, "impl");
+                        } elsif ($attribute->isStatic) {
+                            $functionName = "${implClassName}::${functionName}";
                         } else {
-                            my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
-                            if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                                my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
-                                $implIncludes{"${implementedBy}.h"} = 1;
-                                $functionName = "${implementedBy}::${functionName}";
-                                unshift(@arguments, "impl");
-                            } else {
-                                $functionName = "impl->${functionName}";
-                            }
+                            $functionName = "impl->${functionName}";
+                        }
 
-                            unshift(@arguments, @callWithArgs);
+                        unshift(@arguments, @callWithArgs);
 
-                            my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
-                            push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
-                            if ($codeGenerator->IsSVGAnimatedType($type)) {
-                                push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
-                                push(@implContent, "    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());\n");
-                            } else {
-                                push(@implContent, "    JSValue result = $jsType;\n");
-                            }
+                        my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
+                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n") if !$attribute->isStatic;
+                        if ($codeGenerator->IsSVGAnimatedType($type)) {
+                            push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
+                            push(@implContent, "    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());\n");
+                        } else {
+                            push(@implContent, "    JSValue result = $jsType;\n");
                         }
+                    }
 
-                        push(@implContent, "    castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
-                        push(@implContent, "    return result;\n");
+                    push(@implContent, "    castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
+                    push(@implContent, "    return result;\n");
 
-                    } else {
-                        my @arguments = ("ec");
-                        push(@implContent, "    ExceptionCode ec = 0;\n");
+                } else {
+                    my @arguments = ("ec");
+                    push(@implContent, "    ExceptionCode ec = 0;\n");
 
-                        unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"));
+                    unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"));
 
-                        if ($svgPropertyOrListPropertyType) {
-                            push(@implContent, "    $svgPropertyOrListPropertyType impl(*castedThis->impl());\n");
-                            push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
-                        } else {
-                            push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
-                            push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
-                        }
-
-                        push(@implContent, "    setDOMException(exec, ec);\n");
-                        push(@implContent, "    return result;\n");
+                    if ($svgPropertyOrListPropertyType) {
+                        push(@implContent, "    $svgPropertyOrListPropertyType impl(*castedThis->impl());\n");
+                        push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
+                    } else {
+                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
+                        push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
                     }
+
+                    push(@implContent, "    setDOMException(exec, ec);\n");
+                    push(@implContent, "    return result;\n");
                 }
 
                 push(@implContent, "}\n\n");
@@ -1927,13 +1923,6 @@
                         push(@implContent, ", JSValue value)\n");
                         push(@implContent, "{\n");
 
-                        if ($attribute->isStatic) {
-                            push(@implContent, "    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n");
-                            push(@implContent, "    if (!scriptContext)\n");
-                            push(@implContent, "        return;\n");
-                            my $nativeValue = JSValueToNative($attribute->signature, "value");
-                            push(@implContent, "    ${implClassName}::set$implSetterFunctionName(scriptContext, ${nativeValue});\n");
-                        } else {
                             push(@implContent, "    UNUSED_PARAM(exec);\n");
 
                             if ($dataNode->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
@@ -1982,8 +1971,10 @@
                                 push(@implContent, "    // Shadowing a built-in object\n");
                                 push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
                             } else {
-                                push(@implContent, "    $className* castedThis = jsCast<$className*>(thisObject);\n");
-                                push(@implContent, "    $implType* impl = static_cast<$implType*>(castedThis->impl());\n");
+                                if (!$attribute->isStatic) {
+                                    push(@implContent, "    $className* castedThis = jsCast<$className*>(thisObject);\n");
+                                    push(@implContent, "    $implType* impl = static_cast<$implType*>(castedThis->impl());\n");
+                                }
                                 push(@implContent, "    ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
 
                                 # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an
@@ -2037,6 +2028,8 @@
                                         $implIncludes{"${implementedBy}.h"} = 1;
                                         unshift(@arguments, "impl");
                                         $functionName = "${implementedBy}::${functionName}";
+                                    } elsif ($attribute->isStatic) {
+                                        $functionName = "${implClassName}::${functionName}";
                                     } else {
                                         $functionName = "impl->${functionName}";
                                     }
@@ -2048,7 +2041,6 @@
                                     push(@implContent, "    setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
                                 }
                             }
-                        }
 
                         push(@implContent, "}\n\n");
                         push(@implContent, "#endif\n") if $attributeConditionalString;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to