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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 v8::Local<v8::FunctionTemplate> getter; | 54 v8::Local<v8::FunctionTemplate> getter; |
55 if (getterCallback) { | 55 if (getterCallback) { |
56 getter = v8::FunctionTemplate::New(isolate, getterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 0); | 56 getter = v8::FunctionTemplate::New(isolate, getterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 0); |
57 getter->RemovePrototype(); | 57 getter->RemovePrototype(); |
58 } | 58 } |
59 v8::Local<v8::FunctionTemplate> setter; | 59 v8::Local<v8::FunctionTemplate> setter; |
60 if (setterCallback) { | 60 if (setterCallback) { |
61 setter = v8::FunctionTemplate::New(isolate, setterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 1); | 61 setter = v8::FunctionTemplate::New(isolate, setterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 1); |
62 setter->RemovePrototype(); | 62 setter->RemovePrototype(); |
63 } | 63 } |
64 prototype->SetAccessorProperty(v8::String::NewFromUtf8(isolate, accessor s[i].name, v8::String::kInternalizedString), getter, setter, accessors[i].attrib ute, accessors[i].settings); | 64 prototype->SetAccessorProperty(v8AtomicString(isolate, accessors[i].name ), getter, setter, accessors[i].attribute, accessors[i].settings); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> funct ionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfigura tion* constants, size_t constantCount, v8::Isolate* isolate) | 68 void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> funct ionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfigura tion* constants, size_t constantCount, v8::Isolate* isolate) |
69 { | 69 { |
70 for (size_t i = 0; i < constantCount; ++i) { | 70 for (size_t i = 0; i < constantCount; ++i) { |
71 const ConstantConfiguration* constant = &constants[i]; | 71 const ConstantConfiguration* constant = &constants[i]; |
72 functionDescriptor->Set(v8::String::NewFromUtf8(isolate, constant->name, v8::String::kInternalizedString), v8::Integer::New(isolate, constant->value), s tatic_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); | 72 functionDescriptor->Set(v8AtomicString(isolate, constant->name), v8::Int eger::New(isolate, constant->value), static_cast<v8::PropertyAttribute>(v8::Read Only | v8::DontDelete)); |
sof
2013/12/29 13:20:12
Possible to avoid duplicate calls ?
haraken
2013/12/29 13:48:00
Done.
| |
73 prototype->Set(v8::String::NewFromUtf8(isolate, constant->name, v8::Stri ng::kInternalizedString), v8::Integer::New(isolate, constant->value), static_cas t<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); | 73 prototype->Set(v8AtomicString(isolate, constant->name), v8::Integer::New (isolate, constant->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8 ::DontDelete)); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate, Wra pperWorldType currentWorldType) | 77 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate, Wra pperWorldType currentWorldType) |
78 { | 78 { |
79 for (size_t i = 0; i < callbackCount; ++i) { | 79 for (size_t i = 0; i < callbackCount; ++i) { |
80 v8::FunctionCallback callback = callbacks[i].callback; | 80 v8::FunctionCallback callback = callbacks[i].callback; |
81 if (currentWorldType == MainWorld && callbacks[i].callbackForMainWorld) | 81 if (currentWorldType == MainWorld && callbacks[i].callbackForMainWorld) |
82 callback = callbacks[i].callbackForMainWorld; | 82 callback = callbacks[i].callbackForMainWorld; |
83 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length); | 83 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length); |
84 functionTemplate->RemovePrototype(); | 84 functionTemplate->RemovePrototype(); |
85 prototype->Set(v8::String::NewFromUtf8(isolate, callbacks[i].name, v8::S tring::kInternalizedString), functionTemplate, attributes); | 85 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl ate, attributes); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Handle< v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Handle< v8::FunctionTemplate> parentClass, size_t fieldCount, | 89 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Handle< v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Handle< v8::FunctionTemplate> parentClass, size_t fieldCount, |
90 const AttributeConfiguration* attributes, size_t attributeCount, | 90 const AttributeConfiguration* attributes, size_t attributeCount, |
91 const AccessorConfiguration* accessors, size_t accessorCount, | 91 const AccessorConfiguration* accessors, size_t accessorCount, |
92 const MethodConfiguration* callbacks, size_t callbackCount, | 92 const MethodConfiguration* callbacks, size_t callbackCount, |
93 v8::Isolate* isolate, WrapperWorldType currentWorldType) | 93 v8::Isolate* isolate, WrapperWorldType currentWorldType) |
94 { | 94 { |
95 functionDescriptor->SetClassName(v8::String::NewFromUtf8(isolate, interfaceN ame, v8::String::kInternalizedString)); | 95 functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName)); |
96 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate(); | 96 v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->Instanc eTemplate(); |
97 instanceTemplate->SetInternalFieldCount(fieldCount); | 97 instanceTemplate->SetInternalFieldCount(fieldCount); |
98 if (!parentClass.IsEmpty()) { | 98 if (!parentClass.IsEmpty()) { |
99 functionDescriptor->Inherit(parentClass); | 99 functionDescriptor->Inherit(parentClass); |
100 // Marks the prototype object as one of native-backed objects. | 100 // Marks the prototype object as one of native-backed objects. |
101 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones. | 101 // This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones. |
102 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure. | 102 // This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure. |
103 v8::Local<v8::ObjectTemplate> prototype = functionDescriptor->PrototypeT emplate(); | 103 v8::Local<v8::ObjectTemplate> prototype = functionDescriptor->PrototypeT emplate(); |
104 prototype->SetInternalFieldCount(v8PrototypeInternalFieldcount); | 104 prototype->SetInternalFieldCount(v8PrototypeInternalFieldcount); |
105 } | 105 } |
106 | 106 |
107 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor); | 107 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, func tionDescriptor); |
108 if (attributeCount) | 108 if (attributeCount) |
109 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat e(), attributes, attributeCount, isolate, currentWorldType); | 109 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat e(), attributes, attributeCount, isolate, currentWorldType); |
110 if (accessorCount) | 110 if (accessorCount) |
111 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu re, accessors, accessorCount, isolate, currentWorldType); | 111 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu re, accessors, accessorCount, isolate, currentWorldType); |
112 if (callbackCount) | 112 if (callbackCount) |
113 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount , isolate, currentWorldType); | 113 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount , isolate, currentWorldType); |
114 return defaultSignature; | 114 return defaultSignature; |
115 } | 115 } |
116 | 116 |
117 } // namespace WebCore | 117 } // namespace WebCore |
OLD | NEW |