зеркало из https://github.com/mozilla/pjs.git
Backing out bug 202080 until I can figure out bustage
This commit is contained in:
Родитель
0741ca912e
Коммит
83d1de4ecc
|
@ -61,7 +61,12 @@ nsIDOMNode *nsAccessNode::gLastFocusedNode = 0;
|
|||
PRBool nsAccessNode::gIsAccessibilityActive = PR_FALSE;
|
||||
PRBool nsAccessNode::gIsCacheDisabled = PR_FALSE;
|
||||
|
||||
|
||||
#ifdef OLD_HASH
|
||||
nsSupportsHashtable *nsAccessNode::gGlobalDocAccessibleCache = nsnull;
|
||||
#else
|
||||
nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *nsAccessNode::gGlobalDocAccessibleCache = nsnull;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class nsAccessNode
|
||||
|
@ -181,8 +186,12 @@ void nsAccessNode::InitXPAccessibility()
|
|||
}
|
||||
nsAccessibilityAtoms::AddRefAtoms();
|
||||
|
||||
#ifdef OLD_HASH
|
||||
gGlobalDocAccessibleCache = new nsSupportsHashtable(4);
|
||||
#else
|
||||
gGlobalDocAccessibleCache = new nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>;
|
||||
gGlobalDocAccessibleCache->Init(4); // Initialize for 4 entries
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPref> prefService(do_GetService(kPrefCID));
|
||||
if (prefService) {
|
||||
|
@ -205,7 +214,7 @@ void nsAccessNode::ShutdownXPAccessibility()
|
|||
NS_IF_RELEASE(gKeyStringBundle);
|
||||
NS_IF_RELEASE(gLastFocusedNode);
|
||||
|
||||
ClearCache(*gGlobalDocAccessibleCache);
|
||||
ClearCache(gGlobalDocAccessibleCache);
|
||||
delete gGlobalDocAccessibleCache;
|
||||
gGlobalDocAccessibleCache = nsnull;
|
||||
|
||||
|
@ -261,6 +270,55 @@ nsIFrame* nsAccessNode::GetFrame()
|
|||
|
||||
/***************** Hashtable of nsIAccessNode's *****************/
|
||||
|
||||
#ifdef OLD_HASH
|
||||
void nsAccessNode::GetDocAccessibleFor(nsIWeakReference *aPresShell,
|
||||
nsIAccessibleDocument **aDocAccessible)
|
||||
{
|
||||
*aDocAccessible = nsnull;
|
||||
NS_ASSERTION(gGlobalDocAccessibleCache, "Global doc cache does not exist");
|
||||
|
||||
nsVoidKey key(NS_STATIC_CAST(void*, aPresShell));
|
||||
nsCOMPtr<nsIAccessNode> accessNode = NS_STATIC_CAST(nsIAccessNode*, gGlobalDocAccessibleCache->Get(&key));
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc(do_QueryInterface(accessNode));
|
||||
*aDocAccessible = accDoc; // already addrefed
|
||||
}
|
||||
|
||||
void nsAccessNode::PutCacheEntry(nsSupportsHashtable *aCache, void* aUniqueID,
|
||||
nsIAccessNode *aAccessNode)
|
||||
{
|
||||
nsVoidKey key(aUniqueID);
|
||||
#ifdef DEBUG
|
||||
if (aCache->Exists(&key)) {
|
||||
NS_ASSERTION(PR_FALSE, "This cache entry shouldn't exist already");
|
||||
nsCOMPtr<nsIAccessNode> oldAccessNode;
|
||||
GetCacheEntry(aCache, aUniqueID, getter_AddRefs(oldAccessNode));
|
||||
}
|
||||
#endif
|
||||
aCache->Put(&key, aAccessNode);
|
||||
}
|
||||
|
||||
void nsAccessNode::GetCacheEntry(nsSupportsHashtable *aCache, void* aUniqueID,
|
||||
nsIAccessNode **aAccessNode)
|
||||
{
|
||||
nsVoidKey key(aUniqueID);
|
||||
*aAccessNode = NS_STATIC_CAST(nsIAccessNode*, aCache->Get(&key)); // AddRefs for us
|
||||
}
|
||||
|
||||
PRIntn PR_CALLBACK nsAccessNode::ClearCacheEntry(nsHashKey *aKey, void *aAccessNode,
|
||||
void* aClosure)
|
||||
{
|
||||
nsIAccessNode* accessNode = NS_STATIC_CAST(nsIAccessNode*, aAccessNode);
|
||||
accessNode->Shutdown();
|
||||
|
||||
return kHashEnumerateRemove;
|
||||
}
|
||||
|
||||
void nsAccessNode::ClearCache(nsSupportsHashtable *aCache)
|
||||
{
|
||||
aCache->Enumerate(ClearCacheEntry);
|
||||
}
|
||||
|
||||
#else
|
||||
void nsAccessNode::GetDocAccessibleFor(nsIWeakReference *aPresShell,
|
||||
nsIAccessibleDocument **aDocAccessible)
|
||||
{
|
||||
|
@ -274,35 +332,34 @@ void nsAccessNode::GetDocAccessibleFor(nsIWeakReference *aPresShell,
|
|||
}
|
||||
}
|
||||
|
||||
void nsAccessNode::PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> &aCache,
|
||||
void nsAccessNode::PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache,
|
||||
void* aUniqueID,
|
||||
nsIAccessNode *aAccessNode)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIAccessNode> oldAccessNode;
|
||||
GetCacheEntry(aCache, aUniqueID, getter_AddRefs(oldAccessNode));
|
||||
NS_ASSERTION(!oldAccessNode, "This cache entry shouldn't exist already");
|
||||
#endif
|
||||
aCache.Put(aUniqueID, aAccessNode);
|
||||
aCache->Put(aUniqueID, aAccessNode);
|
||||
}
|
||||
|
||||
void nsAccessNode::GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> &aCache,
|
||||
void nsAccessNode::GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache,
|
||||
void* aUniqueID,
|
||||
nsIAccessNode **aAccessNode)
|
||||
{
|
||||
aCache.Get(aUniqueID, aAccessNode); // AddRefs for us
|
||||
aCache->Get(aUniqueID, aAccessNode); // AddRefs for us
|
||||
}
|
||||
|
||||
PLDHashOperator nsAccessNode::ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg)
|
||||
PLDHashOperator ClearCacheEntry(void *const& aKey, nsCOMPtr<nsIAccessNode> aAccessNode, void* aUserArg)
|
||||
{
|
||||
aAccessNode->Shutdown();
|
||||
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
void nsAccessNode::ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> &aCache)
|
||||
void nsAccessNode::ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache)
|
||||
{
|
||||
aCache.Enumerate(ClearCacheEntry, nsnull);
|
||||
//aCache->EnumerateEntries(ClearCacheEntry, nsnull);
|
||||
aCache->EnumerateRead(ClearCacheEntry, nsnull);
|
||||
aCache->Clear();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,7 +49,16 @@
|
|||
#include "nsIStringBundle.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#define OLD_HASH 1
|
||||
|
||||
#ifdef OLD_HASH
|
||||
class nsSupportsHashtable;
|
||||
class nsHashKey;
|
||||
#include "nsHashtable.h"
|
||||
#else
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "pldhash.h"
|
||||
#endif
|
||||
|
||||
class nsIPresShell;
|
||||
class nsIPresContext;
|
||||
|
@ -63,31 +72,34 @@ enum { eSiblingsUninitialized = -1, eSiblingsWalkNormalDOM = -2 };
|
|||
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
|
||||
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
|
||||
|
||||
#ifndef OLD_HASH
|
||||
/* hashkey wrapper using void* KeyType
|
||||
*
|
||||
* @see nsTHashtable::EntryType for specification
|
||||
*/
|
||||
class nsVoidHashKey : public PLDHashEntryHdr
|
||||
class NS_COM nsVoidHashKey : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef const void* KeyType;
|
||||
typedef const void* KeyTypePointer;
|
||||
public: typedef void* voidPointer;
|
||||
typedef const voidPointer& KeyType;
|
||||
typedef const voidPointer* KeyTypePointer;
|
||||
|
||||
nsVoidHashKey(KeyTypePointer aKey) : mValue(aKey) { }
|
||||
const voidPointer mValue;
|
||||
|
||||
public:
|
||||
nsVoidHashKey(KeyTypePointer aKey) : mValue(*aKey) { }
|
||||
nsVoidHashKey(const nsVoidHashKey& toCopy) : mValue(toCopy.mValue) { }
|
||||
~nsVoidHashKey() { }
|
||||
|
||||
KeyType GetKey() const { return mValue; }
|
||||
KeyTypePointer GetKeyPointer() const { return mValue; }
|
||||
PRBool KeyEquals(KeyTypePointer aKey) const { return aKey == mValue; }
|
||||
KeyTypePointer GetKeyPointer() const { return &mValue; }
|
||||
PRBool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey) { return NS_PTR_TO_INT32(aKey) >> 2; }
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey) { return NS_PTR_TO_INT32(*aKey) >> 2; }
|
||||
static PRBool AllowMemMove() { return PR_TRUE; }
|
||||
|
||||
private:
|
||||
const void* mValue;
|
||||
};
|
||||
#endif
|
||||
|
||||
class nsAccessNode: public nsIAccessNode
|
||||
{
|
||||
|
@ -104,13 +116,23 @@ class nsAccessNode: public nsIAccessNode
|
|||
static void ShutdownXPAccessibility();
|
||||
|
||||
// Static methods for handling per-document cache
|
||||
static void PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache,
|
||||
#ifdef OLD_HASH
|
||||
static void PutCacheEntry(nsSupportsHashtable *aCache,
|
||||
void* aUniqueID, nsIAccessNode *aAccessNode);
|
||||
static void GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache, void* aUniqueID,
|
||||
static void GetCacheEntry(nsSupportsHashtable *aCache, void* aUniqueID,
|
||||
nsIAccessNode **aAccessNode);
|
||||
static void ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache);
|
||||
static void ClearCache(nsSupportsHashtable *aCache);
|
||||
static PRIntn PR_CALLBACK ClearCacheEntry(nsHashKey *aKey, void *aData,
|
||||
void* aClosure);
|
||||
#else
|
||||
static void PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache,
|
||||
void* aUniqueID, nsIAccessNode *aAccessNode);
|
||||
static void GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache, void* aUniqueID,
|
||||
nsIAccessNode **aAccessNode);
|
||||
static void ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *aCache);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg);
|
||||
static PLDHashOperator PR_CALLBACK ClearCacheEntry(void *const& aKey, nsCOMPtr<nsIAccessNode> aAccessNode, void* aUserArg);
|
||||
#endif
|
||||
|
||||
// Static cache methods for global document cache
|
||||
static void GetDocAccessibleFor(nsIWeakReference *aPresShell,
|
||||
|
@ -140,7 +162,11 @@ class nsAccessNode: public nsIAccessNode
|
|||
static PRBool gIsAccessibilityActive;
|
||||
static PRBool gIsCacheDisabled;
|
||||
|
||||
#ifdef OLD_HASH
|
||||
static nsSupportsHashtable *gGlobalDocAccessibleCache;
|
||||
#else
|
||||
static nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *gGlobalDocAccessibleCache;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1442,6 +1442,9 @@ NS_IMETHODIMP nsAccessibilityService::GetCachedAccessNode(nsIDOMNode *aNode,
|
|||
nsAccessNode::GetDocAccessibleFor(aWeakShell, getter_AddRefs(accessibleDoc));
|
||||
|
||||
if (!accessibleDoc) {
|
||||
#ifdef DEBUG_aaronl
|
||||
printf("\nWARNING: No accessible document for weak shell %x\n", aWeakShell);
|
||||
#endif
|
||||
*aAccessNode = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1520,7 +1523,7 @@ nsresult nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
|
|||
// Please leave this in for now, it's a convenient debugging method
|
||||
nsAutoString name;
|
||||
aNode->GetLocalName(name);
|
||||
if (name.EqualsIgnoreCase("object"))
|
||||
if (name.EqualsIgnoreCase("browser"))
|
||||
printf("## aaronl debugging tag name\n");
|
||||
|
||||
nsAutoString attrib;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDocAccessible.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsICommandManager.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -106,11 +107,15 @@ nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell)
|
|||
}
|
||||
|
||||
NS_ASSERTION(gGlobalDocAccessibleCache, "No global doc accessible cache");
|
||||
PutCacheEntry(*gGlobalDocAccessibleCache, mWeakShell, this);
|
||||
PutCacheEntry(gGlobalDocAccessibleCache, mWeakShell, this);
|
||||
|
||||
// XXX aaronl should we use an algorithm for the initial cache size?
|
||||
#ifdef OLD_HASH
|
||||
mAccessNodeCache = new nsSupportsHashtable(kDefaultCacheSize);
|
||||
#else
|
||||
mAccessNodeCache = new nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>;
|
||||
mAccessNodeCache->Init(kDefaultCacheSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
@ -293,14 +298,14 @@ NS_IMETHODIMP nsDocAccessible::GetIsEditable(PRBool *aIsEditable)
|
|||
NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNode **aAccessNode)
|
||||
{
|
||||
NS_ASSERTION(mAccessNodeCache, "No accessibility cache for document");
|
||||
GetCacheEntry(*mAccessNodeCache, aUniqueID, aAccessNode); // Addrefs for us
|
||||
GetCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode); // Addrefs for us
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::CacheAccessNode(void *aUniqueID, nsIAccessNode *aAccessNode)
|
||||
{
|
||||
NS_ASSERTION(mAccessNodeCache, "No accessibility cache for document");
|
||||
PutCacheEntry(*mAccessNodeCache, aUniqueID, aAccessNode);
|
||||
PutCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -342,7 +347,12 @@ NS_IMETHODIMP nsDocAccessible::Destroy()
|
|||
{
|
||||
NS_ASSERTION(gGlobalDocAccessibleCache, "No global doc accessible cache");
|
||||
if (gGlobalDocAccessibleCache) {
|
||||
#ifdef OLD_HASH
|
||||
nsVoidKey key(NS_STATIC_CAST(void*, mWeakShell));
|
||||
gGlobalDocAccessibleCache->Remove(&key);
|
||||
#else
|
||||
gGlobalDocAccessibleCache->Remove(NS_STATIC_CAST(void*, mWeakShell));
|
||||
#endif
|
||||
}
|
||||
return Shutdown();
|
||||
}
|
||||
|
@ -370,9 +380,13 @@ NS_IMETHODIMP nsDocAccessible::Shutdown()
|
|||
mWebProgress = nsnull;
|
||||
|
||||
if (mAccessNodeCache) {
|
||||
#ifdef OLD_HASH
|
||||
nsSupportsHashtable *hashToClear = mAccessNodeCache; // Avoid reentrency
|
||||
#else
|
||||
nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *hashToClear = mAccessNodeCache; // Avoid reentrency
|
||||
#endif
|
||||
mAccessNodeCache = nsnull;
|
||||
ClearCache(*hashToClear);
|
||||
ClearCache(hashToClear);
|
||||
delete hashToClear;
|
||||
}
|
||||
|
||||
|
@ -869,7 +883,12 @@ NS_IMETHODIMP nsDocAccessible::InvalidateCacheSubtree(nsIDOMNode *aStartNode)
|
|||
accessNode->GetUniqueID(&uniqueID);
|
||||
accessNode->Shutdown();
|
||||
// Remove from hash table as well
|
||||
#ifdef OLD_HASH
|
||||
nsVoidKey key(uniqueID);
|
||||
mAccessNodeCache->Remove(&key);
|
||||
#else
|
||||
mAccessNodeCache->Remove(uniqueID);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define _nsDocAccessible_H_
|
||||
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsIAccessibleEventReceiver.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -117,7 +118,11 @@ class nsDocAccessible : public nsAccessibleWrap,
|
|||
nsIAccessibleDocument **aAccessibleDoc);
|
||||
void CheckForEditor();
|
||||
|
||||
#ifdef OLD_HASH
|
||||
nsSupportsHashtable *mAccessNodeCache;
|
||||
#else
|
||||
nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *mAccessNodeCache;
|
||||
#endif
|
||||
void *mWnd;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsITimer> mScrollWatchTimer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче