Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 v8::Local<v8::Signature> signature, | 351 v8::Local<v8::Signature> signature, |
| 352 const Configuration& method, | 352 const Configuration& method, |
| 353 const DOMWrapperWorld& world) { | 353 const DOMWrapperWorld& world) { |
| 354 if (method.exposeConfiguration == | 354 if (method.exposeConfiguration == |
| 355 V8DOMConfiguration::OnlyExposedToPrivateScript && | 355 V8DOMConfiguration::OnlyExposedToPrivateScript && |
| 356 !world.isPrivateScriptIsolatedWorld()) | 356 !world.isPrivateScriptIsolatedWorld()) |
| 357 return; | 357 return; |
| 358 | 358 |
| 359 v8::Local<v8::Name> name = method.methodName(isolate); | 359 v8::Local<v8::Name> name = method.methodName(isolate); |
| 360 v8::FunctionCallback callback = method.callbackForWorld(world); | 360 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 361 // Promise-returning functions need to return a reject promise when | |
| 362 // an exception occurs. This includes a case that the receiver object is not | |
| 363 // of the type. So, we disable the type check of the receiver object on V8 | |
| 364 // side so that V8 won't throw. Instead, we do the check on Blink side and | |
| 365 // convert an exception to a reject promise. | |
| 366 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) | |
| 367 signature = v8::Local<v8::Signature>(); | |
| 361 | 368 |
| 362 DCHECK(method.propertyLocationConfiguration); | 369 DCHECK(method.propertyLocationConfiguration); |
| 363 if (method.propertyLocationConfiguration & | 370 if (method.propertyLocationConfiguration & |
| 364 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { | 371 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { |
| 365 v8::Local<v8::FunctionTemplate> functionTemplate = | 372 v8::Local<v8::FunctionTemplate> functionTemplate = |
| 366 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 373 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
| 367 signature, method.length); | 374 signature, method.length); |
| 368 functionTemplate->RemovePrototype(); | 375 functionTemplate->RemovePrototype(); |
| 369 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstance) | 376 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstance) |
| 370 instanceTemplate->Set( | 377 instanceTemplate->Set( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 382 v8::Local<v8::FunctionTemplate> functionTemplate = | 389 v8::Local<v8::FunctionTemplate> functionTemplate = |
| 383 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 390 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
| 384 v8::Local<v8::Signature>(), method.length); | 391 v8::Local<v8::Signature>(), method.length); |
| 385 functionTemplate->RemovePrototype(); | 392 functionTemplate->RemovePrototype(); |
| 386 interfaceTemplate->Set( | 393 interfaceTemplate->Set( |
| 387 name, functionTemplate, | 394 name, functionTemplate, |
| 388 static_cast<v8::PropertyAttribute>(method.attribute)); | 395 static_cast<v8::PropertyAttribute>(method.attribute)); |
| 389 } | 396 } |
| 390 } | 397 } |
| 391 | 398 |
| 392 void installMethodInternal( | 399 void installMethodInternal( |
|
haraken
2016/11/16 17:37:31
Not related to this CL, why do we (need to) have t
Yuki
2016/11/17 07:14:28
One for the interface template / prototype tempalt
| |
| 393 v8::Isolate* isolate, | 400 v8::Isolate* isolate, |
| 394 v8::Local<v8::Object> instance, | 401 v8::Local<v8::Object> instance, |
| 395 v8::Local<v8::Object> prototype, | 402 v8::Local<v8::Object> prototype, |
| 396 v8::Local<v8::Function> interface, | 403 v8::Local<v8::Function> interface, |
| 397 v8::Local<v8::Signature> signature, | 404 v8::Local<v8::Signature> signature, |
| 398 const V8DOMConfiguration::MethodConfiguration& method, | 405 const V8DOMConfiguration::MethodConfiguration& method, |
| 399 const DOMWrapperWorld& world) { | 406 const DOMWrapperWorld& world) { |
| 400 if (method.exposeConfiguration == | 407 if (method.exposeConfiguration == |
| 401 V8DOMConfiguration::OnlyExposedToPrivateScript && | 408 V8DOMConfiguration::OnlyExposedToPrivateScript && |
| 402 !world.isPrivateScriptIsolatedWorld()) | 409 !world.isPrivateScriptIsolatedWorld()) |
| 403 return; | 410 return; |
| 404 | 411 |
| 405 v8::Local<v8::Name> name = method.methodName(isolate); | 412 v8::Local<v8::Name> name = method.methodName(isolate); |
| 406 v8::FunctionCallback callback = method.callbackForWorld(world); | 413 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 414 // Promise-returning functions need to return a reject promise when | |
| 415 // an exception occurs. This includes a case that the receiver object is not | |
| 416 // of the type. So, we disable the type check of the receiver object on V8 | |
| 417 // side so that V8 won't throw. Instead, we do the check on Blink side and | |
| 418 // convert an exception to a reject promise. | |
| 419 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) | |
| 420 signature = v8::Local<v8::Signature>(); | |
| 407 | 421 |
| 408 DCHECK(method.propertyLocationConfiguration); | 422 DCHECK(method.propertyLocationConfiguration); |
| 409 if (method.propertyLocationConfiguration & | 423 if (method.propertyLocationConfiguration & |
| 410 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { | 424 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { |
| 411 v8::Local<v8::FunctionTemplate> functionTemplate = | 425 v8::Local<v8::FunctionTemplate> functionTemplate = |
| 412 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 426 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
| 413 signature, method.length); | 427 signature, method.length); |
| 414 functionTemplate->RemovePrototype(); | 428 functionTemplate->RemovePrototype(); |
| 415 v8::Local<v8::Function> function = | 429 v8::Local<v8::Function> function = |
| 416 functionTemplate->GetFunction(isolate->GetCurrentContext()) | 430 functionTemplate->GetFunction(isolate->GetCurrentContext()) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 void V8DOMConfiguration::setClassString( | 682 void V8DOMConfiguration::setClassString( |
| 669 v8::Isolate* isolate, | 683 v8::Isolate* isolate, |
| 670 v8::Local<v8::ObjectTemplate> objectTemplate, | 684 v8::Local<v8::ObjectTemplate> objectTemplate, |
| 671 const char* classString) { | 685 const char* classString) { |
| 672 objectTemplate->Set( | 686 objectTemplate->Set( |
| 673 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), | 687 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), |
| 674 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 688 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
| 675 } | 689 } |
| 676 | 690 |
| 677 } // namespace blink | 691 } // namespace blink |
| OLD | NEW |