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 42d85dcbecd53d7934f031b9d48289849b73708d..0af9a401b3d99c5b7356a08730a5f0ab5356adb0 100644 |
| --- a/Source/bindings/core/v8/V8DOMConfiguration.h |
| +++ b/Source/bindings/core/v8/V8DOMConfiguration.h |
| @@ -177,6 +177,34 @@ public: |
| static void installAccessors(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount); |
| + template<class ObjectOrTemplate> |
| + static inline void installAccessor(v8::Handle<ObjectOrTemplate> instanceTemplate, v8::Handle<ObjectOrTemplate> prototype, v8::Handle<v8::Signature> signature, const AccessorConfiguration& accessor, v8::Isolate* isolate) |
|
haraken
2015/02/13 15:08:24
We might not want to duplicate the code between in
Yuki
2015/02/16 10:51:51
Refactored the code a bit.
Since it seemed that ge
|
| + { |
| + DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); |
| + if (accessor.exposeConfiguration == OnlyExposedToPrivateScript && !world.isPrivateScriptIsolatedWorld()) |
| + return; |
| + |
| + v8::FunctionCallback getterCallback = accessor.getter; |
| + v8::FunctionCallback setterCallback = accessor.setter; |
| + if (world.isMainWorld()) { |
| + if (accessor.getterForMainWorld) |
| + getterCallback = accessor.getterForMainWorld; |
| + if (accessor.setterForMainWorld) |
| + setterCallback = accessor.setterForMainWorld; |
| + } |
| + v8::Local<v8::FunctionTemplate> getter; |
| + if (getterCallback) { |
| + getter = v8::FunctionTemplate::New(isolate, getterCallback, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(accessor.data)), signature, 0); |
| + getter->RemovePrototype(); |
| + } |
| + v8::Local<v8::FunctionTemplate> setter; |
| + if (setterCallback) { |
| + setter = v8::FunctionTemplate::New(isolate, setterCallback, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(accessor.data)), signature, 1); |
| + setter->RemovePrototype(); |
| + } |
| + prototype->SetAccessorProperty(v8AtomicString(isolate, accessor.name), getter, setter, accessor.attribute, accessor.settings); |
| + } |
| + |
| 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, |
| const AccessorConfiguration*, size_t accessorCount, |