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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 1372373002: bindings: Reduces the custom registration of methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (world.isMainWorld()) { 48 if (world.isMainWorld()) {
49 if (attribute.getterForMainWorld) 49 if (attribute.getterForMainWorld)
50 getter = attribute.getterForMainWorld; 50 getter = attribute.getterForMainWorld;
51 if (attribute.setterForMainWorld) 51 if (attribute.setterForMainWorld)
52 setter = attribute.setterForMainWorld; 52 setter = attribute.setterForMainWorld;
53 } 53 }
54 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(attribute.data)); 54 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(attribute.data));
55 55
56 ASSERT(attribute.propertyLocationConfiguration); 56 ASSERT(attribute.propertyLocationConfiguration);
57 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) 57 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance )
58 instanceTemplate->SetAccessor(name, getter, setter, data, attribute.sett ings, attribute.attribute); 58 instanceTemplate->SetAccessor(name, getter, setter, data, static_cast<v8 ::AccessControl>(attribute.settings), static_cast<v8::PropertyAttribute>(attribu te.attribute));
59 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) 59 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e)
60 prototypeTemplate->SetAccessor(name, getter, setter, data, attribute.set tings, attribute.attribute); 60 prototypeTemplate->SetAccessor(name, getter, setter, data, static_cast<v 8::AccessControl>(attribute.settings), static_cast<v8::PropertyAttribute>(attrib ute.attribute));
61 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) 61 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e)
62 ASSERT_NOT_REACHED(); 62 ASSERT_NOT_REACHED();
63 } 63 }
64 64
65 template<class FunctionOrTemplate> 65 template<class FunctionOrTemplate>
66 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th); 66 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th);
67 67
68 template<> 68 template<>
69 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length) 69 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length)
70 { 70 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (accessor.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolde r) 118 if (accessor.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolde r)
119 signature = v8::Local<v8::Signature>(); 119 signature = v8::Local<v8::Signature>();
120 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(accessor.data)); 120 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(accessor.data));
121 121
122 ASSERT(accessor.propertyLocationConfiguration); 122 ASSERT(accessor.propertyLocationConfiguration);
123 if (accessor.propertyLocationConfiguration & 123 if (accessor.propertyLocationConfiguration &
124 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { 124 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) {
125 v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, getterCallback, data, signature, 0); 125 v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, getterCallback, data, signature, 0);
126 v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, setterCallback, data, signature, 1); 126 v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, setterCallback, data, signature, 1);
127 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnInsta nce) 127 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnInsta nce)
128 instanceOrTemplate->SetAccessorProperty(name, getter, setter, access or.attribute, accessor.settings); 128 instanceOrTemplate->SetAccessorProperty(name, getter, setter, static _cast<v8::PropertyAttribute>(accessor.attribute), static_cast<v8::AccessControl> (accessor.settings));
129 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnProto type) 129 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnProto type)
130 prototypeOrTemplate->SetAccessorProperty(name, getter, setter, acces sor.attribute, accessor.settings); 130 prototypeOrTemplate->SetAccessorProperty(name, getter, setter, stati c_cast<v8::PropertyAttribute>(accessor.attribute), static_cast<v8::AccessControl >(accessor.settings));
131 } 131 }
132 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnInterface ) { 132 if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnInterface ) {
133 // Attributes installed on the interface object must be static 133 // Attributes installed on the interface object must be static
134 // attributes, so no need to specify a signature, i.e. no need to do 134 // attributes, so no need to specify a signature, i.e. no need to do
135 // type check against a holder. 135 // type check against a holder.
136 v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, getterCallback, data, v8::Local<v8::Signature>(), 0 ); 136 v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, getterCallback, data, v8::Local<v8::Signature>(), 0 );
137 v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, setterCallback, data, v8::Local<v8::Signature>(), 1 ); 137 v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate< FunctionOrTemplate>(isolate, setterCallback, data, v8::Local<v8::Signature>(), 1 );
138 interfaceOrTemplate->SetAccessorProperty(name, getter, setter, accessor. attribute, accessor.settings); 138 interfaceOrTemplate->SetAccessorProperty(name, getter, setter, static_ca st<v8::PropertyAttribute>(accessor.attribute), static_cast<v8::AccessControl>(ac cessor.settings));
139 } 139 }
140 } 140 }
141 141
142 void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::FunctionTemplat e> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8 DOMConfiguration::ConstantConfiguration& constant) 142 void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::FunctionTemplat e> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8 DOMConfiguration::ConstantConfiguration& constant)
143 { 143 {
144 v8::Local<v8::String> constantName = v8AtomicString(isolate, constant.name); 144 v8::Local<v8::String> constantName = v8AtomicString(isolate, constant.name);
145 v8::PropertyAttribute attributes = 145 v8::PropertyAttribute attributes =
146 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); 146 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
147 v8::Local<v8::Primitive> value; 147 v8::Local<v8::Primitive> value;
148 switch (constant.type) { 148 switch (constant.type) {
(...skipping 10 matching lines...) Expand all
159 value = v8::Number::New(isolate, constant.dvalue); 159 value = v8::Number::New(isolate, constant.dvalue);
160 break; 160 break;
161 default: 161 default:
162 ASSERT_NOT_REACHED(); 162 ASSERT_NOT_REACHED();
163 } 163 }
164 functionDescriptor->Set(constantName, value, attributes); 164 functionDescriptor->Set(constantName, value, attributes);
165 prototypeTemplate->Set(constantName, value, attributes); 165 prototypeTemplate->Set(constantName, value, attributes);
166 } 166 }
167 167
168 template<class Configuration> 168 template<class Configuration>
169 void installMethodInternal(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> i nstanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8:: FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signature, v8::Pro pertyAttribute attribute, const Configuration& method, const DOMWrapperWorld& wo rld) 169 void installMethodInternal(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> i nstanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8:: FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signature, const C onfiguration& method, const DOMWrapperWorld& world)
170 { 170 {
171 if (method.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivateSc ript 171 if (method.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivateSc ript
172 && !world.isPrivateScriptIsolatedWorld()) 172 && !world.isPrivateScriptIsolatedWorld())
173 return; 173 return;
174 174
175 v8::Local<v8::Name> name = method.methodName(isolate); 175 v8::Local<v8::Name> name = method.methodName(isolate);
176 v8::FunctionCallback callback = method.callbackForWorld(world); 176 v8::FunctionCallback callback = method.callbackForWorld(world);
177 177
178 ASSERT(method.propertyLocationConfiguration); 178 ASSERT(method.propertyLocationConfiguration);
179 if (method.propertyLocationConfiguration & 179 if (method.propertyLocationConfiguration &
180 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { 180 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) {
181 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), signature, method.length); 181 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), signature, method.length);
182 functionTemplate->RemovePrototype(); 182 functionTemplate->RemovePrototype();
183 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstanc e) 183 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstanc e)
184 instanceTemplate->Set(name, functionTemplate, attribute); 184 instanceTemplate->Set(name, functionTemplate, static_cast<v8::Proper tyAttribute>(method.attribute));
185 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnPrototy pe) 185 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnPrototy pe)
186 prototypeTemplate->Set(name, functionTemplate, attribute); 186 prototypeTemplate->Set(name, functionTemplate, static_cast<v8::Prope rtyAttribute>(method.attribute));
187 } 187 }
188 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) { 188 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) {
189 // Operations installed on the interface object must be static 189 // Operations installed on the interface object must be static
190 // operations, so no need to specify a signature, i.e. no need to do 190 // operations, so no need to specify a signature, i.e. no need to do
191 // type check against a holder. 191 // type check against a holder.
192 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), v8::Local<v8::Signature>(), meth od.length); 192 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), v8::Local<v8::Signature>(), meth od.length);
193 functionTemplate->RemovePrototype(); 193 functionTemplate->RemovePrototype();
194 interfaceTemplate->Set(name, functionTemplate, attribute); 194 interfaceTemplate->Set(name, functionTemplate, static_cast<v8::PropertyA ttribute>(method.attribute));
195 } 195 }
196 } 196 }
197 197
198 void installMethodInternal(v8::Isolate* isolate, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface, v8::Local<v 8::Signature> signature, const V8DOMConfiguration::MethodConfiguration& method, const DOMWrapperWorld& world)
199 {
200 if (method.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivateSc ript
201 && !world.isPrivateScriptIsolatedWorld())
202 return;
203
204 v8::Local<v8::Name> name = method.methodName(isolate);
205 v8::FunctionCallback callback = method.callbackForWorld(world);
206
207 ASSERT(method.propertyLocationConfiguration);
208 if (method.propertyLocationConfiguration &
209 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) {
210 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), signature, method.length);
211 functionTemplate->RemovePrototype();
212 v8::Local<v8::Function> function = v8CallOrCrash(functionTemplate->GetFu nction(isolate->GetCurrentContext()));
213 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstanc e)
214 v8CallOrCrash(instance->DefineOwnProperty(isolate->GetCurrentContext (), name, function, static_cast<v8::PropertyAttribute>(method.attribute)));
215 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnPrototy pe)
216 v8CallOrCrash(prototype->DefineOwnProperty(isolate->GetCurrentContex t(), name, function, static_cast<v8::PropertyAttribute>(method.attribute)));
217 }
218 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) {
219 // Operations installed on the interface object must be static
220 // operations, so no need to specify a signature, i.e. no need to do
221 // type check against a holder.
222 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8::Local<v8::Value>(), v8::Local<v8::Signature>(), meth od.length);
223 functionTemplate->RemovePrototype();
224 v8::Local<v8::Function> function = v8CallOrCrash(functionTemplate->GetFu nction(isolate->GetCurrentContext()));
225 v8CallOrCrash(interface->DefineOwnProperty(isolate->GetCurrentContext(), name, function, static_cast<v8::PropertyAttribute>(method.attribute)));
226 }
227 }
228
198 } // namespace 229 } // namespace
199 230
200 void V8DOMConfiguration::installAttributes(v8::Isolate* isolate, v8::Local<v8::O bjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate , const AttributeConfiguration* attributes, size_t attributeCount) 231 void V8DOMConfiguration::installAttributes(v8::Isolate* isolate, v8::Local<v8::O bjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate , const AttributeConfiguration* attributes, size_t attributeCount)
201 { 232 {
202 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 233 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
203 for (size_t i = 0; i < attributeCount; ++i) 234 for (size_t i = 0; i < attributeCount; ++i)
204 installAttributeInternal(isolate, instanceTemplate, prototypeTemplate, a ttributes[i], world); 235 installAttributeInternal(isolate, instanceTemplate, prototypeTemplate, a ttributes[i], world);
205 } 236 }
206 237
207 void V8DOMConfiguration::installAttribute(v8::Isolate* isolate, v8::Local<v8::Ob jectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeConfiguration& attribute) 238 void V8DOMConfiguration::installAttribute(v8::Isolate* isolate, v8::Local<v8::Ob jectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeConfiguration& attribute)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 273
243 void V8DOMConfiguration::installConstantWithGetter(v8::Isolate* isolate, v8::Loc al<v8::FunctionTemplate> functionDescriptor, v8::Local<v8::ObjectTemplate> proto typeTemplate, const char* name, v8::AccessorNameGetterCallback getter) 274 void V8DOMConfiguration::installConstantWithGetter(v8::Isolate* isolate, v8::Loc al<v8::FunctionTemplate> functionDescriptor, v8::Local<v8::ObjectTemplate> proto typeTemplate, const char* name, v8::AccessorNameGetterCallback getter)
244 { 275 {
245 v8::Local<v8::String> constantName = v8AtomicString(isolate, name); 276 v8::Local<v8::String> constantName = v8AtomicString(isolate, name);
246 v8::PropertyAttribute attributes = 277 v8::PropertyAttribute attributes =
247 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); 278 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
248 functionDescriptor->SetNativeDataProperty(constantName, getter, 0, v8::Local <v8::Value>(), attributes); 279 functionDescriptor->SetNativeDataProperty(constantName, getter, 0, v8::Local <v8::Value>(), attributes);
249 prototypeTemplate->SetNativeDataProperty(constantName, getter, 0, v8::Local< v8::Value>(), attributes); 280 prototypeTemplate->SetNativeDataProperty(constantName, getter, 0, v8::Local< v8::Value>(), attributes);
250 } 281 }
251 282
252 void V8DOMConfiguration::installMethods(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v 8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signa ture, v8::PropertyAttribute attribute, const MethodConfiguration* methods, size_ t methodCount) 283 void V8DOMConfiguration::installMethods(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v 8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signa ture, const MethodConfiguration* methods, size_t methodCount)
253 { 284 {
254 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 285 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
255 for (size_t i = 0; i < methodCount; ++i) 286 for (size_t i = 0; i < methodCount; ++i)
256 installMethodInternal(isolate, instanceTemplate, prototypeTemplate, inte rfaceTemplate, signature, attribute, methods[i], world); 287 installMethodInternal(isolate, instanceTemplate, prototypeTemplate, inte rfaceTemplate, signature, methods[i], world);
257 } 288 }
258 289
259 void V8DOMConfiguration::installMethod(v8::Isolate* isolate, v8::Local<v8::Objec tTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8 ::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signat ure, v8::PropertyAttribute attribute, const MethodConfiguration& method) 290 void V8DOMConfiguration::installMethod(v8::Isolate* isolate, v8::Local<v8::Objec tTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8 ::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signat ure, const MethodConfiguration& method)
260 { 291 {
261 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 292 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
262 installMethodInternal(isolate, instanceTemplate, prototypeTemplate, interfac eTemplate, signature, attribute, method, world); 293 installMethodInternal(isolate, instanceTemplate, prototypeTemplate, interfac eTemplate, signature, method, world);
263 } 294 }
264 295
265 void V8DOMConfiguration::installMethod(v8::Isolate* isolate, v8::Local<v8::Objec tTemplate> prototypeTemplate, v8::Local<v8::Signature> signature, v8::PropertyAt tribute attribute, const SymbolKeyedMethodConfiguration& method) 296 void V8DOMConfiguration::installMethod(v8::Isolate* isolate, v8::Local<v8::Objec t> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface, v8::Local<v8::Signature> signature, const MethodConfiguration& method)
266 { 297 {
267 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 298 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
268 installMethodInternal(isolate, v8::Local<v8::ObjectTemplate>(), prototypeTem plate, v8::Local<v8::FunctionTemplate>(), signature, attribute, method, world); 299 installMethodInternal(isolate, instance, prototype, interface, signature, me thod, world);
300 }
301
302 void V8DOMConfiguration::installMethod(v8::Isolate* isolate, v8::Local<v8::Objec tTemplate> prototypeTemplate, v8::Local<v8::Signature> signature, const SymbolKe yedMethodConfiguration& method)
303 {
304 const DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
305 installMethodInternal(isolate, v8::Local<v8::ObjectTemplate>(), prototypeTem plate, v8::Local<v8::FunctionTemplate>(), signature, method, world);
269 } 306 }
270 307
271 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Isolate * isolate, v8::Local<v8::FunctionTemplate> functionDescriptor, const char* inter faceName, v8::Local<v8::FunctionTemplate> parentClass, size_t fieldCount, 308 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Isolate * isolate, v8::Local<v8::FunctionTemplate> functionDescriptor, const char* inter faceName, v8::Local<v8::FunctionTemplate> parentClass, size_t fieldCount,
272 const AttributeConfiguration* attributes, size_t attributeCount, 309 const AttributeConfiguration* attributes, size_t attributeCount,
273 const AccessorConfiguration* accessors, size_t accessorCount, 310 const AccessorConfiguration* accessors, size_t accessorCount,
274 const MethodConfiguration* methods, size_t methodCount) 311 const MethodConfiguration* methods, size_t methodCount)
275 { 312 {
276 functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName)); 313 functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName));
277 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate(); 314 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate();
278 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionDescriptor->Protot ypeTemplate(); 315 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionDescriptor->Protot ypeTemplate();
279 instanceTemplate->SetInternalFieldCount(fieldCount); 316 instanceTemplate->SetInternalFieldCount(fieldCount);
280 if (!parentClass.IsEmpty()) { 317 if (!parentClass.IsEmpty()) {
281 functionDescriptor->Inherit(parentClass); 318 functionDescriptor->Inherit(parentClass);
282 // Marks the prototype object as one of native-backed objects. 319 // Marks the prototype object as one of native-backed objects.
283 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones. 320 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones.
284 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure. 321 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure.
285 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount); 322 prototypeTemplate->SetInternalFieldCount(v8PrototypeInternalFieldcount);
286 } 323 }
287 324
288 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor); 325 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor);
289 if (attributeCount) 326 if (attributeCount)
290 installAttributes(isolate, instanceTemplate, prototypeTemplate, attribut es, attributeCount); 327 installAttributes(isolate, instanceTemplate, prototypeTemplate, attribut es, attributeCount);
291 if (accessorCount) 328 if (accessorCount)
292 installAccessors(isolate, instanceTemplate, prototypeTemplate, functionD escriptor, defaultSignature, accessors, accessorCount); 329 installAccessors(isolate, instanceTemplate, prototypeTemplate, functionD escriptor, defaultSignature, accessors, accessorCount);
293 if (methodCount) 330 if (methodCount)
294 installMethods(isolate, instanceTemplate, prototypeTemplate, functionDes criptor, defaultSignature, static_cast<v8::PropertyAttribute>(v8::None), methods , methodCount); 331 installMethods(isolate, instanceTemplate, prototypeTemplate, functionDes criptor, defaultSignature, methods, methodCount);
295 return defaultSignature; 332 return defaultSignature;
296 } 333 }
297 334
298 v8::Local<v8::FunctionTemplate> V8DOMConfiguration::domClassTemplate(v8::Isolate * isolate, WrapperTypeInfo* wrapperTypeInfo, void (*configureDOMClassTemplate)(v 8::Local<v8::FunctionTemplate>, v8::Isolate*)) 335 v8::Local<v8::FunctionTemplate> V8DOMConfiguration::domClassTemplate(v8::Isolate * isolate, WrapperTypeInfo* wrapperTypeInfo, void (*configureDOMClassTemplate)(v 8::Local<v8::FunctionTemplate>, v8::Isolate*))
299 { 336 {
300 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 337 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
301 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(wrapperTy peInfo); 338 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(wrapperTy peInfo);
302 if (!result.IsEmpty()) 339 if (!result.IsEmpty())
303 return result; 340 return result;
304 341
305 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); 342 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
306 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode); 343 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode);
307 configureDOMClassTemplate(result, isolate); 344 configureDOMClassTemplate(result, isolate);
308 data->setDOMTemplate(wrapperTypeInfo, result); 345 data->setDOMTemplate(wrapperTypeInfo, result);
309 return result; 346 return result;
310 } 347 }
311 348
312 } // namespace blink 349 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698