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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 | 1161 |
1162 my $interface = ParseInterface($implementedBy); | 1162 my $interface = ParseInterface($implementedBy); |
1163 | 1163 |
1164 return $interface->extendedAttributes->{"ImplementedAs"} || $implementedBy; | 1164 return $interface->extendedAttributes->{"ImplementedAs"} || $implementedBy; |
1165 } | 1165 } |
1166 | 1166 |
1167 sub GenerateDomainSafeFunctionGetter | 1167 sub GenerateDomainSafeFunctionGetter |
1168 { | 1168 { |
1169 my $function = shift; | 1169 my $function = shift; |
1170 my $interface = shift; | 1170 my $interface = shift; |
| 1171 my $forMainWorldSuffix = shift; |
1171 | 1172 |
1172 my $implClassName = GetImplName($interface); | 1173 my $implClassName = GetImplName($interface); |
1173 my $v8ClassName = GetV8ClassName($interface); | 1174 my $v8ClassName = GetV8ClassName($interface); |
1174 my $funcName = $function->name; | 1175 my $funcName = $function->name; |
1175 | 1176 |
1176 my $functionLength = GetFunctionLength($function); | 1177 my $functionLength = GetFunctionLength($function); |
1177 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate()
)->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))"; | 1178 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate()
)->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))"; |
1178 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { | 1179 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { |
1179 $signature = "v8::Local<v8::Signature>()"; | 1180 $signature = "v8::Local<v8::Signature>()"; |
1180 } | 1181 } |
1181 | 1182 |
1182 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba
ck, v8Undefined(), $signature"; | 1183 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba
ck${forMainWorldSuffix}, v8Undefined(), $signature"; |
1183 | 1184 |
1184 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1185 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
1185 $implementation{nameSpaceInternal}->add(<<END); | 1186 $implementation{nameSpaceInternal}->add(<<END); |
1186 static void ${funcName}AttributeGetter(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Value>& info) | 1187 static void ${funcName}AttributeGetter${forMainWorldSuffix}(v8::Local<v8::String
> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
1187 { | 1188 { |
1188 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 1189 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
1189 static int privateTemplateUniqueKey; | 1190 static int privateTemplateUniqueKey; |
1190 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 1191 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
1191 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 1192 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
1192 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLength); | 1193 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLength); |
1193 | 1194 |
1194 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), currentWorldType)); | 1195 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), currentWorldType)); |
1195 if (holder.IsEmpty()) { | 1196 if (holder.IsEmpty()) { |
1196 // can only reach here by 'object.__proto__.func', and it should passed | 1197 // can only reach here by 'object.__proto__.func', and it should passed |
(...skipping 13 matching lines...) Expand all Loading... |
1210 if (!hiddenValue.IsEmpty()) { | 1211 if (!hiddenValue.IsEmpty()) { |
1211 v8SetReturnValue(info, hiddenValue); | 1212 v8SetReturnValue(info, hiddenValue); |
1212 return; | 1213 return; |
1213 } | 1214 } |
1214 | 1215 |
1215 v8SetReturnValue(info, privateTemplate->GetFunction()); | 1216 v8SetReturnValue(info, privateTemplate->GetFunction()); |
1216 } | 1217 } |
1217 | 1218 |
1218 END | 1219 END |
1219 $implementation{nameSpaceInternal}->add(<<END); | 1220 $implementation{nameSpaceInternal}->add(<<END); |
1220 static void ${funcName}AttributeGetterCallback(v8::Local<v8::String> name, const
v8::PropertyCallbackInfo<v8::Value>& info) | 1221 static void ${funcName}AttributeGetterCallback${forMainWorldSuffix}(v8::Local<v8
::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
1221 { | 1222 { |
1222 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 1223 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
1223 ${implClassName}V8Internal::${funcName}AttributeGetter(name, info); | 1224 ${implClassName}V8Internal::${funcName}AttributeGetter${forMainWorldSuffix}(
name, info); |
1224 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 1225 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
1225 } | 1226 } |
1226 | 1227 |
1227 END | 1228 END |
1228 } | 1229 } |
1229 | 1230 |
1230 sub GenerateDomainSafeFunctionSetter | 1231 sub GenerateDomainSafeFunctionSetter |
1231 { | 1232 { |
1232 my $interface = shift; | 1233 my $interface = shift; |
1233 | 1234 |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 | 3281 |
3281 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { | 3282 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { |
3282 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal:
:${implClassName}DomainSafeFunctionSetter"; | 3283 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal:
:${implClassName}DomainSafeFunctionSetter"; |
3283 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed | 3284 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed |
3284 # and then accessed on a different domain we do not return the underlyin
g value but instead | 3285 # and then accessed on a different domain we do not return the underlyin
g value but instead |
3285 # return a new copy of the original function. This is achieved by storin
g the changed value | 3286 # return a new copy of the original function. This is achieved by storin
g the changed value |
3286 # as hidden property. | 3287 # as hidden property. |
3287 $code .= <<END; | 3288 $code .= <<END; |
3288 | 3289 |
3289 // $commentInfo | 3290 // $commentInfo |
3290 ${conditional}$template->SetAccessor(v8::String::NewSymbol("$name"), ${implC
lassName}V8Internal::${name}AttributeGetterCallback, ${setter}, v8Undefined(), v
8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); | |
3291 END | 3291 END |
| 3292 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
| 3293 $code .= " if (currentWorldType == MainWorld) {\n"; |
| 3294 $code .= " ${conditional}$template->SetAccessor(v8::String::NewSy
mbol(\"$name\"), ${implClassName}V8Internal::${name}AttributeGetterCallbackForMa
inWorld, ${setter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAtt
ribute>($property_attributes));\n"; |
| 3295 $code .= " } else {\n"; |
| 3296 $code .= " ${conditional}$template->SetAccessor(v8::String::NewSy
mbol(\"$name\"), ${implClassName}V8Internal::${name}AttributeGetterCallback, ${s
etter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($pro
perty_attributes));\n"; |
| 3297 $code .= " }\n"; |
| 3298 } else { |
| 3299 $code .= " ${conditional}$template->SetAccessor(v8::String::NewSymbol
(\"$name\"), ${implClassName}V8Internal::${name}AttributeGetterCallback, ${sette
r}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($propert
y_attributes));\n"; |
| 3300 } |
| 3301 |
3292 return $code; | 3302 return $code; |
3293 } | 3303 } |
3294 | 3304 |
3295 my $signature = "defaultSignature"; | 3305 my $signature = "defaultSignature"; |
3296 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { | 3306 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { |
3297 $signature = "v8::Local<v8::Signature>()"; | 3307 $signature = "v8::Local<v8::Signature>()"; |
3298 } | 3308 } |
3299 | 3309 |
3300 my $conditionalString = GenerateConditionalString($function); | 3310 my $conditionalString = GenerateConditionalString($function); |
3301 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3311 $code .= "#if ${conditionalString}\n" if $conditionalString; |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4227 if ($function->extendedAttributes->{"PerWorldBindings"}) { | 4237 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
4228 GenerateFunctionCallback($function, $interface, "ForMainWorld"); | 4238 GenerateFunctionCallback($function, $interface, "ForMainWorld"); |
4229 } | 4239 } |
4230 } | 4240 } |
4231 | 4241 |
4232 # If the function does not need domain security check, we need to | 4242 # If the function does not need domain security check, we need to |
4233 # generate an access getter that returns different function objects | 4243 # generate an access getter that returns different function objects |
4234 # for different calling context. | 4244 # for different calling context. |
4235 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->exte
ndedAttributes->{"DoNotCheckSecurity"}) { | 4245 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->exte
ndedAttributes->{"DoNotCheckSecurity"}) { |
4236 if (!HasCustomMethod($function->extendedAttributes) || $function->{o
verloadIndex} == 1) { | 4246 if (!HasCustomMethod($function->extendedAttributes) || $function->{o
verloadIndex} == 1) { |
4237 GenerateDomainSafeFunctionGetter($function, $interface); | 4247 my @worldSuffixes = (""); |
| 4248 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
| 4249 push(@worldSuffixes, "ForMainWorld"); |
| 4250 } |
| 4251 foreach my $worldSuffix (@worldSuffixes) { |
| 4252 GenerateDomainSafeFunctionGetter($function, $interface, $wor
ldSuffix); |
| 4253 } |
4238 if (!$function->extendedAttributes->{"ReadOnly"}) { | 4254 if (!$function->extendedAttributes->{"ReadOnly"}) { |
4239 $needsDomainSafeFunctionSetter = 1; | 4255 $needsDomainSafeFunctionSetter = 1; |
4240 } | 4256 } |
4241 } | 4257 } |
4242 } | 4258 } |
4243 | 4259 |
4244 # Separate out functions that are enabled per context so we can process
them specially. | 4260 # Separate out functions that are enabled per context so we can process
them specially. |
4245 if ($function->extendedAttributes->{"PerContextEnabled"}) { | 4261 if ($function->extendedAttributes->{"PerContextEnabled"}) { |
4246 push(@perContextEnabledFunctions, $function); | 4262 push(@perContextEnabledFunctions, $function); |
4247 } else { | 4263 } else { |
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6283 | 6299 |
6284 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6300 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6285 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6301 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6286 return 1 if InheritsInterface($interface, "Document"); | 6302 return 1 if InheritsInterface($interface, "Document"); |
6287 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); | 6303 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); |
6288 | 6304 |
6289 return 0; | 6305 return 0; |
6290 } | 6306 } |
6291 | 6307 |
6292 1; | 6308 1; |
OLD | NEW |