Bug 303133. Regression -- accessible tree getting truncated at frame and iframe nodes. r=parente, sr=neil, a=mkaply

This commit is contained in:
aaronleventhal%moonset.net 2005-08-10 01:39:43 +00:00
Родитель a8d486f572
Коммит d1e883edfb
5 изменённых файлов: 49 добавлений и 58 удалений

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

@ -404,7 +404,7 @@ NS_IMETHODIMP nsDocAccessible::CacheAccessNode(void *aUniqueID, nsIAccessNode *a
return NS_OK;
}
NS_IMETHODIMP nsDocAccessible::Init()
NS_IMETHODIMP nsDocAccessible::GetParent(nsIAccessible **aParent)
{
// Hook up our new accessible with our parent
if (!mParent) {
@ -421,17 +421,16 @@ NS_IMETHODIMP nsDocAccessible::Init()
// the document hierarchy. GetAccessibleFor() is bad because
// it doesn't support our concept of multiple presshells per doc.
// It should be changed to use GetAccessibleInWeakShell()
nsCOMPtr<nsIAccessible> accParent;
accService->GetAccessibleFor(ownerNode, getter_AddRefs(accParent));
nsCOMPtr<nsPIAccessible> privateParent(do_QueryInterface(accParent));
if (privateParent) {
SetParent(accParent);
privateParent->SetFirstChild(this);
}
accService->GetAccessibleFor(ownerNode, getter_AddRefs(mParent));
}
}
}
}
return mParent ? nsAccessible::GetParent(aParent) : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDocAccessible::Init()
{
AddEventListeners();
nsresult rv = nsBlockAccessible::Init();

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

@ -78,6 +78,7 @@ class nsDocAccessible : public nsBlockAccessible,
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
NS_IMETHOD GetParent(nsIAccessible **aParent);
// ----- nsIScrollPositionListener ---------------------------
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY);

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

@ -50,13 +50,6 @@ nsOuterDocAccessible::nsOuterDocAccessible(nsIDOMNode* aNode,
nsIWeakReference* aShell):
nsAccessibleWrap(aNode, aShell)
{
mAccChildCount = 1;
}
NS_IMETHODIMP nsOuterDocAccessible::GetChildCount(PRInt32 *aAccChildCount)
{
*aAccChildCount = 1;
return NS_OK;
}
/* attribute wstring accName; */
@ -73,11 +66,6 @@ NS_IMETHODIMP nsOuterDocAccessible::GetName(nsAString& aName)
return rv;
}
NS_IMETHODIMP nsOuterDocAccessible::GetValue(nsAString& aValue)
{
return NS_OK;
}
/* unsigned long getRole (); */
NS_IMETHODIMP nsOuterDocAccessible::GetRole(PRUint32 *_retval)
{
@ -96,48 +84,55 @@ NS_IMETHODIMP nsOuterDocAccessible::GetState(PRUint32 *aState)
return NS_OK;
}
NS_IMETHODIMP nsOuterDocAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height)
{
return mFirstChild? mFirstChild->GetBounds(x, y, width, height): NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsOuterDocAccessible::Init()
{
nsresult rv = nsAccessibleWrap::Init();
if (NS_FAILED(rv)) {
return rv;
void nsOuterDocAccessible::CacheChildren(PRBool aWalkAnonContent)
{
// An outer doc accessible usually has 1 nsDocAccessible child,
// but could have none if we can't get to the inner documnet
if (!mWeakShell) {
mAccChildCount = eChildCountUninitialized;
return; // This outer doc node has been shut down
}
// We're in the accessibility cache now
if (mAccChildCount != eChildCountUninitialized) {
return;
}
mAccChildCount = 0;
SetFirstChild(nsnull);
// In these variable names, "outer" relates to the nsOuterDocAccessible
// as opposed to the nsDocAccessibleWrap which is "inner".
// The outer node is a something like a <browser>, <frame>, <iframe>, <page> or
// <editor> tag, whereas the inner node
// corresponds to the inner document root.
// <editor> tag, whereas the inner node corresponds to the inner document root.
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ASSERTION(content, "No nsIContent for <browser>/<iframe>/<editor> dom node");
nsCOMPtr<nsIDocument> outerDoc = content->GetDocument();
NS_ENSURE_TRUE(outerDoc, NS_ERROR_FAILURE);
if (!outerDoc) {
return;
}
nsIDocument *innerDoc = outerDoc->GetSubDocumentFor(content);
nsCOMPtr<nsIDOMNode> innerNode(do_QueryInterface(innerDoc));
NS_ENSURE_TRUE(innerNode, NS_ERROR_FAILURE);
nsIPresShell *innerPresShell = innerDoc->GetShellAt(0);
NS_ENSURE_TRUE(innerPresShell, NS_ERROR_FAILURE);
if (!innerNode) {
return;
}
nsCOMPtr<nsIAccessible> innerAccessible;
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
accService->GetAccessibleInShell(innerNode, innerPresShell,
getter_AddRefs(innerAccessible));
NS_ENSURE_TRUE(innerAccessible, NS_ERROR_FAILURE);
SetFirstChild(innerAccessible); // weak ref
accService->GetAccessibleFor(innerNode, getter_AddRefs(innerAccessible));
nsCOMPtr<nsPIAccessible> privateInnerAccessible =
do_QueryInterface(innerAccessible);
return privateInnerAccessible->SetParent(this);
if (!privateInnerAccessible) {
return;
}
// Success getting inner document as first child -- now we cache it.
mAccChildCount = 1;
SetFirstChild(innerAccessible); // weak ref
SetNextSibling(nsnull);
privateInnerAccessible->SetParent(this);
privateInnerAccessible->SetNextSibling(nsnull);
}

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

@ -52,15 +52,10 @@ class nsOuterDocAccessible : public nsAccessibleWrap
nsOuterDocAccessible(nsIDOMNode* aNode,
nsIWeakReference* aShell);
NS_IMETHOD GetChildCount(PRInt32 *aAccChildCount);
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetValue(nsAString& Value);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height);
NS_IMETHOD Init();
void CacheChildren(PRBool aWalkAnonContent);
};
#endif

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

@ -550,7 +550,13 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
#ifndef MOZ_ACCESSIBILITY_ATK
#ifdef MOZ_XUL
// tree event
if (treeItemAccessible) {
if (eventType.LowerCaseEqualsLiteral("checkboxstatechange") ||
eventType.LowerCaseEqualsLiteral("openstatechange")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
accessible, nsnull);
return NS_OK;
}
else if (treeItemAccessible) {
if (eventType.LowerCaseEqualsLiteral("focus")) {
FireAccessibleFocusEvent(accessible, targetNode); // Tree has focus
}
@ -650,11 +656,6 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ALERT,
accessible, nsnull);
}
else if (eventType.LowerCaseEqualsLiteral("checkboxstatechange") ||
eventType.LowerCaseEqualsLiteral("openstatechange")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
accessible, nsnull);
}
else if (eventType.LowerCaseEqualsLiteral("radiostatechange") ) {
// first the XUL radio buttons
if (targetNode &&