Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp

Issue 2647643002: Fix V8 bindings for named constructors to set prototype object correctly (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. 5 // This file has been auto-generated by code_generator_v8.py.
6 // DO NOT MODIFY! 6 // DO NOT MODIFY!
7 7
8 // This file has been generated from the Jinja2 template in 8 // This file has been generated from the Jinja2 template in
9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl 9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl
10 10
11 // clang-format off 11 // clang-format off
12 #include "V8TestInterfaceEventTarget.h" 12 #include "V8TestInterfaceEventTarget.h"
13 13
14 #include "bindings/core/v8/ExceptionState.h" 14 #include "bindings/core/v8/ExceptionState.h"
15 #include "bindings/core/v8/V8DOMConfiguration.h" 15 #include "bindings/core/v8/V8DOMConfiguration.h"
16 #include "bindings/core/v8/V8ObjectConstructor.h" 16 #include "bindings/core/v8/V8ObjectConstructor.h"
17 #include "bindings/core/v8/V8PrivateProperty.h"
17 #include "core/dom/Document.h" 18 #include "core/dom/Document.h"
18 #include "core/frame/LocalDOMWindow.h" 19 #include "core/frame/LocalDOMWindow.h"
19 #include "wtf/GetPtr.h" 20 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h" 21 #include "wtf/RefPtr.h"
21 22
22 namespace blink { 23 namespace blink {
23 24
24 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 25 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
25 // and does not depend on another global objects. 26 // and does not depend on another global objects.
26 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 27 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 v8::Local<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTempla te(v8::Isolate* isolate, const DOMWrapperWorld& world) { 87 v8::Local<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTempla te(v8::Isolate* isolate, const DOMWrapperWorld& world) {
87 static int domTemplateKey; // This address is used for a key to look up the do m template. 88 static int domTemplateKey; // This address is used for a key to look up the do m template.
88 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 89 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
89 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d omTemplateKey); 90 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d omTemplateKey);
90 if (!result.IsEmpty()) 91 if (!result.IsEmpty())
91 return result; 92 return result;
92 93
93 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstruc torCallback); 94 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstruc torCallback);
94 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); 95 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
95 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFi eldCount); 96 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFi eldCount);
96 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget")); 97 result->SetClassName(v8AtomicString(isolate, "Name"));
97 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate, world)); 98 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate, world));
98 data->setInterfaceTemplate(world, &domTemplateKey, result); 99 data->setInterfaceTemplate(world, &domTemplateKey, result);
99 return result; 100 return result;
100 } 101 }
101 102
103 void V8TestInterfaceEventTargetConstructor::NamedConstructorAttributeGetter(
104 v8::Local<v8::Name> propertyName,
105 const v8::PropertyCallbackInfo<v8::Value>& info) {
106 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext();
107 V8PerContextData* perContextData = V8PerContextData::from(creationContext);
108 if (!perContextData) {
109 // TODO(yukishiino): Return a valid named constructor even after the context is detached
110 return;
111 }
112
113 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType( &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo);
114
115 // Set the prototype of named constructors to the regular constructor.
116 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info. GetIsolate());
117 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ;
118 v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedC onstructor);
119
120 if (privateValue.IsEmpty()) {
121 v8::Local<v8::Function> interface = perContextData->constructorForType(&V8Te stInterfaceEventTarget::wrapperTypeInfo);
122 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked();
123 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked();
124 if (!result)
125 return;
126 privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsola te()));
127 }
128
129 v8SetReturnValue(info, namedConstructor);
130 }
131
102 static void installV8TestInterfaceEventTargetTemplate(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { 132 static void installV8TestInterfaceEventTargetTemplate(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
103 // Initialize the interface object's template. 133 // Initialize the interface object's template.
104 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterfaceEventTarget::wrapperTypeInfo.interfaceName, V8EventTarget::domTe mplate(isolate, world), V8TestInterfaceEventTarget::internalFieldCount); 134 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterfaceEventTarget::wrapperTypeInfo.interfaceName, V8EventTarget::domTe mplate(isolate, world), V8TestInterfaceEventTarget::internalFieldCount);
105 135
106 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 136 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
107 ALLOW_UNUSED_LOCAL(signature); 137 ALLOW_UNUSED_LOCAL(signature);
108 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate(); 138 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate();
109 ALLOW_UNUSED_LOCAL(instanceTemplate); 139 ALLOW_UNUSED_LOCAL(instanceTemplate);
110 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template(); 140 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template();
111 ALLOW_UNUSED_LOCAL(prototypeTemplate); 141 ALLOW_UNUSED_LOCAL(prototypeTemplate);
(...skipping 15 matching lines...) Expand all
127 157
128 TestInterfaceEventTarget* V8TestInterfaceEventTarget::toImplWithTypeCheck(v8::Is olate* isolate, v8::Local<v8::Value> value) { 158 TestInterfaceEventTarget* V8TestInterfaceEventTarget::toImplWithTypeCheck(v8::Is olate* isolate, v8::Local<v8::Value> value) {
129 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr; 159 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr;
130 } 160 }
131 161
132 TestInterfaceEventTarget* NativeValueTraits<TestInterfaceEventTarget>::nativeVal ue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionSt ate) { 162 TestInterfaceEventTarget* NativeValueTraits<TestInterfaceEventTarget>::nativeVal ue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionSt ate) {
133 return V8TestInterfaceEventTarget::toImplWithTypeCheck(isolate, value); 163 return V8TestInterfaceEventTarget::toImplWithTypeCheck(isolate, value);
134 } 164 }
135 165
136 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698