Chromium Code Reviews| Index: third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp |
| diff --git a/third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp b/third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp |
| index 186ca2f0102b663fa9f0a738baee8afe53280562..d2d9e79933fb37b1230b70e39db8d5e722729d31 100644 |
| --- a/third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp |
| +++ b/third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp |
| @@ -65,6 +65,50 @@ v8::Local<v8::Object> V8DOMWrapper::CreateWrapper( |
| return wrapper; |
| } |
| +namespace { |
| + |
| +v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, |
|
Yuki
2017/05/30 14:35:57
Why don't you remove this function?
peria
2017/06/01 08:33:34
Done.
|
| + const DOMWrapperWorld& world, |
| + v8::Local<v8::Context> context, |
| + const WrapperTypeInfo* type) { |
| + v8::Context::Scope scope(context); |
| + // We shouldn't reach this point for the types that are implemented in v8 such |
| + // as typed arrays and hence don't have domTemplateFunction. |
| + DCHECK(type->dom_template_function); |
| + v8::Local<v8::FunctionTemplate> interface_template = |
| + type->domTemplate(isolate, world); |
| + // Getting the function might fail if we're running out of stack or memory. |
| + v8::Local<v8::Function> interface_object; |
| + if (!interface_template->GetFunction(context).ToLocal(&interface_object)) |
| + return v8::Local<v8::Function>(); |
| + |
| + if (type->parent_class) { |
| + v8::Local<v8::Object> prototype_template = |
| + ConstructPlainType(isolate, world, context, type->parent_class); |
| + CHECK(interface_object->SetPrototype(context, prototype_template) |
| + .ToChecked()); |
| + } |
| + |
| + v8::Local<v8::Value> prototype_value; |
| + CHECK(interface_object->Get(context, V8AtomicString(isolate, "prototype")) |
| + .ToLocal(&prototype_value)); |
| + CHECK(prototype_value->IsObject()); |
| + v8::Local<v8::Object> prototype_object = prototype_value.As<v8::Object>(); |
| + if (prototype_object->InternalFieldCount() == |
| + kV8PrototypeInternalFieldcount && |
| + type->wrapper_type_prototype == |
| + WrapperTypeInfo::kWrapperTypeObjectPrototype) { |
| + prototype_object->SetAlignedPointerInInternalField( |
| + kV8PrototypeTypeIndex, const_cast<WrapperTypeInfo*>(type)); |
| + } |
| + type->PreparePrototypeAndInterfaceObject( |
| + context, world, prototype_object, interface_object, interface_template); |
| + |
| + return interface_object; |
| +} |
| + |
| +} // namespace |
| + |
| bool V8DOMWrapper::IsWrapper(v8::Isolate* isolate, v8::Local<v8::Value> value) { |
| if (value.IsEmpty() || !value->IsObject()) |
| return false; |