| 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 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 1269 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 END | 1272 END |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 sub GenerateDomainSafeFunctionSetter | 1275 sub GenerateDomainSafeFunctionSetter |
| 1276 { | 1276 { |
| 1277 my $interface = shift; | 1277 my $interface = shift; |
| 1278 | 1278 |
| 1279 my $interfaceName = $interface->name(); |
| 1279 my $implClassName = GetImplName($interface); | 1280 my $implClassName = GetImplName($interface); |
| 1280 my $v8ClassName = GetV8ClassName($interface); | 1281 my $v8ClassName = GetV8ClassName($interface); |
| 1281 | 1282 |
| 1282 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1283 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 1283 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 1284 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1284 $implementation{nameSpaceInternal}->add(<<END); | 1285 $implementation{nameSpaceInternal}->add(<<END); |
| 1285 static void ${implClassName}OriginSafeMethodSetter(v8::Local<v8::String> name, v
8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 1286 static void ${implClassName}OriginSafeMethodSetter(v8::Local<v8::String> name, v
8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 1286 { | 1287 { |
| 1287 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 1288 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 1288 if (holder.IsEmpty()) | 1289 if (holder.IsEmpty()) |
| 1289 return; | 1290 return; |
| 1290 ${implClassName}* imp = ${v8ClassName}::toNative(holder); | 1291 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
| 1291 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 1292 ExceptionState exceptionState(ExceptionState::SetterContext, *v8::String::Ut
f8Value(name), "${interfaceName}", info.Holder(), info.GetIsolate()); |
| 1292 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 1293 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 1293 exceptionState.throwIfNeeded(); | 1294 exceptionState.throwIfNeeded(); |
| 1294 return; | 1295 return; |
| 1295 } | 1296 } |
| 1296 | 1297 |
| 1297 info.This()->SetHiddenValue(name, jsValue); | 1298 info.This()->SetHiddenValue(name, jsValue); |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String>
name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 1301 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String>
name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 1301 { | 1302 { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1536 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1536 END | 1537 END |
| 1537 } | 1538 } |
| 1538 } | 1539 } |
| 1539 | 1540 |
| 1540 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; | 1541 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; |
| 1541 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_
MISSING" or $raisesException eq "Getter"); | 1542 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_
MISSING" or $raisesException eq "Getter"); |
| 1542 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) { | 1543 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) { |
| 1543 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 1544 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 1544 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 1545 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1545 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; | 1546 $code .= " ExceptionState exceptionState(ExceptionState::GetterContex
t, \"${attrName}\", \"${interfaceName}\" ,info.Holder(), info.GetIsolate());\n"; |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 # Generate security checks if necessary | 1549 # Generate security checks if necessary |
| 1549 if ($attribute->extendedAttributes->{"CheckSecurity"}) { | 1550 if ($attribute->extendedAttributes->{"CheckSecurity"}) { |
| 1550 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1551 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 1551 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($attribute) . "(), exceptionState)) {\n"; | 1552 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($attribute) . "(), exceptionState)) {\n"; |
| 1552 $code .= " v8SetReturnValueNull(info);\n"; | 1553 $code .= " v8SetReturnValueNull(info);\n"; |
| 1553 $code .= " exceptionState.throwIfNeeded();\n"; | 1554 $code .= " exceptionState.throwIfNeeded();\n"; |
| 1554 $code .= " return;\n"; | 1555 $code .= " return;\n"; |
| 1555 $code .= " }\n"; | 1556 $code .= " }\n"; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 } | 1794 } |
| 1794 $code .= " ${implClassName}V8Internal::${implClassName}ReplaceableAttribu
teSetter(name, jsValue, info);\n"; | 1795 $code .= " ${implClassName}V8Internal::${implClassName}ReplaceableAttribu
teSetter(name, jsValue, info);\n"; |
| 1795 $code .= "}\n\n"; | 1796 $code .= "}\n\n"; |
| 1796 $implementation{nameSpaceInternal}->add($code); | 1797 $implementation{nameSpaceInternal}->add($code); |
| 1797 } | 1798 } |
| 1798 | 1799 |
| 1799 sub GenerateReplaceableAttributeSetter | 1800 sub GenerateReplaceableAttributeSetter |
| 1800 { | 1801 { |
| 1801 my $interface = shift; | 1802 my $interface = shift; |
| 1802 | 1803 |
| 1804 my $interfaceName = $interface->name(); |
| 1803 my $implClassName = GetImplName($interface); | 1805 my $implClassName = GetImplName($interface); |
| 1804 my $v8ClassName = GetV8ClassName($interface); | 1806 my $v8ClassName = GetV8ClassName($interface); |
| 1805 | 1807 |
| 1806 my $code = ""; | 1808 my $code = ""; |
| 1807 $code .= <<END; | 1809 $code .= <<END; |
| 1808 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam
e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 1810 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam
e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 1809 { | 1811 { |
| 1810 END | 1812 END |
| 1811 if ($interface->extendedAttributes->{"CheckSecurity"}) { | 1813 if ($interface->extendedAttributes->{"CheckSecurity"}) { |
| 1812 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1814 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 1813 $code .= <<END; | 1815 $code .= <<END; |
| 1814 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1816 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1815 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 1817 ExceptionState exceptionState(ExceptionState::SetterContext, *v8::String::Ut
f8Value(name), "${interfaceName}", info.Holder(), info.GetIsolate()); |
| 1816 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 1818 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 1817 exceptionState.throwIfNeeded(); | 1819 exceptionState.throwIfNeeded(); |
| 1818 return; | 1820 return; |
| 1819 } | 1821 } |
| 1820 END | 1822 END |
| 1821 } | 1823 } |
| 1822 | 1824 |
| 1823 $code .= <<END; | 1825 $code .= <<END; |
| 1824 info.This()->ForceSet(name, jsValue); | 1826 info.This()->ForceSet(name, jsValue); |
| 1825 } | 1827 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 my $conditionalString = GenerateConditionalString($attribute); | 1921 my $conditionalString = GenerateConditionalString($attribute); |
| 1920 my $code = ""; | 1922 my $code = ""; |
| 1921 $code .= "#if ${conditionalString}\n" if $conditionalString; | 1923 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 1922 if ($exposeJSAccessors) { | 1924 if ($exposeJSAccessors) { |
| 1923 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8
::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; | 1925 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8
::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
| 1924 } else { | 1926 } else { |
| 1925 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8
::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; | 1927 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8
::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; |
| 1926 } | 1928 } |
| 1927 $code .= "{\n"; | 1929 $code .= "{\n"; |
| 1928 | 1930 |
| 1931 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; |
| 1932 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_
MISSING" or $raisesException eq "Setter"); |
| 1933 |
| 1934 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 1935 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1936 $code .= " ExceptionState exceptionState(ExceptionState::SetterContext, \
"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
| 1937 |
| 1929 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an | 1938 # If the "StrictTypeChecking" extended attribute is present, and the attribu
te's type is an |
| 1930 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is | 1939 # interface type, then if the incoming value does not implement that interfa
ce, a TypeError is |
| 1931 # thrown rather than silently passing NULL to the C++ code. | 1940 # thrown rather than silently passing NULL to the C++ code. |
| 1932 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both | 1941 # Per the Web IDL and ECMAScript specifications, incoming values can always
be converted to both |
| 1933 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. | 1942 # strings and numbers, so do not throw TypeError if the attribute is of thes
e types. |
| 1934 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { | 1943 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { |
| 1935 my $argType = $attribute->type; | 1944 my $argType = $attribute->type; |
| 1936 if (IsWrapperType($argType)) { | 1945 if (IsWrapperType($argType)) { |
| 1937 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${argType}::hasI
nstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 1946 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${argType}::hasI
nstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
| 1938 $code .= " throwTypeError(ExceptionMessages::failedToSet(\"${
attrName}\", \"${interfaceName}\", \"The provided value is not of type '${argTyp
e}'.\"), info.GetIsolate());\n"; | 1947 $code .= " exceptionState.throwTypeError(\"The provided value
is not of type '${argType}'.\");\n"; |
| 1948 $code .= " exceptionState.throwIfNeeded();\n"; |
| 1939 $code .= " return;\n"; | 1949 $code .= " return;\n"; |
| 1940 $code .= " }\n"; | 1950 $code .= " }\n"; |
| 1941 } | 1951 } |
| 1942 } | 1952 } |
| 1943 | 1953 |
| 1944 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1954 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
| 1945 if ($svgNativeType) { | 1955 if ($svgNativeType) { |
| 1946 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1956 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
| 1947 if ($svgWrappedNativeType =~ /List$/) { | 1957 if ($svgWrappedNativeType =~ /List$/) { |
| 1948 $code .= <<END; | 1958 $code .= <<END; |
| 1949 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); | 1959 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1950 END | 1960 END |
| 1951 } else { | 1961 } else { |
| 1952 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 1962 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 1953 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 1963 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1954 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf
o.Holder());\n"; | 1964 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf
o.Holder());\n"; |
| 1955 $code .= " if (wrapper->isReadOnly()) {\n"; | 1965 $code .= " if (wrapper->isReadOnly()) {\n"; |
| 1956 $code .= " setDOMException(NoModificationAllowedError, Except
ionMessages::failedToSet(\"${attrName}\", \"${interfaceName}\", \"The attribute
is read-only.\"), info.GetIsolate());\n"; | 1966 $code .= " exceptionState.throwDOMException(NoModificationAll
owedError, \"The attribute is read-only.\");\n"; |
| 1967 $code .= " exceptionState.throwIfNeeded();\n"; |
| 1957 $code .= " return;\n"; | 1968 $code .= " return;\n"; |
| 1958 $code .= " }\n"; | 1969 $code .= " }\n"; |
| 1959 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 1970 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
| 1960 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 1971 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 1961 } | 1972 } |
| 1962 } elsif ($attrExt->{"OnPrototype"}) { | 1973 } elsif ($attrExt->{"OnPrototype"}) { |
| 1963 $code .= <<END; | 1974 $code .= <<END; |
| 1964 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1975 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1965 END | 1976 END |
| 1966 } elsif($attrExt->{"PutForwards"}) { | 1977 } elsif($attrExt->{"PutForwards"}) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { | 2049 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { |
| 2039 $expression = "WTF::getPtr(" . $expression . ")"; | 2050 $expression = "WTF::getPtr(" . $expression . ")"; |
| 2040 } | 2051 } |
| 2041 | 2052 |
| 2042 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt
tributes); | 2053 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt
tributes); |
| 2043 | 2054 |
| 2044 my $returnSvgNativeType = GetSVGTypeNeedingTearOff($returnType); | 2055 my $returnSvgNativeType = GetSVGTypeNeedingTearOff($returnType); |
| 2045 if ($returnSvgNativeType) { | 2056 if ($returnSvgNativeType) { |
| 2046 $code .= <<END; | 2057 $code .= <<END; |
| 2047 if (!$expression) { | 2058 if (!$expression) { |
| 2048 throwTypeError(ExceptionMessages::failedToSet(\"${attrName}\", \"${inter
faceName}\", \"The provided value is not of type '$returnType'.\"), info.GetIsol
ate()); | 2059 exceptionState.throwTypeError(\"The provided value is not of type '$retu
rnType'.\"); |
| 2060 exceptionState.throwIfNeeded(); |
| 2049 return; | 2061 return; |
| 2050 } | 2062 } |
| 2051 END | 2063 END |
| 2052 $expression = $expression . "->propertyReference()"; | 2064 $expression = $expression . "->propertyReference()"; |
| 2053 } | 2065 } |
| 2054 | 2066 |
| 2055 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; | |
| 2056 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_
MISSING" or $raisesException eq "Setter"); | |
| 2057 | |
| 2058 if ($useExceptions) { | |
| 2059 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | |
| 2060 AddToImplIncludes("bindings/v8/ExceptionState.h"); | |
| 2061 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; | |
| 2062 } | |
| 2063 | |
| 2064 if ($attribute->type eq "EventHandler") { | 2067 if ($attribute->type eq "EventHandler") { |
| 2065 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; | 2068 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; |
| 2066 my $implementedByImplName; | 2069 my $implementedByImplName; |
| 2067 if ($implementedBy) { | 2070 if ($implementedBy) { |
| 2068 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy
); | 2071 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy
); |
| 2069 } | 2072 } |
| 2070 if (!InheritsInterface($interface, "Node")) { | 2073 if (!InheritsInterface($interface, "Node")) { |
| 2071 my $attrImplName = GetImplName($attribute); | 2074 my $attrImplName = GetImplName($attribute); |
| 2072 my @arguments; | 2075 my @arguments; |
| 2073 if ($implementedBy) { | 2076 if ($implementedBy) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 sub GenerateFunction | 2327 sub GenerateFunction |
| 2325 { | 2328 { |
| 2326 my $function = shift; | 2329 my $function = shift; |
| 2327 my $interface = shift; | 2330 my $interface = shift; |
| 2328 my $forMainWorldSuffix = shift; | 2331 my $forMainWorldSuffix = shift; |
| 2329 | 2332 |
| 2330 my $interfaceName = $interface->name; | 2333 my $interfaceName = $interface->name; |
| 2331 my $implClassName = GetImplName($interface); | 2334 my $implClassName = GetImplName($interface); |
| 2332 my $v8ClassName = GetV8ClassName($interface); | 2335 my $v8ClassName = GetV8ClassName($interface); |
| 2333 my $name = $function->name; | 2336 my $name = $function->name; |
| 2337 my $unoverloadedName = $function->name; |
| 2334 my $implName = GetImplName($function); | 2338 my $implName = GetImplName($function); |
| 2335 my $funcExt = $function->extendedAttributes; | 2339 my $funcExt = $function->extendedAttributes; |
| 2336 | 2340 |
| 2337 if (HasCustomMethod($funcExt) || $name eq "") { | 2341 if (HasCustomMethod($funcExt) || $name eq "") { |
| 2338 return; | 2342 return; |
| 2339 } | 2343 } |
| 2340 | 2344 |
| 2341 if (@{$function->{overloads}} > 1) { | 2345 if (@{$function->{overloads}} > 1) { |
| 2342 # Append a number to an overloaded method's name to make it unique: | 2346 # Append a number to an overloaded method's name to make it unique: |
| 2343 $name = $name . $function->{overloadIndex}; | 2347 $name = $name . $function->{overloadIndex}; |
| 2344 } | 2348 } |
| 2345 | 2349 |
| 2346 my $conditionalString = GenerateConditionalString($function); | 2350 my $conditionalString = GenerateConditionalString($function); |
| 2347 my $code = ""; | 2351 my $code = ""; |
| 2348 $code .= "#if ${conditionalString}\n" if $conditionalString; | 2352 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 2349 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC
allbackInfo<v8::Value>& info)\n"; | 2353 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC
allbackInfo<v8::Value>& info)\n"; |
| 2350 $code .= "{\n"; | 2354 $code .= "{\n"; |
| 2351 | 2355 |
| 2356 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionContext
, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate(
));\n"; |
| 2357 |
| 2352 if ($name eq "addEventListener" || $name eq "removeEventListener") { | 2358 if ($name eq "addEventListener" || $name eq "removeEventListener") { |
| 2353 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 2359 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
| 2354 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 2360 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
| 2355 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; | 2361 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; |
| 2356 | 2362 |
| 2357 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2363 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2358 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2364 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2359 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 2365 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 2360 AddToImplIncludes("core/frame/DOMWindow.h"); | 2366 AddToImplIncludes("core/frame/DOMWindow.h"); |
| 2361 $code .= <<END; | 2367 $code .= <<END; |
| 2362 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); | 2368 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); |
| 2363 if (DOMWindow* window = impl->toDOMWindow()) { | 2369 if (DOMWindow* window = impl->toDOMWindow()) { |
| 2364 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | |
| 2365 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio
nState)) { | 2370 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio
nState)) { |
| 2366 exceptionState.throwIfNeeded(); | 2371 exceptionState.throwIfNeeded(); |
| 2367 return; | 2372 return; |
| 2368 } | 2373 } |
| 2369 if (!window->document()) | 2374 if (!window->document()) |
| 2370 return; | 2375 return; |
| 2371 } | 2376 } |
| 2372 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[
1], false, ListenerFind${lookupType}); | 2377 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[
1], false, ListenerFind${lookupType}); |
| 2373 if (listener) { | 2378 if (listener) { |
| 2374 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev
entName, info[0]); | 2379 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev
entName, info[0]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2402 if ($svgNativeType) { | 2407 if ($svgNativeType) { |
| 2403 my $nativeClassName = GetNativeType($interfaceName); | 2408 my $nativeClassName = GetNativeType($interfaceName); |
| 2404 if ($interfaceName =~ /List$/) { | 2409 if ($interfaceName =~ /List$/) { |
| 2405 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H
older());\n"; | 2410 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H
older());\n"; |
| 2406 } else { | 2411 } else { |
| 2407 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2412 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2408 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2413 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2409 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2414 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 2410 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in
fo.Holder());\n"; | 2415 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in
fo.Holder());\n"; |
| 2411 $code .= " if (wrapper->isReadOnly()) {\n"; | 2416 $code .= " if (wrapper->isReadOnly()) {\n"; |
| 2412 $code .= " setDOMException(NoModificationAllowedError, Except
ionMessages::failedToExecute(\"${name}\", \"${interfaceName}\", \"The object is
read-only.\"), info.GetIsolate());\n"; | 2417 $code .= " exceptionState.throwDOMException(NoModificationAll
owedError, \"The object is read-only.\");\n"; |
| 2418 $code .= " exceptionState.throwIfNeeded();\n"; |
| 2413 $code .= " return;\n"; | 2419 $code .= " return;\n"; |
| 2414 $code .= " }\n"; | 2420 $code .= " }\n"; |
| 2415 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); | 2421 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); |
| 2416 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 2422 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
| 2417 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 2423 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 2418 } | 2424 } |
| 2419 } elsif (!$function->isStatic) { | 2425 } elsif (!$function->isStatic) { |
| 2420 $code .= <<END; | 2426 $code .= <<END; |
| 2421 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 2427 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 2422 END | 2428 END |
| 2423 } | 2429 } |
| 2424 | 2430 |
| 2425 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); | 2431 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); |
| 2426 | 2432 |
| 2427 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} ||
($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri
butes->{"DoNotCheckSecurity"}); | |
| 2428 if ($raisesExceptions) { | |
| 2429 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | |
| 2430 AddToImplIncludes("bindings/v8/ExceptionState.h"); | |
| 2431 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; | |
| 2432 } | |
| 2433 | |
| 2434 # Check domain security if needed | 2433 # Check domain security if needed |
| 2435 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende
dAttributes->{"DoNotCheckSecurity"}) { | 2434 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende
dAttributes->{"DoNotCheckSecurity"}) { |
| 2436 # We have not find real use cases yet. | 2435 # We have not find real use cases yet. |
| 2437 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2436 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2438 $code .= <<END; | 2437 $code .= <<END; |
| 2439 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 2438 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 2440 exceptionState.throwIfNeeded(); | 2439 exceptionState.throwIfNeeded(); |
| 2441 return; | 2440 return; |
| 2442 } | 2441 } |
| 2443 END | 2442 END |
| (...skipping 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6447 return 1 if $name eq "FileCallback"; | 6446 return 1 if $name eq "FileCallback"; |
| 6448 return 1 if $name eq "FileSystemCallback"; | 6447 return 1 if $name eq "FileSystemCallback"; |
| 6449 return 1 if $name eq "FileWriterCallback"; | 6448 return 1 if $name eq "FileWriterCallback"; |
| 6450 return 1 if $name eq "MetadataCallback"; | 6449 return 1 if $name eq "MetadataCallback"; |
| 6451 # Used everywhere | 6450 # Used everywhere |
| 6452 return 1 if $name eq "VoidCallback"; | 6451 return 1 if $name eq "VoidCallback"; |
| 6453 return 0; | 6452 return 0; |
| 6454 } | 6453 } |
| 6455 | 6454 |
| 6456 1; | 6455 1; |
| OLD | NEW |