| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const char* const name; | 62 const char* const name; |
| 63 v8::FunctionCallback getter; | 63 v8::FunctionCallback getter; |
| 64 v8::FunctionCallback setter; | 64 v8::FunctionCallback setter; |
| 65 v8::FunctionCallback getterForMainWorld; | 65 v8::FunctionCallback getterForMainWorld; |
| 66 v8::FunctionCallback setterForMainWorld; | 66 v8::FunctionCallback setterForMainWorld; |
| 67 const WrapperTypeInfo* data; | 67 const WrapperTypeInfo* data; |
| 68 v8::AccessControl settings; | 68 v8::AccessControl settings; |
| 69 v8::PropertyAttribute attribute; | 69 v8::PropertyAttribute attribute; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:
:ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isol
ate*, WrapperWorldType currentWorldType); | 72 static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:
:ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isol
ate*); |
| 73 | 73 |
| 74 template<class ObjectOrTemplate> | 74 template<class ObjectOrTemplate> |
| 75 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate* isolate) | 75 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate* isolate) |
| 76 { | 76 { |
| 77 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewFromUtf8(isolate, attribute.name, v8::String::kInternalizedString), | |
| 78 attribute.getter, | |
| 79 attribute.setter, | |
| 80 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), | |
| 81 attribute.settings, | |
| 82 attribute.attribute); | |
| 83 } | |
| 84 | |
| 85 template<class ObjectOrTemplate> | |
| 86 static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTem
plate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& att
ribute, v8::Isolate* isolate, WrapperWorldType currentWorldType) | |
| 87 { | |
| 88 v8::AccessorGetterCallback getter = attribute.getter; | 77 v8::AccessorGetterCallback getter = attribute.getter; |
| 89 v8::AccessorSetterCallback setter = attribute.setter; | 78 v8::AccessorSetterCallback setter = attribute.setter; |
| 90 if (currentWorldType == MainWorld) { | 79 if (DOMWrapperWorld::current(isolate)->isMainWorld()) { |
| 91 if (attribute.getterForMainWorld) | 80 if (attribute.getterForMainWorld) |
| 92 getter = attribute.getterForMainWorld; | 81 getter = attribute.getterForMainWorld; |
| 93 if (attribute.setterForMainWorld) | 82 if (attribute.setterForMainWorld) |
| 94 setter = attribute.setterForMainWorld; | 83 setter = attribute.setterForMainWorld; |
| 95 } | 84 } |
| 96 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewFromUtf8(isolate, attribute.name, v8::String::kInternalizedString), | 85 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::
String::NewFromUtf8(isolate, attribute.name, v8::String::kInternalizedString), |
| 97 getter, | 86 getter, |
| 98 setter, | 87 setter, |
| 99 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), | 88 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), |
| 100 attribute.settings, | 89 attribute.settings, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 113 | 102 |
| 114 // MethodConfiguration translates into calls to Set() on the prototype | 103 // MethodConfiguration translates into calls to Set() on the prototype |
| 115 // ObjectTemplate. | 104 // ObjectTemplate. |
| 116 struct MethodConfiguration { | 105 struct MethodConfiguration { |
| 117 const char* const name; | 106 const char* const name; |
| 118 v8::FunctionCallback callback; | 107 v8::FunctionCallback callback; |
| 119 v8::FunctionCallback callbackForMainWorld; | 108 v8::FunctionCallback callbackForMainWorld; |
| 120 int length; | 109 int length; |
| 121 }; | 110 }; |
| 122 | 111 |
| 123 static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCo
unt, v8::Isolate*, WrapperWorldType); | 112 static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCo
unt, v8::Isolate*); |
| 124 | 113 |
| 125 static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*, Wr
apperWorldType); | 114 static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::
Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*); |
| 126 | 115 |
| 127 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct
ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent
Class, size_t fieldCount, | 116 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct
ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent
Class, size_t fieldCount, |
| 128 const AttributeConfiguration*, size_t attributeCount, | 117 const AttributeConfiguration*, size_t attributeCount, |
| 129 const AccessorConfiguration*, size_t accessorCount, | 118 const AccessorConfiguration*, size_t accessorCount, |
| 130 const MethodConfiguration*, size_t callbackCount, | 119 const MethodConfiguration*, size_t callbackCount, |
| 131 v8::Isolate*, WrapperWorldType); | 120 v8::Isolate*); |
| 132 }; | 121 }; |
| 133 | 122 |
| 134 } // namespace WebCore | 123 } // namespace WebCore |
| 135 | 124 |
| 136 #endif // V8DOMConfiguration_h | 125 #endif // V8DOMConfiguration_h |
| OLD | NEW |