bug 801659 - clean up cache of DocAccessible on pres shells, and add fast path to nsAccDocManager::GetDocAccessible() r=surkov, dholbert

This commit is contained in:
Trevor Saunders 2012-10-15 10:58:42 -04:00
parent 428c858534
commit bc9ac5fb2d
4 changed files with 27 additions and 9 deletions

View File

@ -40,7 +40,14 @@ public:
*/
DocAccessible* GetDocAccessible(const nsIPresShell* aPresShell)
{
return aPresShell ? GetDocAccessible(aPresShell->GetDocument()) : nullptr;
if (!aPresShell)
return nullptr;
DocAccessible* doc = aPresShell->GetDocAccessible();
if (doc)
return doc;
return GetDocAccessible(aPresShell->GetDocument());
}
/**

View File

@ -86,7 +86,7 @@ DocAccessible::
{
mFlags |= eDocAccessible | eNotNodeMapEntry;
if (mPresShell)
mPresShell->SetAccDocument(this);
mPresShell->SetDocAccessible(this);
mDependentIDsHash.Init();
// XXX aaronl should we use an algorithm for the initial cache size?
@ -636,7 +636,7 @@ DocAccessible::Shutdown()
logging::DocDestroy("document shutdown", mDocument, this);
#endif
mPresShell->SetAccDocument(nullptr);
mPresShell->SetDocAccessible(nullptr);
if (mNotificationController) {
mNotificationController->Shutdown();

View File

@ -277,9 +277,20 @@ public:
nsIViewManager* GetViewManager() const { return mViewManager; }
#ifdef ACCESSIBILITY
void SetAccDocument(DocAccessible* aAccDocument)
/**
* Return the document accessible for this pres shell if there is one.
*/
DocAccessible* GetDocAccessible() const
{
mAccDocument = aAccDocument;
return mDocAccessible;
}
/**
* Set the document accessible for this pres shell.
*/
void SetDocAccessible(DocAccessible* aDocAccessible)
{
mDocAccessible = aDocAccessible;
}
#endif
@ -1371,7 +1382,7 @@ protected:
nsWeakPtr mForwardingContainer;
nsRefreshDriver* mHiddenInvalidationObserverRefreshDriver;
#ifdef ACCESSIBILITY
DocAccessible* mAccDocument;
DocAccessible* mDocAccessible;
#endif
#ifdef DEBUG

View File

@ -937,14 +937,14 @@ PresShell::Destroy()
return;
#ifdef ACCESSIBILITY
if (mAccDocument) {
if (mDocAccessible) {
#ifdef DEBUG
if (a11y::logging::IsEnabled(a11y::logging::eDocDestroy))
a11y::logging::DocDestroy("presshell destroyed", mDocument);
#endif
mAccDocument->Shutdown();
mAccDocument = nullptr;
mDocAccessible->Shutdown();
mDocAccessible = nullptr;
}
#endif // ACCESSIBILITY