OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 prototype->Set(v8::String::NewSymbol(constant->name), v8Integer(constant
->value, isolate), v8::ReadOnly); | 47 prototype->Set(v8::String::NewSymbol(constant->name), v8Integer(constant
->value, isolate), v8::ReadOnly); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void V8DOMConfiguration::batchConfigureCallbacks(v8::Handle<v8::ObjectTemplate>
prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes
, const BatchedMethod* callbacks, size_t callbackCount, v8::Isolate*, WrapperWor
ldType currentWorldType) | 51 void V8DOMConfiguration::batchConfigureCallbacks(v8::Handle<v8::ObjectTemplate>
prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes
, const BatchedMethod* callbacks, size_t callbackCount, v8::Isolate*, WrapperWor
ldType currentWorldType) |
52 { | 52 { |
53 for (size_t i = 0; i < callbackCount; ++i) { | 53 for (size_t i = 0; i < callbackCount; ++i) { |
54 v8::InvocationCallback callback = callbacks[i].callback; | 54 v8::InvocationCallback callback = callbacks[i].callback; |
55 if (currentWorldType == MainWorld && callbacks[i].callbackForMainWorld) | 55 if (currentWorldType == MainWorld && callbacks[i].callbackForMainWorld) |
56 callback = callbacks[i].callbackForMainWorld; | 56 callback = callbacks[i].callbackForMainWorld; |
57 prototype->Set(v8::String::NewSymbol(callbacks[i].name), v8::FunctionTem
plate::New(callback, v8Undefined(), signature), attributes); | 57 prototype->Set(v8::String::NewSymbol(callbacks[i].name), v8::FunctionTem
plate::New(callback, v8Undefined(), signature, callbacks[i].length), attributes)
; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 v8::Local<v8::Signature> V8DOMConfiguration::configureTemplate(v8::Persistent<v8
::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Persisten
t<v8::FunctionTemplate> parentClass, | 61 v8::Local<v8::Signature> V8DOMConfiguration::configureTemplate(v8::Persistent<v8
::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Persisten
t<v8::FunctionTemplate> parentClass, |
62 size_t fieldCount, const BatchedAttribute* attributes, size_t attributeCount
, const BatchedMethod* callbacks, size_t callbackCount, v8::Isolate* isolate, Wr
apperWorldType currentWorldType) | 62 size_t fieldCount, const BatchedAttribute* attributes, size_t attributeCount
, const BatchedMethod* callbacks, size_t callbackCount, v8::Isolate* isolate, Wr
apperWorldType currentWorldType) |
63 { | 63 { |
64 functionDescriptor->SetClassName(v8::String::NewSymbol(interfaceName)); | 64 functionDescriptor->SetClassName(v8::String::NewSymbol(interfaceName)); |
65 v8::Local<v8::ObjectTemplate> instance = functionDescriptor->InstanceTemplat
e(); | 65 v8::Local<v8::ObjectTemplate> instance = functionDescriptor->InstanceTemplat
e(); |
66 instance->SetInternalFieldCount(fieldCount); | 66 instance->SetInternalFieldCount(fieldCount); |
67 if (!parentClass.IsEmpty()) { | 67 if (!parentClass.IsEmpty()) { |
68 functionDescriptor->Inherit(parentClass); | 68 functionDescriptor->Inherit(parentClass); |
69 // Marks the prototype object as one of native-backed objects. | 69 // Marks the prototype object as one of native-backed objects. |
70 // This is needed since bug 110436 asks WebKit to tell native-initiated
prototypes from pure-JS ones. | 70 // This is needed since bug 110436 asks WebKit to tell native-initiated
prototypes from pure-JS ones. |
71 // This doesn't mark kinds "root" classes like Node, where setting this
changes prototype chain structure. | 71 // This doesn't mark kinds "root" classes like Node, where setting this
changes prototype chain structure. |
72 v8::Local<v8::ObjectTemplate> prototype = functionDescriptor->PrototypeT
emplate(); | 72 v8::Local<v8::ObjectTemplate> prototype = functionDescriptor->PrototypeT
emplate(); |
73 prototype->SetInternalFieldCount(v8PrototypeInternalFieldcount); | 73 prototype->SetInternalFieldCount(v8PrototypeInternalFieldcount); |
74 } | 74 } |
75 | 75 |
76 if (attributeCount) | 76 if (attributeCount) |
77 batchConfigureAttributes(instance, functionDescriptor->PrototypeTemplate
(), attributes, attributeCount, isolate, currentWorldType); | 77 batchConfigureAttributes(instance, functionDescriptor->PrototypeTemplate
(), attributes, attributeCount, isolate, currentWorldType); |
78 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(functionDescr
iptor); | 78 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(functionDescr
iptor); |
79 if (callbackCount) | 79 if (callbackCount) |
80 batchConfigureCallbacks(functionDescriptor->PrototypeTemplate(), default
Signature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callba
ckCount, isolate, currentWorldType); | 80 batchConfigureCallbacks(functionDescriptor->PrototypeTemplate(), default
Signature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callba
ckCount, isolate, currentWorldType); |
81 return defaultSignature; | 81 return defaultSignature; |
82 } | 82 } |
83 | 83 |
84 } // namespace WebCore | 84 } // namespace WebCore |
OLD | NEW |