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