Bug 846204 - Unregister DocManager from DOM event listeners. r=tbsaunde

This commit is contained in:
Alexander Surkov 2013-03-05 09:56:34 -05:00
parent a76374a3e1
commit 2135e46a10
2 changed files with 16 additions and 1 deletions

View File

@ -348,6 +348,19 @@ DocManager::AddListeners(nsIDocument* aDocument,
}
}
void
DocManager::RemoveListeners(nsIDocument* aDocument)
{
nsPIDOMWindow* window = aDocument->GetWindow();
nsIDOMEventTarget* target = window->GetChromeEventHandler();
nsEventListenerManager* elm = target->GetListenerManager(true);
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
dom::TrustedEventsAtCapture());
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
dom::TrustedEventsAtCapture());
}
DocAccessible*
DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
{

View File

@ -65,6 +65,7 @@ public:
inline void NotifyOfDocumentShutdown(nsIDocument* aDocument)
{
mDocAccessibleCache.Remove(aDocument);
RemoveListeners(aDocument);
}
#ifdef DEBUG
@ -101,9 +102,10 @@ private:
uint32_t aLoadEventType);
/**
* Add 'pagehide' and 'DOMContentLoaded' event listeners.
* Add/remove 'pagehide' and 'DOMContentLoaded' event listeners.
*/
void AddListeners(nsIDocument *aDocument, bool aAddPageShowListener);
void RemoveListeners(nsIDocument* aDocument);
/**
* Create document or root accessible.