diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index b585c9ffd01..bf7895d0645 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -1193,22 +1193,33 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLContext) NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLContext) NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLContext) + +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WebGLContext) + NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER +NS_IMPL_CYCLE_COLLECTION_TRACE_END + NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCanvasElement) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mEnabledExtensions) + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_END + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCanvasElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mEnabledExtensions) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END DOMCI_DATA(WebGLRenderingContext, WebGLContext) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsIDOMWebGLRenderingContext) NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextInternal) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsITimerCallback) + // If the exact way we cast to nsISupports here ever changes, fix our + // PreCreate hook! NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWebGLRenderingContext) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebGLRenderingContext) NS_INTERFACE_MAP_END diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index cdd8230f9b0..f0c22e9449a 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -523,7 +523,8 @@ class WebGLContext : public nsICanvasRenderingContextInternal, public nsSupportsWeakReference, public nsITimerCallback, - public WebGLRectangleObject + public WebGLRectangleObject, + public nsWrapperCache { friend class WebGLMemoryMultiReporterWrapper; friend class WebGLExtensionLoseContext; @@ -536,7 +537,12 @@ public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebGLContext, nsIDOMWebGLRenderingContext) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext, + nsIDOMWebGLRenderingContext) + + nsINode* GetParentObject() { + return HTMLCanvasElement(); + } NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 758e252012b..792f64329ba 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -10908,8 +10908,20 @@ WebGLExtensionSH::PreCreate(nsISupports *nativeObj, JSContext *cx, WebGLExtension *ext = static_cast(nativeObj); WebGLContext *webgl = ext->Context(); - nsHTMLCanvasElement *canvas = webgl->HTMLCanvasElement(); - nsINode *node = static_cast(canvas); + nsINode *node = webgl->GetParentObject(); + + return WrapNativeParent(cx, globalObj, node, node, parentObj); +} + +NS_IMETHODIMP +nsWebGLViewportHandlerSH::PreCreate(nsISupports *nativeObj, JSContext *cx, + JSObject *globalObj, JSObject **parentObj) +{ + *parentObj = globalObj; + + WebGLContext *webgl = static_cast( + static_cast(nativeObj)); + nsINode *node = webgl->GetParentObject(); return WrapNativeParent(cx, globalObj, node, node, parentObj); } diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 0f06bd8cac9..19f6c0063fc 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -1612,6 +1612,9 @@ public: return rv; } + NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx, + JSObject *globalObj, JSObject **parentObj); + static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) { return new nsWebGLViewportHandlerSH(aData);