bug 434464 - invalidate access node cache, patch by Alexander Surkov <surkov.alexander@gmail.com>, r=aaronlev

This commit is contained in:
Marco Zehe 2008-06-11 11:17:37 +02:00
parent c031b61a7e
commit fe6c72f9e1
2 changed files with 21 additions and 5 deletions

View File

@ -1335,11 +1335,15 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
nsCOMPtr<nsIAccessible> newAcc;
if (accessNode) {
// Retrieved from cache
// QI might not succeed if it's a node that's not accessible
// Retrieved from cache. QI might not succeed if it's a node that's not
// accessible. In this case try to create new accessible because one and
// the same DOM node may be accessible or not in time (for example,
// when it is visible or hidden).
newAcc = do_QueryInterface(accessNode);
NS_IF_ADDREF(*aAccessible = newAcc);
return NS_OK;
if (newAcc) {
NS_ADDREF(*aAccessible = newAcc);
return NS_OK;
}
}
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));

View File

@ -517,8 +517,20 @@ NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNod
return NS_OK;
}
NS_IMETHODIMP nsDocAccessible::CacheAccessNode(void *aUniqueID, nsIAccessNode *aAccessNode)
NS_IMETHODIMP
nsDocAccessible::CacheAccessNode(void *aUniqueID, nsIAccessNode *aAccessNode)
{
// If there is an access node for the given unique ID then let's shutdown it.
// The unique ID may be presented in the cache if originally we created
// access node object and then we want to create accessible object when
// DOM node is changed.
nsCOMPtr<nsIAccessNode> accessNode;
GetCacheEntry(mAccessNodeCache, aUniqueID, getter_AddRefs(accessNode));
if (accessNode) {
nsCOMPtr<nsPIAccessNode> prAccessNode = do_QueryInterface(accessNode);
prAccessNode->Shutdown();
}
PutCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode);
return NS_OK;
}