Bug 359494, Make nsXBLWindowHandler to use nsISupportsWeakReference, not nsIBoxObject, r+sr=bz

This commit is contained in:
Olli.Pettay%helsinki.fi 2006-11-15 06:11:42 +00:00
Родитель 7e18d9771a
Коммит 98aa97e3b7
3 изменённых файлов: 8 добавлений и 19 удалений

Просмотреть файл

@ -182,14 +182,7 @@ nsXBLWindowHandler::nsXBLWindowHandler(nsIDOMElement* aElement,
mHandler(nsnull),
mUserHandler(nsnull)
{
if (aElement) {
nsCOMPtr<nsIDOMDocument> domDoc;
aElement->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMNSDocument> nsDomDoc = do_QueryInterface(domDoc);
if (nsDomDoc) {
nsDomDoc->GetBoxObjectFor(aElement, getter_AddRefs(mBoxObjectForElement));
}
}
mWeakPtrForElement = do_GetWeakReference(aElement);
++sRefCnt;
}
@ -213,11 +206,7 @@ nsXBLWindowHandler::~nsXBLWindowHandler()
already_AddRefed<nsIDOMElement>
nsXBLWindowHandler::GetElement()
{
if (!mBoxObjectForElement) {
return nsnull;
}
nsCOMPtr<nsIDOMElement> element;
mBoxObjectForElement->GetElement(getter_AddRefs(element));
nsCOMPtr<nsIDOMElement> element = do_QueryReferent(mWeakPtrForElement);
nsIDOMElement* el = nsnull;
element.swap(el);
return el;

Просмотреть файл

@ -45,7 +45,7 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsXBLPrototypeHandler.h"
#include "nsIBoxObject.h"
#include "nsWeakPtr.h"
class nsIDOMEventReceiver;
@ -91,8 +91,8 @@ protected:
// unless the element has been removed from the document.
already_AddRefed<nsIDOMElement> GetElement();
// Using nsIBoxObject as a weak reference to a DOM Element.
nsCOMPtr<nsIBoxObject> mBoxObjectForElement;
// Using weak pointer to the DOM Element.
nsWeakPtr mWeakPtrForElement;
nsIDOMEventReceiver* mReceiver; // weak ref
// these are not owning references; the prototype handlers are owned

Просмотреть файл

@ -69,8 +69,8 @@ nsXBLWindowKeyHandler::nsXBLWindowKeyHandler(nsIDOMElement* aElement, nsIDOMEven
nsXBLWindowKeyHandler::~nsXBLWindowKeyHandler()
{
// If mBoxObjectForElement is non-null, we created a prototype handler.
if (mBoxObjectForElement)
// If mWeakPtrForElement is non-null, we created a prototype handler.
if (mWeakPtrForElement)
delete mHandler;
}
@ -111,7 +111,7 @@ nsresult
nsXBLWindowKeyHandler::EnsureHandlers(PRBool *aIsEditor)
{
nsCOMPtr<nsIDOMElement> el = GetElement();
NS_ENSURE_STATE(!mBoxObjectForElement || el);
NS_ENSURE_STATE(!mWeakPtrForElement || el);
if (el) {
// We are actually a XUL <keyset>.
if (aIsEditor)