Bug 571184 - remove nsIAccessNode traversal methods, r=davidb, marcoz

This commit is contained in:
Alexander Surkov 2010-06-12 13:04:35 +09:00
Родитель 837f2efa4c
Коммит 3fa5fc35ac
51 изменённых файлов: 310 добавлений и 685 удалений

Просмотреть файл

@ -56,7 +56,7 @@ interface nsIDOMCSSPrimitiveValue;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(bd458843-1895-42c6-b7f9-f0ca88eeab6b)]
[scriptable, uuid(ef16ff42-0256-4b48-ae87-b18a95b7f7d6)]
interface nsIAccessNode : nsISupports
{
/**
@ -64,45 +64,6 @@ interface nsIAccessNode : nsISupports
*/
readonly attribute nsIDOMNode DOMNode;
/**
* The number of DOM children for the DOM node, which
* matches the number of nsIAccessNode children for this
* nsIAccessNode.
*/
readonly attribute long numChildren;
/**
* Get the nth child of this node
* @param childNum Zero-based child index
* @return The nth nsIAccessNode child
*/
nsIAccessNode getChildNodeAt(in long childNum);
/**
* The parent nsIAccessNode
*/
readonly attribute nsIAccessNode parentNode;
/**
* The first nsIAccessNode child
*/
readonly attribute nsIAccessNode firstChildNode;
/**
* The last nsIAccessNode child
*/
readonly attribute nsIAccessNode lastChildNode;
/**
* The previous nsIAccessNode sibling
*/
readonly attribute nsIAccessNode previousSiblingNode;
/**
* The next nsIAccessNode sibling
*/
readonly attribute nsIAccessNode nextSiblingNode;
/**
* The document accessible that this access node resides in.
*/

Просмотреть файл

@ -306,11 +306,11 @@ void nsAccessibleWrap::ShutdownAtkObject()
}
}
nsresult
void
nsAccessibleWrap::Shutdown()
{
ShutdownAtkObject();
return nsAccessible::Shutdown();
nsAccessible::Shutdown();
}
MaiHyperlink* nsAccessibleWrap::GetMaiHyperlink(PRBool aCreate /* = PR_TRUE */)

Просмотреть файл

@ -90,7 +90,7 @@ public:
void ShutdownAtkObject();
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
#ifdef MAI_LOGGING
virtual void DumpnsAccessibleWrapInfo(int aDepth) {}

Просмотреть файл

@ -532,7 +532,7 @@ nsApplicationAccessibleWrap::~nsApplicationAccessibleWrap()
nsAccessibleWrap::ShutdownAtkObject();
}
nsresult
PRBool
nsApplicationAccessibleWrap::Init()
{
// XXX following code is copied from widget/src/gtk2/nsWindow.cpp

Просмотреть файл

@ -55,7 +55,7 @@ public:
virtual ~nsApplicationAccessibleWrap();
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// return the atk object for app root accessible
NS_IMETHOD GetNativeInterface(void **aOutAccessible);

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsRefPtrHashtable.h"
#include "nsCycleCollectionParticipant.h"
class nsIAccessNode;
class nsIAccessible;
////////////////////////////////////////////////////////////////////////////////
// Accessible cache utils
@ -53,11 +53,11 @@ class nsIAccessNode;
*/
template <class T>
static PLDHashOperator
ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessNode, void* aUserArg)
ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessible, void* aUserArg)
{
NS_ASSERTION(aAccessNode, "Calling ClearCacheEntry with a NULL pointer!");
if (aAccessNode)
aAccessNode->Shutdown();
NS_ASSERTION(aAccessible, "Calling ClearCacheEntry with a NULL pointer!");
if (aAccessible)
aAccessible->Shutdown();
return PL_DHASH_REMOVE;
}
@ -77,7 +77,7 @@ ClearCache(nsRefPtrHashtable<nsVoidPtrHashKey, T> & aCache)
*/
template <class T>
static PLDHashOperator
CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessNode,
CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
void *aUserArg)
{
nsCycleCollectionTraversalCallback *cb =
@ -85,7 +85,7 @@ CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessNode,
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "accessible cache entry");
nsISupports *supports = static_cast<nsIAccessNode*>(aAccessNode);
nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
cb->NoteXPCOMChild(supports);
return PL_DHASH_NEXT;
}

Просмотреть файл

@ -595,12 +595,9 @@ nsAccDocManager::SearchAccessibleInDocCache(const void* aKey,
if (aDocAccessible) {
nsSearchAccessibleInCacheArg* arg =
static_cast<nsSearchAccessibleInCacheArg*>(aUserArg);
nsAccessNode* accessNode =
aDocAccessible->GetCachedAccessNode(arg->mUniqueID);
if (accessNode) {
arg->mAccessible = do_QueryObject(accessNode);
arg->mAccessible = aDocAccessible->GetCachedAccessible(arg->mUniqueID);
if (arg->mAccessible)
return PL_DHASH_STOP;
}
}
return PL_DHASH_NEXT;

Просмотреть файл

@ -174,7 +174,7 @@ private:
struct nsSearchAccessibleInCacheArg
{
nsRefPtr<nsAccessible> mAccessible;
nsAccessible *mAccessible;
void *mUniqueID;
};

Просмотреть файл

@ -651,16 +651,8 @@ nsAccUtils::GetScreenCoordsForWindow(nsAccessNode *aAccessNode)
nsIntPoint
nsAccUtils::GetScreenCoordsForParent(nsAccessNode *aAccessNode)
{
nsRefPtr<nsAccessNode> parent;
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessNode));
if (accessible) {
parent = do_QueryObject(accessible->GetParent());
} else {
nsCOMPtr<nsIAccessNode> parentAccessNode;
aAccessNode->GetParentNode(getter_AddRefs(parentAccessNode));
parent = do_QueryObject(parentAccessNode);
}
nsAccessible *parent =
GetAccService()->GetContainerAccessible(aAccessNode->GetNode(), PR_TRUE);
if (!parent)
return nsIntPoint(0, 0);

Просмотреть файл

@ -137,61 +137,18 @@ void nsAccessNode::LastRelease()
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public
nsresult
PRBool
nsAccessNode::Init()
{
// We have to put this here, instead of constructor, otherwise
// we don't have the virtual GetUniqueID() method for the hash key.
// We need that for accessibles that don't have DOM nodes
#ifdef DEBUG_A11Y
NS_ASSERTION(!mIsInitialized, "Initialized twice!");
#endif
nsDocAccessible *docAcc = nsnull;
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (presShell)
docAcc = GetAccService()->GetDocAccessible(presShell->GetDocument());
NS_ASSERTION(docAcc, "Cannot cache new nsAccessNode");
if (!docAcc) {
#ifdef DEBUG
docAcc = GetAccService()->GetDocAccessible(presShell->GetDocument());
#endif
return NS_ERROR_FAILURE;
}
void* uniqueID;
GetUniqueID(&uniqueID);
if (!docAcc->CacheAccessNode(uniqueID, this))
return NS_ERROR_OUT_OF_MEMORY;
// Make sure an ancestor in real content is cached
// so that nsDocAccessible::RefreshNodes() can find the anonymous subtree to release when
// the root node goes away
if (mContent && mContent->IsInAnonymousSubtree()) {
// Specific examples of where this is used: <input type="file"> and <xul:findbar>
nsAccessible *parent = GetAccService()->GetContainerAccessible(mContent,
PR_TRUE);
if (parent)
parent->EnsureChildren();
}
#ifdef DEBUG_A11Y
mIsInitialized = PR_TRUE;
#endif
return NS_OK;
return PR_TRUE;
}
nsresult
void
nsAccessNode::Shutdown()
{
mContent = nsnull;
mWeakShell = nsnull;
return NS_OK;
}
// nsIAccessNode
@ -361,20 +318,6 @@ nsAccessNode::GetFrame()
return mContent ? mContent->GetPrimaryFrame() : nsnull;
}
#ifdef DEBUG
PRBool
nsAccessNode::IsInCache()
{
nsDocAccessible *docAccessible = nsAccUtils::GetDocAccessibleFor(mWeakShell);
if (!docAccessible)
return nsnull;
void* uniqueID = nsnull;
GetUniqueID(&uniqueID);
return docAccessible->GetCachedAccessNode(uniqueID) ? PR_TRUE : PR_FALSE;
}
#endif
////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode
@ -392,19 +335,6 @@ nsAccessNode::GetDOMNode(nsIDOMNode **aDOMNode)
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetNumChildren(PRInt32 *aNumChildren)
{
NS_ENSURE_ARG_POINTER(aNumChildren);
*aNumChildren = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aNumChildren = GetNode()->GetChildCount();
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetDocument(nsIAccessibleDocument **aDocument)
{
@ -474,144 +404,6 @@ nsAccessNode::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
return NS_OK;
}
// nsAccessNode protected
nsAccessNode *
nsAccessNode::MakeAccessNode(nsINode *aNode)
{
nsAccessNode *accessNode = GetAccService()->GetCachedAccessNode(aNode,
mWeakShell);
if (!accessNode)
accessNode = GetAccService()->GetAccessibleInWeakShell(aNode, mWeakShell);
if (accessNode)
return accessNode;
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (!content)
return nsnull;
nsAccessNode *newAccessNode = new nsAccessNode(content, mWeakShell);
if (!newAccessNode)
return nsnull;
// Initialize and cache it.
if (NS_FAILED(newAccessNode->Init())) {
newAccessNode->Shutdown();
delete newAccessNode;
return nsnull;
}
return newAccessNode;
}
NS_IMETHODIMP
nsAccessNode::GetFirstChildNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsIContent* childNode = GetNode()->GetChildAt(0);
if (childNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(childNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetLastChildNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRUint32 childCount = GetNode()->GetChildCount();
nsIContent* childNode = GetNode()->GetChildAt(childCount - 1);
if (childNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(childNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetParentNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsINode* parentNode = GetNode()->GetNodeParent();
if (parentNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(parentNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetPreviousSiblingNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsINode* parentNode = GetNode()->GetNodeParent();
PRInt32 indexOf = parentNode->IndexOf(GetNode());
if (indexOf == -1)
return NS_OK;
nsIContent *siblingNode = parentNode->GetChildAt(indexOf - 1);
if (siblingNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(siblingNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetNextSiblingNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsINode* parentNode = GetNode()->GetNodeParent();
PRInt32 indexOf = parentNode->IndexOf(GetNode());
if (indexOf == -1)
return NS_OK;
nsIContent *siblingNode = parentNode->GetChildAt(indexOf + 1);
if (siblingNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(siblingNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetChildNodeAt(PRInt32 aChildNum, nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsIContent* childNode = GetNode()->GetChildAt(aChildNum);
if (childNode)
NS_IF_ADDREF(*aAccessNode = MakeAccessNode(childNode));
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,

Просмотреть файл

@ -66,9 +66,6 @@ class nsPresContext;
class nsIFrame;
class nsIDocShellTreeItem;
typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsAccessNode>
nsAccessNodeHashtable;
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
@ -129,15 +126,15 @@ public:
*/
virtual PRBool IsDefunct();
/**
* Initialize the access node object, add it to the cache.
*/
virtual nsresult Init();
/**
* Initialize the access node object, add it to the cache.
*/
virtual PRBool Init();
/**
* Shutdown the access node object.
*/
virtual nsresult Shutdown();
/**
* Shutdown the access node object.
*/
virtual void Shutdown();
/**
* Return frame for the given access node object.
@ -184,19 +181,7 @@ public:
*/
PRBool HasWeakShell() const { return !!mWeakShell; }
#ifdef DEBUG
/**
* Return true if the access node is cached.
*/
PRBool IsInCache();
#endif
protected:
/**
* Return the access node for the given DOM node.
*/
nsAccessNode *MakeAccessNode(nsINode *aNode);
nsPresContext* GetPresContext();
void LastRelease();
@ -204,10 +189,6 @@ protected:
nsCOMPtr<nsIContent> mContent;
nsCOMPtr<nsIWeakReference> mWeakShell;
#ifdef DEBUG_A11Y
PRBool mIsInitialized;
#endif
/**
* Notify global nsIObserver's that a11y is getting init'd or shutdown
*/

Просмотреть файл

@ -780,14 +780,14 @@ nsAccessibilityService::CreateHTMLCaptionAccessible(nsIFrame *aFrame,
return NS_OK;
}
// nsAccessibilityService public
nsAccessNode*
nsAccessibilityService::GetCachedAccessNode(nsINode *aNode,
// nsAccessibilityService protected
nsAccessible *
nsAccessibilityService::GetCachedAccessible(nsINode *aNode,
nsIWeakReference *aWeakShell)
{
nsDocAccessible *docAccessible = nsAccUtils::GetDocAccessibleFor(aWeakShell);
nsDocAccessible *docAccessible = GetDocAccessible(aNode->GetOwnerDoc());
return docAccessible ?
docAccessible->GetCachedAccessNode(static_cast<void*>(aNode)) : nsnull;
docAccessible->GetCachedAccessible(static_cast<void*>(aNode)) : nsnull;
}
////////////////////////////////////////////////////////////////////////////////
@ -1072,10 +1072,7 @@ nsAccessibilityService::GetContainerAccessible(nsINode *aNode,
} else {
// Only return cached accessible, don't create anything.
nsRefPtr<nsAccessible> cachedAcc =
do_QueryObject(GetCachedAccessNode(currNode, weakShell));
accessible = cachedAcc;
accessible = GetCachedAccessible(currNode, weakShell);
}
}
@ -1099,8 +1096,8 @@ nsAccessibilityService::InitAccessible(nsAccessible *aAccessible,
if (!aAccessible)
return PR_FALSE;
nsresult rv = aAccessible->Init(); // Add to cache, etc.
if (NS_FAILED(rv)) {
// Add to cache an accessible, etc.
if (!aAccessible->Init()) {
NS_ERROR("Failed to initialize an accessible!");
aAccessible->Shutdown();
@ -1148,24 +1145,17 @@ nsAccessibilityService::GetAccessible(nsINode *aNode,
nsIWeakReference *aWeakShell,
PRBool *aIsHidden)
{
if (!aPresShell || !aWeakShell || gIsShutdown)
if (!aPresShell || !aWeakShell || !aNode || gIsShutdown)
return nsnull;
NS_ASSERTION(aNode, "GetAccessible() called with no node.");
if (aIsHidden)
*aIsHidden = PR_FALSE;
// Check to see if we already have an accessible for this node in the cache.
nsAccessNode* cachedAccessNode = GetCachedAccessNode(aNode, aWeakShell);
if (cachedAccessNode) {
// XXX: the cache might contain the access node for the DOM node that is not
// accessible because of wrong cache update. In this case try to create new
// accessible.
nsRefPtr<nsAccessible> cachedAccessible = do_QueryObject(cachedAccessNode);
if (cachedAccessible)
return cachedAccessible.forget();
nsAccessible *cachedAccessible = GetCachedAccessible(aNode, aWeakShell);
if (cachedAccessible) {
NS_ADDREF(cachedAccessible);
return cachedAccessible;
}
// No cache entry, so we must create the accessible.
@ -1611,13 +1601,8 @@ nsAccessibilityService::GetAreaAccessible(nsIFrame *aImageFrame,
// Try to get image map accessible from the global cache or create it
// if failed.
nsRefPtr<nsAccessible> imageAcc;
nsAccessNode *cachedImgAcc = GetCachedAccessNode(aImageFrame->GetContent(),
aWeakShell);
if (cachedImgAcc)
imageAcc = do_QueryObject(cachedImgAcc);
nsRefPtr<nsAccessible> imageAcc =
GetCachedAccessible(aImageFrame->GetContent(), aWeakShell);
if (!imageAcc) {
nsCOMPtr<nsIAccessible> imageAccessible;
CreateHTMLImageAccessible(aImageFrame,
@ -1632,12 +1617,9 @@ nsAccessibilityService::GetAreaAccessible(nsIFrame *aImageFrame,
// that they should be available in global cache.
imageAcc->EnsureChildren();
nsAccessNode *cachedAreaAcc = GetCachedAccessNode(aAreaNode, aWeakShell);
if (!cachedAreaAcc)
return nsnull;
nsRefPtr<nsAccessible> areaAcc = do_QueryObject(cachedAreaAcc);
return areaAcc.forget();
nsAccessible *cachedAreaAcc = GetCachedAccessible(aAreaNode, aWeakShell);
NS_IF_ADDREF(cachedAreaAcc);
return cachedAreaAcc;
}
already_AddRefed<nsAccessible>

Просмотреть файл

@ -195,17 +195,6 @@ public:
*/
nsINode *GetRelevantContentNodeFor(nsINode *aNode);
/**
* Return an access node for the DOM node in the given presentation shell if
* the access node already exists, otherwise null.
*
* @param aNode [in] the DOM node to get an access node for
* @param aPresShell [in] the presentation shell which contains layout info
* for the DOM node
*/
nsAccessNode* GetCachedAccessNode(nsINode *aNode,
nsIWeakReference *aShell);
/**
* Initialize an accessible and cache it. The method should be called for
* every created accessible.
@ -219,6 +208,18 @@ public:
PRBool InitAccessible(nsAccessible *aAccessible,
nsRoleMapEntry *aRoleMapEntry);
protected:
/**
* Return an accessible for the DOM node in the given presentation shell if
* the accessible already exists, otherwise null.
*
* @param aNode [in] the DOM node to get an access node for
* @param aPresShell [in] the presentation shell which contains layout info
* for the DOM node
*/
nsAccessible *GetCachedAccessible(nsINode *aNode,
nsIWeakReference *aShell);
private:
// nsAccessibilityService creation is controlled by friend
// NS_GetAccessibilityService, keep constructors private.

Просмотреть файл

@ -434,20 +434,6 @@ nsAccessible::GetKeyboardShortcut(nsAString& aAccessKey)
return NS_OK;
}
nsresult
nsAccessible::Shutdown()
{
// Invalidate the child count and pointers to other accessibles, also make
// sure none of its children point to this parent
InvalidateChildren();
if (mParent) {
mParent->InvalidateChildren();
mParent = nsnull;
}
return nsAccessNodeWrap::Shutdown();
}
NS_IMETHODIMP
nsAccessible::GetParent(nsIAccessible **aParent)
{
@ -2671,6 +2657,56 @@ nsAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLe
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public methods
PRBool
nsAccessible::Init()
{
if (!nsAccessNodeWrap::Init())
return PR_FALSE;
nsDocAccessible *docAcc =
GetAccService()->GetDocAccessible(mContent->GetOwnerDoc());
NS_ASSERTION(docAcc, "Cannot cache new nsAccessible!");
if (!docAcc)
return PR_FALSE;
void *uniqueID = nsnull;
GetUniqueID(&uniqueID);
if (!docAcc->CacheAccessible(uniqueID, this))
return PR_FALSE;
// Make sure an ancestor in real content is cached so that
// nsDocAccessible::RefreshNodes() can find the anonymous subtree to release
// when the root node goes away. /Specific examples of where this is used:
// <input type="file"> and <xul:findbar>.
// XXX: remove this once we create correct accessible tree.
if (mContent && mContent->IsInAnonymousSubtree()) {
nsAccessible *parent = GetAccService()->GetContainerAccessible(mContent,
PR_TRUE);
if (parent)
parent->EnsureChildren();
}
return PR_TRUE;
}
void
nsAccessible::Shutdown()
{
// Invalidate the child count and pointers to other accessibles, also make
// sure none of its children point to this parent
InvalidateChildren();
if (mParent) {
mParent->InvalidateChildren();
mParent = nsnull;
}
nsAccessNodeWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessible public methods
@ -2828,6 +2864,23 @@ nsAccessible::GetCachedFirstChild()
}
#ifdef DEBUG
PRBool
nsAccessible::IsInCache()
{
nsDocAccessible *docAccessible =
GetAccService()->GetDocAccessible(mContent->GetOwnerDoc());
if (!docAccessible)
return nsnull;
void *uniqueID = nsnull;
GetUniqueID(&uniqueID);
return docAccessible->GetCachedAccessible(uniqueID) ? PR_TRUE : PR_FALSE;
}
#endif
////////////////////////////////////////////////////////////////////////////////
// nsAccessible protected methods

Просмотреть файл

@ -107,7 +107,8 @@ public:
//////////////////////////////////////////////////////////////////////////////
// nsAccessNode
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
//////////////////////////////////////////////////////////////////////////////
// Public methods
@ -270,6 +271,13 @@ public:
*/
nsAccessible* GetCachedFirstChild();
#ifdef DEBUG
/**
* Return true if the access node is cached.
*/
PRBool IsInCache();
#endif
//////////////////////////////////////////////////////////////////////////////
// Miscellaneous methods

Просмотреть файл

@ -357,18 +357,17 @@ nsApplicationAccessible::IsDefunct()
return nsAccessibilityService::IsShutdown();
}
nsresult
PRBool
nsApplicationAccessible::Init()
{
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
return NS_OK;
return PR_TRUE;
}
nsresult
void
nsApplicationAccessible::Shutdown()
{
mAppInfo = nsnull;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
@ -519,63 +518,6 @@ nsApplicationAccessible::GetDOMNode(nsIDOMNode **aDOMNode)
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetNumChildren(PRInt32 *aNumChildren)
{
NS_ENSURE_ARG_POINTER(aNumChildren);
*aNumChildren = 0;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetChildNodeAt(PRInt32 aChildNum,
nsIAccessNode **aChildNode)
{
NS_ENSURE_ARG_POINTER(aChildNode);
*aChildNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetParentNode(nsIAccessNode **aParentNode)
{
NS_ENSURE_ARG_POINTER(aParentNode);
*aParentNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetFirstChildNode(nsIAccessNode **aFirstChildNode)
{
NS_ENSURE_ARG_POINTER(aFirstChildNode);
*aFirstChildNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetLastChildNode(nsIAccessNode **aLastChildNode)
{
NS_ENSURE_ARG_POINTER(aLastChildNode);
*aLastChildNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetPreviousSiblingNode(nsIAccessNode **aPreviousSiblingNode)
{
NS_ENSURE_ARG_POINTER(aPreviousSiblingNode);
*aPreviousSiblingNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetNextSiblingNode(nsIAccessNode **aNextSiblingNode)
{
NS_ENSURE_ARG_POINTER(aNextSiblingNode);
*aNextSiblingNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetDocument(nsIAccessibleDocument **aDocument)
{

Просмотреть файл

@ -106,8 +106,8 @@ public:
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);

Просмотреть файл

@ -228,18 +228,18 @@ nsLinkableAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible. nsAccessNode
nsresult
PRBool
nsLinkableAccessible::Init()
{
CacheActionContent();
return nsAccessibleWrap::Init();
}
nsresult
void
nsLinkableAccessible::Shutdown()
{
mActionContent = nsnull;
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -98,8 +98,8 @@ public:
NS_IMETHOD GetURI(PRInt32 i, nsIURI **aURI);
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);

Просмотреть файл

@ -93,7 +93,7 @@ nsDocAccessible::
mDocument(aDocument), mIsLoaded(PR_FALSE), mScrollPositionChangedTicks(0)
{
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessNodeCache.Init(kDefaultCacheSize);
mAccessibleCache.Init(kDefaultCacheSize);
// For GTK+ native window, we do nothing here.
if (!mDocument)
@ -129,12 +129,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDocAccessible, nsAccessible)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEventQueue");
cb.NoteXPCOMChild(tmp->mEventQueue.get());
CycleCollectorTraverseCache(tmp->mAccessNodeCache, &cb);
CycleCollectorTraverseCache(tmp->mAccessibleCache, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDocAccessible, nsAccessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mEventQueue)
ClearCache(tmp->mAccessNodeCache);
ClearCache(tmp->mAccessibleCache);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDocAccessible)
@ -533,18 +533,20 @@ NS_IMETHODIMP nsDocAccessible::GetAssociatedEditor(nsIEditor **aEditor)
return NS_OK;
}
nsAccessNode*
nsDocAccessible::GetCachedAccessNode(void *aUniqueID)
nsAccessible *
nsDocAccessible::GetCachedAccessible(void *aUniqueID)
{
nsAccessNode* accessNode = mAccessNodeCache.GetWeak(aUniqueID);
nsAccessible* accessible = mAccessibleCache.GetWeak(aUniqueID);
// No accessible in the cache, check if the given ID is unique ID of this
// document accesible.
if (!accessNode) {
// document accessible.
if (!accessible) {
void* thisUniqueID = nsnull;
GetUniqueID(&thisUniqueID);
if (thisUniqueID == aUniqueID)
accessNode = this;
if (thisUniqueID != aUniqueID)
return nsnull;
accessible = this;
}
#ifdef DEBUG
@ -552,53 +554,52 @@ nsDocAccessible::GetCachedAccessNode(void *aUniqueID)
// It will assert if not all the children were created
// when they were first cached, and no invalidation
// ever corrected parent accessible's child cache.
nsRefPtr<nsAccessible> acc = do_QueryObject(accessNode);
if (acc) {
nsAccessible* parent(acc->GetCachedParent());
if (parent)
parent->TestChildCache(acc);
}
nsAccessible* parent(accessible->GetCachedParent());
if (parent)
parent->TestChildCache(accessible);
#endif
return accessNode;
return accessible;
}
// nsDocAccessible public method
PRBool
nsDocAccessible::CacheAccessNode(void *aUniqueID, nsAccessNode *aAccessNode)
nsDocAccessible::CacheAccessible(void *aUniqueID, nsAccessible *aAccessible)
{
// If there is already an access node with the given unique ID, shut it down
// If there is already an accessible with the given unique ID, shut it down
// because the DOM node has changed.
nsAccessNode* accessNode = mAccessNodeCache.GetWeak(aUniqueID);
if (accessNode)
accessNode->Shutdown();
nsAccessible *accessible = mAccessibleCache.GetWeak(aUniqueID);
NS_ASSERTION(!accessible,
"Caching new accessible for the DOM node while the old one is alive");
return mAccessNodeCache.Put(aUniqueID, aAccessNode);
if (accessible)
accessible->Shutdown();
return mAccessibleCache.Put(aUniqueID, aAccessible);
}
// nsDocAccessible public method
void
nsDocAccessible::RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode)
nsDocAccessible::RemoveAccessNodeFromCache(nsAccessible *aAccessible)
{
if (!aAccessNode)
if (!aAccessible)
return;
void *uniqueID = nsnull;
aAccessNode->GetUniqueID(&uniqueID);
mAccessNodeCache.Remove(uniqueID);
aAccessible->GetUniqueID(&uniqueID);
mAccessibleCache.Remove(uniqueID);
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode
nsresult
PRBool
nsDocAccessible::Init()
{
// Initialize event queue.
mEventQueue = new nsAccEventQueue(this);
if (!mEventQueue)
return NS_ERROR_OUT_OF_MEMORY;
return PR_FALSE;
AddEventListeners();
@ -607,18 +608,17 @@ nsDocAccessible::Init()
nsRefPtr<nsAccEvent> reorderEvent =
new nsAccReorderEvent(mParent, PR_FALSE, PR_TRUE, mDocument);
if (!reorderEvent)
return NS_ERROR_OUT_OF_MEMORY;
return PR_FALSE;
FireDelayedAccessibleEvent(reorderEvent);
return NS_OK;
return PR_TRUE;
}
nsresult
void
nsDocAccessible::Shutdown()
{
if (!mWeakShell) {
return NS_OK; // Already shutdown
}
if (!mWeakShell) // already shutdown
return;
NS_LOG_ACCDOCDESTROY_FOR("document shutdown", mDocument, this)
@ -636,13 +636,12 @@ nsDocAccessible::Shutdown()
mWeakShell = nsnull; // Avoid reentrancy
ClearCache(mAccessNodeCache);
ClearCache(mAccessibleCache);
nsCOMPtr<nsIDocument> kungFuDeathGripDoc = mDocument;
mDocument = nsnull;
nsHyperTextAccessibleWrap::Shutdown();
return NS_OK;
}
nsIFrame*
@ -1189,7 +1188,7 @@ void nsDocAccessible::ContentAppended(nsIDocument *aDocument,
nsIContent* aFirstNewContent,
PRInt32 /* unused */)
{
if (!IsContentLoaded() && mAccessNodeCache.Count() <= 1) {
if (!IsContentLoaded() && mAccessibleCache.Count() <= 1) {
// See comments in nsDocAccessible::InvalidateCacheSubtree
InvalidateChildren();
return;
@ -1615,9 +1614,9 @@ nsDocAccessible::ProcessPendingEvent(nsAccEvent *aEvent)
void
nsDocAccessible::InvalidateChildrenInSubtree(nsINode *aStartNode)
{
nsRefPtr<nsAccessible> acc = do_QueryObject(GetCachedAccessNode(aStartNode));
if (acc)
acc->InvalidateChildren();
nsAccessible *accessible = GetCachedAccessible(aStartNode);
if (accessible)
accessible->InvalidateChildren();
// Invalidate accessible children in the DOM subtree
PRInt32 index, numChildren = aStartNode->GetChildCount();
@ -1630,15 +1629,13 @@ nsDocAccessible::InvalidateChildrenInSubtree(nsINode *aStartNode)
void
nsDocAccessible::RefreshNodes(nsINode *aStartNode)
{
if (mAccessNodeCache.Count() <= 1) {
if (mAccessibleCache.Count() <= 1) {
return; // All we have is a doc accessible. There is nothing to invalidate, quit early
}
nsRefPtr<nsAccessNode> accessNode = GetCachedAccessNode(aStartNode);
// Shut down accessible subtree, which may have been created for
// anonymous content subtree
nsRefPtr<nsAccessible> accessible = do_QueryObject(accessNode);
// Shut down accessible subtree, which may have been created for anonymous
// content subtree.
nsAccessible *accessible = GetCachedAccessible(aStartNode);
if (accessible) {
// Fire menupopup end if a menu goes away
PRUint32 role = nsAccUtils::Role(accessible);
@ -1687,10 +1684,10 @@ nsDocAccessible::RefreshNodes(nsINode *aStartNode)
RefreshNodes(childContent);
}
if (!accessNode)
if (!accessible)
return;
if (accessNode == this) {
if (accessible == this) {
// Don't shutdown our doc object -- this may just be from the finished loading.
// We will completely shut it down when the pagehide event is received
// However, we must invalidate the doc accessible's children in order to be sure
@ -1701,11 +1698,11 @@ nsDocAccessible::RefreshNodes(nsINode *aStartNode)
// Shut down the actual accessible or access node
void *uniqueID;
accessNode->GetUniqueID(&uniqueID);
accessNode->Shutdown();
accessible->GetUniqueID(&uniqueID);
accessible->Shutdown();
// Remove from hash table as well
mAccessNodeCache.Remove(uniqueID);
mAccessibleCache.Remove(uniqueID);
}
// nsDocAccessible public member
@ -1749,7 +1746,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
if (!IsContentLoaded()) {
// Still loading document
if (mAccessNodeCache.Count() <= 1) {
if (mAccessibleCache.Count() <= 1) {
// Still loading and no accessibles has yet been created other than this
// doc accessible. In this case we optimize
// by not firing SHOW/HIDE/REORDER events for every document mutation
@ -1783,8 +1780,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
}
// Update last change state information
nsRefPtr<nsAccessible> childAccessible =
do_QueryObject(GetCachedAccessNode(childNode));
nsAccessible *childAccessible = GetCachedAccessible(childNode);
#ifdef DEBUG_A11Y
nsAutoString localName;
@ -1944,11 +1940,11 @@ nsDocAccessible::FireShowHideEvents(nsINode *aNode,
{
NS_ENSURE_ARG(aNode);
nsRefPtr<nsAccessible> accessible;
nsAccessible *accessible = nsnull;
if (!aAvoidOnThisNode) {
if (aEventType == nsIAccessibleEvent::EVENT_HIDE) {
// Don't allow creation for accessibles when nodes going away
accessible = do_QueryObject(GetCachedAccessNode(aNode));
accessible = GetCachedAccessible(aNode);
} else {
// Allow creation of new accessibles for show events
accessible = GetAccService()->GetAttachedAccessibleFor(aNode);

Просмотреть файл

@ -101,8 +101,8 @@ public:
NS_DECL_NSIDOCUMENTOBSERVER
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
virtual nsIFrame* GetFrame();
virtual PRBool IsDefunct();
virtual nsINode* GetNode() const { return mDocument; }
@ -178,31 +178,31 @@ public:
void InvalidateCacheSubtree(nsIContent *aContent, PRUint32 aEvent);
/**
* Return the cached access node by the given unique ID if it's in subtree of
* Return the cached accessible by the given unique ID if it's in subtree of
* this document accessible or the document accessible itself, otherwise null.
*
* @note the unique ID matches with the uniqueID attribute on nsIAccessNode
*
* @param aUniqueID [in] the unique ID used to cache the node.
*
* @return the access node object
* @return the accessible object
*/
nsAccessNode* GetCachedAccessNode(void *aUniqueID);
nsAccessible* GetCachedAccessible(void *aUniqueID);
/**
* Cache the access node.
* Cache the accessible.
*
* @param aUniquID [in] the unique identifier of accessible
* @param aAccessNode [in] accessible to cache
* @param aAccessible [in] accessible to cache
*
* @return true if node beign cached, otherwise false
* @return true if accessible being cached, otherwise false
*/
PRBool CacheAccessNode(void *aUniqueID, nsAccessNode *aAccessNode);
PRBool CacheAccessible(void *aUniqueID, nsAccessible *aAccessible);
/**
* Remove the given access node from document cache.
* Remove the given accessible from document cache.
*/
void RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode);
void RemoveAccessNodeFromCache(nsAccessible *aAccessible);
/**
* Process the event when the queue of pending events is untwisted. Fire
@ -317,7 +317,11 @@ protected:
*/
void FireValueChangeForTextFields(nsAccessible *aAccessible);
nsAccessNodeHashtable mAccessNodeCache;
/**
* Cache of accessibles within this document accessible.
*/
nsAccessibleHashtable mAccessibleCache;
void *mWnd;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsITimer> mScrollWatchTimer;

Просмотреть файл

@ -156,7 +156,7 @@ nsOuterDocAccessible::DoAction(PRUint8 aIndex)
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public
nsresult
void
nsOuterDocAccessible::Shutdown()
{
// Shutdown child document if any.
@ -170,7 +170,7 @@ nsOuterDocAccessible::Shutdown()
nsAccessible::InvalidateChildren();
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -64,7 +64,7 @@ public:
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -817,33 +817,34 @@ void nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNo
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode
nsresult
PRBool
nsRootAccessible::Init()
{
nsApplicationAccessible *applicationAcc = GetApplicationAccessible();
NS_ENSURE_STATE(applicationAcc);
if (!applicationAcc)
return PR_FALSE;
applicationAcc->AddRootAccessible(this);
return nsDocAccessibleWrap::Init();
}
nsresult
void
nsRootAccessible::Shutdown()
{
// Called manually or by nsAccessNode::LastRelease()
if (!mWeakShell) {
return NS_OK; // Already shutdown
}
if (!mWeakShell)
return; // Already shutdown
nsApplicationAccessible *applicationAcc = GetApplicationAccessible();
NS_ENSURE_STATE(applicationAcc);
if (!applicationAcc)
return;
applicationAcc->RemoveRootAccessible(this);
mCurrentARIAMenubar = nsnull;
return nsDocAccessibleWrap::Shutdown();
nsDocAccessibleWrap::Shutdown();
}
// nsRootAccessible protected member

Просмотреть файл

@ -81,8 +81,8 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -149,8 +149,7 @@ nsHTMLImageMapAccessible::CacheChildren()
if (!areaAcc)
return;
nsresult rv = areaAcc->Init();
if (NS_FAILED(rv)) {
if (!areaAcc->Init()) {
areaAcc->Shutdown();
return;
}

Просмотреть файл

@ -925,7 +925,7 @@ nsHTMLComboboxAccessible::CacheChildren()
mListAccessible->SetParent(this);
}
nsresult
void
nsHTMLComboboxAccessible::Shutdown()
{
nsAccessibleWrap::Shutdown();
@ -934,7 +934,6 @@ nsHTMLComboboxAccessible::Shutdown()
mListAccessible->Shutdown();
mListAccessible = nsnull;
}
return NS_OK;
}
/**

Просмотреть файл

@ -232,7 +232,7 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -220,7 +220,7 @@ nsHTMLLIAccessible::
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLIAccessible, nsHyperTextAccessible)
nsresult
void
nsHTMLLIAccessible::Shutdown()
{
if (mBulletAccessible) {
@ -228,9 +228,8 @@ nsHTMLLIAccessible::Shutdown()
mBulletAccessible->Shutdown();
}
nsresult rv = nsHyperTextAccessibleWrap::Shutdown();
nsHyperTextAccessibleWrap::Shutdown();
mBulletAccessible = nsnull;
return rv;
}
nsresult
@ -303,11 +302,11 @@ nsHTMLListBulletAccessible::GetUniqueID(void **aUniqueID)
return NS_OK;
}
nsresult
void
nsHTMLListBulletAccessible::Shutdown()
{
mBulletText.Truncate();
return nsLeafAccessible::Shutdown();
nsLeafAccessible::Shutdown();
}
NS_IMETHODIMP

Просмотреть файл

@ -121,7 +121,7 @@ public:
NS_IMETHOD GetName(nsAString& aName);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -173,7 +173,7 @@ public:
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -75,7 +75,7 @@ class nsAccessibleWrap : public nsAccessible
// returns a pointer to the native window for this accessible tree.
void GetNativeWindow (void **aOutNativeWindow);
virtual nsresult Shutdown ();
virtual void Shutdown ();
virtual void InvalidateChildren();
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);

Просмотреть файл

@ -60,19 +60,20 @@ nsAccessibleWrap::~nsAccessibleWrap()
}
}
nsresult
PRBool
nsAccessibleWrap::Init ()
{
// need to pass the call up, so we're cached (which nsAccessNode::Init() takes care of).
nsresult rv = nsAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsAccessible::Init())
return PR_FALSE;
if (!mNativeWrapper && !AncestorIsFlat()) {
// Create our native object using the class type specified in GetNativeType().
mNativeWrapper = new AccessibleWrapper (this, GetNativeType());
if (!mNativeWrapper)
return PR_FALSE;
}
return NS_OK;
return PR_TRUE;
}
NS_IMETHODIMP
@ -148,7 +149,7 @@ nsAccessibleWrap::GetNativeType ()
// this method is very important. it is fired when an accessible object "dies". after this point
// the object might still be around (because some 3rd party still has a ref to it), but it is
// in fact 'dead'.
nsresult
void
nsAccessibleWrap::Shutdown ()
{
if (mNativeWrapper) {
@ -156,7 +157,7 @@ nsAccessibleWrap::Shutdown ()
mNativeWrapper = nsnull;
}
return nsAccessible::Shutdown();
nsAccessible::Shutdown();
}
nsresult

Просмотреть файл

@ -48,12 +48,12 @@ public:
nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
// nsIAccessNode
// nsIAccessNode
/**
* Creates the native accessible connected to this one.
*/
virtual nsresult Init ();
/**
* Creates the native accessible connected to this one.
*/
virtual PRBoo Init();
};
#endif

Просмотреть файл

@ -50,18 +50,20 @@ nsDocAccessibleWrap::~nsDocAccessibleWrap()
{
}
nsresult
PRBool
nsDocAccessibleWrap::Init ()
{
nsresult rv = nsDocAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsDocAccessible::Init())
return PR_FALSE;
NS_ASSERTION(!mNativeWrapper, "nsDocAccessibleWrap::Init() called more than once!");
if (!mNativeWrapper) {
// Create our native object using the class type specified in GetNativeType().
mNativeWrapper = new AccessibleWrapper (this, GetNativeType());
if (!mNativeWrapper)
return PR_FALSE;
}
return NS_OK;
return PR_TRUE;
}

Просмотреть файл

@ -324,9 +324,6 @@ __try {
if (!*pszName)
return E_OUTOFMEMORY;
#ifdef DEBUG_A11Y
NS_ASSERTION(mIsInitialized, "Access node was not initialized");
#endif
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;

Просмотреть файл

@ -54,12 +54,11 @@ nsHTMLWin32ObjectOwnerAccessible::
////////////////////////////////////////////////////////////////////////////////
// nsHTMLWin32ObjectOwnerAccessible: nsAccessNode implementation
nsresult
void
nsHTMLWin32ObjectOwnerAccessible::Shutdown()
{
nsAccessibleWrap::Shutdown();
mNativeAccessible = nsnull;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -58,7 +58,7 @@ public:
virtual ~nsHTMLWin32ObjectOwnerAccessible() {}
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -120,14 +120,14 @@ nsXULColorPickerAccessible::
////////////////////////////////////////////////////////////////////////////////
// nsXULColorPickerAccessible: nsAccessNode
nsresult
PRBool
nsXULColorPickerAccessible::Init()
{
nsresult rv = nsXULColorPickerTileAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsXULColorPickerTileAccessible::Init())
return PR_FALSE;
nsCoreUtils::GeneratePopupTree(mContent, PR_TRUE);
return NS_OK;
return PR_TRUE;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -69,7 +69,7 @@ public:
nsXULColorPickerAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -56,12 +56,14 @@ nsXULComboboxAccessible::
{
}
nsresult
PRBool
nsXULComboboxAccessible::Init()
{
nsresult rv = nsAccessibleWrap::Init();
if (!nsAccessibleWrap::Init())
return PR_FALSE;
nsCoreUtils::GeneratePopupTree(mContent);
return rv;
return PR_TRUE;
}
nsresult

Просмотреть файл

@ -61,7 +61,7 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -110,16 +110,16 @@ nsXULButtonAccessible::DoAction(PRUint8 aIndex)
////////////////////////////////////////////////////////////////////////////////
// nsXULButtonAccessible: nsAccessNode
nsresult
PRBool
nsXULButtonAccessible::Init()
{
nsresult rv = nsAccessibleWrap::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsAccessibleWrap::Init())
return PR_FALSE;
if (ContainsMenu())
nsCoreUtils::GeneratePopupTree(mContent);
return NS_OK;
return PR_TRUE;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -67,7 +67,7 @@ public:
NS_IMETHOD DoAction(PRUint8 index);
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -75,11 +75,11 @@ nsXULSelectableAccessible::
NS_IMPL_ISUPPORTS_INHERITED1(nsXULSelectableAccessible, nsAccessible, nsIAccessibleSelectable)
nsresult
void
nsXULSelectableAccessible::Shutdown()
{
mSelectControl = nsnull;
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
nsresult nsXULSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
@ -271,12 +271,14 @@ nsXULMenuitemAccessible::
{
}
nsresult
PRBool
nsXULMenuitemAccessible::Init()
{
nsresult rv = nsAccessibleWrap::Init();
if (!nsAccessibleWrap::Init())
return PR_FALSE;
nsCoreUtils::GeneratePopupTree(mContent);
return rv;
return PR_TRUE;
}
nsresult

Просмотреть файл

@ -56,7 +56,7 @@ public:
virtual ~nsXULSelectableAccessible() {}
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
protected:
nsresult ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
@ -85,7 +85,7 @@ public:
NS_IMETHOD GetNumActions(PRUint8 *_retval);
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);

Просмотреть файл

@ -163,7 +163,7 @@ nsXULTreeAccessible::IsDefunct()
return nsXULSelectableAccessible::IsDefunct() || !mTree || !mTreeView;
}
nsresult
void
nsXULTreeAccessible::Shutdown()
{
// XXX: we don't remove accessible from document cache if shutdown wasn't
@ -176,7 +176,6 @@ nsXULTreeAccessible::Shutdown()
mTreeView = nsnull;
nsXULSelectableAccessible::Shutdown();
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
@ -509,8 +508,7 @@ nsXULTreeAccessible::GetTreeItemAccessible(PRInt32 aRow)
if (!accessible)
return nsnull;
nsresult rv = accessible->Init();
if (NS_FAILED(rv)) {
if (!accessible->Init()) {
accessible->Shutdown();
return nsnull;
}
@ -913,14 +911,14 @@ nsXULTreeItemAccessibleBase::IsDefunct()
return NS_FAILED(rv) || mRow >= rowCount;
}
nsresult
void
nsXULTreeItemAccessibleBase::Shutdown()
{
mTree = nsnull;
mTreeView = nsnull;
mRow = -1;
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@ -1186,20 +1184,21 @@ nsXULTreeItemAccessible::IsDefunct()
return nsXULTreeItemAccessibleBase::IsDefunct() || !mColumn;
}
nsresult
PRBool
nsXULTreeItemAccessible::Init()
{
nsresult rv = nsXULTreeItemAccessibleBase::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsXULTreeItemAccessibleBase::Init())
return PR_FALSE;
return GetName(mCachedName);
GetName(mCachedName);
return PR_TRUE;
}
nsresult
void
nsXULTreeItemAccessible::Shutdown()
{
mColumn = nsnull;
return nsXULTreeItemAccessibleBase::Shutdown();
nsXULTreeItemAccessibleBase::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -80,7 +80,7 @@ public:
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -195,7 +195,7 @@ public:
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
@ -259,8 +259,8 @@ public:
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -624,11 +624,11 @@ NS_IMPL_RELEASE_INHERITED(nsXULTreeGridRowAccessible,
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridRowAccessible: nsAccessNode implementation
nsresult
void
nsXULTreeGridRowAccessible::Shutdown()
{
ClearCache(mAccessibleCache);
return nsXULTreeItemAccessibleBase::Shutdown();
nsXULTreeItemAccessibleBase::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@ -727,8 +727,7 @@ nsXULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
if (!accessible)
return nsnull;
nsresult rv = accessible->Init();
if (NS_FAILED(rv)) {
if (!accessible->Init()) {
accessible->Shutdown();
return nsnull;
}
@ -1098,11 +1097,11 @@ nsXULTreeGridCellAccessible::IsDefunct()
!mColumn;
}
nsresult
PRBool
nsXULTreeGridCellAccessible::Init()
{
nsresult rv = nsLeafAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsLeafAccessible::Init())
return PR_FALSE;
PRInt16 type;
mColumn->GetType(&type);
@ -1111,7 +1110,7 @@ nsXULTreeGridCellAccessible::Init()
else
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
return NS_OK;
return PR_TRUE;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -85,7 +85,7 @@ public:
nsAccessible)
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -155,7 +155,7 @@ public:
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Init();
virtual PRBool Init();
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);

Просмотреть файл

@ -88,7 +88,6 @@ _TEST_FILES =\
$(warning test_elm_media.html temporarily disabled) \
test_elm_nsApplicationAcc.html \
test_elm_plugin.html \
test_invalidate_accessnode.html \
test_name.html \
test_name.xul \
test_name_button.html \

Просмотреть файл

@ -1,82 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=434464
-->
<head>
<title>Test NSIAccessNode cache invalidation</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript">
function doTest()
{
var parentElm = getNode("parent");
if (!parentElm) {
SimpleTest.finish();
return;
}
var elm = getNode("para");
if (!elm) {
SimpleTest.finish();
return;
}
// It's currently hidden. Ask for its parent's nsIAccessNode.
var parentElmAccNode = getAccessible(parentElm, [nsIAccessNode]);
if (!parentElmAccNode) {
SimpleTest.finish();
return;
}
// Get the paragraph's accessNode.
var elmAccNode = null;
try {
elmAccNode = parentElmAccNode.firstChildNode;
} catch(e) {}
if (!elmAccNode) {
ok(false, "No accessNode for hidden paragraph!");
SimpleTest.finish();
return;
}
// Now make the paragraph visible. This invalidates the just-retrieved
// AccessNode. An nsIAccessible should then be retrievable.
elm.style.display = "block";
// Now, get an accessible for it. Use a timeout so the layout engine can
// catch up.
window.setTimeout(
function()
{
var elmAcc = getAccessible(elm);
ok(elmAcc, "No accessible for paragraph after it became visible!");
SimpleTest.finish();
},
200);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=434464">Mozilla Bug 434464</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="parent"><p style="display: none;" id="para">I'm hidden initially, but then made visible.</p></div>
</body>
</html>