Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 v8::String::Utf8Value attributeName(name);
1293 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "${interfaceName}", info.Holder(), info.GetIsolate());
1292 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 1294 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
1293 exceptionState.throwIfNeeded(); 1295 exceptionState.throwIfNeeded();
1294 return; 1296 return;
1295 } 1297 }
1296 1298
1297 info.This()->SetHiddenValue(name, jsValue); 1299 info.This()->SetHiddenValue(name, jsValue);
1298 } 1300 }
1299 1301
1300 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1302 static void ${implClassName}OriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1301 { 1303 {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1537 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1536 END 1538 END
1537 } 1539 }
1538 } 1540 }
1539 1541
1540 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; 1542 my $raisesException = $attribute->extendedAttributes->{"RaisesException"};
1541 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Getter"); 1543 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Getter");
1542 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) { 1544 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) {
1543 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 1545 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1544 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1546 AddToImplIncludes("bindings/v8/ExceptionState.h");
1545 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; 1547 $code .= " ExceptionState exceptionState(ExceptionState::GetterContex t, \"${attrName}\", \"${interfaceName}\" ,info.Holder(), info.GetIsolate());\n";
1546 } 1548 }
1547 1549
1548 # Generate security checks if necessary 1550 # Generate security checks if necessary
1549 if ($attribute->extendedAttributes->{"CheckSecurity"}) { 1551 if ($attribute->extendedAttributes->{"CheckSecurity"}) {
1550 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1552 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1551 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), exceptionState)) {\n"; 1553 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), exceptionState)) {\n";
1552 $code .= " v8SetReturnValueNull(info);\n"; 1554 $code .= " v8SetReturnValueNull(info);\n";
1553 $code .= " exceptionState.throwIfNeeded();\n"; 1555 $code .= " exceptionState.throwIfNeeded();\n";
1554 $code .= " return;\n"; 1556 $code .= " return;\n";
1555 $code .= " }\n"; 1557 $code .= " }\n";
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 } 1795 }
1794 $code .= " ${implClassName}V8Internal::${implClassName}ReplaceableAttribu teSetter(name, jsValue, info);\n"; 1796 $code .= " ${implClassName}V8Internal::${implClassName}ReplaceableAttribu teSetter(name, jsValue, info);\n";
1795 $code .= "}\n\n"; 1797 $code .= "}\n\n";
1796 $implementation{nameSpaceInternal}->add($code); 1798 $implementation{nameSpaceInternal}->add($code);
1797 } 1799 }
1798 1800
1799 sub GenerateReplaceableAttributeSetter 1801 sub GenerateReplaceableAttributeSetter
1800 { 1802 {
1801 my $interface = shift; 1803 my $interface = shift;
1802 1804
1805 my $interfaceName = $interface->name();
1803 my $implClassName = GetImplName($interface); 1806 my $implClassName = GetImplName($interface);
1804 my $v8ClassName = GetV8ClassName($interface); 1807 my $v8ClassName = GetV8ClassName($interface);
1805 1808
1806 my $code = ""; 1809 my $code = "";
1807 $code .= <<END; 1810 $code .= <<END;
1808 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1811 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1809 { 1812 {
1810 END 1813 END
1811 if ($interface->extendedAttributes->{"CheckSecurity"}) { 1814 if ($interface->extendedAttributes->{"CheckSecurity"}) {
1812 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1815 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1813 $code .= <<END; 1816 $code .= <<END;
1814 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1817 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1815 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 1818 v8::String::Utf8Value attributeName(name);
1819 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "${interfaceName}", info.Holder(), info.GetIsolate());
1816 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 1820 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
1817 exceptionState.throwIfNeeded(); 1821 exceptionState.throwIfNeeded();
1818 return; 1822 return;
1819 } 1823 }
1820 END 1824 END
1821 } 1825 }
1822 1826
1823 $code .= <<END; 1827 $code .= <<END;
1824 info.This()->ForceSet(name, jsValue); 1828 info.This()->ForceSet(name, jsValue);
1825 } 1829 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 my $conditionalString = GenerateConditionalString($attribute); 1923 my $conditionalString = GenerateConditionalString($attribute);
1920 my $code = ""; 1924 my $code = "";
1921 $code .= "#if ${conditionalString}\n" if $conditionalString; 1925 $code .= "#if ${conditionalString}\n" if $conditionalString;
1922 if ($exposeJSAccessors) { 1926 if ($exposeJSAccessors) {
1923 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; 1927 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n";
1924 } else { 1928 } else {
1925 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; 1929 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
1926 } 1930 }
1927 $code .= "{\n"; 1931 $code .= "{\n";
1928 1932
1933 my $raisesException = $attribute->extendedAttributes->{"RaisesException"};
1934 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter");
1935
1936 # We throw exceptions using 'ExceptionState' if the attribute explicitly cla ims that exceptions
1937 # may be raised, or if a strict type check might fail, or if we're dealing w ith SVG, which does
1938 # strange things with tearoffs and read-only wrappers.
1939 if ($useExceptions or $attribute->extendedAttributes->{"StrictTypeChecking"} or GetSVGTypeNeedingTearOff($interfaceName) or GetSVGTypeNeedingTearOff($attrTy pe)) {
1940 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1941 AddToImplIncludes("bindings/v8/ExceptionState.h");
1942 $code .= " ExceptionState exceptionState(ExceptionState::SetterContex t, \"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n";
1943 }
1944
1929 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an 1945 # 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 1946 # 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. 1947 # 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 1948 # 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. 1949 # strings and numbers, so do not throw TypeError if the attribute is of thes e types.
1934 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { 1950 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) {
1935 my $argType = $attribute->type; 1951 my $argType = $attribute->type;
1936 if (IsWrapperType($argType)) { 1952 if (IsWrapperType($argType)) {
1937 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${argType}::hasI nstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; 1953 $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"; 1954 $code .= " exceptionState.throwTypeError(\"The provided value is not of type '${argType}'.\");\n";
1955 $code .= " exceptionState.throwIfNeeded();\n";
1939 $code .= " return;\n"; 1956 $code .= " return;\n";
1940 $code .= " }\n"; 1957 $code .= " }\n";
1941 } 1958 }
1942 } 1959 }
1943 1960
1944 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1961 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1945 if ($svgNativeType) { 1962 if ($svgNativeType) {
1946 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1963 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1947 if ($svgWrappedNativeType =~ /List$/) { 1964 if ($svgWrappedNativeType =~ /List$/) {
1948 $code .= <<END; 1965 $code .= <<END;
1949 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); 1966 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
1950 END 1967 END
1951 } else { 1968 } else {
1952 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1953 AddToImplIncludes("bindings/v8/ExceptionState.h");
1954 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n"; 1969 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n";
1955 $code .= " if (wrapper->isReadOnly()) {\n"; 1970 $code .= " if (wrapper->isReadOnly()) {\n";
1956 $code .= " setDOMException(NoModificationAllowedError, Except ionMessages::failedToSet(\"${attrName}\", \"${interfaceName}\", \"The attribute is read-only.\"), info.GetIsolate());\n"; 1971 $code .= " exceptionState.throwDOMException(NoModificationAll owedError, \"The attribute is read-only.\");\n";
1972 $code .= " exceptionState.throwIfNeeded();\n";
1957 $code .= " return;\n"; 1973 $code .= " return;\n";
1958 $code .= " }\n"; 1974 $code .= " }\n";
1959 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 1975 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
1960 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 1976 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
1961 } 1977 }
1962 } elsif ($attrExt->{"OnPrototype"}) { 1978 } elsif ($attrExt->{"OnPrototype"}) {
1963 $code .= <<END; 1979 $code .= <<END;
1964 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1980 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1965 END 1981 END
1966 } elsif($attrExt->{"PutForwards"}) { 1982 } elsif($attrExt->{"PutForwards"}) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { 2054 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) {
2039 $expression = "WTF::getPtr(" . $expression . ")"; 2055 $expression = "WTF::getPtr(" . $expression . ")";
2040 } 2056 }
2041 2057
2042 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes); 2058 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes);
2043 2059
2044 my $returnSvgNativeType = GetSVGTypeNeedingTearOff($returnType); 2060 my $returnSvgNativeType = GetSVGTypeNeedingTearOff($returnType);
2045 if ($returnSvgNativeType) { 2061 if ($returnSvgNativeType) {
2046 $code .= <<END; 2062 $code .= <<END;
2047 if (!$expression) { 2063 if (!$expression) {
2048 throwTypeError(ExceptionMessages::failedToSet(\"${attrName}\", \"${inter faceName}\", \"The provided value is not of type '$returnType'.\"), info.GetIsol ate()); 2064 exceptionState.throwTypeError(\"The provided value is not of type '$retu rnType'.\");
2065 exceptionState.throwIfNeeded();
2049 return; 2066 return;
2050 } 2067 }
2051 END 2068 END
2052 $expression = $expression . "->propertyReference()"; 2069 $expression = $expression . "->propertyReference()";
2053 } 2070 }
2054 2071
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") { 2072 if ($attribute->type eq "EventHandler") {
2065 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 2073 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
2066 my $implementedByImplName; 2074 my $implementedByImplName;
2067 if ($implementedBy) { 2075 if ($implementedBy) {
2068 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy ); 2076 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy );
2069 } 2077 }
2070 if (!InheritsInterface($interface, "Node")) { 2078 if (!InheritsInterface($interface, "Node")) {
2071 my $attrImplName = GetImplName($attribute); 2079 my $attrImplName = GetImplName($attribute);
2072 my @arguments; 2080 my @arguments;
2073 if ($implementedBy) { 2081 if ($implementedBy) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 sub GenerateFunction 2332 sub GenerateFunction
2325 { 2333 {
2326 my $function = shift; 2334 my $function = shift;
2327 my $interface = shift; 2335 my $interface = shift;
2328 my $forMainWorldSuffix = shift; 2336 my $forMainWorldSuffix = shift;
2329 2337
2330 my $interfaceName = $interface->name; 2338 my $interfaceName = $interface->name;
2331 my $implClassName = GetImplName($interface); 2339 my $implClassName = GetImplName($interface);
2332 my $v8ClassName = GetV8ClassName($interface); 2340 my $v8ClassName = GetV8ClassName($interface);
2333 my $name = $function->name; 2341 my $name = $function->name;
2342 my $unoverloadedName = $function->name;
2334 my $implName = GetImplName($function); 2343 my $implName = GetImplName($function);
2335 my $funcExt = $function->extendedAttributes; 2344 my $funcExt = $function->extendedAttributes;
2336 2345
2337 if (HasCustomMethod($funcExt) || $name eq "") { 2346 if (HasCustomMethod($funcExt) || $name eq "") {
2338 return; 2347 return;
2339 } 2348 }
2340 2349
2341 if (@{$function->{overloads}} > 1) { 2350 if (@{$function->{overloads}} > 1) {
2342 # Append a number to an overloaded method's name to make it unique: 2351 # Append a number to an overloaded method's name to make it unique:
2343 $name = $name . $function->{overloadIndex}; 2352 $name = $name . $function->{overloadIndex};
2344 } 2353 }
2345 2354
2346 my $conditionalString = GenerateConditionalString($function); 2355 my $conditionalString = GenerateConditionalString($function);
2347 my $code = ""; 2356 my $code = "";
2348 $code .= "#if ${conditionalString}\n" if $conditionalString; 2357 $code .= "#if ${conditionalString}\n" if $conditionalString;
2349 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n"; 2358 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n";
2350 $code .= "{\n"; 2359 $code .= "{\n";
2351 2360
2352 if ($name eq "addEventListener" || $name eq "removeEventListener") { 2361 # We throw exceptions using 'ExceptionState' if the function explicitly clai ms that exceptions
2362 # may be raised, or for event listeners, or for security-checking, and for w eird SVG stuff.
2363 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi stener";
2364 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"};
2365 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2366 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2367 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/);
2368
2369 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i sNonListSVGType) {
2370 AddToImplIncludes("bindings/v8/ExceptionState.h");
2371 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol ate());\n";
2372 }
2373
2374 if ($isEventListener) {
2353 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; 2375 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only";
2354 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; 2376 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2355 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; 2377 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2356 2378
2357 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2379 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2358 AddToImplIncludes("bindings/v8/ExceptionState.h");
2359 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 2380 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
2360 AddToImplIncludes("core/frame/DOMWindow.h"); 2381 AddToImplIncludes("core/frame/DOMWindow.h");
2361 $code .= <<END; 2382 $code .= <<END;
2362 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); 2383 EventTarget* impl = ${v8ClassName}::toNative(info.Holder());
2363 if (DOMWindow* window = impl->toDOMWindow()) { 2384 if (DOMWindow* window = impl->toDOMWindow()) {
2364 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
2365 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio nState)) { 2385 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio nState)) {
2366 exceptionState.throwIfNeeded(); 2386 exceptionState.throwIfNeeded();
2367 return; 2387 return;
2368 } 2388 }
2369 if (!window->document()) 2389 if (!window->document())
2370 return; 2390 return;
2371 } 2391 }
2372 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType}); 2392 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType});
2373 if (listener) { 2393 if (listener) {
2374 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]); 2394 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]);
(...skipping 15 matching lines...) Expand all
2390 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); 2410 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h");
2391 $code .= <<END; 2411 $code .= <<END;
2392 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(info); 2412 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(info);
2393 } 2413 }
2394 2414
2395 END 2415 END
2396 $implementation{nameSpaceInternal}->add($code); 2416 $implementation{nameSpaceInternal}->add($code);
2397 return; 2417 return;
2398 } 2418 }
2399 2419
2400 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2401
2402 if ($svgNativeType) { 2420 if ($svgNativeType) {
2403 my $nativeClassName = GetNativeType($interfaceName); 2421 my $nativeClassName = GetNativeType($interfaceName);
2404 if ($interfaceName =~ /List$/) { 2422 if ($interfaceName =~ /List$/) {
2405 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H older());\n"; 2423 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H older());\n";
2406 } else { 2424 } else {
2407 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2408 AddToImplIncludes("bindings/v8/ExceptionState.h");
2409 AddToImplIncludes("core/dom/ExceptionCode.h"); 2425 AddToImplIncludes("core/dom/ExceptionCode.h");
2410 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in fo.Holder());\n"; 2426 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in fo.Holder());\n";
2411 $code .= " if (wrapper->isReadOnly()) {\n"; 2427 $code .= " if (wrapper->isReadOnly()) {\n";
2412 $code .= " setDOMException(NoModificationAllowedError, Except ionMessages::failedToExecute(\"${name}\", \"${interfaceName}\", \"The object is read-only.\"), info.GetIsolate());\n"; 2428 $code .= " exceptionState.throwDOMException(NoModificationAll owedError, \"The object is read-only.\");\n";
2429 $code .= " exceptionState.throwIfNeeded();\n";
2413 $code .= " return;\n"; 2430 $code .= " return;\n";
2414 $code .= " }\n"; 2431 $code .= " }\n";
2415 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName); 2432 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName);
2416 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 2433 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
2417 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 2434 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
2418 } 2435 }
2419 } elsif (!$function->isStatic) { 2436 } elsif (!$function->isStatic) {
2420 $code .= <<END; 2437 $code .= <<END;
2421 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 2438 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
2422 END 2439 END
2423 } 2440 }
2424 2441
2425 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); 2442 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt);
2426 2443
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 2444 # Check domain security if needed
2435 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) { 2445 if ($isSecurityCheckNecessary) {
2436 # We have not find real use cases yet. 2446 # We have not find real use cases yet.
2437 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2447 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2438 $code .= <<END; 2448 $code .= <<END;
2439 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 2449 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
2440 exceptionState.throwIfNeeded(); 2450 exceptionState.throwIfNeeded();
2441 return; 2451 return;
2442 } 2452 }
2443 END 2453 END
2444 } 2454 }
2445 2455
(...skipping 4004 matching lines...) Expand 10 before | Expand all | Expand 10 after
6450 return 1 if $name eq "ErrorCallback"; 6460 return 1 if $name eq "ErrorCallback";
6451 return 1 if $name eq "FileCallback"; 6461 return 1 if $name eq "FileCallback";
6452 return 1 if $name eq "FileSystemCallback"; 6462 return 1 if $name eq "FileSystemCallback";
6453 return 1 if $name eq "FileSystemVoidCallback"; 6463 return 1 if $name eq "FileSystemVoidCallback";
6454 return 1 if $name eq "FileWriterCallback"; 6464 return 1 if $name eq "FileWriterCallback";
6455 return 1 if $name eq "MetadataCallback"; 6465 return 1 if $name eq "MetadataCallback";
6456 return 0; 6466 return 0;
6457 } 6467 }
6458 6468
6459 1; 6469 1;
OLDNEW
« no previous file with comments | « LayoutTests/webaudio/dom-exceptions-expected.txt ('k') | Source/bindings/tests/results/V8SupportTestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698