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..8d468ff91cea4fe67961b097447c4290821df151 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp |
@@ -107,12 +107,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 +241,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 +251,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 +438,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 +451,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 +731,16 @@ 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; |
+ if (!interface_template.IsEmpty()) |
+ return interface_template; |
- result = v8::FunctionTemplate::New( |
+ interface_template = v8::FunctionTemplate::New( |
isolate, V8ObjectConstructor::IsValidConstructorMode); |
- configure_dom_class_template(isolate, world, result); |
- data->SetInterfaceTemplate(world, wrapper_type_info, result); |
- return result; |
+ configure_dom_class_template(isolate, world, interface_template); |
+ data->SetInterfaceTemplate(world, wrapper_type_info, interface_template); |
+ return interface_template; |
} |
void V8DOMConfiguration::SetClassString( |