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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8Binding.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
index 8df4565ec2c0e61384ba263ed524172a55e7dba3..2a529350f0df9b34134f212ab90e5773cc727f21 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
@@ -202,6 +202,22 @@
v8SetReturnValue(callbackInfo, wrapper);
}
+// Special versions for DOMWindow and EventTarget
+
+template <typename CallbackInfo>
+inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
+ DOMWindow* impl) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
+}
+
+template <typename CallbackInfo>
+inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
+ EventTarget* impl) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
+}
+
template <typename CallbackInfo, typename T>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
PassRefPtr<T> impl) {
@@ -224,6 +240,46 @@
v8SetReturnValue(callbackInfo, wrapper);
}
+template <typename CallbackInfo>
+inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
+ Node* impl) {
+ // Since EventTarget has a special version of ToV8 and V8EventTarget.h
+ // defines its own v8SetReturnValue family, which are slow, we need to
+ // override them with optimized versions for Node and its subclasses.
+ // Without this overload, v8SetReturnValueForMainWorld for Node would be
+ // very slow.
+ //
+ // class hierarchy:
+ // ScriptWrappable <-- EventTarget <--+-- Node <-- ...
+ // +-- Window
+ // overloads:
+ // v8SetReturnValueForMainWorld(ScriptWrappable*)
+ // Optimized and very fast.
+ // v8SetReturnValueForMainWorld(EventTarget*)
+ // Uses custom toV8 function and slow.
+ // v8SetReturnValueForMainWorld(Node*)
+ // Optimized and very fast.
+ // v8SetReturnValueForMainWorld(Window*)
+ // Uses custom toV8 function and slow.
+ v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl));
+}
+
+// Special versions for DOMWindow and EventTarget
+
+template <typename CallbackInfo>
+inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
+ DOMWindow* impl) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
+}
+
+template <typename CallbackInfo>
+inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
+ EventTarget* impl) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
+}
+
template <typename CallbackInfo, typename T>
inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
PassRefPtr<T> impl) {
@@ -260,6 +316,24 @@
v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(
callbackInfo.GetIsolate(), callbackInfo.Holder());
v8SetReturnValue(callbackInfo, wrapper);
+}
+
+// Special versions for DOMWindow and EventTarget
+
+template <typename CallbackInfo>
+inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
+ DOMWindow* impl,
+ const ScriptWrappable*) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
+}
+
+template <typename CallbackInfo>
+inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
+ EventTarget* impl,
+ const ScriptWrappable*) {
+ v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
+ callbackInfo.GetIsolate()));
}
template <typename CallbackInfo, typename T, typename Wrappable>
« 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