Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.h

Issue 2690943002: Revert of binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 v8SetReturnValueNull(callbackInfo); 195 v8SetReturnValueNull(callbackInfo);
196 return; 196 return;
197 } 197 }
198 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl)) 198 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
199 return; 199 return;
200 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( 200 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(
201 callbackInfo.GetIsolate(), callbackInfo.Holder()); 201 callbackInfo.GetIsolate(), callbackInfo.Holder());
202 v8SetReturnValue(callbackInfo, wrapper); 202 v8SetReturnValue(callbackInfo, wrapper);
203 } 203 }
204 204
205 // Special versions for DOMWindow and EventTarget
206
207 template <typename CallbackInfo>
208 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
209 DOMWindow* impl) {
210 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
211 callbackInfo.GetIsolate()));
212 }
213
214 template <typename CallbackInfo>
215 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
216 EventTarget* impl) {
217 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
218 callbackInfo.GetIsolate()));
219 }
220
205 template <typename CallbackInfo, typename T> 221 template <typename CallbackInfo, typename T>
206 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, 222 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
207 PassRefPtr<T> impl) { 223 PassRefPtr<T> impl) {
208 v8SetReturnValue(callbackInfo, impl.get()); 224 v8SetReturnValue(callbackInfo, impl.get());
209 } 225 }
210 226
211 template <typename CallbackInfo> 227 template <typename CallbackInfo>
212 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 228 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
213 ScriptWrappable* impl) { 229 ScriptWrappable* impl) {
214 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld()); 230 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
215 if (UNLIKELY(!impl)) { 231 if (UNLIKELY(!impl)) {
216 v8SetReturnValueNull(callbackInfo); 232 v8SetReturnValueNull(callbackInfo);
217 return; 233 return;
218 } 234 }
219 if (DOMDataStore::setReturnValueForMainWorld(callbackInfo.GetReturnValue(), 235 if (DOMDataStore::setReturnValueForMainWorld(callbackInfo.GetReturnValue(),
220 impl)) 236 impl))
221 return; 237 return;
222 v8::Local<v8::Object> wrapper = 238 v8::Local<v8::Object> wrapper =
223 impl->wrap(callbackInfo.GetIsolate(), callbackInfo.Holder()); 239 impl->wrap(callbackInfo.GetIsolate(), callbackInfo.Holder());
224 v8SetReturnValue(callbackInfo, wrapper); 240 v8SetReturnValue(callbackInfo, wrapper);
225 } 241 }
226 242
243 template <typename CallbackInfo>
244 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
245 Node* impl) {
246 // Since EventTarget has a special version of ToV8 and V8EventTarget.h
247 // defines its own v8SetReturnValue family, which are slow, we need to
248 // override them with optimized versions for Node and its subclasses.
249 // Without this overload, v8SetReturnValueForMainWorld for Node would be
250 // very slow.
251 //
252 // class hierarchy:
253 // ScriptWrappable <-- EventTarget <--+-- Node <-- ...
254 // +-- Window
255 // overloads:
256 // v8SetReturnValueForMainWorld(ScriptWrappable*)
257 // Optimized and very fast.
258 // v8SetReturnValueForMainWorld(EventTarget*)
259 // Uses custom toV8 function and slow.
260 // v8SetReturnValueForMainWorld(Node*)
261 // Optimized and very fast.
262 // v8SetReturnValueForMainWorld(Window*)
263 // Uses custom toV8 function and slow.
264 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl));
265 }
266
267 // Special versions for DOMWindow and EventTarget
268
269 template <typename CallbackInfo>
270 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
271 DOMWindow* impl) {
272 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
273 callbackInfo.GetIsolate()));
274 }
275
276 template <typename CallbackInfo>
277 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
278 EventTarget* impl) {
279 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
280 callbackInfo.GetIsolate()));
281 }
282
227 template <typename CallbackInfo, typename T> 283 template <typename CallbackInfo, typename T>
228 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 284 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
229 PassRefPtr<T> impl) { 285 PassRefPtr<T> impl) {
230 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); 286 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
231 } 287 }
232 288
233 template <typename CallbackInfo> 289 template <typename CallbackInfo>
234 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 290 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
235 ScriptWrappable* impl, 291 ScriptWrappable* impl,
236 const ScriptWrappable* wrappable) { 292 const ScriptWrappable* wrappable) {
(...skipping 18 matching lines...) Expand all
255 return; 311 return;
256 } 312 }
257 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, 313 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl,
258 callbackInfo.Holder(), wrappable)) 314 callbackInfo.Holder(), wrappable))
259 return; 315 return;
260 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( 316 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(
261 callbackInfo.GetIsolate(), callbackInfo.Holder()); 317 callbackInfo.GetIsolate(), callbackInfo.Holder());
262 v8SetReturnValue(callbackInfo, wrapper); 318 v8SetReturnValue(callbackInfo, wrapper);
263 } 319 }
264 320
321 // Special versions for DOMWindow and EventTarget
322
323 template <typename CallbackInfo>
324 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
325 DOMWindow* impl,
326 const ScriptWrappable*) {
327 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
328 callbackInfo.GetIsolate()));
329 }
330
331 template <typename CallbackInfo>
332 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
333 EventTarget* impl,
334 const ScriptWrappable*) {
335 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
336 callbackInfo.GetIsolate()));
337 }
338
265 template <typename CallbackInfo, typename T, typename Wrappable> 339 template <typename CallbackInfo, typename T, typename Wrappable>
266 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 340 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
267 PassRefPtr<T> impl, 341 PassRefPtr<T> impl,
268 const Wrappable* wrappable) { 342 const Wrappable* wrappable) {
269 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); 343 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
270 } 344 }
271 345
272 template <typename CallbackInfo, typename T> 346 template <typename CallbackInfo, typename T>
273 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 347 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
274 const v8::Local<T> handle, 348 const v8::Local<T> handle,
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 // If the argument isn't an object, this will crash. 1161 // If the argument isn't an object, this will crash.
1088 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, 1162 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>,
1089 v8::Isolate*); 1163 v8::Isolate*);
1090 1164
1091 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*, 1165 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*,
1092 const String& stringifiedJSON, 1166 const String& stringifiedJSON,
1093 ExceptionState&); 1167 ExceptionState&);
1094 } // namespace blink 1168 } // namespace blink
1095 1169
1096 #endif // V8Binding_h 1170 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ToV8.cpp ('k') | third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698