| OLD | NEW |
| 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
| 5 # Copyright (C) 2006 Apple Computer, Inc. | 5 # Copyright (C) 2006 Apple Computer, Inc. |
| 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. | 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. |
| 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. | 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 return; | 1257 return; |
| 1258 } | 1258 } |
| 1259 ${implClassName}* imp = ${v8ClassName}::toNative(holder); | 1259 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
| 1260 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 1260 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
| 1261 static int sharedTemplateUniqueKey; | 1261 static int sharedTemplateUniqueKey; |
| 1262 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLength)
; | 1262 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLength)
; |
| 1263 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 1263 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 1264 return; | 1264 return; |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicStrin
g(info.GetIsolate(), "${funcName}")); | 1267 v8::Local<v8::Value> hiddenValue = getHiddenValue(info.GetIsolate(), info.Th
is(), "${funcName}"); |
| 1268 if (!hiddenValue.IsEmpty()) { | 1268 if (!hiddenValue.IsEmpty()) { |
| 1269 v8SetReturnValue(info, hiddenValue); | 1269 v8SetReturnValue(info, hiddenValue); |
| 1270 return; | 1270 return; |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 v8SetReturnValue(info, privateTemplate->GetFunction()); | 1273 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 1274 } | 1274 } |
| 1275 | 1275 |
| 1276 END | 1276 END |
| 1277 $implementation{nameSpaceInternal}->add(<<END); | 1277 $implementation{nameSpaceInternal}->add(<<END); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1301 if (holder.IsEmpty()) | 1301 if (holder.IsEmpty()) |
| 1302 return; | 1302 return; |
| 1303 ${implClassName}* imp = ${v8ClassName}::toNative(holder); | 1303 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
| 1304 v8::String::Utf8Value attributeName(name); | 1304 v8::String::Utf8Value attributeName(name); |
| 1305 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"${interfaceName}", info.Holder(), info.GetIsolate()); | 1305 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"${interfaceName}", info.Holder(), info.GetIsolate()); |
| 1306 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 1306 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 1307 exceptionState.throwIfNeeded(); | 1307 exceptionState.throwIfNeeded(); |
| 1308 return; | 1308 return; |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 info.This()->SetHiddenValue(name, jsValue); | 1311 setHiddenValue(info.GetIsolate(), info.This(), name, jsValue); |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String>
name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 1314 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String>
name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 1315 { | 1315 { |
| 1316 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 1316 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 1317 ${implClassName}V8Internal::${implClassName}OriginSafeMethodSetter(name, jsV
alue, info); | 1317 ${implClassName}V8Internal::${implClassName}OriginSafeMethodSetter(name, jsV
alue, info); |
| 1318 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 1318 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 1319 } | 1319 } |
| 1320 | 1320 |
| 1321 END | 1321 END |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 return; | 1535 return; |
| 1536 # Skip the rest of the function! | 1536 # Skip the rest of the function! |
| 1537 } | 1537 } |
| 1538 my $imp = 0; | 1538 my $imp = 0; |
| 1539 if ($attrCached) { | 1539 if ($attrCached) { |
| 1540 $imp = 1; | 1540 $imp = 1; |
| 1541 $code .= <<END; | 1541 $code .= <<END; |
| 1542 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "${a
ttrName}"); | 1542 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "${a
ttrName}"); |
| 1543 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1543 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1544 if (!imp->$attrCached()) { | 1544 if (!imp->$attrCached()) { |
| 1545 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa
me); | 1545 v8::Handle<v8::Value> jsValue = getHiddenValue(info.GetIsolate(), info.H
older(), propertyName); |
| 1546 if (!jsValue.IsEmpty()) { | 1546 if (!jsValue.IsEmpty()) { |
| 1547 v8SetReturnValue(info, jsValue); | 1547 v8SetReturnValue(info, jsValue); |
| 1548 return; | 1548 return; |
| 1549 } | 1549 } |
| 1550 } | 1550 } |
| 1551 END | 1551 END |
| 1552 } | 1552 } |
| 1553 if (!$attribute->isStatic && !$imp) { | 1553 if (!$attribute->isStatic && !$imp) { |
| 1554 $code .= <<END; | 1554 $code .= <<END; |
| 1555 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1555 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 | 1644 |
| 1645 if (ShouldKeepAttributeAlive($interface, $attribute, $attrType)) { | 1645 if (ShouldKeepAttributeAlive($interface, $attribute, $attrType)) { |
| 1646 my $arrayType = GetArrayType($attrType); | 1646 my $arrayType = GetArrayType($attrType); |
| 1647 if ($arrayType) { | 1647 if ($arrayType) { |
| 1648 $code .= " v8SetReturnValue(info, v8Array(${getterString}, info.G
etIsolate()));\n"; | 1648 $code .= " v8SetReturnValue(info, v8Array(${getterString}, info.G
etIsolate()));\n"; |
| 1649 $code .= "}\n\n"; | 1649 $code .= "}\n\n"; |
| 1650 $implementation{nameSpaceInternal}->add($code); | 1650 $implementation{nameSpaceInternal}->add($code); |
| 1651 return; | 1651 return; |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 AddToImplIncludes("bindings/v8/V8HiddenPropertyName.h"); | |
| 1655 # Check for a wrapper in the wrapper cache. If there is one, we know tha
t a hidden reference has already | 1654 # Check for a wrapper in the wrapper cache. If there is one, we know tha
t a hidden reference has already |
| 1656 # been created. If we don't find a wrapper, we create both a wrapper and
a hidden reference. | 1655 # been created. If we don't find a wrapper, we create both a wrapper and
a hidden reference. |
| 1657 my $nativeReturnType = GetNativeType($attrType); | 1656 my $nativeReturnType = GetNativeType($attrType); |
| 1658 my $v8ReturnType = "V8" . $attrType; | 1657 my $v8ReturnType = "V8" . $attrType; |
| 1659 $code .= " $nativeReturnType result = ${getterString};\n"; | 1658 $code .= " $nativeReturnType result = ${getterString};\n"; |
| 1660 if ($forMainWorldSuffix) { | 1659 if ($forMainWorldSuffix) { |
| 1661 $code .= " if (result && DOMDataStore::setReturnValueFromWrapper$
{forMainWorldSuffix}<${v8ReturnType}>(info.GetReturnValue(), result.get()))\n"; | 1660 $code .= " if (result && DOMDataStore::setReturnValueFromWrapper$
{forMainWorldSuffix}<${v8ReturnType}>(info.GetReturnValue(), result.get()))\n"; |
| 1662 } else { | 1661 } else { |
| 1663 $code .= " if (result && DOMDataStore::setReturnValueFromWrapper<
${v8ReturnType}>(info.GetReturnValue(), result.get()))\n"; | 1662 $code .= " if (result && DOMDataStore::setReturnValueFromWrapper<
${v8ReturnType}>(info.GetReturnValue(), result.get()))\n"; |
| 1664 } | 1663 } |
| 1665 $code .= " return;\n"; | 1664 $code .= " return;\n"; |
| 1666 $code .= " v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Ho
lder(), info.GetIsolate());\n"; | 1665 $code .= " v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Ho
lder(), info.GetIsolate());\n"; |
| 1667 $code .= " if (!wrapper.IsEmpty()) {\n"; | 1666 $code .= " if (!wrapper.IsEmpty()) {\n"; |
| 1668 $code .= " V8HiddenPropertyName::setNamedHiddenReference(info.Hol
der(), \"${attrName}\", wrapper);\n"; | 1667 $code .= " setHiddenValue(info.GetIsolate(), info.Holder(), \"${a
ttrName}\", wrapper);\n"; |
| 1669 $code .= " v8SetReturnValue(info, wrapper);\n"; | 1668 $code .= " v8SetReturnValue(info, wrapper);\n"; |
| 1670 $code .= " }\n"; | 1669 $code .= " }\n"; |
| 1671 $code .= "}\n"; | 1670 $code .= "}\n"; |
| 1672 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1671 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 1673 $code .= "\n"; | 1672 $code .= "\n"; |
| 1674 $implementation{nameSpaceInternal}->add($code); | 1673 $implementation{nameSpaceInternal}->add($code); |
| 1675 return; | 1674 return; |
| 1676 } | 1675 } |
| 1677 | 1676 |
| 1678 if ((IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") a
nd IsSVGTypeNeedingTearOff($attrType)) { | 1677 if ((IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") a
nd IsSVGTypeNeedingTearOff($attrType)) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 if ($forMainWorldSuffix eq "ForMainWorld") { | 1716 if ($forMainWorldSuffix eq "ForMainWorld") { |
| 1718 $code .= " v8SetReturnValueForMainWorld(info, $wrappedValue);\n"; | 1717 $code .= " v8SetReturnValueForMainWorld(info, $wrappedValue);\n"; |
| 1719 } else { | 1718 } else { |
| 1720 $code .= " v8SetReturnValueFast(info, $wrappedValue, imp);\n"; | 1719 $code .= " v8SetReturnValueFast(info, $wrappedValue, imp);\n"; |
| 1721 } | 1720 } |
| 1722 } elsif ($attrCached) { | 1721 } elsif ($attrCached) { |
| 1723 if ($attribute->type eq "SerializedScriptValue") { | 1722 if ($attribute->type eq "SerializedScriptValue") { |
| 1724 $code .= <<END; | 1723 $code .= <<END; |
| 1725 RefPtr<SerializedScriptValue> serialized = $getterString; | 1724 RefPtr<SerializedScriptValue> serialized = $getterString; |
| 1726 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8
::Value>(v8::Null(info.GetIsolate())); | 1725 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8
::Value>(v8::Null(info.GetIsolate())); |
| 1727 info.Holder()->SetHiddenValue(propertyName, jsValue); | 1726 setHiddenValue(info.GetIsolate(), info.Holder(), propertyName, jsValue); |
| 1728 v8SetReturnValue(info, jsValue); | 1727 v8SetReturnValue(info, jsValue); |
| 1729 END | 1728 END |
| 1730 } else { | 1729 } else { |
| 1731 if (!$useExceptions && !$isNullable) { | 1730 if (!$useExceptions && !$isNullable) { |
| 1732 $code .= <<END; | 1731 $code .= <<END; |
| 1733 ScriptValue jsValue = $getterString; | 1732 ScriptValue jsValue = $getterString; |
| 1734 END | 1733 END |
| 1735 } | 1734 } |
| 1736 $code .= <<END; | 1735 $code .= <<END; |
| 1737 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value()); | 1736 setHiddenValue(info.GetIsolate(), info.Holder(), propertyName, jsValue.v8Val
ue()); |
| 1738 v8SetReturnValue(info, jsValue.v8Value()); | 1737 v8SetReturnValue(info, jsValue.v8Value()); |
| 1739 END | 1738 END |
| 1740 } | 1739 } |
| 1741 } elsif ($attribute->type eq "EventHandler") { | 1740 } elsif ($attribute->type eq "EventHandler") { |
| 1742 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1741 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1743 # FIXME: Pass the main world ID for main-world-only getters. | 1742 # FIXME: Pass the main world ID for main-world-only getters. |
| 1744 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri
bute); | 1743 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri
bute); |
| 1745 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; | 1744 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; |
| 1746 if ($implementedBy) { | 1745 if ($implementedBy) { |
| 1747 my $implementedByImplName = GetImplNameFromImplementedBy($implemente
dBy); | 1746 my $implementedByImplName = GetImplNameFromImplementedBy($implemente
dBy); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 if ($useExceptions) { | 2153 if ($useExceptions) { |
| 2155 $code .= " if (!exceptionState.hadException())\n"; | 2154 $code .= " if (!exceptionState.hadException())\n"; |
| 2156 $code .= " wrapper->commitChange();\n"; | 2155 $code .= " wrapper->commitChange();\n"; |
| 2157 } else { | 2156 } else { |
| 2158 $code .= " wrapper->commitChange();\n"; | 2157 $code .= " wrapper->commitChange();\n"; |
| 2159 } | 2158 } |
| 2160 } | 2159 } |
| 2161 | 2160 |
| 2162 if ($attrCached) { | 2161 if ($attrCached) { |
| 2163 $code .= <<END; | 2162 $code .= <<END; |
| 2164 info.Holder()->DeleteHiddenValue(v8AtomicString(info.GetIsolate(), "${attrNa
me}")); // Invalidate the cached value. | 2163 deleteHiddenValue(info.GetIsolate(), info.Holder(), "${attrName}"); // Inval
idate the cached value. |
| 2165 END | 2164 END |
| 2166 } | 2165 } |
| 2167 | 2166 |
| 2168 $code .= "}\n"; # end of setter | 2167 $code .= "}\n"; # end of setter |
| 2169 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 2168 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2170 $code .= "\n"; | 2169 $code .= "\n"; |
| 2171 $implementation{nameSpaceInternal}->add($code); | 2170 $implementation{nameSpaceInternal}->add($code); |
| 2172 } | 2171 } |
| 2173 | 2172 |
| 2174 sub GenerateParametersCheckExpression | 2173 sub GenerateParametersCheckExpression |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 exceptionState.throwIfNeeded(); | 2995 exceptionState.throwIfNeeded(); |
| 2997 return; | 2996 return; |
| 2998 } | 2997 } |
| 2999 END | 2998 END |
| 3000 | 2999 |
| 3001 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. | 3000 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. |
| 3002 foreach my $attrName (@anyAttributeNames) { | 3001 foreach my $attrName (@anyAttributeNames) { |
| 3003 $implementation{nameSpaceInternal}->add(<<END); | 3002 $implementation{nameSpaceInternal}->add(<<END); |
| 3004 options.get("${attrName}", ${attrName}); | 3003 options.get("${attrName}", ${attrName}); |
| 3005 if (!${attrName}.IsEmpty()) | 3004 if (!${attrName}.IsEmpty()) |
| 3006 info.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(info
.GetIsolate()), ${attrName}); | 3005 setHiddenValue(info.GetIsolate(), info.Holder(), "${attrName}", ${at
trName}); |
| 3007 END | 3006 END |
| 3008 } | 3007 } |
| 3009 | 3008 |
| 3010 $implementation{nameSpaceInternal}->add(<<END); | 3009 $implementation{nameSpaceInternal}->add(<<END); |
| 3011 } | 3010 } |
| 3012 END | 3011 END |
| 3013 | 3012 |
| 3014 my $exceptionStateArgument = ""; | 3013 my $exceptionStateArgument = ""; |
| 3015 if ($constructorRaisesException) { | 3014 if ($constructorRaisesException) { |
| 3016 ${exceptionStateArgument} = ", exceptionState"; | 3015 ${exceptionStateArgument} = ", exceptionState"; |
| (...skipping 3385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6402 if ($parameter->type eq "SerializedScriptValue") { | 6401 if ($parameter->type eq "SerializedScriptValue") { |
| 6403 return 1; | 6402 return 1; |
| 6404 } elsif (IsIntegerType($parameter->type)) { | 6403 } elsif (IsIntegerType($parameter->type)) { |
| 6405 return 1; | 6404 return 1; |
| 6406 } | 6405 } |
| 6407 } | 6406 } |
| 6408 return 0; | 6407 return 0; |
| 6409 } | 6408 } |
| 6410 | 6409 |
| 6411 1; | 6410 1; |
| OLD | NEW |