Bug 524665 - use empty CacheChildren for leaf accessibles instead of implicit GetFirstChild and etc, r=davidb

This commit is contained in:
Alexander Surkov 2009-10-28 18:42:36 +08:00
Родитель 1dd6314fe2
Коммит a50d95f646
6 изменённых файлов: 60 добавлений и 118 удалений

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

@ -54,9 +54,9 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIURI.h" #include "nsIURI.h"
//------------- ////////////////////////////////////////////////////////////////////////////////
// nsLeafAccessible // nsLeafAccessible
//------------- ////////////////////////////////////////////////////////////////////////////////
nsLeafAccessible::nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsLeafAccessible::nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsAccessibleWrap(aNode, aShell) nsAccessibleWrap(aNode, aShell)
@ -65,34 +65,6 @@ nsAccessibleWrap(aNode, aShell)
NS_IMPL_ISUPPORTS_INHERITED0(nsLeafAccessible, nsAccessible) NS_IMPL_ISUPPORTS_INHERITED0(nsLeafAccessible, nsAccessible)
/* nsIAccessible getFirstChild (); */
NS_IMETHODIMP nsLeafAccessible::GetFirstChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getLastChild (); */
NS_IMETHODIMP nsLeafAccessible::GetLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsLeafAccessible::GetChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}
// nsAccessible::GetAllowsAnonChildAccessibles()
PRBool
nsLeafAccessible::GetAllowsAnonChildAccessibles()
{
return PR_FALSE;
}
// nsAccessible::GetChildAtPoint() // nsAccessible::GetChildAtPoint()
nsresult nsresult
nsLeafAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, nsLeafAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
@ -104,8 +76,18 @@ nsLeafAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
return NS_OK; return NS_OK;
} }
// nsAccessible::CacheChildren()
void
nsLeafAccessible::CacheChildren()
{
// No children for leaf accessible.
mAccChildCount = IsDefunct() ? eChildCountUninitialized : 0;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible // nsLinkableAccessible
////////////////////////////////////////////////////////////////////////////////
nsLinkableAccessible:: nsLinkableAccessible::
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) : nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :

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

@ -62,16 +62,15 @@ public:
// nsISupports // nsISupports
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible
NS_IMETHOD GetFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetLastChild(nsIAccessible **_retval);
NS_IMETHOD GetChildCount(PRInt32 *_retval);
// nsAccessible // nsAccessible
virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY, virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
PRBool aDeepestChild, PRBool aDeepestChild,
nsIAccessible **aChild); nsIAccessible **aChild);
virtual PRBool GetAllowsAnonChildAccessibles();
protected:
// nsAccessible
virtual void CacheChildren();
}; };
/** /**

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

@ -38,21 +38,18 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
// NOTE: alphabetically ordered
#include "nsTextAccessible.h" #include "nsTextAccessible.h"
// ------------ ////////////////////////////////////////////////////////////////////////////////
// Text Accessibles // nsTextAccessible
// ------------ ////////////////////////////////////////////////////////////////////////////////
nsTextAccessible::nsTextAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell): nsTextAccessible::
nsTextAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
nsLinkableAccessible(aDOMNode, aShell) nsLinkableAccessible(aDOMNode, aShell)
{ {
} }
/**
* We are text
*/
nsresult nsresult
nsTextAccessible::GetRoleInternal(PRUint32 *aRole) nsTextAccessible::GetRoleInternal(PRUint32 *aRole)
{ {
@ -60,33 +57,6 @@ nsTextAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK; return NS_OK;
} }
/**
* No Children
*/
NS_IMETHODIMP nsTextAccessible::GetFirstChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/**
* No Children
*/
NS_IMETHODIMP nsTextAccessible::GetLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/**
* No Children
*/
NS_IMETHODIMP nsTextAccessible::GetChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}
nsresult nsresult
nsTextAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLength) nsTextAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLength)
{ {
@ -96,3 +66,9 @@ nsTextAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32
return frame->GetRenderedText(&aText, nsnull, nsnull, aStartOffset, aLength); return frame->GetRenderedText(&aText, nsnull, nsnull, aStartOffset, aLength);
} }
void
nsTextAccessible::CacheChildren()
{
// No children for text accessible.
mAccChildCount = IsDefunct() ? eChildCountUninitialized : 0;
}

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

@ -42,24 +42,22 @@
#include "nsBaseWidgetAccessible.h" #include "nsBaseWidgetAccessible.h"
/** /**
* Text nodes have no children, but since double inheritance * Generic class used for text nodes.
* no-worky we have to re-impl the LeafAccessiblity blocks
* this way.
*/ */
class nsTextAccessible : public nsLinkableAccessible class nsTextAccessible : public nsLinkableAccessible
{ {
public: public:
nsTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell); nsTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
// nsIAccessible
NS_IMETHOD GetFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetLastChild(nsIAccessible **_retval);
NS_IMETHOD GetChildCount(PRInt32 *_retval);
// nsAccessible // nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole); virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset, virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
PRUint32 aLength); PRUint32 aLength);
protected:
// nsAccessible
virtual void CacheChildren();
}; };

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

@ -47,6 +47,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsHTMLAreaAccessible // nsHTMLAreaAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLAreaAccessible:: nsHTMLAreaAccessible::
nsHTMLAreaAccessible(nsIDOMNode *aDomNode, nsIAccessible *aParent, nsHTMLAreaAccessible(nsIDOMNode *aDomNode, nsIAccessible *aParent,
@ -89,33 +90,6 @@ nsHTMLAreaAccessible::GetDescription(nsAString& aDescription)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsHTMLAreaAccessible::GetFirstChild(nsIAccessible **aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLAreaAccessible::GetLastChild(nsIAccessible **aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLAreaAccessible::GetChildCount(PRInt32 *aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height) PRInt32 *width, PRInt32 *height)
@ -161,7 +135,9 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
return NS_OK; return NS_OK;
} }
// nsAccessible::GetChildAtPoint() ////////////////////////////////////////////////////////////////////////////////
// nsAccessible public implementation
nsresult nsresult
nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
PRBool aDeepestChild, PRBool aDeepestChild,
@ -171,3 +147,13 @@ nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
NS_ADDREF(*aChild = this); NS_ADDREF(*aChild = this);
return NS_OK; return NS_OK;
} }
////////////////////////////////////////////////////////////////////////////////
// nsAccessible protected implementation
void
nsHTMLAreaAccessible::CacheChildren()
{
// No children for aria accessible.
mAccChildCount = IsDefunct() ? eChildCountUninitialized : 0;
}

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

@ -41,9 +41,9 @@
#include "nsHTMLLinkAccessible.h" #include "nsHTMLLinkAccessible.h"
/* Accessible for image map areas - must be child of image /**
* Accessible for image map areas - must be child of image.
*/ */
class nsHTMLAreaAccessible : public nsHTMLLinkAccessible class nsHTMLAreaAccessible : public nsHTMLLinkAccessible
{ {
@ -54,10 +54,6 @@ public:
// nsIAccessible // nsIAccessible
NS_IMETHOD GetDescription(nsAString& aDescription); NS_IMETHOD GetDescription(nsAString& aDescription);
NS_IMETHOD GetFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetLastChild(nsIAccessible **_retval);
NS_IMETHOD GetChildCount(PRInt32 *_retval);
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height); NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
// nsAccessible // nsAccessible
@ -65,6 +61,11 @@ public:
virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY, virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
PRBool aDeepestChild, PRBool aDeepestChild,
nsIAccessible **aChild); nsIAccessible **aChild);
protected:
// nsAccessible
virtual void CacheChildren();
}; };
#endif #endif