Backing out fix for bug 548291 to fix test crash (b=550819)
authorDavid Bolter <dbolter@mozilla.com>
Mon, 08 Mar 2010 12:24:35 -0500
changeset 39114 5de3bdcca2cf5114d7bfd444420ba58102f5d978
parent 39113 e6ef0bd6059318cd974d8513755f70c11bc9c811
child 39115 172a268c94418eba9ad9051a6a0458ef74c8ed94
push idunknown
push userunknown
push dateunknown
bugs548291, 550819
milestone1.9.3a3pre
Backing out fix for bug 548291 to fix test crash (b=550819)
accessible/src/html/nsHTMLAreaAccessible.cpp
accessible/src/html/nsHTMLAreaAccessible.h
accessible/src/html/nsHTMLImageAccessible.cpp
accessible/src/html/nsHTMLImageAccessible.h
accessible/tests/mochitest/Makefile.in
accessible/tests/mochitest/states/Makefile.in
accessible/tests/mochitest/states/test_aria_imagemap.html
accessible/tests/mochitest/tree/Makefile.in
accessible/tests/mochitest/tree/test_aria_imagemap.html
--- a/accessible/src/html/nsHTMLAreaAccessible.cpp
+++ b/accessible/src/html/nsHTMLAreaAccessible.cpp
@@ -134,28 +134,16 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 
 
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessible public implementation
 
 nsresult
-nsHTMLAreaAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
-{
-  // Bypass the link states specialization for non links.
-  if (mRoleMapEntry && mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING
-                    && mRoleMapEntry->role != nsIAccessibleRole::ROLE_LINK) {
-    return nsAccessible::GetStateInternal(aState,aExtraState);
-  }
-
-  return nsHTMLLinkAccessible::GetStateInternal(aState,aExtraState);
-}
-
-nsresult
 nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
                                       PRBool aDeepestChild,
                                       nsIAccessible **aChild)
 {
   // Don't walk into area accessibles.
   NS_ADDREF(*aChild = this);
   return NS_OK;
 }
--- a/accessible/src/html/nsHTMLAreaAccessible.h
+++ b/accessible/src/html/nsHTMLAreaAccessible.h
@@ -53,17 +53,16 @@ public:
 
   // nsIAccessible
   NS_IMETHOD GetDescription(nsAString& aDescription);
 
   NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
 
   // nsAccessible
   virtual nsresult GetNameInternal(nsAString& aName);
-  virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
   virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
                                    PRBool aDeepestChild,
                                    nsIAccessible **aChild);
 
 protected:
 
   // nsAccessible
   virtual void CacheChildren();
--- a/accessible/src/html/nsHTMLImageAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageAccessible.cpp
@@ -160,25 +160,27 @@ nsHTMLImageAccessible::CacheChildren()
 {
   nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
   if (!mapAreas)
     return;
 
   PRUint32 areaCount = 0;
   mapAreas->GetLength(&areaCount);
 
-  nsRefPtr<nsAccessible> areaAccessible;
+  nsCOMPtr<nsIAccessible> areaAccessible;
+  nsRefPtr<nsAccessible> areaAcc;
 
   for (PRUint32 areaIdx = 0; areaIdx < areaCount; areaIdx++) {
     areaAccessible = GetAreaAccessible(mapAreas, areaIdx);
     if (!areaAccessible)
       return;
 
-    mChildren.AppendElement(areaAccessible);
-    areaAccessible->SetParent(this);
+    areaAcc = nsAccUtils::QueryObject<nsAccessible>(areaAccessible);
+    mChildren.AppendElement(areaAcc);
+    areaAcc->SetParent(this);
   }
 }
 
 NS_IMETHODIMP
 nsHTMLImageAccessible::GetNumActions(PRUint8 *aNumActions)
 {
   NS_ENSURE_ARG_POINTER(aNumActions);
   *aNumActions = 0;
@@ -281,17 +283,18 @@ nsHTMLImageAccessible::GetAnchor(PRInt32
   NS_ENSURE_ARG_POINTER(aAccessible);
   *aAccessible = nsnull;
 
   if (!mMapElement)
     return nsLinkableAccessible::GetAnchor(aIndex, aAccessible);
 
   nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
   if (mapAreas) {
-    nsRefPtr<nsAccessible> accessible = GetAreaAccessible(mapAreas, aIndex);
+    nsCOMPtr<nsIAccessible> accessible;
+    accessible = GetAreaAccessible(mapAreas, aIndex);
     if (!accessible)
       return NS_ERROR_INVALID_ARG;
 
     NS_ADDREF(*aAccessible = accessible);
   }
 
   return NS_OK;
 }
@@ -366,51 +369,44 @@ nsHTMLImageAccessible::GetAreaCollection
   nsIDOMHTMLCollection *mapAreas = nsnull;
   nsresult rv = mMapElement->GetAreas(&mapAreas);
   if (NS_FAILED(rv))
     return nsnull;
 
   return mapAreas;
 }
 
-already_AddRefed<nsAccessible>
+already_AddRefed<nsIAccessible>
 nsHTMLImageAccessible::GetAreaAccessible(nsIDOMHTMLCollection *aAreaCollection,
                                          PRInt32 aAreaNum)
 {
   if (!aAreaCollection)
     return nsnull;
 
   nsCOMPtr<nsIDOMNode> domNode;
   aAreaCollection->Item(aAreaNum,getter_AddRefs(domNode));
   if (!domNode)
     return nsnull;
 
   void* key = reinterpret_cast<void*>(aAreaNum);
-  nsRefPtr<nsAccessible> accessible =
-    nsAccUtils::QueryObject<nsAccessible>(mAccessNodeCache->GetWeak(key));
+  nsRefPtr<nsAccessNode> accessNode = mAccessNodeCache->GetWeak(key);
 
-  if (!accessible) {
-    accessible = new nsHTMLAreaAccessible(domNode, this, mWeakShell);
-    if (!accessible)
+  if (!accessNode) {
+    accessNode = new nsHTMLAreaAccessible(domNode, this, mWeakShell);
+    if (!accessNode)
       return nsnull;
 
-    nsresult rv = accessible->Init();
-    if (NS_FAILED(rv)) {
-      accessible->Shutdown();
+    nsresult rv = accessNode->Init();
+    if (NS_FAILED(rv))
       return nsnull;
-    }
 
-    // We should respect ARIA on area elements (for the canvas map technique)
-    accessible->SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(domNode));
-
-    if (!mAccessNodeCache->Put(key, accessible)) {
-      return nsnull;
-    }
+    mAccessNodeCache->Put(key, accessNode);
   }
 
+  nsCOMPtr<nsIAccessible> accessible = do_QueryInterface(accessNode);
   return accessible.forget();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Private methods
 
 PRBool
 nsHTMLImageAccessible::HasLongDesc()
--- a/accessible/src/html/nsHTMLImageAccessible.h
+++ b/accessible/src/html/nsHTMLImageAccessible.h
@@ -80,21 +80,17 @@ public:
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
 
 protected:
   // nsAccessible
   virtual void CacheChildren();
 
   // nsHTMLImageAccessible
   already_AddRefed<nsIDOMHTMLCollection> GetAreaCollection();
-
-  /*
-   * Return the accessible for the area element.
-   */
-  already_AddRefed<nsAccessible>
+  already_AddRefed<nsIAccessible>
     GetAreaAccessible(nsIDOMHTMLCollection* aAreaNodes, PRInt32 aAreaNum);
 
   // Reference on linked map element if any.
   nsCOMPtr<nsIDOMHTMLMapElement> mMapElement;
 
   // Cache of area accessibles. We do not use common cache because images can
   // share area elements but we need to have separate area accessibles for
   // each image accessible.
--- a/accessible/tests/mochitest/Makefile.in
+++ b/accessible/tests/mochitest/Makefile.in
@@ -43,17 +43,16 @@ VPATH		= @srcdir@
 relativesrcdir  = accessible
 
 DIRS	= actions attributes events selectable states tree
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =\
-		formimage.png \
 		letters.gif \
 		moz.png \
 		$(topsrcdir)/content/media/test/bug461281.ogg \
 		longdesc_src.html \
 		actions.js \
 		attributes.js \
 		common.js \
 		editabletext.js \
--- a/accessible/tests/mochitest/states/Makefile.in
+++ b/accessible/tests/mochitest/states/Makefile.in
@@ -42,17 +42,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = accessible/states
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =\
 		test_aria.html \
-		test_aria_imagemap.html \
 		test_doc.html \
 		test_docarticle.html \
 		test_editablebody.html \
 		test_frames.html \
 		test_link.html \
 		test_popup.xul \
 		test_tree.xul \
 		z_frames.html \
deleted file mode 100644
--- a/accessible/tests/mochitest/states/test_aria_imagemap.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Test usemap elements and ARIA</title>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/common.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/role.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/states.js"></script>
-
-  <script type="application/javascript">
-  function doTest()
-  {
-    testStates("t1", 0, EXT_STATE_EDITABLE, STATE_LINKED);
-    testStates("t2", 0, EXT_STATE_EDITABLE, STATE_LINKED);
-    testStates("rb1", (STATE_CHECKABLE | STATE_CHECKED), 0, STATE_LINKED);
-    testStates("rb2", STATE_CHECKABLE, 0, STATE_CHECKED, STATE_LINKED);
-    testStates("cb1", (STATE_CHECKABLE | STATE_CHECKED), 0, STATE_LINKED);
-    testStates("cbox",(STATE_HASPOPUP | STATE_COLLAPSED), EXT_STATE_EXPANDABLE
-                     , STATE_LINKED);
-
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  addA11yLoadEvent(doTest);
-  </script>
-</head>
-<body>
-
-<a target="_blank"
-  href="https://bugzilla.mozilla.org/show_bug.cgi?id=548291"
-  title="ARIA states on image maps">
-Mozilla Bug 548291
-</a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-</pre>
-
-<img id="imagemap" src="../formimage.png" width="219" height="229" border="0" usemap="#aMap">
-<map id="aMap" name="aMap">
-  <area id="t1" role="textbox" shape="rect" tabindex="0" alt="" title="first name"  coords="4,20,108,48" href="#" />
-  <area id="t2" role="textbox" shape="rect" alt="" title="last name"  coords="111,21,215,50" href="#" />
-  <area id="rb1" role="radio" aria-checked="true" shape="circle" alt="" title="male"  coords="60,75,11" href="#" />
-  <area id="rb2" role="radio" shape="circle" alt="" title="female"  coords="73,94,11" href="#" />
-  <area id="cb1" role="checkbox" aria-checked="true" shape="rect" alt="" title="have bike"  coords="95,123,118,145" href="#" />
-  <area id="cbox" role="combobox" shape="rect" alt="" title="bike model"  coords="120,124,184,146" href="#" />
-  <area id="cb2" role="checkbox" shape="rect" alt="" title="have car"  coords="90,145,114,164" href="#" />
-  <area id="cb3" role="checkbox" shape="rect" alt="" title="have airplane"  coords="130,163,152,184" href="#" />
-  <area id="b1" role="button" shape="rect" alt="" title="submit"  coords="4,198,67,224" href="#" />
-</map>
-</body>
-</html>
--- a/accessible/tests/mochitest/tree/Makefile.in
+++ b/accessible/tests/mochitest/tree/Makefile.in
@@ -41,17 +41,16 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = accessible/tree
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =\
-		test_aria_imagemap.html \
 		test_button.xul \
 		test_colorpicker.xul \
 		test_combobox.xul \
 		test_filectrl.html \
 		test_formctrl.html \
 		test_formctrl.xul \
 		test_gencontent.html \
 		test_groupbox.xul \
deleted file mode 100644
--- a/accessible/tests/mochitest/tree/test_aria_imagemap.html
+++ /dev/null
@@ -1,99 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Test usemap elements and ARIA</title>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/common.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/role.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/a11y/accessible/states.js"></script>
-
-  <script type="application/javascript">
-  function doTest()
-  {
-    var accTree = {
-      role: ROLE_IMAGE_MAP,
-      children: [
-        {
-          role: ROLE_ENTRY,
-          name: "first name"
-        },
-        {
-          role: ROLE_ENTRY,
-          name: "last name"
-        },
-        {
-          role: ROLE_RADIOBUTTON,
-          name: "male"
-        },
-        {
-          role: ROLE_RADIOBUTTON,
-          name: "female"
-        },
-        {
-          role: ROLE_CHECKBUTTON,
-          name: "have bike"
-        },
-        {
-          role: ROLE_COMBOBOX,
-          name: "bike model"
-        },
-        {
-          role: ROLE_CHECKBUTTON,
-          name: "have car"
-        },
-        {
-          role: ROLE_CHECKBUTTON,
-          name: "have airplane"
-        },
-        {
-          role: ROLE_PUSHBUTTON,
-          name: "submit"
-        }
-      ]
-    };
-
-    // Test image map tree structure, roles, and names.
-    testAccessibleTree("imagemap", accTree);
-
-    SimpleTest.finish();
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  addA11yLoadEvent(doTest);
-  </script>
-</head>
-<body>
-
-<a target="_blank"
-  href="https://bugzilla.mozilla.org/show_bug.cgi?id=548291"
-  title="Accessible tree of ARIA image maps">
-Mozilla Bug 548291
-</a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-</pre>
-
-<img id="imagemap" src="../formimage.png" width="219" height="229" border="0" usemap="#aMap">
-<map id="aMap" name="aMap">
-  <area id="t1" role="textbox" shape="rect" tabindex="0" alt="" title="first name"  coords="4,20,108,48" href="#" />
-  <area id="t2" role="textbox" shape="rect" alt="" title="last name"  coords="111,21,215,50" href="#" />
-  <area id="rb1" role="radio" aria-checked="true" shape="circle" alt="" title="male"  coords="60,75,11" href="#" />
-  <area id="rb2" role="radio" shape="circle" alt="" title="female"  coords="73,94,11" href="#" />
-  <area id="cb1" role="checkbox" aria-checked="true" shape="rect" alt="" title="have bike"  coords="95,123,118,145" href="#" />
-  <area id="cbox" role="combobox" shape="rect" alt="" title="bike model"  coords="120,124,184,146" href="#" />
-  <area id="cb2" role="checkbox" shape="rect" alt="" title="have car"  coords="90,145,114,164" href="#" />
-  <area id="cb3" role="checkbox" shape="rect" alt="" title="have airplane"  coords="130,163,152,184" href="#" />
-  <area id="b1" role="button" shape="rect" alt="" title="submit"  coords="4,198,67,224" href="#" />
-</map>
-</body>
-</html>