| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( | 202 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( |
| 203 callbackInfo.GetIsolate(), callbackInfo.Holder()); | 203 callbackInfo.GetIsolate(), callbackInfo.Holder()); |
| 204 v8SetReturnValue(callbackInfo, wrapper); | 204 v8SetReturnValue(callbackInfo, wrapper); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget | 207 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget |
| 208 | 208 |
| 209 template <typename CallbackInfo> | 209 template <typename CallbackInfo> |
| 210 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, | 210 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, |
| 211 DOMWindow* impl) { | 211 DOMWindow* impl) { |
| 212 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 212 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 213 callbackInfo.GetIsolate())); | 213 callbackInfo.GetIsolate())); |
| 214 } | 214 } |
| 215 | 215 |
| 216 template <typename CallbackInfo> | 216 template <typename CallbackInfo> |
| 217 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, | 217 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, |
| 218 EventTarget* impl) { | 218 EventTarget* impl) { |
| 219 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 219 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 220 callbackInfo.GetIsolate())); | 220 callbackInfo.GetIsolate())); |
| 221 } | 221 } |
| 222 | 222 |
| 223 template <typename CallbackInfo> | 223 template <typename CallbackInfo> |
| 224 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, | 224 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, |
| 225 WorkerGlobalScope* impl) { | 225 WorkerGlobalScope* impl) { |
| 226 v8SetReturnValue(callbackInfo, | 226 v8SetReturnValue(callbackInfo, |
| 227 toV8((WorkerOrWorkletGlobalScope*)impl, | 227 ToV8((WorkerOrWorkletGlobalScope*)impl, |
| 228 callbackInfo.Holder(), callbackInfo.GetIsolate())); | 228 callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| 229 } | 229 } |
| 230 | 230 |
| 231 template <typename CallbackInfo, typename T> | 231 template <typename CallbackInfo, typename T> |
| 232 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, | 232 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, |
| 233 PassRefPtr<T> impl) { | 233 PassRefPtr<T> impl) { |
| 234 v8SetReturnValue(callbackInfo, impl.get()); | 234 v8SetReturnValue(callbackInfo, impl.get()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 template <typename CallbackInfo> | 237 template <typename CallbackInfo> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // v8SetReturnValueForMainWorld(Window*) | 272 // v8SetReturnValueForMainWorld(Window*) |
| 273 // Uses custom toV8 function and slow. | 273 // Uses custom toV8 function and slow. |
| 274 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl)); | 274 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget | 277 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget |
| 278 | 278 |
| 279 template <typename CallbackInfo> | 279 template <typename CallbackInfo> |
| 280 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, | 280 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, |
| 281 DOMWindow* impl) { | 281 DOMWindow* impl) { |
| 282 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 282 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 283 callbackInfo.GetIsolate())); | 283 callbackInfo.GetIsolate())); |
| 284 } | 284 } |
| 285 | 285 |
| 286 template <typename CallbackInfo> | 286 template <typename CallbackInfo> |
| 287 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, | 287 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, |
| 288 EventTarget* impl) { | 288 EventTarget* impl) { |
| 289 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 289 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 290 callbackInfo.GetIsolate())); | 290 callbackInfo.GetIsolate())); |
| 291 } | 291 } |
| 292 | 292 |
| 293 template <typename CallbackInfo> | 293 template <typename CallbackInfo> |
| 294 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, | 294 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, |
| 295 WorkerGlobalScope* impl) { | 295 WorkerGlobalScope* impl) { |
| 296 v8SetReturnValue(callbackInfo, | 296 v8SetReturnValue(callbackInfo, |
| 297 toV8((WorkerOrWorkletGlobalScope*)impl, | 297 ToV8((WorkerOrWorkletGlobalScope*)impl, |
| 298 callbackInfo.Holder(), callbackInfo.GetIsolate())); | 298 callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| 299 } | 299 } |
| 300 | 300 |
| 301 template <typename CallbackInfo, typename T> | 301 template <typename CallbackInfo, typename T> |
| 302 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, | 302 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, |
| 303 PassRefPtr<T> impl) { | 303 PassRefPtr<T> impl) { |
| 304 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); | 304 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); |
| 305 } | 305 } |
| 306 | 306 |
| 307 template <typename CallbackInfo> | 307 template <typename CallbackInfo> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 335 callbackInfo.GetIsolate(), callbackInfo.Holder()); | 335 callbackInfo.GetIsolate(), callbackInfo.Holder()); |
| 336 v8SetReturnValue(callbackInfo, wrapper); | 336 v8SetReturnValue(callbackInfo, wrapper); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget | 339 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget |
| 340 | 340 |
| 341 template <typename CallbackInfo> | 341 template <typename CallbackInfo> |
| 342 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, | 342 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, |
| 343 DOMWindow* impl, | 343 DOMWindow* impl, |
| 344 const ScriptWrappable*) { | 344 const ScriptWrappable*) { |
| 345 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 345 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 346 callbackInfo.GetIsolate())); | 346 callbackInfo.GetIsolate())); |
| 347 } | 347 } |
| 348 | 348 |
| 349 template <typename CallbackInfo> | 349 template <typename CallbackInfo> |
| 350 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, | 350 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, |
| 351 EventTarget* impl, | 351 EventTarget* impl, |
| 352 const ScriptWrappable*) { | 352 const ScriptWrappable*) { |
| 353 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), | 353 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), |
| 354 callbackInfo.GetIsolate())); | 354 callbackInfo.GetIsolate())); |
| 355 } | 355 } |
| 356 | 356 |
| 357 template <typename CallbackInfo> | 357 template <typename CallbackInfo> |
| 358 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, | 358 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, |
| 359 WorkerGlobalScope* impl, | 359 WorkerGlobalScope* impl, |
| 360 const ScriptWrappable*) { | 360 const ScriptWrappable*) { |
| 361 v8SetReturnValue(callbackInfo, | 361 v8SetReturnValue(callbackInfo, |
| 362 toV8((WorkerOrWorkletGlobalScope*)impl, | 362 ToV8((WorkerOrWorkletGlobalScope*)impl, |
| 363 callbackInfo.Holder(), callbackInfo.GetIsolate())); | 363 callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| 364 } | 364 } |
| 365 | 365 |
| 366 template <typename CallbackInfo, typename T, typename Wrappable> | 366 template <typename CallbackInfo, typename T, typename Wrappable> |
| 367 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, | 367 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, |
| 368 PassRefPtr<T> impl, | 368 PassRefPtr<T> impl, |
| 369 const Wrappable* wrappable) { | 369 const Wrappable* wrappable) { |
| 370 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 370 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
| 371 } | 371 } |
| 372 | 372 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 private: | 1154 private: |
| 1155 v8::Isolate* m_isolate; | 1155 v8::Isolate* m_isolate; |
| 1156 }; | 1156 }; |
| 1157 | 1157 |
| 1158 typedef void (*InstallTemplateFunction)( | 1158 typedef void (*InstallTemplateFunction)( |
| 1159 v8::Isolate*, | 1159 v8::Isolate*, |
| 1160 const DOMWrapperWorld&, | 1160 const DOMWrapperWorld&, |
| 1161 v8::Local<v8::FunctionTemplate> interfaceTemplate); | 1161 v8::Local<v8::FunctionTemplate> interfaceTemplate); |
| 1162 | 1162 |
| 1163 // Freeze a V8 object. The type of the first parameter and the return value is | 1163 // Freeze a V8 object. The type of the first parameter and the return value is |
| 1164 // intentionally v8::Value so that this function can wrap toV8(). | 1164 // intentionally v8::Value so that this function can wrap ToV8(). |
| 1165 // If the argument isn't an object, this will crash. | 1165 // If the argument isn't an object, this will crash. |
| 1166 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, | 1166 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, |
| 1167 v8::Isolate*); | 1167 v8::Isolate*); |
| 1168 | 1168 |
| 1169 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*, | 1169 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*, |
| 1170 const String& stringifiedJSON, | 1170 const String& stringifiedJSON, |
| 1171 ExceptionState&); | 1171 ExceptionState&); |
| 1172 } // namespace blink | 1172 } // namespace blink |
| 1173 | 1173 |
| 1174 #endif // V8Binding_h | 1174 #endif // V8Binding_h |
| OLD | NEW |