зеркало из https://github.com/mozilla/pjs.git
Bug 288017: proper init/shudown for list items and list bullet accessibles. r=pkw, sr=neil
This commit is contained in:
Родитель
5b686c3c4b
Коммит
5c893944e2
|
@ -165,11 +165,16 @@ NS_IMETHODIMP nsHTMLLabelAccessible::GetChildCount(PRInt32 *aAccChildCount)
|
|||
|
||||
nsHTMLLIAccessible::nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
nsIFrame *aBulletFrame, const nsAString& aBulletText):
|
||||
nsAccessibleWrap(aDOMNode, aShell),
|
||||
mBulletAccessible(aBulletText.IsEmpty() ? nsnull :
|
||||
new nsHTMLListBulletAccessible(mDOMNode, mWeakShell,
|
||||
aBulletFrame, aBulletText))
|
||||
nsAccessibleWrap(aDOMNode, aShell)
|
||||
{
|
||||
if (!aBulletText.IsEmpty()) {
|
||||
mBulletAccessible = new nsHTMLListBulletAccessible(mDOMNode, mWeakShell,
|
||||
aBulletFrame, aBulletText);
|
||||
nsCOMPtr<nsPIAccessNode> bulletANode(mBulletAccessible);
|
||||
if (bulletANode) {
|
||||
bulletANode->Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLLIAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
|
@ -202,7 +207,7 @@ void nsHTMLLIAccessible::CacheChildren(PRBool aWalkAnonContent)
|
|||
walker.mState.frame = GetFrame();
|
||||
walker.GetFirstChild();
|
||||
|
||||
nsCOMPtr<nsPIAccessible> privatePrevAccessible = do_QueryInterface(mBulletAccessible);
|
||||
nsCOMPtr<nsPIAccessible> privatePrevAccessible = mBulletAccessible;
|
||||
while (walker.mState.accessible) {
|
||||
++mAccChildCount;
|
||||
privatePrevAccessible->SetNextSibling(walker.mState.accessible);
|
||||
|
@ -220,6 +225,20 @@ nsHTMLListBulletAccessible::nsHTMLListBulletAccessible(nsIDOMNode* aDomNode,
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLListBulletAccessible::GetUniqueID(void **aUniqueID)
|
||||
{
|
||||
// Since mDOMNode is same as for list item, use |this| pointer as the unique Id
|
||||
*aUniqueID = NS_STATIC_CAST(void*, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLListBulletAccessible::Shutdown()
|
||||
{
|
||||
mBulletText.Truncate();
|
||||
return nsHTMLTextAccessible::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLListBulletAccessible::GetName(nsAString &aName)
|
||||
{
|
||||
aName = mBulletText;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#define _nsHTMLTextAccessible_H_
|
||||
|
||||
#include "nsTextAccessibleWrap.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class nsIWeakReference;
|
||||
|
||||
|
@ -80,6 +81,30 @@ public:
|
|||
NS_IMETHOD GetChildCount(PRInt32 *aAccChildCount);
|
||||
};
|
||||
|
||||
class nsHTMLListBulletAccessible : public nsHTMLTextAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLListBulletAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
nsIFrame *aFrame, const nsAString& aBulletText);
|
||||
NS_IMETHOD GetUniqueID(void **aUniqueID);
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD GetName(nsAString& aName);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_STATICTEXT; return NS_OK; }
|
||||
NS_IMETHOD GetState(PRUint32 *aState) { nsHTMLTextAccessible::GetState(aState); *aState &= ~STATE_FOCUSABLE; *aState |= STATE_READONLY; return NS_OK; }
|
||||
// Don't cache via unique ID -- bullet accessible shares the same dom node as this LI accessible.
|
||||
// Also, don't cache via mParent/SetParent(), prevent circular reference since li holds onto us.
|
||||
NS_IMETHOD SetParent(nsIAccessible *aParentAccessible) { mParent = nsnull; return NS_OK; }
|
||||
protected:
|
||||
// XXX Ideally we'd get the bullet text directly from the bullet frame via
|
||||
// nsBulletFrame::GetListItemText(), but we'd need an interface
|
||||
// for getting text from contentless anonymous frames.
|
||||
// Perhaps something like nsIAnonymousFrame::GetText() ?
|
||||
// However, in practice storing the bullet text here should not be a
|
||||
// problem if we invalidate the right parts of the accessibility cache
|
||||
// when mutation events occur.
|
||||
nsString mBulletText;
|
||||
};
|
||||
|
||||
class nsHTMLListAccessible : public nsAccessibleWrap
|
||||
{
|
||||
public:
|
||||
|
@ -94,35 +119,13 @@ class nsHTMLLIAccessible : public nsAccessibleWrap
|
|||
public:
|
||||
nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
nsIFrame *aBulletFrame, const nsAString& aBulletText);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) {* aRole = ROLE_LISTITEM; return NS_OK; }
|
||||
NS_IMETHOD Shutdown() { nsresult rv = nsAccessibleWrap::Shutdown(); mBulletAccessible = nsnull; return rv; }
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_LISTITEM; return NS_OK; }
|
||||
NS_IMETHOD GetState(PRUint32 *aState) { nsAccessibleWrap::GetState(aState); *aState &= ~STATE_FOCUSABLE; *aState |= STATE_READONLY; return NS_OK; }
|
||||
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
void CacheChildren(PRBool aWalkAnonContent); // Include bullet accessible
|
||||
protected:
|
||||
nsCOMPtr<nsIAccessible> mBulletAccessible;
|
||||
};
|
||||
|
||||
class nsHTMLListBulletAccessible : public nsHTMLTextAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLListBulletAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
nsIFrame *aFrame, const nsAString& aBulletText);
|
||||
NS_IMETHOD GetName(nsAString& aName);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_STATICTEXT; return NS_OK; }
|
||||
NS_IMETHOD GetState(PRUint32 *aState) { nsHTMLTextAccessible::GetState(aState); *aState &= ~STATE_FOCUSABLE; *aState |= STATE_READONLY; return NS_OK; }
|
||||
// Don't cache via unique ID -- bullet accessible shares the same dom node as this LI accessible.
|
||||
// Also, don't cache via mParent/SetParent(), prevent circular reference since li holds onto us.
|
||||
NS_IMETHOD SetParent(nsIAccessible *aParentAccessible) { mParent = nsnull; return NS_OK; }
|
||||
protected:
|
||||
// XXX Ideally we'd get the bullet text directly from the bullet frame via
|
||||
// nsBulletFrame::GetListItemText(), but we'd need an interface
|
||||
// for getting text from contentless anonymous frames.
|
||||
// Perhaps something like nsIAnonymousFrame::GetText() ?
|
||||
// However, in practice storing the bullet text here should not be a
|
||||
// problem if we invalidate the right parts of the accessibility cache
|
||||
// when mutation events occur. We'll also need to watch for mere style
|
||||
// changes -- perhaps we need to look for reflows and their reasons.
|
||||
nsString mBulletText;
|
||||
nsRefPtr<nsHTMLListBulletAccessible> mBulletAccessible;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче