Bug 420960. Crash when aria-activedescendant attribute removed. r=marcoz, a=beltzner

git-svn-id: svn://10.0.0.236/trunk@247163 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronleventhal%moonset.net
2008-03-06 03:43:51 +00:00
parent 4715c2d960
commit 4cbf7f6c81
2 changed files with 23 additions and 19 deletions

View File

@@ -142,8 +142,8 @@ public:
#endif
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state; aAcc->GetFinalState(&state, nsnull); return state; }
static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role; aAcc->GetFinalRole(&role); return role; }
static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state = 0; if (aAcc) aAcc->GetFinalState(&state, nsnull); return state; }
static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role = nsIAccessibleRole::ROLE_NOTHING; if (aAcc) aAcc->GetFinalRole(&role); return role; }
static PRBool IsText(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role == nsIAccessibleRole::ROLE_TEXT_LEAF || role == nsIAccessibleRole::ROLE_STATICTEXT; }
static PRBool IsEmbeddedObject(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role != nsIAccessibleRole::ROLE_TEXT_LEAF && role != nsIAccessibleRole::ROLE_WHITESPACE && role != nsIAccessibleRole::ROLE_STATICTEXT; }
static PRInt32 TextLength(nsIAccessible *aAccessible); // Returns -1 on failure

View File

@@ -463,13 +463,7 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
if (!finalFocusNode) {
return PR_FALSE;
}
GetAccService()->GetAccessibleFor(finalFocusNode, getter_AddRefs(finalFocusAccessible));
// For activedescendant, the ARIA spec does not require that the user agent
// checks whether finalFocusNode is actually a descendant of the element with
// the activedescendant attribute.
if (!finalFocusAccessible) {
return PR_FALSE;
}
finalFocusAccessible = nsnull;
}
}
@@ -478,6 +472,16 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
return PR_FALSE;
}
if (!finalFocusAccessible) {
GetAccService()->GetAccessibleFor(finalFocusNode, getter_AddRefs(finalFocusAccessible));
// For activedescendant, the ARIA spec does not require that the user agent
// checks whether finalFocusNode is actually a descendant of the element with
// the activedescendant attribute.
if (!finalFocusAccessible) {
return PR_FALSE;
}
}
gLastFocusedAccessiblesState = State(finalFocusAccessible);
PRUint32 role = Role(finalFocusAccessible);
if (role == nsIAccessibleRole::ROLE_MENUITEM) {
@@ -845,7 +849,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
}
}
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
PRBool fireFocus = PR_FALSE;
PRBool fireFocus = PR_FALSE;
if (!treeItemAccessible) {
#ifdef MOZ_XUL
if (isTree) {
@@ -858,8 +862,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
NS_ENSURE_TRUE(menuFrame, NS_ERROR_FAILURE);
nsIMenuFrame* imenuFrame;
CallQueryInterface(menuFrame, &imenuFrame);
if (imenuFrame)
fireFocus = PR_TRUE;
if (imenuFrame)
fireFocus = PR_TRUE;
// QI failed for nsIMenuFrame means it's not on menu bar
if (imenuFrame && imenuFrame->IsOnMenuBar() &&
!imenuFrame->IsOnActiveMenuBar()) {
@@ -873,7 +877,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
// It is not top level menuitem
// Only fire focus event if it is not inside collapsed popup
// and not a listitem of a combo box
if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) {
if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) {
nsCOMPtr<nsIAccessible> containerParent;
containerAccessible->GetParent(getter_AddRefs(containerParent));
NS_ENSURE_TRUE(containerParent, NS_ERROR_FAILURE);
@@ -893,16 +897,16 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
if (popup || containerContent == realFocusedContent) {
// If we're inside the focus or a popup we can fire focus events
// for the changed active item
fireFocus = PR_TRUE;
break;
fireFocus = PR_TRUE;
break;
}
containerContent = containerContent->GetParent();
}
}
if (fireFocus) {
nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE); // Always asynch, always from user input
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE, PR_TRUE);
}
if (fireFocus) {
nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE); // Always asynch, always from user input
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE, PR_TRUE);
}
}
else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always asynch, always from user input
nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE);