Bug 613502 - Map <article> like we do aria role "article". r=MarcoZ,surkov a=davidb
authorDavid Bolter <dbolter@mozilla.com>
Mon, 29 Nov 2010 13:32:19 -0500
changeset 58338 d0a46bfe92d5ee1b266f6bd139123e2b3ecbffa3
parent 58337 bb7e3b21b9ab2b5d732aec6528d79b8caf198c91
child 58339 1f53f85ddfb58ffe51330e52ca122cdcbc3e5222
push id17250
push userdbolter@mozilla.com
push dateMon, 29 Nov 2010 18:32:49 +0000
treeherdermozilla-central@d0a46bfe92d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ, surkov, davidb
bugs613502
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 613502 - Map <article> like we do aria role "article". r=MarcoZ,surkov a=davidb
accessible/src/html/nsHyperTextAccessible.cpp
accessible/tests/mochitest/states/test_docarticle.html
accessible/tests/mochitest/test_elm_landmarks.html
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -129,30 +129,32 @@ nsresult nsHyperTextAccessible::QueryInt
 PRUint32
 nsHyperTextAccessible::NativeRole()
 {
   nsIAtom *tag = mContent->Tag();
 
   if (tag == nsAccessibilityAtoms::form)
     return nsIAccessibleRole::ROLE_FORM;
 
-  if (tag == nsAccessibilityAtoms::article ||
-      tag == nsAccessibilityAtoms::blockquote ||
+  if (tag == nsAccessibilityAtoms::blockquote ||
       tag == nsAccessibilityAtoms::div ||
       tag == nsAccessibilityAtoms::nav)
     return nsIAccessibleRole::ROLE_SECTION;
 
   if (tag == nsAccessibilityAtoms::h1 ||
       tag == nsAccessibilityAtoms::h2 ||
       tag == nsAccessibilityAtoms::h3 ||
       tag == nsAccessibilityAtoms::h4 ||
       tag == nsAccessibilityAtoms::h5 ||
       tag == nsAccessibilityAtoms::h6)
     return nsIAccessibleRole::ROLE_HEADING;
 
+  if (tag == nsAccessibilityAtoms::article)
+    return nsIAccessibleRole::ROLE_DOCUMENT;
+        
   // Deal with html landmark elements
   if (tag == nsAccessibilityAtoms::header)
     return nsIAccessibleRole::ROLE_HEADER;
 
   if (tag == nsAccessibilityAtoms::footer)
     return nsIAccessibleRole::ROLE_FOOTER;
 
   if (tag == nsAccessibilityAtoms::aside)
@@ -182,16 +184,19 @@ nsHyperTextAccessible::GetStateInternal(
   nsCOMPtr<nsIEditor> editor;
   GetAssociatedEditor(getter_AddRefs(editor));
   if (editor) {
     PRUint32 flags;
     editor->GetFlags(&flags);
     if (0 == (flags & nsIPlaintextEditor::eEditorReadonlyMask)) {
       *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE;
     }
+  } else if (mContent->Tag() == nsAccessibilityAtoms::article) {
+    // We want <article> to behave like a document in terms of readonly state.
+    *aState |= nsIAccessibleStates::STATE_READONLY;
   }
 
   PRInt32 childCount;
   GetChildCount(&childCount);
   if (childCount > 0) {
     *aExtraState |= nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT;
   }
 
@@ -1216,19 +1221,16 @@ nsHyperTextAccessible::GetAttributesInte
     nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::xmlroles,
                            NS_LITERAL_STRING("navigation"));
   else if (mContent->Tag() == nsAccessibilityAtoms::header) 
     nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::xmlroles,
                            NS_LITERAL_STRING("banner"));
   else if (mContent->Tag() == nsAccessibilityAtoms::footer) 
     nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::xmlroles,
                            NS_LITERAL_STRING("contentinfo"));
-  else if (mContent->Tag() == nsAccessibilityAtoms::article) 
-    nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::xmlroles,
-                           NS_LITERAL_STRING("main"));
   else if (mContent->Tag() == nsAccessibilityAtoms::aside) 
     nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::xmlroles,
                            NS_LITERAL_STRING("note"));
 
   return  NS_OK;
 }
 
 /*
--- a/accessible/tests/mochitest/states/test_docarticle.html
+++ b/accessible/tests/mochitest/states/test_docarticle.html
@@ -16,29 +16,34 @@
           src="../states.js"></script>
 
   <script type="application/javascript">
     function doTest()
     {
       var docAcc = getAccessible(document, [nsIAccessibleDocument]);
       if (docAcc) {
         testStates(docAcc, STATE_READONLY);
+        testStates("aria_article", STATE_READONLY);
+        testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
         testStates("article", STATE_READONLY);
         testStates("editable_article", 0, EXT_STATE_EDITABLE);
 
         document.designMode = "on";
 
         testStates(docAcc, 0, EXT_STATE_EDITABLE);
-        testStates("article", 0, EXT_STATE_EDITABLE);
+        testStates("aria_article", 0, EXT_STATE_EDITABLE);
+        testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
         testStates("article", 0, EXT_STATE_EDITABLE);
         testStates("editable_article", 0, EXT_STATE_EDITABLE);
   
         document.designMode = "off";
 
         testStates(docAcc, STATE_READONLY);
+        testStates("aria_article", STATE_READONLY);
+        testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
         testStates("article", STATE_READONLY);
         testStates("editable_article", 0, EXT_STATE_EDITABLE);
       }
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
@@ -46,18 +51,29 @@
 </head>
 
 <body role="article">
 
   <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=467387"
     title="Expose non-editable documents as readonly, regardless of role">
      Mozilla Bug 467387
+  </a><br/>
+  <a target="_blank"
+    href="https://bugzilla.mozilla.org/show_bug.cgi?id=613502"
+    title="Map <article> like we do aria role article">
+     Mozilla Bug 613502
   </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
-  <div id="article" role="article">article</div>
-  <div id="editable_article" role="article" contentEditable="true">editable article</doc>
+  <div id="aria_article" role="article">aria article</div>
+  <div id="editable_aria_article" role="article" contentEditable="true">
+    editable aria article</div>
+
+  <article id="article">article</article>
+  <article id="editable_article" contentEditable="true">
+    editable article</article>
+
 </body>
 </html>
--- a/accessible/tests/mochitest/test_elm_landmarks.html
+++ b/accessible/tests/mochitest/test_elm_landmarks.html
@@ -19,54 +19,62 @@
 
   <script type="application/javascript">
 
     function doTest()
     {
       testRole("nav", ROLE_SECTION);
       testRole("header", ROLE_HEADER);
       testRole("footer", ROLE_FOOTER);
-      testRole("article", ROLE_SECTION);
+      testRole("article", ROLE_DOCUMENT);
       testRole("aside", ROLE_NOTE);
 
+      testRole("main", ROLE_DOCUMENT);
+
       // Some AT may look for this
       testAttrs("nav", {"xml-roles" : "navigation"}, true);
       testAttrs("header", {"xml-roles" : "banner"}, true);
       testAttrs("footer", {"xml-roles" : "contentinfo"}, true);
-      testAttrs("article", {"xml-roles" : "main"}, true);
       testAttrs("aside", {"xml-roles" : "note"}, true);
-      testAttrs("document", {"xml-roles" : "document"}, true); // ARIA override
+      testAttrs("main", {"xml-roles" : "main"}, true); // ARIA override
 
       // And some AT may look for this
       testAttrs("nav", {"tag" : "NAV"}, true);
       testAttrs("header", {"tag" : "HEADER"}, true);
       testAttrs("footer", {"tag" : "FOOTER"}, true);
       testAttrs("article", {"tag" : "ARTICLE"}, true);
       testAttrs("aside", {"tag" : "ASIDE"}, true);
-      testAttrs("document", {"tag" : "ARTICLE"}, true); // no override expected
+      testAttrs("main", {"tag" : "ARTICLE"}, true); // no override expected
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
 
   <a target="_blank"
-     title="Provide mappings for html5 <nav> <header> <footer> <article>"
-     href="https://bugzilla.mozilla.org/show_bug.cgi?id=593368">Bug 593368</a>
+    title="Provide mappings for html5 <nav> <header> <footer> <article>"
+    href="https://bugzilla.mozilla.org/show_bug.cgi?id=593368">
+     Mozilla Bug 593368
+  </a><br/>
+  <a target="_blank"
+    href="https://bugzilla.mozilla.org/show_bug.cgi?id=613502"
+    title="Map <article> like we do aria role article">
+     Mozilla Bug 613502
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <nav id="nav">a nav</nav>
   <header id="header">a header</header>
   <footer id="footer">a footer</footer>
-  <article id="article">an article</article>
   <aside id="aside">by the way I am an aside</aside>
 
-  <article id="document" role="document">a document</article>
+  <article id="article">an article</article>
+  <article id="main" role="main">a main area</article>
 
 </body>
 </html>