Bug 423700 - aria-activedescendant broken on <body>, patch=aaronlev, r=ginn.chen, a=beltzner
authorsurkov.alexander@gmail.com
Wed, 19 Mar 2008 18:10:36 -0700
changeset 13346 b13f23028d25381f59dfac1a688581f50ccf2e92
parent 13345 a597acbec44a9ad486efa382fd526b14a1be31ea
child 13347 2d88d312cd634215eed63afd7c7f7d4f2c0625eb
push idunknown
push userunknown
push dateunknown
reviewersginn.chen, beltzner
bugs423700
milestone1.9b5pre
Bug 423700 - aria-activedescendant broken on <body>, patch=aaronlev, r=ginn.chen, a=beltzner
accessible/src/base/nsDocAccessible.cpp
accessible/src/base/nsRootAccessible.cpp
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -1137,17 +1137,17 @@ nsDocAccessible::ARIAAttributeChanged(ns
     FireDelayedAccessibleEvent(event);
     return;
   }
 
   if (aAttribute == nsAccessibilityAtoms::aria_activedescendant) {
     // The activedescendant universal property redirects accessible focus events
     // to the element with the id that activedescendant points to
     nsCOMPtr<nsIDOMNode> currentFocus = GetCurrentFocus();
-    if (currentFocus == targetNode) {
+    if (SameCOMIdentity(GetRoleContent(currentFocus), targetNode)) {
       nsRefPtr<nsRootAccessible> rootAcc = GetRootAccessible();
       if (rootAcc)
         rootAcc->FireAccessibleFocusEvent(nsnull, currentFocus, nsnull, PR_TRUE);
     }
     return;
   }
 
   if (!aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) {
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -458,17 +458,19 @@ PRBool nsRootAccessible::FireAccessibleF
       }
       if (!domDoc) {
         return PR_FALSE;
       }
       nsCOMPtr<nsIDOMElement> relatedEl;
       domDoc->GetElementById(id, getter_AddRefs(relatedEl));
       finalFocusNode = do_QueryInterface(relatedEl);
       if (!finalFocusNode) {
-        return PR_FALSE;
+        // If aria-activedescendant is set to nonextistant ID, then treat as focus
+        // on the activedescendant container (which has real DOM focus)
+        finalFocusNode = aNode;
       }
       finalFocusAccessible = nsnull;
     }
   }
 
   // Fire focus only if it changes, but always fire focus events when aForceEvent == PR_TRUE
   if (gLastFocusedNode == finalFocusNode && !aForceEvent) {
     return PR_FALSE;