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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 signature = v8::Local<v8::Signature>(); | 463 signature = v8::Local<v8::Signature>(); |
464 | 464 |
465 const unsigned location = config.property_location_configuration; | 465 const unsigned location = config.property_location_configuration; |
466 DCHECK(location); | 466 DCHECK(location); |
467 if (location & | 467 if (location & |
468 (V8DOMConfiguration::kOnInstance | V8DOMConfiguration::kOnPrototype)) { | 468 (V8DOMConfiguration::kOnInstance | V8DOMConfiguration::kOnPrototype)) { |
469 v8::Local<v8::FunctionTemplate> function_template = | 469 v8::Local<v8::FunctionTemplate> function_template = |
470 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 470 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
471 signature, config.length); | 471 signature, config.length); |
472 function_template->RemovePrototype(); | 472 function_template->RemovePrototype(); |
473 if (config.access_check_configuration == V8DOMConfiguration::kCheckAccess) { | 473 if (config.access_check_configuration == V8DOMConfiguration::kCheckAccess) |
474 function_template->SetAcceptAnyReceiver(false); | 474 function_template->SetAcceptAnyReceiver(false); |
475 } | |
476 v8::Local<v8::Function> function = | 475 v8::Local<v8::Function> function = |
477 function_template->GetFunction(isolate->GetCurrentContext()) | 476 function_template->GetFunction(isolate->GetCurrentContext()) |
478 .ToLocalChecked(); | 477 .ToLocalChecked(); |
479 if (location & V8DOMConfiguration::kOnInstance && !instance.IsEmpty()) { | 478 if (location & V8DOMConfiguration::kOnInstance && !instance.IsEmpty()) |
480 instance | 479 instance |
481 ->DefineOwnProperty( | 480 ->DefineOwnProperty( |
482 isolate->GetCurrentContext(), name, function, | 481 isolate->GetCurrentContext(), name, function, |
483 static_cast<v8::PropertyAttribute>(config.attribute)) | 482 static_cast<v8::PropertyAttribute>(config.attribute)) |
484 .ToChecked(); | 483 .ToChecked(); |
485 } | 484 if (location & V8DOMConfiguration::kOnPrototype && !prototype.IsEmpty()) |
486 if (location & V8DOMConfiguration::kOnPrototype && !prototype.IsEmpty()) { | |
487 prototype | 485 prototype |
488 ->DefineOwnProperty( | 486 ->DefineOwnProperty( |
489 isolate->GetCurrentContext(), name, function, | 487 isolate->GetCurrentContext(), name, function, |
490 static_cast<v8::PropertyAttribute>(config.attribute)) | 488 static_cast<v8::PropertyAttribute>(config.attribute)) |
491 .ToChecked(); | 489 .ToChecked(); |
492 } | |
493 } | 490 } |
494 if (location & V8DOMConfiguration::kOnInterface && !interface.IsEmpty()) { | 491 if (location & V8DOMConfiguration::kOnInterface && !interface.IsEmpty()) { |
495 // Operations installed on the interface object must be static | 492 // Operations installed on the interface object must be static |
496 // operations, so no need to specify a signature, i.e. no need to do | 493 // operations, so no need to specify a signature, i.e. no need to do |
497 // type check against a holder. | 494 // type check against a holder. |
498 v8::Local<v8::FunctionTemplate> function_template = | 495 v8::Local<v8::FunctionTemplate> function_template = |
499 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 496 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
500 v8::Local<v8::Signature>(), config.length); | 497 v8::Local<v8::Signature>(), config.length); |
501 function_template->RemovePrototype(); | 498 function_template->RemovePrototype(); |
502 v8::Local<v8::Function> function = | 499 v8::Local<v8::Function> function = |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 prototype_template->SetInternalFieldCount(kV8PrototypeInternalFieldcount); | 746 prototype_template->SetInternalFieldCount(kV8PrototypeInternalFieldcount); |
750 } | 747 } |
751 } | 748 } |
752 | 749 |
753 v8::Local<v8::FunctionTemplate> V8DOMConfiguration::DomClassTemplate( | 750 v8::Local<v8::FunctionTemplate> V8DOMConfiguration::DomClassTemplate( |
754 v8::Isolate* isolate, | 751 v8::Isolate* isolate, |
755 const DOMWrapperWorld& world, | 752 const DOMWrapperWorld& world, |
756 WrapperTypeInfo* wrapper_type_info, | 753 WrapperTypeInfo* wrapper_type_info, |
757 InstallTemplateFunction configure_dom_class_template) { | 754 InstallTemplateFunction configure_dom_class_template) { |
758 V8PerIsolateData* data = V8PerIsolateData::From(isolate); | 755 V8PerIsolateData* data = V8PerIsolateData::From(isolate); |
759 v8::Local<v8::FunctionTemplate> interface_template = | 756 v8::Local<v8::FunctionTemplate> result = |
760 data->FindInterfaceTemplate(world, wrapper_type_info); | 757 data->FindInterfaceTemplate(world, wrapper_type_info); |
761 if (!interface_template.IsEmpty()) | 758 if (!result.IsEmpty()) |
762 return interface_template; | 759 return result; |
763 | 760 |
764 interface_template = v8::FunctionTemplate::New( | 761 result = v8::FunctionTemplate::New( |
765 isolate, V8ObjectConstructor::IsValidConstructorMode); | 762 isolate, V8ObjectConstructor::IsValidConstructorMode); |
766 configure_dom_class_template(isolate, world, interface_template); | 763 configure_dom_class_template(isolate, world, result); |
767 data->SetInterfaceTemplate(world, wrapper_type_info, interface_template); | 764 data->SetInterfaceTemplate(world, wrapper_type_info, result); |
768 return interface_template; | 765 return result; |
769 } | 766 } |
770 | 767 |
771 void V8DOMConfiguration::SetClassString( | 768 void V8DOMConfiguration::SetClassString( |
772 v8::Isolate* isolate, | 769 v8::Isolate* isolate, |
773 v8::Local<v8::ObjectTemplate> object_template, | 770 v8::Local<v8::ObjectTemplate> object_template, |
774 const char* class_string) { | 771 const char* class_string) { |
775 object_template->Set( | 772 object_template->Set( |
776 v8::Symbol::GetToStringTag(isolate), | 773 v8::Symbol::GetToStringTag(isolate), |
777 V8AtomicString(isolate, class_string), | 774 V8AtomicString(isolate, class_string), |
778 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 775 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
779 } | 776 } |
780 | 777 |
781 } // namespace blink | 778 } // namespace blink |
OLD | NEW |