diff --git a/accessible/src/base/nsAccessibilityAtomList.h b/accessible/src/base/nsAccessibilityAtomList.h index 200f2ce8508..062542fb12e 100644 --- a/accessible/src/base/nsAccessibilityAtomList.h +++ b/accessible/src/base/nsAccessibilityAtomList.h @@ -100,6 +100,7 @@ ACCESSIBILITY_ATOM(a, "a") ACCESSIBILITY_ATOM(abbr, "abbr") ACCESSIBILITY_ATOM(acronym, "acronym") ACCESSIBILITY_ATOM(area, "area") +ACCESSIBILITY_ATOM(article, "article") // HTML landmark ACCESSIBILITY_ATOM(autocomplete, "autocomplete") ACCESSIBILITY_ATOM(blockquote, "blockquote") ACCESSIBILITY_ATOM(br, "br") @@ -111,7 +112,9 @@ ACCESSIBILITY_ATOM(dd, "dd") ACCESSIBILITY_ATOM(div, "div") ACCESSIBILITY_ATOM(dl, "dl") ACCESSIBILITY_ATOM(dt, "dt") +ACCESSIBILITY_ATOM(footer, "footer") // HTML landmark ACCESSIBILITY_ATOM(form, "form") +ACCESSIBILITY_ATOM(header, "header") // HTML landmark ACCESSIBILITY_ATOM(h1, "h1") ACCESSIBILITY_ATOM(h2, "h2") ACCESSIBILITY_ATOM(h3, "h3") @@ -135,6 +138,7 @@ ACCESSIBILITY_ATOM(map, "map") ACCESSIBILITY_ATOM(math, "math") ACCESSIBILITY_ATOM(menupopup, "menupopup") // XUL ACCESSIBILITY_ATOM(object, "object") +ACCESSIBILITY_ATOM(nav, "nav") // HTML landmark ACCESSIBILITY_ATOM(ol, "ol") ACCESSIBILITY_ATOM(optgroup, "optgroup") ACCESSIBILITY_ATOM(option, "option") @@ -290,3 +294,4 @@ ACCESSIBILITY_ATOM(live, "live") ACCESSIBILITY_ATOM(lineNumber, "line-number") ACCESSIBILITY_ATOM(posinset, "posinset") ACCESSIBILITY_ATOM(setsize, "setsize") +ACCESSIBILITY_ATOM(xmlroles, "xml-roles") diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index 138aeb7e35a..3fa396be68b 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -134,8 +134,10 @@ nsHyperTextAccessible::NativeRole() if (tag == nsAccessibilityAtoms::form) return nsIAccessibleRole::ROLE_FORM; - if (tag == nsAccessibilityAtoms::div || - tag == nsAccessibilityAtoms::blockquote) + if (tag == nsAccessibilityAtoms::article || + tag == nsAccessibilityAtoms::blockquote || + tag == nsAccessibilityAtoms::div || + tag == nsAccessibilityAtoms::nav) return nsIAccessibleRole::ROLE_SECTION; if (tag == nsAccessibilityAtoms::h1 || @@ -146,6 +148,14 @@ nsHyperTextAccessible::NativeRole() tag == nsAccessibilityAtoms::h6) return nsIAccessibleRole::ROLE_HEADING; + // Deal with html landmark elements + if (tag == nsAccessibilityAtoms::header) + return nsIAccessibleRole::ROLE_HEADER; + + if (tag == nsAccessibilityAtoms::footer) + return nsIAccessibleRole::ROLE_FOOTER; + + // Treat block frames as paragraphs nsIFrame *frame = GetFrame(); if (frame && frame->GetType() == nsAccessibilityAtoms::blockFrame && frame->GetContent()->Tag() != nsAccessibilityAtoms::input) { @@ -1197,6 +1207,21 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute } } + // For the html landmark elements we expose them like we do aria landmarks to + // make AT navigation schemes "just work". + if (mContent->Tag() == nsAccessibilityAtoms::nav) + 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")); + return NS_OK; } diff --git a/accessible/tests/mochitest/Makefile.in b/accessible/tests/mochitest/Makefile.in index 4799a1e314f..106947b0111 100644 --- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -95,6 +95,7 @@ _TEST_FILES =\ test_descr.html \ test_editabletext_1.html \ test_editabletext_2.html \ + test_elm_landmarks.html \ test_elm_listbox.xul \ $(warning test_elm_media.html temporarily disabled) \ test_elm_nsApplicationAcc.html \ diff --git a/accessible/tests/mochitest/role.js b/accessible/tests/mochitest/role.js index 38eeaf9c4ee..021e536eb0b 100644 --- a/accessible/tests/mochitest/role.js +++ b/accessible/tests/mochitest/role.js @@ -19,11 +19,13 @@ const ROLE_DIALOG = nsIAccessibleRole.ROLE_DIALOG; const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT; const ROLE_EMBEDDED_OBJECT = nsIAccessibleRole.ROLE_EMBEDDED_OBJECT; const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY; +const ROLE_FOOTER = nsIAccessibleRole.ROLE_FOOTER; const ROLE_FLAT_EQUATION = nsIAccessibleRole.ROLE_FLAT_EQUATION; const ROLE_FORM = nsIAccessibleRole.ROLE_FORM; const ROLE_GRAPHIC = nsIAccessibleRole.ROLE_GRAPHIC; const ROLE_GRID_CELL = nsIAccessibleRole.ROLE_GRID_CELL; const ROLE_GROUPING = nsIAccessibleRole.ROLE_GROUPING; +const ROLE_HEADER = nsIAccessibleRole.ROLE_HEADER; const ROLE_HEADING = nsIAccessibleRole.ROLE_HEADING; const ROLE_IMAGE_MAP = nsIAccessibleRole.ROLE_IMAGE_MAP; const ROLE_INTERNAL_FRAME = nsIAccessibleRole.ROLE_INTERNAL_FRAME; diff --git a/accessible/tests/mochitest/test_elm_landmarks.html b/accessible/tests/mochitest/test_elm_landmarks.html new file mode 100644 index 00000000000..d1556caedcd --- /dev/null +++ b/accessible/tests/mochitest/test_elm_landmarks.html @@ -0,0 +1,68 @@ + + +
+++ + +