Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
| index 0ac2cb919c8facb5746e548989a81f6ae4158897..97c0b0a07376ec115ec8576845b87ecccc6cf46c 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
| @@ -28,6 +28,7 @@ |
| #include "bindings/core/v8/V8DOMConfiguration.h" |
| +#include "bindings/core/v8/V8SnapshotUtil.h" |
| #include "platform/bindings/V8ObjectConstructor.h" |
| #include "platform/bindings/V8PerContextData.h" |
| #include "platform/instrumentation/tracing/TraceEvent.h" |
| @@ -107,12 +108,12 @@ void InstallAttributeInternal( |
| DCHECK(location); |
| v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| - if (location & V8DOMConfiguration::kOnInstance) { |
| + if (location & V8DOMConfiguration::kOnInstance && !instance.IsEmpty()) { |
| instance |
| ->SetNativeDataProperty(context, name, getter, setter, data, attribute) |
| .ToChecked(); |
| } |
| - if (location & V8DOMConfiguration::kOnPrototype) { |
| + if (location & V8DOMConfiguration::kOnPrototype && !prototype.IsEmpty()) { |
| prototype |
| ->SetNativeDataProperty(context, name, getter, setter, data, attribute) |
| .ToChecked(); |
| @@ -241,8 +242,9 @@ void InstallAccessorInternal( |
| v8::Local<v8::Value> data = |
| v8::External::New(isolate, const_cast<WrapperTypeInfo*>(accessor.data)); |
| - DCHECK(accessor.property_location_configuration); |
| - if (accessor.property_location_configuration & |
| + const unsigned location = accessor.property_location_configuration; |
| + DCHECK(location); |
| + if (location & |
| (V8DOMConfiguration::kOnInstance | V8DOMConfiguration::kOnPrototype)) { |
| v8::Local<FunctionOrTemplate> getter = |
| CreateAccessorFunctionOrTemplate<FunctionOrTemplate>( |
| @@ -250,21 +252,21 @@ void InstallAccessorInternal( |
| v8::Local<FunctionOrTemplate> setter = |
| CreateAccessorFunctionOrTemplate<FunctionOrTemplate>( |
| isolate, setter_callback, nullptr, data, signature, 1); |
| - if (accessor.property_location_configuration & |
| - V8DOMConfiguration::kOnInstance) { |
| + if (location & V8DOMConfiguration::kOnInstance && |
| + !instance_or_template.IsEmpty()) { |
| instance_or_template->SetAccessorProperty( |
| name, getter, setter, |
| static_cast<v8::PropertyAttribute>(accessor.attribute)); |
| } |
| - if (accessor.property_location_configuration & |
| - V8DOMConfiguration::kOnPrototype) { |
| + if (location & V8DOMConfiguration::kOnPrototype && |
| + !prototype_or_template.IsEmpty()) { |
| prototype_or_template->SetAccessorProperty( |
| name, getter, setter, |
| static_cast<v8::PropertyAttribute>(accessor.attribute)); |
| } |
| } |
| - if (accessor.property_location_configuration & |
| - V8DOMConfiguration::kOnInterface) { |
| + if (location & V8DOMConfiguration::kOnInterface && |
| + !interface_or_template.IsEmpty()) { |
| // Attributes installed on the interface object must be static |
| // attributes, so no need to specify a signature, i.e. no need to do |
| // type check against a holder. |
| @@ -437,8 +439,9 @@ void InstallMethodInternal( |
| V8DOMConfiguration::kDoNotCheckHolder) |
| signature = v8::Local<v8::Signature>(); |
| - DCHECK(method.property_location_configuration); |
| - if (method.property_location_configuration & |
| + const unsigned location = method.property_location_configuration; |
| + DCHECK(location); |
| + if (location & |
| (V8DOMConfiguration::kOnInstance | V8DOMConfiguration::kOnPrototype)) { |
| v8::Local<v8::FunctionTemplate> function_template = |
| v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
| @@ -449,23 +452,22 @@ void InstallMethodInternal( |
| v8::Local<v8::Function> function = |
| function_template->GetFunction(isolate->GetCurrentContext()) |
| .ToLocalChecked(); |
| - if (method.property_location_configuration & |
| - V8DOMConfiguration::kOnInstance) |
| + if (location & V8DOMConfiguration::kOnInstance && !instance.IsEmpty()) { |
| instance |
| ->DefineOwnProperty( |
| isolate->GetCurrentContext(), name, function, |
| static_cast<v8::PropertyAttribute>(method.attribute)) |
| .ToChecked(); |
| - if (method.property_location_configuration & |
| - V8DOMConfiguration::kOnPrototype) |
| + } |
| + if (location & V8DOMConfiguration::kOnPrototype && !prototype.IsEmpty()) { |
| prototype |
| ->DefineOwnProperty( |
| isolate->GetCurrentContext(), name, function, |
| static_cast<v8::PropertyAttribute>(method.attribute)) |
| .ToChecked(); |
| + } |
| } |
| - if (method.property_location_configuration & |
| - V8DOMConfiguration::kOnInterface) { |
| + if (location & V8DOMConfiguration::kOnInterface && !interface.IsEmpty()) { |
| // Operations installed on the interface object must be static |
| // operations, so no need to specify a signature, i.e. no need to do |
| // type check against a holder. |
| @@ -730,16 +732,21 @@ v8::Local<v8::FunctionTemplate> V8DOMConfiguration::DomClassTemplate( |
| WrapperTypeInfo* wrapper_type_info, |
| InstallTemplateFunction configure_dom_class_template) { |
| V8PerIsolateData* data = V8PerIsolateData::From(isolate); |
| - v8::Local<v8::FunctionTemplate> result = |
| + v8::Local<v8::FunctionTemplate> interface_template = |
| data->FindInterfaceTemplate(world, wrapper_type_info); |
| - if (!result.IsEmpty()) |
| - return result; |
| - |
| - result = v8::FunctionTemplate::New( |
| - isolate, V8ObjectConstructor::IsValidConstructorMode); |
| - configure_dom_class_template(isolate, world, result); |
| - data->SetInterfaceTemplate(world, wrapper_type_info, result); |
| - return result; |
| + if (!interface_template.IsEmpty()) |
| + return interface_template; |
| + |
| + interface_template = V8SnapshotUtil::InterfaceTemplateFromSnapshot( |
|
Yuki
2017/06/20 14:20:11
Do we really need this code?
V8SnapshotUtil::Ensur
peria
2017/06/21 07:19:16
Done.
|
| + isolate, world, wrapper_type_info); |
| + |
| + if (interface_template.IsEmpty()) { |
| + interface_template = v8::FunctionTemplate::New( |
| + isolate, V8ObjectConstructor::IsValidConstructorMode); |
| + configure_dom_class_template(isolate, world, interface_template); |
| + } |
| + data->SetInterfaceTemplate(world, wrapper_type_info, interface_template); |
| + return interface_template; |
| } |
| void V8DOMConfiguration::SetClassString( |