Bug 509696 - Empty role on body removes read-only state; breaks virtual buffers. r=MarcoZ,surkov

This commit is contained in:
David Bolter 2009-08-31 09:12:08 -04:00
parent 7186fd81c3
commit 5d019747bc
3 changed files with 30 additions and 7 deletions

View File

@ -648,7 +648,10 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
{
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
nsAutoString roleString;
if (!content || !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString)) {
if (!content ||
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString) ||
roleString.IsEmpty()) {
// We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
return nsnull;
}
@ -674,7 +677,7 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
}
}
// Always use some entry if there is a role string
// Always use some entry if there is a non-empty role string
// To ensure an accessible object is created
return &nsARIAMap::gLandmarkRoleMap;
}

View File

@ -2030,9 +2030,12 @@ nsAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
}
if (mRoleMapEntry) {
// Once an ARIA role is used, default to not-readonly. This can be overridden
// by aria-readonly, or if the ARIA role is mapped to readonly by default
*aState &= ~nsIAccessibleStates::STATE_READONLY;
// We only force the readonly bit off if we have a real mapping for the aria
// role. This preserves the ability for screen readers to use readonly
// (primarily on the document) as the hint for creating a virtual buffer.
if (mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING)
*aState &= ~nsIAccessibleStates::STATE_READONLY;
if (content->HasAttr(kNameSpaceID_None, content->GetIDAttributeName())) {
// If has a role & ID and aria-activedescendant on the container, assume focusable

View File

@ -3,6 +3,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=454997
https://bugzilla.mozilla.org/show_bug.cgi?id=467387
https://bugzilla.mozilla.org/show_bug.cgi?id=509696
-->
<head>
<title>states of document</title>
@ -21,6 +22,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467387
<script type="application/javascript">
function doTest()
{
// Bug 509696
testStates(document, STATE_READONLY); // role=""
todo(false, "enable commented tests when we support body role changes");
/*
document.body.setAttribute("role","banner"); // no platform mapping
testStates(document, STATE_READONLY);
document.body.setAttribute("role","foo"); // bogus role
testStates(document, STATE_READONLY);
document.body.removeAttribute("role");
testStates(document, STATE_READONLY);
*/
// Bugs 454997 and 467387
testStates(document, STATE_READONLY);
testStates("document", STATE_READONLY);
testStates("editable_document", 0, EXT_STATE_EDITABLE);
@ -46,14 +60,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467387
</script>
</head>
<body>
<body role="">
<a target="_blank"
title="nsIAccessible states tests of editable document"
title="<body contenteditable='true'> exposed incorrectly"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454997">Mozilla Bug 454997</a>
<a target="_blank"
title="nsIAccessible states tests of editable document"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467387">Mozilla Bug 467387</a>
<a target="_blank"
title="Role attribute on body with empty string causes DocAccessible not to have read-only state."
href="https://bugzilla.mozilla.org/show_bug.cgi?id=509696">Mozilla Bug 509696</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">