| 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 19 matching lines...) Expand all Loading... |
| 30 #define V8DOMConfiguration_h | 30 #define V8DOMConfiguration_h |
| 31 | 31 |
| 32 #include "bindings/core/v8/V8Binding.h" | 32 #include "bindings/core/v8/V8Binding.h" |
| 33 #include "bindings/core/v8/V8DOMWrapper.h" | 33 #include "bindings/core/v8/V8DOMWrapper.h" |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include <v8.h> | 35 #include <v8.h> |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class CORE_EXPORT V8DOMConfiguration final { | 39 class CORE_EXPORT V8DOMConfiguration final { |
| 40 DISALLOW_NEW(); | 40 STATIC_ONLY(V8DOMConfiguration); |
| 41 WTF_MAKE_NONCOPYABLE(V8DOMConfiguration); | |
| 42 public: | 41 public: |
| 43 // The following Configuration structs and install methods are used for | 42 // The following Configuration structs and install methods are used for |
| 44 // setting multiple properties on ObjectTemplate / FunctionTemplate, used | 43 // setting multiple properties on ObjectTemplate / FunctionTemplate, used |
| 45 // from the generated bindings initialization (ConfigureXXXTemplate). | 44 // from the generated bindings initialization (ConfigureXXXTemplate). |
| 46 // This greatly reduces the binary size by moving from code driven setup to | 45 // This greatly reduces the binary size by moving from code driven setup to |
| 47 // data table driven setup. | 46 // data table driven setup. |
| 48 | 47 |
| 49 enum ExposeConfiguration { | 48 enum ExposeConfiguration { |
| 50 ExposedToAllScripts, | 49 ExposedToAllScripts, |
| 51 OnlyExposedToPrivateScript, | 50 OnlyExposedToPrivateScript, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 }; | 130 }; |
| 132 | 131 |
| 133 // Constant installation | 132 // Constant installation |
| 134 // | 133 // |
| 135 // installConstants and installConstant are used for simple constants. They | 134 // installConstants and installConstant are used for simple constants. They |
| 136 // install constants using v8::Template::Set(), which results in a property | 135 // install constants using v8::Template::Set(), which results in a property |
| 137 // that is much faster to access from scripts. | 136 // that is much faster to access from scripts. |
| 138 // installConstantWithGetter is used when some C++ code needs to be executed | 137 // installConstantWithGetter is used when some C++ code needs to be executed |
| 139 // when the constant is accessed, e.g. to handle deprecation or measuring | 138 // when the constant is accessed, e.g. to handle deprecation or measuring |
| 140 // usage. The property appears the same to scripts, but is slower to access. | 139 // usage. The property appears the same to scripts, but is slower to access. |
| 141 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> f
unctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Consta
ntConfiguration*, size_t constantCount); | 140 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> i
nterfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan
tConfiguration*, size_t constantCount); |
| 142 | 141 |
| 143 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> fu
nctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan
tConfiguration&); | 142 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> in
terfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constant
Configuration&); |
| 144 | 143 |
| 145 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe
mplate> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, con
st char* name, v8::AccessorNameGetterCallback); | 144 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe
mplate> interfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, cons
t char* name, v8::AccessorNameGetterCallback); |
| 146 | 145 |
| 147 // MethodConfiguration translates into calls to Set() for setting up an | 146 // MethodConfiguration translates into calls to Set() for setting up an |
| 148 // object's callbacks. It sets the method on both the FunctionTemplate or | 147 // object's callbacks. It sets the method on both the FunctionTemplate or |
| 149 // the ObjectTemplate. | 148 // the ObjectTemplate. |
| 150 struct MethodConfiguration { | 149 struct MethodConfiguration { |
| 151 MethodConfiguration& operator=(const MethodConfiguration&) = delete; | 150 MethodConfiguration& operator=(const MethodConfiguration&) = delete; |
| 152 DISALLOW_NEW(); | 151 DISALLOW_NEW(); |
| 153 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At
omicString(isolate, name); } | 152 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At
omicString(isolate, name); } |
| 154 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons
t | 153 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons
t |
| 155 { | 154 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 184 }; | 183 }; |
| 185 | 184 |
| 186 static void installMethods(v8::Isolate*, v8::Local<v8::ObjectTemplate> insta
nceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Func
tionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const MethodConfigura
tion*, size_t methodCount); | 185 static void installMethods(v8::Isolate*, v8::Local<v8::ObjectTemplate> insta
nceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Func
tionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const MethodConfigura
tion*, size_t methodCount); |
| 187 | 186 |
| 188 static void installMethod(v8::Isolate*, v8::Local<v8::ObjectTemplate> instan
ceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Funct
ionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const MethodConfigurat
ion&); | 187 static void installMethod(v8::Isolate*, v8::Local<v8::ObjectTemplate> instan
ceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Funct
ionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const MethodConfigurat
ion&); |
| 189 | 188 |
| 190 static void installMethod(v8::Isolate*, v8::Local<v8::Object> instance, v8::
Local<v8::Object> prototype, v8::Local<v8::Function> interface, v8::Local<v8::Si
gnature>, const MethodConfiguration&); | 189 static void installMethod(v8::Isolate*, v8::Local<v8::Object> instance, v8::
Local<v8::Object> prototype, v8::Local<v8::Function> interface, v8::Local<v8::Si
gnature>, const MethodConfiguration&); |
| 191 | 190 |
| 192 static void installMethod(v8::Isolate*, v8::Local<v8::ObjectTemplate>, v8::L
ocal<v8::Signature>, const SymbolKeyedMethodConfiguration&); | 191 static void installMethod(v8::Isolate*, v8::Local<v8::ObjectTemplate>, v8::L
ocal<v8::Signature>, const SymbolKeyedMethodConfiguration&); |
| 193 | 192 |
| 194 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Isolate*, v8::Lo
cal<v8::FunctionTemplate>, const char* interfaceName, v8::Local<v8::FunctionTemp
late> parentClass, size_t fieldCount, | 193 static void initializeDOMInterfaceTemplate(v8::Isolate*, v8::Local<v8::Funct
ionTemplate> interfaceTemplate, const char* interfaceName, v8::Local<v8::Functio
nTemplate> parentInterfaceTemplate, size_t v8InternalFieldCount); |
| 195 const AttributeConfiguration*, size_t attributeCount, | |
| 196 const AccessorConfiguration*, size_t accessorCount, | |
| 197 const MethodConfiguration*, size_t methodCount); | |
| 198 | 194 |
| 199 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); | 195 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); |
| 200 | 196 |
| 201 // Sets the class string of platform objects, interface prototype objects, e
tc. | 197 // Sets the class string of platform objects, interface prototype objects, e
tc. |
| 202 // See also http://heycam.github.io/webidl/#dfn-class-string | 198 // See also http://heycam.github.io/webidl/#dfn-class-string |
| 203 static void setClassString(v8::Isolate*, v8::Local<v8::ObjectTemplate>, cons
t char* classString); | 199 static void setClassString(v8::Isolate*, v8::Local<v8::ObjectTemplate>, cons
t char* classString); |
| 204 }; | 200 }; |
| 205 | 201 |
| 206 } // namespace blink | 202 } // namespace blink |
| 207 | 203 |
| 208 #endif // V8DOMConfiguration_h | 204 #endif // V8DOMConfiguration_h |
| OLD | NEW |