diff --git a/content/base/public/Makefile.in b/content/base/public/Makefile.in index c22327668030..5a8e717f0c48 100644 --- a/content/base/public/Makefile.in +++ b/content/base/public/Makefile.in @@ -77,7 +77,6 @@ nsLineBreaker.h \ nsReferencedElement.h \ nsTreeSanitizer.h \ nsXMLNameSpaceMap.h \ -nsDOMEventTargetWrapperCache.h \ nsIXFormsUtilityService.h \ $(NULL) diff --git a/content/base/public/nsDOMEventTargetWrapperCache.h b/content/base/public/nsDOMEventTargetWrapperCache.h deleted file mode 100644 index a14dee342df9..000000000000 --- a/content/base/public/nsDOMEventTargetWrapperCache.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=8 et tw=80 : */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Wellington Fernando de Macedo. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Wellington Fernando de Macedo (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsDOMEventTargetWrapperCache_h__ -#define nsDOMEventTargetWrapperCache_h__ - -#include "nsDOMEventTargetHelper.h" -#include "nsWrapperCache.h" -#include "nsIScriptContext.h" - - -// Base class intended to be used for objets like XMLHttpRequest, -// EventSource and WebSocket. - -class nsDOMEventTargetWrapperCache : public nsDOMEventTargetHelper, - public nsWrapperCache -{ -public: - NS_DECL_ISUPPORTS_INHERITED - - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMEventTargetWrapperCache, - nsDOMEventTargetHelper) - - void GetParentObject(nsIScriptGlobalObject **aParentObject) - { - if (mOwner) { - CallQueryInterface(mOwner, aParentObject); - } - else { - *aParentObject = nsnull; - } - } - - static nsDOMEventTargetWrapperCache* FromSupports(nsISupports* aSupports) - { - nsIDOMEventTarget* target = - static_cast(aSupports); -#ifdef DEBUG - { - nsCOMPtr target_qi = - do_QueryInterface(aSupports); - - // If this assertion fires the QI implementation for the object in - // question doesn't use the nsIDOMEventTarget pointer as the - // nsISupports pointer. That must be fixed, or we'll crash... - NS_ASSERTION(target_qi == target, "Uh, fix QI!"); - } -#endif - - return static_cast(target); - } - - void Init(JSContext* aCx = nsnull); - -protected: - nsDOMEventTargetWrapperCache() : nsDOMEventTargetHelper(), nsWrapperCache() {} - virtual ~nsDOMEventTargetWrapperCache(); -}; - -#define NS_DECL_EVENT_HANDLER(_event) \ - protected: \ - nsRefPtr mOn##_event##Listener; \ - public: - -#define NS_DECL_AND_IMPL_EVENT_HANDLER(_event) \ - protected: \ - nsRefPtr mOn##_event##Listener; \ - public: \ - NS_IMETHOD GetOn##_event(nsIDOMEventListener** a##_event) \ - { \ - return GetInnerEventListener(mOn##_event##Listener, a##_event); \ - } \ - NS_IMETHOD SetOn##_event(nsIDOMEventListener* a##_event) \ - { \ - return RemoveAddEventListener(NS_LITERAL_STRING(#_event), \ - mOn##_event##Listener, a##_event); \ - } - -#define NS_IMPL_EVENT_HANDLER(_class, _event) \ - NS_IMETHODIMP \ - _class::GetOn##_event(nsIDOMEventListener** a##_event) \ - { \ - return GetInnerEventListener(mOn##_event##Listener, a##_event); \ - } \ - NS_IMETHODIMP \ - _class::SetOn##_event(nsIDOMEventListener* a##_event) \ - { \ - return RemoveAddEventListener(NS_LITERAL_STRING(#_event), \ - mOn##_event##Listener, a##_event); \ - } - -#define NS_IMPL_FORWARD_EVENT_HANDLER(_class, _event, _baseclass) \ - NS_IMETHODIMP \ - _class::GetOn##_event(nsIDOMEventListener** a##_event) \ - { \ - return _baseclass::GetOn##_event(a##_event); \ - } \ - NS_IMETHODIMP \ - _class::SetOn##_event(nsIDOMEventListener* a##_event) \ - { \ - return _baseclass::SetOn##_event(a##_event); \ - } - -#define NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(_event) \ - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOn##_event##Listener) - -#define NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(_event) \ - NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOn##_event##Listener) - - -#endif // nsDOMEventTargetWrapperCache_h__ diff --git a/content/base/src/FileIOObject.cpp b/content/base/src/FileIOObject.cpp index a58ffc8ed844..d1f5312db601 100644 --- a/content/base/src/FileIOObject.cpp +++ b/content/base/src/FileIOObject.cpp @@ -54,19 +54,19 @@ namespace dom { const PRUint64 kUnknownSize = PRUint64(-1); -NS_IMPL_ADDREF_INHERITED(FileIOObject, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(FileIOObject, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(FileIOObject, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(FileIOObject, nsDOMEventTargetHelper) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileIOObject) NS_INTERFACE_MAP_ENTRY(nsITimerCallback) NS_INTERFACE_MAP_ENTRY(nsIStreamListener) NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_CLASS(FileIOObject) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(FileIOObject, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgressNotifier) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(abort) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error) @@ -74,7 +74,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(FileIOObject, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(FileIOObject, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(abort) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(error) diff --git a/content/base/src/FileIOObject.h b/content/base/src/FileIOObject.h index e00bff4529a4..f5df017d4798 100644 --- a/content/base/src/FileIOObject.h +++ b/content/base/src/FileIOObject.h @@ -39,7 +39,7 @@ #define FileIOObject_h__ #include "nsIDOMEventTarget.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsIChannel.h" #include "nsIFile.h" #include "nsIDOMFile.h" @@ -57,7 +57,7 @@ extern const PRUint64 kUnknownSize; // A common base class for FileReader and FileSaver -class FileIOObject : public nsDOMEventTargetWrapperCache, +class FileIOObject : public nsDOMEventTargetHelper, public nsIStreamListener, public nsITimerCallback { @@ -82,7 +82,7 @@ public: NS_DECL_NSIREQUESTOBSERVER NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileIOObject, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) protected: // Implemented by the derived class to do whatever it needs to do for abort diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index 323942f6ec45..e5ed6db02493 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -98,7 +98,6 @@ CPPSRCS = \ nsDOMAttributeMap.cpp \ nsDOMBlobBuilder.cpp \ nsDOMDocumentType.cpp \ - nsDOMEventTargetWrapperCache.cpp \ nsDOMFile.cpp \ nsDOMFileReader.cpp \ nsDOMLists.cpp \ diff --git a/content/base/src/nsDOMEventTargetWrapperCache.cpp b/content/base/src/nsDOMEventTargetWrapperCache.cpp deleted file mode 100644 index 6f7e18fe6c33..000000000000 --- a/content/base/src/nsDOMEventTargetWrapperCache.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=8 et tw=80 : */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Wellington Fernando de Macedo. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Wellington Fernando de Macedo (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsContentUtils.h" -#include "nsDOMEventTargetWrapperCache.h" -#include "nsIDocument.h" -#include "nsIJSContextStack.h" -#include "nsServiceManagerUtils.h" -#include "nsDOMJSUtils.h" -#include "nsWrapperCacheInlines.h" - -NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMEventTargetWrapperCache) - -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMEventTargetWrapperCache) - NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMEventTargetWrapperCache, - nsDOMEventTargetHelper) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMEventTargetWrapperCache, - nsDOMEventTargetHelper) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMEventTargetWrapperCache) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) - -NS_IMPL_ADDREF_INHERITED(nsDOMEventTargetWrapperCache, nsDOMEventTargetHelper) -NS_IMPL_RELEASE_INHERITED(nsDOMEventTargetWrapperCache, nsDOMEventTargetHelper) - -void -nsDOMEventTargetWrapperCache::Init(JSContext* aCx) -{ - // Set the original mScriptContext and mPrincipal, if available - JSContext* cx = aCx; - if (!cx) { - nsIJSContextStack* stack = nsContentUtils::ThreadJSContextStack(); - - if (!stack) - return; - - if (NS_FAILED(stack->Peek(&cx)) || !cx) - return; - } - - NS_ASSERTION(cx, "Should have returned earlier ..."); - nsIScriptContext* context = GetScriptContextFromJSContext(cx); - if (context) { - mScriptContext = context; - nsCOMPtr window = - do_QueryInterface(context->GetGlobalObject()); - if (window) - mOwner = window->GetCurrentInnerWindow(); - } -} - -nsDOMEventTargetWrapperCache::~nsDOMEventTargetWrapperCache() -{ - nsContentUtils::ReleaseWrapper(this, this); -} diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp index 3d34ec5c1747..1172c4c5e3ca 100644 --- a/content/base/src/nsDOMFileReader.cpp +++ b/content/base/src/nsDOMFileReader.cpp @@ -79,6 +79,7 @@ #include "xpcpublic.h" #include "nsIScriptSecurityManager.h" #include "nsDOMJSUtils.h" +#include "nsDOMEventTargetHelper.h" #include "jstypedarray.h" @@ -114,7 +115,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMFileReader, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) if(tmp->mResultArrayBuffer) { NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer, "mResultArrayBuffer") @@ -173,7 +174,7 @@ nsDOMFileReader::~nsDOMFileReader() nsresult nsDOMFileReader::Init() { - nsDOMEventTargetWrapperCache::Init(); + nsDOMEventTargetHelper::Init(); nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager(); nsCOMPtr subjectPrincipal; diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index 0ca25bf90383..cb91fea9bdbf 100644 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -64,6 +64,7 @@ #include "xpcpublic.h" #include "nsCrossSiteListenerProxy.h" #include "nsWrapperCacheInlines.h" +#include "nsDOMEventTargetHelper.h" using namespace mozilla; @@ -127,11 +128,11 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsEventSource) NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsEventSource, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsEventSource, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSrc) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNotificationCallbacks) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLoadGroup) @@ -144,7 +145,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsEventSource, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mUnicodeDecoder) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsEventSource, nsDOMEventTargetWrapperCache) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsEventSource, nsDOMEventTargetHelper) tmp->Close(); NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnOpenListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnMessageListener) @@ -163,10 +164,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsEventSource) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(EventSource) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(nsEventSource, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(nsEventSource, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(nsEventSource, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(nsEventSource, nsDOMEventTargetHelper) //----------------------------------------------------------------------------- // nsEventSource::nsIEventSource diff --git a/content/base/src/nsEventSource.h b/content/base/src/nsEventSource.h index 760bc40c4d90..4ee1c32b0045 100644 --- a/content/base/src/nsEventSource.h +++ b/content/base/src/nsEventSource.h @@ -48,7 +48,7 @@ #include "nsIEventSource.h" #include "nsIJSNativeInitializer.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsIObserver.h" #include "nsIStreamListener.h" #include "nsIChannelEventSink.h" @@ -69,7 +69,7 @@ class AsyncVerifyRedirectCallbackFwr; class nsAutoClearFields; -class nsEventSource: public nsDOMEventTargetWrapperCache, +class nsEventSource: public nsDOMEventTargetHelper, public nsIEventSource, public nsIJSNativeInitializer, public nsIObserver, @@ -85,7 +85,7 @@ public: virtual ~nsEventSource(); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(nsEventSource, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_DECL_NSIEVENTSOURCE diff --git a/content/base/src/nsInProcessTabChildGlobal.cpp b/content/base/src/nsInProcessTabChildGlobal.cpp index 867a75d6ae10..69a36fc2e0f1 100644 --- a/content/base/src/nsInProcessTabChildGlobal.cpp +++ b/content/base/src/nsInProcessTabChildGlobal.cpp @@ -144,13 +144,13 @@ nsInProcessTabChildGlobal::Init() NS_IMPL_CYCLE_COLLECTION_CLASS(nsInProcessTabChildGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMessageManager) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMessageManager) nsFrameScriptExecutor::Traverse(tmp, cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -163,7 +163,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsInProcessTabChildGlobal) NS_INTERFACE_MAP_ENTRY(nsIScriptContextPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, nsDOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, nsDOMEventTargetHelper) diff --git a/content/base/src/nsInProcessTabChildGlobal.h b/content/base/src/nsInProcessTabChildGlobal.h index 0a1b23db5ab0..75dcbbaa5298 100644 --- a/content/base/src/nsInProcessTabChildGlobal.h +++ b/content/base/src/nsInProcessTabChildGlobal.h @@ -42,7 +42,7 @@ #include "nsCOMPtr.h" #include "nsFrameMessageManager.h" #include "nsIScriptContext.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsIScriptObjectPrincipal.h" #include "nsIScriptContext.h" #include "nsIClassInfo.h" @@ -52,7 +52,7 @@ #include "nsCOMArray.h" #include "nsThreadUtils.h" -class nsInProcessTabChildGlobal : public nsDOMEventTargetWrapperCache, +class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper, public nsFrameScriptExecutor, public nsIInProcessContentFrameMessageManager, public nsIScriptObjectPrincipal, @@ -64,7 +64,7 @@ public: virtual ~nsInProcessTabChildGlobal(); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsInProcessTabChildGlobal, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager) NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, const jsval& aObject, diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index 6723404ad57d..1a6f14571203 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -83,6 +83,7 @@ #include "prmem.h" #include "nsDOMFile.h" #include "nsWrapperCacheInlines.h" +#include "nsDOMEventTargetHelper.h" using namespace mozilla; @@ -459,11 +460,11 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsWebSocket) NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsWebSocket, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsWebSocket, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnOpenListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnMessageListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnCloseListener) @@ -474,7 +475,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsWebSocket, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsWebSocket, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) tmp->Disconnect(); NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnOpenListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnMessageListener) @@ -494,10 +495,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsWebSocket) NS_INTERFACE_MAP_ENTRY(nsIWebSocketListener) NS_INTERFACE_MAP_ENTRY(nsIRequest) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebSocket) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(nsWebSocket, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(nsWebSocket, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(nsWebSocket, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(nsWebSocket, nsDOMEventTargetHelper) //----------------------------------------------------------------------------- // nsWebSocket::nsIJSNativeInitializer methods: diff --git a/content/base/src/nsWebSocket.h b/content/base/src/nsWebSocket.h index ebace902948b..bc4e56ebda44 100644 --- a/content/base/src/nsWebSocket.h +++ b/content/base/src/nsWebSocket.h @@ -48,7 +48,7 @@ #include "nsIPrincipal.h" #include "nsCycleCollectionParticipant.h" #include "nsIDOMEventListener.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsAutoPtr.h" #include "nsIDOMDOMStringList.h" #include "nsIInterfaceRequestor.h" @@ -69,7 +69,7 @@ class nsWSCloseEvent; class nsAutoCloseWS; -class nsWebSocket: public nsDOMEventTargetWrapperCache, +class nsWebSocket: public nsDOMEventTargetHelper, public nsIWebSocket, public nsIJSNativeInitializer, public nsIInterfaceRequestor, @@ -84,7 +84,7 @@ public: virtual ~nsWebSocket(); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(nsWebSocket, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_DECL_NSIWEBSOCKET NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIWEBSOCKETLISTENER diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 5fe4b3dc0683..f5e07725a976 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -300,7 +300,7 @@ nsMultipartProxyListener::OnDataAvailable(nsIRequest *aRequest, NS_IMPL_CYCLE_COLLECTION_CLASS(nsXHREventTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXHREventTarget, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener) @@ -311,7 +311,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXHREventTarget, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXHREventTarget, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener) @@ -323,10 +323,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXHREventTarget) NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequestEventTarget) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(nsXHREventTarget, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(nsXHREventTarget, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(nsXHREventTarget, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(nsXHREventTarget, nsDOMEventTargetHelper) NS_IMETHODIMP nsXHREventTarget::GetOnload(nsIDOMEventListener** aOnLoad) diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 2ef64127676c..3d5a1ab84249 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -63,7 +63,7 @@ #include "nsITimer.h" #include "nsIPrivateDOMEvent.h" #include "nsDOMProgressEvent.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsContentUtils.h" #include "nsDOMFile.h" #include "nsDOMBlobBuilder.h" @@ -72,14 +72,14 @@ class nsILoadGroup; class AsyncVerifyRedirectCallbackForwarder; class nsIUnicodeDecoder; -class nsXHREventTarget : public nsDOMEventTargetWrapperCache, +class nsXHREventTarget : public nsDOMEventTargetHelper, public nsIXMLHttpRequestEventTarget { public: virtual ~nsXHREventTarget() {} NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXHREventTarget, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_DECL_NSIXMLHTTPREQUESTEVENTTARGET NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) diff --git a/content/events/src/nsDOMEventTargetHelper.cpp b/content/events/src/nsDOMEventTargetHelper.cpp index 144197cc37bc..5a4e85c7cf9d 100644 --- a/content/events/src/nsDOMEventTargetHelper.cpp +++ b/content/events/src/nsDOMEventTargetHelper.cpp @@ -41,9 +41,10 @@ #include "nsEventDispatcher.h" #include "nsGUIEvent.h" #include "nsIDocument.h" +#include "nsIJSContextStack.h" +#include "nsDOMJSUtils.h" NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMEventListenerWrapper) - NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMEventListenerWrapper) NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener) NS_INTERFACE_MAP_END_AGGREGATED(mListener) @@ -67,7 +68,12 @@ nsDOMEventListenerWrapper::HandleEvent(nsIDOMEvent* aEvent) NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMEventTargetHelper) +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMEventTargetHelper) + NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER +NS_IMPL_CYCLE_COLLECTION_TRACE_END + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEventTargetHelper) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mListenerManager, nsEventListenerManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mScriptContext) @@ -75,12 +81,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEventTargetHelper) + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mListenerManager) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mScriptContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOwner) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMEventTargetHelper) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_END @@ -95,6 +103,7 @@ nsDOMEventTargetHelper::~nsDOMEventTargetHelper() if (mListenerManager) { mListenerManager->Disconnect(); } + nsContentUtils::ReleaseWrapper(this, this); } NS_IMETHODIMP @@ -251,3 +260,28 @@ nsDOMEventTargetHelper::GetContextForEventHandlers(nsresult* aRv) return mScriptContext; } +void +nsDOMEventTargetHelper::Init(JSContext* aCx) +{ + // Set the original mScriptContext and mPrincipal, if available + JSContext* cx = aCx; + if (!cx) { + nsIJSContextStack* stack = nsContentUtils::ThreadJSContextStack(); + + if (!stack) + return; + + if (NS_FAILED(stack->Peek(&cx)) || !cx) + return; + } + + NS_ASSERTION(cx, "Should have returned earlier ..."); + nsIScriptContext* context = GetScriptContextFromJSContext(cx); + if (context) { + mScriptContext = context; + nsCOMPtr window = + do_QueryInterface(context->GetGlobalObject()); + if (window) + mOwner = window->GetCurrentInnerWindow(); + } +} diff --git a/content/events/src/nsDOMEventTargetHelper.h b/content/events/src/nsDOMEventTargetHelper.h index 12b0fcf958ac..33e385336348 100644 --- a/content/events/src/nsDOMEventTargetHelper.h +++ b/content/events/src/nsDOMEventTargetHelper.h @@ -48,6 +48,7 @@ #include "nsIScriptGlobalObject.h" #include "nsEventListenerManager.h" #include "nsIScriptContext.h" +#include "nsWrapperCache.h" class nsDOMEventListenerWrapper : public nsIDOMEventListener { @@ -65,16 +66,48 @@ protected: nsCOMPtr mListener; }; -class nsDOMEventTargetHelper : public nsIDOMEventTarget +class nsDOMEventTargetHelper : public nsIDOMEventTarget, + public nsWrapperCache { public: nsDOMEventTargetHelper() {} virtual ~nsDOMEventTargetHelper(); NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMEventTargetHelper) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMEventTargetHelper) NS_DECL_NSIDOMEVENTTARGET + void GetParentObject(nsIScriptGlobalObject **aParentObject) + { + if (mOwner) { + CallQueryInterface(mOwner, aParentObject); + } + else { + *aParentObject = nsnull; + } + } + + static nsDOMEventTargetHelper* FromSupports(nsISupports* aSupports) + { + nsIDOMEventTarget* target = + static_cast(aSupports); +#ifdef DEBUG + { + nsCOMPtr target_qi = + do_QueryInterface(aSupports); + + // If this assertion fires the QI implementation for the object in + // question doesn't use the nsIDOMEventTarget pointer as the + // nsISupports pointer. That must be fixed, or we'll crash... + NS_ASSERTION(target_qi == target, "Uh, fix QI!"); + } +#endif + + return static_cast(target); + } + + void Init(JSContext* aCx = nsnull); + bool HasListenersFor(const nsAString& aType) { return mListenerManager && mListenerManager->HasListenersFor(aType); @@ -104,6 +137,56 @@ protected: nsCOMPtr mOwner; // Inner window. }; +#define NS_DECL_EVENT_HANDLER(_event) \ + protected: \ + nsRefPtr mOn##_event##Listener; \ + public: + +#define NS_DECL_AND_IMPL_EVENT_HANDLER(_event) \ + protected: \ + nsRefPtr mOn##_event##Listener; \ + public: \ + NS_IMETHOD GetOn##_event(nsIDOMEventListener** a##_event) \ + { \ + return GetInnerEventListener(mOn##_event##Listener, a##_event); \ + } \ + NS_IMETHOD SetOn##_event(nsIDOMEventListener* a##_event) \ + { \ + return RemoveAddEventListener(NS_LITERAL_STRING(#_event), \ + mOn##_event##Listener, a##_event); \ + } + +#define NS_IMPL_EVENT_HANDLER(_class, _event) \ + NS_IMETHODIMP \ + _class::GetOn##_event(nsIDOMEventListener** a##_event) \ + { \ + return GetInnerEventListener(mOn##_event##Listener, a##_event); \ + } \ + NS_IMETHODIMP \ + _class::SetOn##_event(nsIDOMEventListener* a##_event) \ + { \ + return RemoveAddEventListener(NS_LITERAL_STRING(#_event), \ + mOn##_event##Listener, a##_event); \ + } + +#define NS_IMPL_FORWARD_EVENT_HANDLER(_class, _event, _baseclass) \ + NS_IMETHODIMP \ + _class::GetOn##_event(nsIDOMEventListener** a##_event) \ + { \ + return _baseclass::GetOn##_event(a##_event); \ + } \ + NS_IMETHODIMP \ + _class::SetOn##_event(nsIDOMEventListener* a##_event) \ + { \ + return _baseclass::SetOn##_event(a##_event); \ + } + +#define NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(_event) \ + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOn##_event##Listener) + +#define NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(_event) \ + NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOn##_event##Listener) + #define NS_UNMARK_LISTENER_WRAPPER(_event) \ if (tmp->mOn##_event##Listener) { \ nsCOMPtr wjs = \ diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 7766cd95b7e6..d0a57442623f 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -80,7 +80,7 @@ #include "nsCSSValue.h" #include "nsIRunnable.h" #include "nsThreadUtils.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "xpcprivate.h" #include "XrayWrapper.h" @@ -7631,8 +7631,8 @@ NS_IMETHODIMP nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, JSObject **parentObj) { - nsDOMEventTargetWrapperCache *target = - nsDOMEventTargetWrapperCache::FromSupports(nativeObj); + nsDOMEventTargetHelper *target = + nsDOMEventTargetHelper::FromSupports(nativeObj); nsCOMPtr native_parent; target->GetParentObject(getter_AddRefs(native_parent)); @@ -7658,8 +7658,8 @@ nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx, void nsEventTargetSH::PreserveWrapper(nsISupports *aNative) { - nsDOMEventTargetWrapperCache *target = - nsDOMEventTargetWrapperCache::FromSupports(aNative); + nsDOMEventTargetHelper *target = + nsDOMEventTargetHelper::FromSupports(aNative); nsContentUtils::PreserveWrapper(aNative, target); } diff --git a/dom/battery/BatteryManager.cpp b/dom/battery/BatteryManager.cpp index 9d1d8562b14e..2cf48fdeef70 100644 --- a/dom/battery/BatteryManager.cpp +++ b/dom/battery/BatteryManager.cpp @@ -42,6 +42,7 @@ #include "Constants.h" #include "nsDOMEvent.h" #include "mozilla/Preferences.h" +#include "nsDOMEventTargetHelper.h" /** * We have to use macros here because our leak analysis tool things we are @@ -61,7 +62,7 @@ namespace battery { NS_IMPL_CYCLE_COLLECTION_CLASS(BatteryManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BatteryManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(levelchange) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingchange) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingtimechange) @@ -69,7 +70,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BatteryManager, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BatteryManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(levelchange) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingchange) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingtimechange) @@ -79,10 +80,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BatteryManager) NS_INTERFACE_MAP_ENTRY(nsIDOMMozBatteryManager) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBatteryManager) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetHelper) BatteryManager::BatteryManager() : mLevel(kDefaultLevel) diff --git a/dom/battery/BatteryManager.h b/dom/battery/BatteryManager.h index 3b4d27b25a4a..bb6519d36789 100644 --- a/dom/battery/BatteryManager.h +++ b/dom/battery/BatteryManager.h @@ -39,10 +39,11 @@ #define mozilla_dom_battery_BatteryManager_h #include "nsIDOMBatteryManager.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsCycleCollectionParticipant.h" #include "mozilla/Observer.h" #include "Types.h" +#include "nsDOMEventTargetHelper.h" class nsPIDOMWindow; class nsIScriptContext; @@ -56,14 +57,14 @@ class BatteryInformation; namespace dom { namespace battery { -class BatteryManager : public nsDOMEventTargetWrapperCache +class BatteryManager : public nsDOMEventTargetHelper , public nsIDOMMozBatteryManager , public BatteryObserver { public: NS_DECL_ISUPPORTS NS_DECL_NSIDOMMOZBATTERYMANAGER - NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::) + NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) BatteryManager(); @@ -74,7 +75,7 @@ public: void Notify(const hal::BatteryInformation& aBatteryInfo); NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BatteryManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) /** * Returns whether the battery api is supported (ie. not disabled by the user) diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index a97a0ea0aacc..f2ece33abc7e 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -59,6 +59,7 @@ #include "IndexedDatabaseManager.h" #include "TransactionThreadPool.h" #include "DictionaryHelpers.h" +#include "nsDOMEventTargetHelper.h" USING_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/IDBDatabase.h b/dom/indexedDB/IDBDatabase.h index 54ba42e5fb05..9a5225c9d483 100644 --- a/dom/indexedDB/IDBDatabase.h +++ b/dom/indexedDB/IDBDatabase.h @@ -44,7 +44,7 @@ #include "nsIDocument.h" #include "nsIIDBDatabase.h" - +#include "nsDOMEventTargetHelper.h" #include "mozilla/dom/indexedDB/IDBWrapperCache.h" #include "mozilla/dom/indexedDB/FileManager.h" diff --git a/dom/indexedDB/IDBRequest.h b/dom/indexedDB/IDBRequest.h index 78d96ac35e39..7cb0c0687802 100644 --- a/dom/indexedDB/IDBRequest.h +++ b/dom/indexedDB/IDBRequest.h @@ -45,7 +45,7 @@ #include "nsIIDBRequest.h" #include "nsIIDBOpenDBRequest.h" - +#include "nsDOMEventTargetHelper.h" #include "mozilla/dom/indexedDB/IDBWrapperCache.h" class nsIScriptContext; diff --git a/dom/indexedDB/IDBWrapperCache.cpp b/dom/indexedDB/IDBWrapperCache.cpp index c09482fd7c30..7669a8f870e3 100644 --- a/dom/indexedDB/IDBWrapperCache.cpp +++ b/dom/indexedDB/IDBWrapperCache.cpp @@ -11,18 +11,18 @@ USING_INDEXEDDB_NAMESPACE NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) // Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because // nsDOMEventTargetHelper does it for us. NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) tmp->mScriptOwner = nsnull; NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) // Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because // nsDOMEventTargetHelper does it for us. if (tmp->mScriptOwner) { @@ -32,7 +32,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache, NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBWrapperCache) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, nsDOMEventTargetHelper) diff --git a/dom/indexedDB/IDBWrapperCache.h b/dom/indexedDB/IDBWrapperCache.h index 5475a47576de..056f51d0014d 100644 --- a/dom/indexedDB/IDBWrapperCache.h +++ b/dom/indexedDB/IDBWrapperCache.h @@ -9,17 +9,17 @@ #include "mozilla/dom/indexedDB/IndexedDatabase.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" BEGIN_INDEXEDDB_NAMESPACE -class IDBWrapperCache : public nsDOMEventTargetWrapperCache +class IDBWrapperCache : public nsDOMEventTargetHelper { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( IDBWrapperCache, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) JSObject* GetScriptOwner() const { @@ -44,7 +44,7 @@ public: // Do what nsEventTargetSH::PreCreate does. nsCOMPtr parent; - nsDOMEventTargetWrapperCache::GetParentObject(getter_AddRefs(parent)); + nsDOMEventTargetHelper::GetParentObject(getter_AddRefs(parent)); return parent ? parent->GetGlobalJSObject() : nsnull; } @@ -52,7 +52,7 @@ public: static IDBWrapperCache* FromSupports(nsISupports* aSupports) { return static_cast( - nsDOMEventTargetWrapperCache::FromSupports(aSupports)); + nsDOMEventTargetHelper::FromSupports(aSupports)); } protected: diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index ec9e2e0f0ed2..5df15d549ab3 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -1002,12 +1002,12 @@ TabChildGlobal::TabChildGlobal(TabChild* aTabChild) NS_IMPL_CYCLE_COLLECTION_CLASS(TabChildGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TabChildGlobal, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMessageManager) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TabChildGlobal, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMessageManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -1018,7 +1018,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal) NS_INTERFACE_MAP_ENTRY(nsIScriptContextPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(TabChildGlobal, nsDOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(TabChildGlobal, nsDOMEventTargetHelper) diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 8eeecb2ebb94..5d3ad4c683dc 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -65,7 +65,7 @@ #include "nsNetUtil.h" #include "nsFrameMessageManager.h" #include "nsIScriptContext.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsIDialogCreator.h" #include "nsIDialogParamBlock.h" #include "nsIPresShell.h" @@ -87,7 +87,7 @@ namespace dom { class TabChild; class PContentDialogChild; -class TabChildGlobal : public nsDOMEventTargetWrapperCache, +class TabChildGlobal : public nsDOMEventTargetHelper, public nsIContentFrameMessageManager, public nsIScriptObjectPrincipal, public nsIScriptContextPrincipal @@ -95,7 +95,7 @@ class TabChildGlobal : public nsDOMEventTargetWrapperCache, public: TabChildGlobal(TabChild* aTabChild); NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetWrapperCache) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper) NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager) NS_IMETHOD SendSyncMessage(const nsAString& aMessageName, const jsval& aObject, diff --git a/dom/network/src/Connection.cpp b/dom/network/src/Connection.cpp index d023b795e8e3..ef6e86f42c25 100644 --- a/dom/network/src/Connection.cpp +++ b/dom/network/src/Connection.cpp @@ -61,12 +61,12 @@ const bool Connection::sMeteredDefaultValue = false; NS_IMPL_CYCLE_COLLECTION_CLASS(Connection) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(Connection, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(change) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(Connection, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(change) NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -74,10 +74,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Connection) NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozConnection) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(Connection, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(Connection, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(Connection, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(Connection, nsDOMEventTargetHelper) Connection::Connection() : mCanBeMetered(kDefaultCanBeMetered) diff --git a/dom/network/src/Connection.h b/dom/network/src/Connection.h index 7e69f0b7e877..441739a96b38 100644 --- a/dom/network/src/Connection.h +++ b/dom/network/src/Connection.h @@ -39,7 +39,7 @@ #define mozilla_dom_network_Connection_h #include "nsIDOMConnection.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" #include "nsCycleCollectionParticipant.h" #include "mozilla/Observer.h" #include "Types.h" @@ -53,7 +53,7 @@ class NetworkInformation; namespace dom { namespace network { -class Connection : public nsDOMEventTargetWrapperCache +class Connection : public nsDOMEventTargetHelper , public nsIDOMMozConnection , public NetworkObserver { @@ -61,7 +61,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIDOMMOZCONNECTION - NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::) + NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) Connection(); @@ -72,7 +72,7 @@ public: void Notify(const hal::NetworkInformation& aNetworkInfo); NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Connection, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) private: /** diff --git a/dom/sms/src/SmsManager.cpp b/dom/sms/src/SmsManager.cpp index 77d2b2646af3..22c435f7ba05 100644 --- a/dom/sms/src/SmsManager.cpp +++ b/dom/sms/src/SmsManager.cpp @@ -68,14 +68,14 @@ namespace sms { NS_IMPL_CYCLE_COLLECTION_CLASS(SmsManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SmsManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(received) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(sent) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(delivered) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(received) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(sent) NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(delivered) @@ -85,10 +85,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(SmsManager) NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsManager) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozSmsManager) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsManager) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(SmsManager, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(SmsManager, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(SmsManager, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(SmsManager, nsDOMEventTargetHelper) void SmsManager::Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext) diff --git a/dom/sms/src/SmsManager.h b/dom/sms/src/SmsManager.h index 718b6ea92f1d..21f777728bd4 100644 --- a/dom/sms/src/SmsManager.h +++ b/dom/sms/src/SmsManager.h @@ -40,7 +40,7 @@ #include "nsIDOMSmsManager.h" #include "nsIObserver.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" class nsIDOMMozSmsMessage; @@ -50,17 +50,17 @@ namespace sms { class SmsManager : public nsIDOMMozSmsManager , public nsIObserver - , public nsDOMEventTargetWrapperCache + , public nsDOMEventTargetHelper { public: NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER NS_DECL_NSIDOMMOZSMSMANAGER - NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::) + NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SmsManager, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) void Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext); void Shutdown(); diff --git a/dom/sms/src/SmsRequest.cpp b/dom/sms/src/SmsRequest.cpp index 08f2805bee4f..7dbcba0c22d5 100644 --- a/dom/sms/src/SmsRequest.cpp +++ b/dom/sms/src/SmsRequest.cpp @@ -51,7 +51,7 @@ namespace sms { NS_IMPL_CYCLE_COLLECTION_CLASS(SmsRequest) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SmsRequest, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(success) NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error) @@ -59,7 +59,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SmsRequest, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) if (tmp->mResultRooted) { tmp->mResult = JSVAL_VOID; tmp->UnrootResult(); @@ -70,7 +70,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest, NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(SmsRequest, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) if (JSVAL_IS_GCTHING(tmp->mResult)) { void *gcThing = JSVAL_TO_GCTHING(tmp->mResult); NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mResult") @@ -81,10 +81,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(SmsRequest) NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsRequest) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozSmsRequest) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsRequest) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) -NS_IMPL_ADDREF_INHERITED(SmsRequest, nsDOMEventTargetWrapperCache) -NS_IMPL_RELEASE_INHERITED(SmsRequest, nsDOMEventTargetWrapperCache) +NS_IMPL_ADDREF_INHERITED(SmsRequest, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(SmsRequest, nsDOMEventTargetHelper) NS_IMPL_EVENT_HANDLER(SmsRequest, success) NS_IMPL_EVENT_HANDLER(SmsRequest, error) diff --git a/dom/sms/src/SmsRequest.h b/dom/sms/src/SmsRequest.h index c247867b1060..973a2000bc12 100644 --- a/dom/sms/src/SmsRequest.h +++ b/dom/sms/src/SmsRequest.h @@ -39,7 +39,7 @@ #define mozilla_dom_sms_SmsRequest_h #include "nsIDOMSmsRequest.h" -#include "nsDOMEventTargetWrapperCache.h" +#include "nsDOMEventTargetHelper.h" class nsIDOMMozSmsMessage; class nsIDOMMozSmsCursor; @@ -49,7 +49,7 @@ namespace dom { namespace sms { class SmsRequest : public nsIDOMMozSmsRequest - , public nsDOMEventTargetWrapperCache + , public nsDOMEventTargetHelper { public: friend class SmsRequestManager; @@ -70,10 +70,10 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIDOMMOZSMSREQUEST - NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::) + NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(SmsRequest, - nsDOMEventTargetWrapperCache) + nsDOMEventTargetHelper) void Reset();