Accessibility crash with image map areas. r=surkov, a=dsicore
authoraaronleventhal@moonset.net
Mon, 20 Aug 2007 20:18:26 -0700
changeset 4847 19e5ab4d9bc87e975baf16a6ccf8ed3bdce60ebd
parent 4846 d45690d8070c02353e878966ab537e1ecb6739d1
child 4848 ad00aedf5ddf9771e64e6e91a987b52b76586fa5
push idunknown
push userunknown
push dateunknown
reviewerssurkov, dsicore
milestone1.9a8pre
Accessibility crash with image map areas. r=surkov, a=dsicore
accessible/src/html/nsHTMLImageAccessible.cpp
accessible/src/html/nsHyperTextAccessible.cpp
--- a/accessible/src/html/nsHTMLImageAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageAccessible.cpp
@@ -139,20 +139,18 @@ NS_IMETHODIMP nsHTMLImageAccessible::Get
   }
 
   return NS_OK;
 }
 
 /* wstring getRole (); */
 NS_IMETHODIMP nsHTMLImageAccessible::GetRole(PRUint32 *_retval)
 {
-  PRInt32 numChildren;
-  GetChildCount(&numChildren);
-  *_retval = (numChildren > 0) ? nsIAccessibleRole::ROLE_IMAGE_MAP :
-                                 nsIAccessibleRole::ROLE_GRAPHIC;
+  *_retval = mMapElement ? nsIAccessibleRole::ROLE_IMAGE_MAP :
+                           nsIAccessibleRole::ROLE_GRAPHIC;
   return NS_OK;
 }
 
 
 already_AddRefed<nsIAccessible>
 nsHTMLImageAccessible::GetAreaAccessible(PRInt32 aAreaNum)
 {
   if (!mMapElement)
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -85,40 +85,39 @@ nsresult nsHyperTextAccessible::QueryInt
 
     if (aIID.Equals(NS_GET_IID(nsHyperTextAccessible))) {
       *aInstancePtr = static_cast<nsHyperTextAccessible*>(this);
       NS_ADDREF_THIS();
       return NS_OK;
     }
 
     PRUint32 role = Role(this);
+    if (role == nsIAccessibleRole::ROLE_GRAPHIC ||
+        role == nsIAccessibleRole::ROLE_IMAGE_MAP ||
+        role == nsIAccessibleRole::ROLE_TEXT_LEAF) {
+      return nsAccessible::QueryInterface(aIID, aInstancePtr);
+    }
+
     if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
-      if (role == nsIAccessibleRole::ROLE_TEXT_LEAF) {
-        return NS_ERROR_NO_INTERFACE;
-      }
       *aInstancePtr = static_cast<nsIAccessibleText*>(this);
       NS_ADDREF_THIS();
       return NS_OK;
     }
 
     if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
       if (role == nsIAccessibleRole::ROLE_ENTRY ||
-          role == nsIAccessibleRole::ROLE_PASSWORD_TEXT ||
-          role == nsIAccessibleRole::ROLE_TEXT_LEAF) {
+          role == nsIAccessibleRole::ROLE_PASSWORD_TEXT) {
         return NS_ERROR_NO_INTERFACE;
       }
       *aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
       NS_ADDREF_THIS();
       return NS_OK;
     }
 
     if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
-      if (role == nsIAccessibleRole::ROLE_TEXT_LEAF) {
-        return NS_ERROR_NO_INTERFACE;
-      }
       *aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
       NS_ADDREF_THIS();
       return NS_OK;
     }
   }
 
   return nsAccessible::QueryInterface(aIID, aInstancePtr);
 }