Chromium Code Reviews| Index: Source/bindings/core/v8/V8DOMConfiguration.h |
| diff --git a/Source/bindings/core/v8/V8DOMConfiguration.h b/Source/bindings/core/v8/V8DOMConfiguration.h |
| index 3e166a15edaba452568f08a3d346e998665787f4..95656a9a060f01c9bfd073e468af302dd55b8e14 100644 |
| --- a/Source/bindings/core/v8/V8DOMConfiguration.h |
| +++ b/Source/bindings/core/v8/V8DOMConfiguration.h |
| @@ -134,6 +134,12 @@ public: |
| // object's callbacks. It sets the method on both the FunctionTemplate or |
| // the ObjectTemplate. |
| struct MethodConfiguration { |
| + v8::Local<v8::Name> getName(v8::Isolate* isolate) const { return v8AtomicString(isolate, name); } |
|
haraken
2014/08/25 06:22:00
getName => name
Blink doesn't use 'get'.
yhirano
2014/08/25 06:54:58
renamed to methodName to avoid conflict.
|
| + v8::FunctionCallback getCallbackForWorld(const DOMWrapperWorld& world) const |
|
haraken
2014/08/25 06:22:00
getCallbackForWorld => callbackForWorld
yhirano
2014/08/25 06:54:58
Done.
|
| + { |
| + return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld : callback; |
| + } |
| + |
| const char* const name; |
| v8::FunctionCallback callback; |
| v8::FunctionCallback callbackForMainWorld; |
| @@ -141,27 +147,31 @@ public: |
| ExposeConfiguration exposeConfiguration; |
| }; |
| - static void installMethods(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount, v8::Isolate*); |
| + struct SymbolKeyedMethodConfiguration { |
| + v8::Local<v8::Name> getName(v8::Isolate* isolate) const { return getSymbol(isolate); } |
|
haraken
2014/08/25 06:22:00
getName => name
yhirano
2014/08/25 06:54:58
Done.
|
| + v8::FunctionCallback getCallbackForWorld(const DOMWrapperWorld& world) const |
|
haraken
2014/08/25 06:22:00
getCallbackForWorld => callbackForWorld
yhirano
2014/08/25 06:54:58
Done.
|
| + { |
| + return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld : callback; |
| + } |
| - template <class Template> |
| - static void installMethod(v8::Handle<Template> prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attribute, const MethodConfiguration& callback, v8::Isolate* isolate) |
| - { |
| - DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); |
| - if (callback.exposeConfiguration == OnlyExposedToPrivateScript && !world.isPrivateScriptIsolatedWorld()) |
| - return; |
| + v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); |
| + v8::FunctionCallback callback; |
| + v8::FunctionCallback callbackForMainWorld; |
|
haraken
2014/08/25 06:22:00
Now that you don't support per-world-bindings for
yhirano
2014/08/25 06:54:58
Done.
|
| + int length; |
| + ExposeConfiguration exposeConfiguration; |
| + }; |
| - v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForMethod(signature, callback, isolate); |
| - prototype->Set(v8AtomicString(isolate, callback.name), functionTemplate, attribute); |
| - } |
| + static void installMethods(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount, v8::Isolate*); |
| - static void installMethod(v8::Handle<v8::Object> object, v8::Handle<v8::Signature> signature, v8::PropertyAttribute, const MethodConfiguration& callback, v8::Isolate* isolate) |
| + 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; |
| - v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForMethod(signature, callback, isolate); |
| - object->Set(v8AtomicString(isolate, callback.name), functionTemplate->GetFunction()); |
| + v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForCallback(signature, callback.getCallbackForWorld(world), callback.length, isolate); |
| + setMethod(objectOrTemplate, callback.getName(isolate), functionTemplate, attribute); |
| } |
| static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*); |
| @@ -175,7 +185,20 @@ public: |
| static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, WrapperTypeInfo*, void (*)(v8::Handle<v8::FunctionTemplate>, v8::Isolate*)); |
| private: |
| - static v8::Handle<v8::FunctionTemplate> functionTemplateForMethod(v8::Handle<v8::Signature>, const MethodConfiguration&, v8::Isolate*); |
| + 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::Handle<v8::Signature>, v8::FunctionCallback, int length, v8::Isolate*); |
| }; |
| } // namespace blink |