| Index: Source/bindings/core/v8/V8DOMConfiguration.h
|
| diff --git a/Source/bindings/core/v8/V8DOMConfiguration.h b/Source/bindings/core/v8/V8DOMConfiguration.h
|
| index 42d85dcbecd53d7934f031b9d48289849b73708d..d54bde35354be0f41c3185080e08752528d0c051 100644
|
| --- a/Source/bindings/core/v8/V8DOMConfiguration.h
|
| +++ b/Source/bindings/core/v8/V8DOMConfiguration.h
|
| @@ -68,6 +68,12 @@ public:
|
| InstanceOrPrototypeConfiguration instanceOrPrototypeConfiguration;
|
| };
|
|
|
| + static void installAttributes(v8::Isolate*, v8::Handle<v8::ObjectTemplate> instanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfiguration*, size_t attributeCount);
|
| +
|
| + static void installAttribute(v8::Isolate*, v8::Handle<v8::ObjectTemplate> instanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfiguration&);
|
| +
|
| + static void installAttribute(v8::Isolate*, v8::Handle<v8::Object> instanceTemplate, v8::Handle<v8::Object> prototype, const AttributeConfiguration&);
|
| +
|
| // AccessorConfiguration translates into calls to SetAccessorProperty()
|
| // on prototype ObjectTemplate.
|
| struct AccessorConfiguration {
|
| @@ -82,30 +88,9 @@ public:
|
| ExposeConfiguration exposeConfiguration;
|
| };
|
|
|
| - static void installAttributes(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount);
|
| -
|
| - template<class ObjectOrTemplate>
|
| - static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTemplate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& attribute, v8::Isolate* isolate)
|
| - {
|
| - DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
|
| - if (attribute.exposeConfiguration == OnlyExposedToPrivateScript && !world.isPrivateScriptIsolatedWorld())
|
| - return;
|
| -
|
| - v8::AccessorGetterCallback getter = attribute.getter;
|
| - v8::AccessorSetterCallback setter = attribute.setter;
|
| - if (world.isMainWorld()) {
|
| - if (attribute.getterForMainWorld)
|
| - getter = attribute.getterForMainWorld;
|
| - if (attribute.setterForMainWorld)
|
| - setter = attribute.setterForMainWorld;
|
| - }
|
| - (attribute.instanceOrPrototypeConfiguration == OnPrototype ? prototype : instanceTemplate)->SetAccessor(v8AtomicString(isolate, attribute.name),
|
| - getter,
|
| - setter,
|
| - v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)),
|
| - attribute.settings,
|
| - attribute.attribute);
|
| - }
|
| + static void installAccessors(v8::Isolate*, v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount);
|
| +
|
| + static void installAccessor(v8::Isolate*, v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature>, const AccessorConfiguration&);
|
|
|
| enum ConstantType {
|
| ConstantTypeShort,
|
| @@ -128,8 +113,19 @@ public:
|
| ConstantType type;
|
| };
|
|
|
| - static void installConstants(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, v8::Handle<v8::ObjectTemplate>, const ConstantConfiguration*, size_t constantCount);
|
| - static void installConstant(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, v8::Handle<v8::ObjectTemplate>, const char* name, v8::AccessorGetterCallback);
|
| + // Constant installation
|
| + //
|
| + // installConstants and installConstant are used for simple constants. They
|
| + // install constants using v8::Template::Set(), which results in a property
|
| + // that is much faster to access from scripts.
|
| + // installConstantWithGetter is used when some C++ code needs to be executed
|
| + // when the constant is accessed, e.g. to handle deprecation or measuring
|
| + // usage. The property appears the same to scripts, but is slower to access.
|
| + static void installConstants(v8::Isolate*, v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfiguration*, size_t constantCount);
|
| +
|
| + static void installConstant(v8::Isolate*, v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfiguration&);
|
| +
|
| + static void installConstantWithGetter(v8::Isolate*, v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const char* name, v8::AccessorGetterCallback);
|
|
|
| // MethodConfiguration translates into calls to Set() for setting up an
|
| // object's callbacks. It sets the method on both the FunctionTemplate or
|
| @@ -162,20 +158,13 @@ public:
|
| ExposeConfiguration exposeConfiguration;
|
| };
|
|
|
| - static void installMethods(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount);
|
| + static void installMethods(v8::Isolate*, v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount);
|
|
|
| - template <class ObjectOrTemplate, class Configuration>
|
| - static void installMethod(v8::Handle<ObjectOrTemplate> objectOrTemplate, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attribute, const Configuration& callback, v8::Isolate* isolate)
|
| - {
|
| - DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
|
| - if (callback.exposeConfiguration == OnlyExposedToPrivateScript && !world.isPrivateScriptIsolatedWorld())
|
| - return;
|
| + static void installMethod(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&);
|
|
|
| - v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForCallback(isolate, signature, callback.callbackForWorld(world), callback.length);
|
| - setMethod(objectOrTemplate, callback.methodName(isolate), functionTemplate, attribute);
|
| - }
|
| + static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&);
|
|
|
| - static void installAccessors(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount);
|
| + static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const SymbolKeyedMethodConfiguration&);
|
|
|
| static v8::Local<v8::Signature> installDOMClassTemplate(v8::Isolate*, v8::Local<v8::FunctionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parentClass, size_t fieldCount,
|
| const AttributeConfiguration*, size_t attributeCount,
|
| @@ -183,22 +172,6 @@ public:
|
| const MethodConfiguration*, size_t callbackCount);
|
|
|
| static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, WrapperTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*));
|
| -
|
| -private:
|
| - static void setMethod(v8::Handle<v8::Object> target, v8::Handle<v8::Name> name, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAttribute attribute)
|
| - {
|
| - target->Set(name, functionTemplate->GetFunction());
|
| - }
|
| - static void setMethod(v8::Handle<v8::FunctionTemplate> target, v8::Handle<v8::Name> name, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAttribute attribute)
|
| - {
|
| - target->Set(name, functionTemplate, attribute);
|
| - }
|
| - static void setMethod(v8::Handle<v8::ObjectTemplate> target, v8::Handle<v8::Name> name, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAttribute attribute)
|
| - {
|
| - target->Set(name, functionTemplate, attribute);
|
| - }
|
| -
|
| - static v8::Handle<v8::FunctionTemplate> functionTemplateForCallback(v8::Isolate*, v8::Handle<v8::Signature>, v8::FunctionCallback, int length);
|
| };
|
|
|
| } // namespace blink
|
|
|