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

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.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
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "V8TestInterfaceNamedConstructor2.h" 12 #include "V8TestInterfaceNamedConstructor2.h"
13 13
14 #include "bindings/core/v8/ExceptionState.h" 14 #include "bindings/core/v8/ExceptionState.h"
15 #include "bindings/core/v8/IDLTypes.h" 15 #include "bindings/core/v8/IDLTypes.h"
16 #include "bindings/core/v8/NativeValueTraitsImpl.h" 16 #include "bindings/core/v8/NativeValueTraitsImpl.h"
17 #include "bindings/core/v8/V8DOMConfiguration.h" 17 #include "bindings/core/v8/V8DOMConfiguration.h"
18 #include "bindings/core/v8/V8ObjectConstructor.h" 18 #include "bindings/core/v8/V8ObjectConstructor.h"
19 #include "bindings/core/v8/V8PrivateProperty.h"
19 #include "core/dom/Document.h" 20 #include "core/dom/Document.h"
20 #include "core/frame/LocalDOMWindow.h" 21 #include "core/frame/LocalDOMWindow.h"
21 #include "wtf/GetPtr.h" 22 #include "wtf/GetPtr.h"
22 #include "wtf/RefPtr.h" 23 #include "wtf/RefPtr.h"
23 24
24 namespace blink { 25 namespace blink {
25 26
26 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 27 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
27 // and does not depend on another global objects. 28 // and does not depend on another global objects.
28 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 29 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::dom Template(v8::Isolate* isolate, const DOMWrapperWorld& world) { 98 v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::dom Template(v8::Isolate* isolate, const DOMWrapperWorld& world) {
98 static int domTemplateKey; // This address is used for a key to look up the do m template. 99 static int domTemplateKey; // This address is used for a key to look up the do m template.
99 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 100 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
100 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d omTemplateKey); 101 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d omTemplateKey);
101 if (!result.IsEmpty()) 102 if (!result.IsEmpty())
102 return result; 103 return result;
103 104
104 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2Co nstructorCallback); 105 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2Co nstructorCallback);
105 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); 106 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
106 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::inte rnalFieldCount); 107 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::inte rnalFieldCount);
107 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2") ); 108 result->SetClassName(v8AtomicString(isolate, "Audio"));
108 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate, world)) ; 109 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate, world)) ;
109 data->setInterfaceTemplate(world, &domTemplateKey, result); 110 data->setInterfaceTemplate(world, &domTemplateKey, result);
110 return result; 111 return result;
111 } 112 }
112 113
114 void V8TestInterfaceNamedConstructor2Constructor::NamedConstructorAttributeGette r(
115 v8::Local<v8::Name> propertyName,
116 const v8::PropertyCallbackInfo<v8::Value>& info) {
117 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext();
118 V8PerContextData* perContextData = V8PerContextData::from(creationContext);
119 if (!perContextData) {
120 // TODO(yukishiino): Return a valid named constructor even after the context is detached
121 return;
122 }
123
124 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType( &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo);
125
126 // Set the prototype of named constructors to the regular constructor.
127 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info. GetIsolate());
128 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ;
129 v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedC onstructor);
130
131 if (privateValue.IsEmpty()) {
132 v8::Local<v8::Function> interface = perContextData->constructorForType(&V8Te stInterfaceNamedConstructor2::wrapperTypeInfo);
133 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked();
134 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked();
135 if (!result)
136 return;
137 privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsola te()));
138 }
139
140 v8SetReturnValue(info, namedConstructor);
141 }
142
113 static void installV8TestInterfaceNamedConstructor2Template(v8::Isolate* isolate , const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplat e) { 143 static void installV8TestInterfaceNamedConstructor2Template(v8::Isolate* isolate , const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplat e) {
114 // Initialize the interface object's template. 144 // Initialize the interface object's template.
115 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterfaceNamedConstructor2::wrapperTypeInfo.interfaceName, v8::Local<v8:: FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount); 145 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, V8TestInterfaceNamedConstructor2::wrapperTypeInfo.interfaceName, v8::Local<v8:: FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount);
116 146
117 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 147 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
118 ALLOW_UNUSED_LOCAL(signature); 148 ALLOW_UNUSED_LOCAL(signature);
119 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate(); 149 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate();
120 ALLOW_UNUSED_LOCAL(instanceTemplate); 150 ALLOW_UNUSED_LOCAL(instanceTemplate);
121 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template(); 151 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template();
122 ALLOW_UNUSED_LOCAL(prototypeTemplate); 152 ALLOW_UNUSED_LOCAL(prototypeTemplate);
(...skipping 15 matching lines...) Expand all
138 168
139 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toImplWithType Check(v8::Isolate* isolate, v8::Local<v8::Value> value) { 169 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toImplWithType Check(v8::Isolate* isolate, v8::Local<v8::Value> value) {
140 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr; 170 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr;
141 } 171 }
142 172
143 TestInterfaceNamedConstructor2* NativeValueTraits<TestInterfaceNamedConstructor2 >::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) { 173 TestInterfaceNamedConstructor2* NativeValueTraits<TestInterfaceNamedConstructor2 >::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
144 return V8TestInterfaceNamedConstructor2::toImplWithTypeCheck(isolate, value); 174 return V8TestInterfaceNamedConstructor2::toImplWithTypeCheck(isolate, value);
145 } 175 }
146 176
147 } // namespace blink 177 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698