зеркало из https://github.com/mozilla/pjs.git
Bug 163816 Leaking 1 nsAccessibilityService and a bunch of nsGenericAccessible's
r=aaronl, sr=peterv fix the wrong type cast in nsRootAccessible::AddAccessibleEventListener and get rid of the strong pointer to nsHTMLIFrameAccessible in nsHTMLIFrameRootAccessible
This commit is contained in:
Родитель
8765305775
Коммит
d58b422513
|
@ -103,7 +103,6 @@
|
|||
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
nsLayoutAtoms::AddRefAtoms();
|
||||
}
|
||||
|
||||
|
@ -296,8 +295,12 @@ nsAccessibilityService::CreateIFrameAccessible(nsIDOMNode* aDOMNode, nsIAccessib
|
|||
nsCOMPtr<nsIWeakReference> innerWeakShell =
|
||||
do_GetWeakReference(innerPresShell);
|
||||
|
||||
// In these variable names, "outer" relates to the nsHTMLIFrameAccessible,
|
||||
// as opposed to the nsHTMLIFrameRootAccessible which is "inner".
|
||||
// The outer node is a <browser> or <iframe> tag, whereas the inner node
|
||||
// corresponds to the inner document root.
|
||||
nsHTMLIFrameRootAccessible *innerRootAccessible =
|
||||
new nsHTMLIFrameRootAccessible(aDOMNode, innerWeakShell);
|
||||
new nsHTMLIFrameRootAccessible(innerWeakShell);
|
||||
|
||||
if (innerRootAccessible) {
|
||||
nsHTMLIFrameAccessible *outerRootAccessible =
|
||||
|
@ -305,15 +308,12 @@ nsAccessibilityService::CreateIFrameAccessible(nsIDOMNode* aDOMNode, nsIAccessib
|
|||
outerWeakShell, sub_doc);
|
||||
|
||||
if (outerRootAccessible) {
|
||||
innerRootAccessible->Init(outerRootAccessible);
|
||||
*_retval = outerRootAccessible;
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
else // don't leak the innerRoot
|
||||
delete innerRootAccessible;
|
||||
// don't leak the innerRoot
|
||||
delete innerRootAccessible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -435,8 +435,6 @@ PRBool nsAccessibleTreeWalker::GetAccessible()
|
|||
//-----------------------------------------------------
|
||||
nsAccessible::nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): mDOMNode(aNode), mPresShell(aShell), mSiblingIndex(eSiblingsUninitialized)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
#ifdef NS_DEBUG_X
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aShell));
|
||||
|
@ -561,8 +559,14 @@ NS_IMETHODIMP nsAccessible::GetAccId(PRInt32 *aAccId)
|
|||
|
||||
NS_IMETHODIMP nsAccessible::CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList)
|
||||
{
|
||||
if (aParent)
|
||||
mParent = aParent;
|
||||
if (aParent) {
|
||||
PRUint32 role = 0;
|
||||
aParent->GetAccRole(&role);
|
||||
// prevent from invalid caching nsHTMLIFrameRootAccessible
|
||||
if (role != ROLE_NOTHING) {
|
||||
mParent = aParent;
|
||||
}
|
||||
}
|
||||
if (aSiblingList)
|
||||
mSiblingList = aSiblingList;
|
||||
mSiblingIndex = aSiblingIndex;
|
||||
|
|
|
@ -48,7 +48,6 @@ NS_IMPL_ISUPPORTS1(nsGenericAccessible, nsIAccessible)
|
|||
|
||||
nsGenericAccessible::nsGenericAccessible()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
|
|
|
@ -348,11 +348,11 @@ NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventLis
|
|||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
|
||||
|
||||
// add ourself as a CheckboxStateChange listener (custom event fired in nsHTMLInputElement.cpp)
|
||||
rv = target->AddEventListener(NS_LITERAL_STRING("CheckboxStateChange"), NS_STATIC_CAST(nsIDOMFormListener*, this), PR_TRUE);
|
||||
rv = target->AddEventListener(NS_LITERAL_STRING("CheckboxStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
|
||||
|
||||
// add ourself as a RadioStateChange Listener ( custom event fired in in nsHTMLInputElement.cpp & radio.xml)
|
||||
rv = target->AddEventListener(NS_LITERAL_STRING("RadioStateChange"), NS_STATIC_CAST(nsIDOMFormListener*, this), PR_TRUE);
|
||||
rv = target->AddEventListener(NS_LITERAL_STRING("RadioStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
|
||||
|
||||
rv = target->AddEventListener(NS_LITERAL_STRING("ListitemStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
|
@ -390,14 +390,14 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener()
|
|||
if (target) {
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("focus"), NS_STATIC_CAST(nsIDOMFocusListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("select"), NS_STATIC_CAST(nsIDOMFormListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("CheckboxStateChange"), NS_STATIC_CAST(nsIDOMFormListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("CheckboxStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("RadioStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("ListitemStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("popupshowing"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("popuphiding"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("DOMMenuItemActive"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("DOMMenuBarActive"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("DOMMenuBarInactive"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("RadioStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("ListitemStateChange"), NS_STATIC_CAST(nsIDOMXULListener*, this), PR_TRUE);
|
||||
}
|
||||
|
||||
if (mScrollWatchTimer) {
|
||||
|
|
|
@ -54,7 +54,6 @@ NS_IMPL_ISUPPORTS1(nsAccessibleText, nsIAccessibleText)
|
|||
|
||||
nsAccessibleText::nsAccessibleText()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsAccessibleText::~nsAccessibleText()
|
||||
|
|
|
@ -45,12 +45,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameRootAccessible)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsRootAccessible)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
NS_IMPL_ISUPPORTS_INHERITED3(nsHTMLIFrameAccessible, nsBlockAccessible, nsIAccessibleDocument, nsIAccessibleHyperText, nsIAccessibleEventReceiver)
|
||||
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *aDoc):
|
||||
|
@ -345,8 +340,8 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::RemoveAccessibleEventListener()
|
|||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsRootAccessible(aShell), mOuterNode(aNode)
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell):
|
||||
nsRootAccessible(aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -357,55 +352,11 @@ nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
|||
{
|
||||
}
|
||||
|
||||
void nsHTMLIFrameRootAccessible::Init()
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mOuterNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> parentShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(parentShell));
|
||||
if (parentShell) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mOuterNode));
|
||||
nsIFrame* frame = nsnull;
|
||||
parentShell->GetPrimaryFrameFor(content, &frame);
|
||||
NS_ASSERTION(frame, "No outer frame.");
|
||||
if (!frame)
|
||||
return;
|
||||
frame->GetAccessible(getter_AddRefs(mOuterAccessible));
|
||||
NS_ASSERTION(mOuterAccessible, "Something's wrong - there's no accessible for the outer parent of this frame.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsHTMLIFrameRootAccessible::Init(nsIAccessible *aOuterAccessible)
|
||||
{
|
||||
if (aOuterAccessible) {
|
||||
mOuterAccessible = aOuterAccessible;
|
||||
}
|
||||
}
|
||||
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
if (!mOuterAccessible)
|
||||
Init();
|
||||
return mOuterAccessible->GetAccParent(_retval);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccNextSibling (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
if (!mOuterAccessible)
|
||||
Init();
|
||||
return mOuterAccessible->GetAccNextSibling(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
if (!mOuterAccessible)
|
||||
Init();
|
||||
return mOuterAccessible->GetAccPreviousSibling(_retval);
|
||||
// prevent |this| from being cached by nsAccessible::CacheOptimizations
|
||||
*_retval = ROLE_NOTHING;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
|
||||
|
|
|
@ -93,34 +93,14 @@ class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLIFrameRootAccessible();
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
|
||||
|
||||
/* nsIAccessible getAccNextSibling (); */
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
|
||||
// ----- nsIAccessibleEventReceiver -------------------
|
||||
NS_IMETHOD AddAccessibleEventListener(nsIAccessibleEventListener *aListener);
|
||||
NS_IMETHOD RemoveAccessibleEventListener();
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
public:
|
||||
void Init(nsIAccessible *aOuterAccessible);
|
||||
|
||||
// In these variable names, "outer" relates to the nsHTMLIFrameAccessible, as opposed to the
|
||||
// nsHTMLIFrameRootAccessible which is "inner".
|
||||
// The outer node is a <browser> or <iframe> tag, whereas the inner node corresponds to the inner document root.
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mOuterNode;
|
||||
nsCOMPtr<nsIAccessible> mOuterAccessible;
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче