Bug 849624 - Map header and footer to their newly recommended roles. r=surkov

This commit is contained in:
Brandon Coffman 2013-03-29 07:05:39 -04:00
parent 3b8df8a0e5
commit 542f20e2f4

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=78: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1272,27 +1273,48 @@ HyperTextAccessible::NativeAttributes()
return attributes.forget();
// For the html landmark elements we expose them like we do aria landmarks to
// make AT navigation schemes "just work". Note html:header is redundant as
// a landmark since it usually contains headings. We're not yet sure how the
// web will use html:footer but our best bet right now is as contentinfo.
if (mContent->Tag() == nsGkAtoms::nav)
// make AT navigation schemes "just work".
nsIAtom* tag = mContent->Tag();
if (tag == nsGkAtoms::nav) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("navigation"));
else if (mContent->Tag() == nsGkAtoms::section)
} else if (tag == nsGkAtoms::section) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("region"));
else if (mContent->Tag() == nsGkAtoms::footer)
} else if (tag == nsGkAtoms::header || tag == nsGkAtoms::footer) {
// Only map header and footer if they are not descendants
// of an article or section tag.
nsIContent* parent = mContent->GetParent();
while (parent) {
if (parent->Tag() == nsGkAtoms::article ||
parent->Tag() == nsGkAtoms::section)
break;
parent = parent->GetParent();
}
// No article or section elements found.
if (!parent) {
if (tag == nsGkAtoms::header) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("banner"));
} else if (tag == nsGkAtoms::footer) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("contentinfo"));
}
}
} else if (tag == nsGkAtoms::footer) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("contentinfo"));
else if (mContent->Tag() == nsGkAtoms::aside)
} else if (tag == nsGkAtoms::aside) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("complementary"));
else if (mContent->Tag() == nsGkAtoms::article)
} else if (tag == nsGkAtoms::article) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("article"));
else if (mContent->Tag() == nsGkAtoms::main)
} else if (tag == nsGkAtoms::main) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
NS_LITERAL_STRING("main"));
}
return attributes.forget();
}