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 28 matching lines...) Expand all Loading... |
39 class CORE_EXPORT V8DOMConfiguration final { | 39 class CORE_EXPORT V8DOMConfiguration final { |
40 STATIC_ONLY(V8DOMConfiguration); | 40 STATIC_ONLY(V8DOMConfiguration); |
41 | 41 |
42 public: | 42 public: |
43 // The following Configuration structs and install methods are used for | 43 // The following Configuration structs and install methods are used for |
44 // setting multiple properties on ObjectTemplate / FunctionTemplate, used | 44 // setting multiple properties on ObjectTemplate / FunctionTemplate, used |
45 // from the generated bindings initialization (ConfigureXXXTemplate). | 45 // from the generated bindings initialization (ConfigureXXXTemplate). |
46 // This greatly reduces the binary size by moving from code driven setup to | 46 // This greatly reduces the binary size by moving from code driven setup to |
47 // data table driven setup. | 47 // data table driven setup. |
48 | 48 |
49 enum ExposeConfiguration { | |
50 ExposedToAllScripts, | |
51 OnlyExposedToPrivateScript, | |
52 }; | |
53 | |
54 // Bitflags to show where the member will be defined. | 49 // Bitflags to show where the member will be defined. |
55 enum PropertyLocationConfiguration { | 50 enum PropertyLocationConfiguration { |
56 OnInstance = 1 << 0, | 51 OnInstance = 1 << 0, |
57 OnPrototype = 1 << 1, | 52 OnPrototype = 1 << 1, |
58 OnInterface = 1 << 2, | 53 OnInterface = 1 << 2, |
59 }; | 54 }; |
60 | 55 |
61 enum HolderCheckConfiguration { | 56 enum HolderCheckConfiguration { |
62 CheckHolder, | 57 CheckHolder, |
63 DoNotCheckHolder, | 58 DoNotCheckHolder, |
(...skipping 10 matching lines...) Expand all Loading... |
74 const char* const name; | 69 const char* const name; |
75 v8::AccessorNameGetterCallback getter; | 70 v8::AccessorNameGetterCallback getter; |
76 v8::AccessorNameSetterCallback setter; | 71 v8::AccessorNameSetterCallback setter; |
77 v8::AccessorNameGetterCallback getterForMainWorld; | 72 v8::AccessorNameGetterCallback getterForMainWorld; |
78 v8::AccessorNameSetterCallback setterForMainWorld; | 73 v8::AccessorNameSetterCallback setterForMainWorld; |
79 // TODO(vogelheim): This has to be removed too since it's only used in | 74 // TODO(vogelheim): This has to be removed too since it's only used in |
80 // accessors. | 75 // accessors. |
81 // The accessor's 'result' is stored in a private property. | 76 // The accessor's 'result' is stored in a private property. |
82 CachedAccessorCallback cachedAccessorCallback; | 77 CachedAccessorCallback cachedAccessorCallback; |
83 const WrapperTypeInfo* data; | 78 const WrapperTypeInfo* data; |
84 unsigned settings : 8; // v8::AccessControl | 79 unsigned settings : 8; // v8::AccessControl |
85 unsigned attribute : 8; // v8::PropertyAttribute | 80 unsigned attribute : 8; // v8::PropertyAttribute |
86 unsigned exposeConfiguration : 1; // ExposeConfiguration | |
87 unsigned | 81 unsigned |
88 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 82 propertyLocationConfiguration : 3; // PropertyLocationConfiguration |
89 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 83 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration |
90 }; | 84 }; |
91 | 85 |
92 static void installAttributes(v8::Isolate*, | 86 static void installAttributes(v8::Isolate*, |
93 const DOMWrapperWorld&, | 87 const DOMWrapperWorld&, |
94 v8::Local<v8::ObjectTemplate> instanceTemplate, | 88 v8::Local<v8::ObjectTemplate> instanceTemplate, |
95 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 89 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
96 const AttributeConfiguration*, | 90 const AttributeConfiguration*, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; | 122 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; |
129 DISALLOW_NEW(); | 123 DISALLOW_NEW(); |
130 const char* const name; | 124 const char* const name; |
131 v8::FunctionCallback getter; | 125 v8::FunctionCallback getter; |
132 v8::FunctionCallback setter; | 126 v8::FunctionCallback setter; |
133 v8::FunctionCallback getterForMainWorld; | 127 v8::FunctionCallback getterForMainWorld; |
134 v8::FunctionCallback setterForMainWorld; | 128 v8::FunctionCallback setterForMainWorld; |
135 // The accessor's 'result' is stored in a private property. | 129 // The accessor's 'result' is stored in a private property. |
136 CachedAccessorCallback cachedAccessorCallback; | 130 CachedAccessorCallback cachedAccessorCallback; |
137 const WrapperTypeInfo* data; | 131 const WrapperTypeInfo* data; |
138 unsigned settings : 8; // v8::AccessControl | 132 unsigned settings : 8; // v8::AccessControl |
139 unsigned attribute : 8; // v8::PropertyAttribute | 133 unsigned attribute : 8; // v8::PropertyAttribute |
140 unsigned exposeConfiguration : 1; // ExposeConfiguration | |
141 unsigned | 134 unsigned |
142 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 135 propertyLocationConfiguration : 3; // PropertyLocationConfiguration |
143 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 136 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration |
144 }; | 137 }; |
145 | 138 |
146 static void installAccessors( | 139 static void installAccessors( |
147 v8::Isolate*, | 140 v8::Isolate*, |
148 const DOMWrapperWorld&, | 141 const DOMWrapperWorld&, |
149 v8::Local<v8::ObjectTemplate> instanceTemplate, | 142 v8::Local<v8::ObjectTemplate> instanceTemplate, |
150 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 143 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 226 } |
234 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) const { | 227 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) const { |
235 return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld | 228 return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld |
236 : callback; | 229 : callback; |
237 } | 230 } |
238 | 231 |
239 const char* const name; | 232 const char* const name; |
240 v8::FunctionCallback callback; | 233 v8::FunctionCallback callback; |
241 v8::FunctionCallback callbackForMainWorld; | 234 v8::FunctionCallback callbackForMainWorld; |
242 int length; | 235 int length; |
243 unsigned attribute : 8; // v8::PropertyAttribute | 236 unsigned attribute : 8; // v8::PropertyAttribute |
244 unsigned exposeConfiguration : 1; // ExposeConfiguration | |
245 unsigned | 237 unsigned |
246 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 238 propertyLocationConfiguration : 3; // PropertyLocationConfiguration |
247 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 239 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration |
248 }; | 240 }; |
249 | 241 |
250 struct SymbolKeyedMethodConfiguration { | 242 struct SymbolKeyedMethodConfiguration { |
251 SymbolKeyedMethodConfiguration& operator=( | 243 SymbolKeyedMethodConfiguration& operator=( |
252 const SymbolKeyedMethodConfiguration&) = delete; | 244 const SymbolKeyedMethodConfiguration&) = delete; |
253 DISALLOW_NEW(); | 245 DISALLOW_NEW(); |
254 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { | 246 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { |
255 return getSymbol(isolate); | 247 return getSymbol(isolate); |
256 } | 248 } |
257 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const { | 249 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const { |
258 return callback; | 250 return callback; |
259 } | 251 } |
260 | 252 |
261 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); | 253 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); |
262 v8::FunctionCallback callback; | 254 v8::FunctionCallback callback; |
263 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. | 255 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. |
264 int length; | 256 int length; |
265 unsigned attribute : 8; // v8::PropertyAttribute | 257 unsigned attribute : 8; // v8::PropertyAttribute |
266 unsigned exposeConfiguration : 1; // ExposeConfiguration | |
267 unsigned | 258 unsigned |
268 propertyLocationConfiguration : 3; // PropertyLocationConfiguration | 259 propertyLocationConfiguration : 3; // PropertyLocationConfiguration |
269 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration | 260 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration |
270 }; | 261 }; |
271 | 262 |
272 static void installMethods(v8::Isolate*, | 263 static void installMethods(v8::Isolate*, |
273 const DOMWrapperWorld&, | 264 const DOMWrapperWorld&, |
274 v8::Local<v8::ObjectTemplate> instanceTemplate, | 265 v8::Local<v8::ObjectTemplate> instanceTemplate, |
275 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 266 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
276 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 267 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // Sets the class string of platform objects, interface prototype objects, | 307 // Sets the class string of platform objects, interface prototype objects, |
317 // etc. See also http://heycam.github.io/webidl/#dfn-class-string | 308 // etc. See also http://heycam.github.io/webidl/#dfn-class-string |
318 static void setClassString(v8::Isolate*, | 309 static void setClassString(v8::Isolate*, |
319 v8::Local<v8::ObjectTemplate>, | 310 v8::Local<v8::ObjectTemplate>, |
320 const char* classString); | 311 const char* classString); |
321 }; | 312 }; |
322 | 313 |
323 } // namespace blink | 314 } // namespace blink |
324 | 315 |
325 #endif // V8DOMConfiguration_h | 316 #endif // V8DOMConfiguration_h |
OLD | NEW |