Bug 558036 - make HTML <output> accessible. r=MarcoZ,surkov a=davidb

This commit is contained in:
David Bolter 2010-09-21 11:05:31 -04:00
Родитель caeb4fbd2d
Коммит 18eb4e1d3a
8 изменённых файлов: 132 добавлений и 2 удалений

Просмотреть файл

@ -138,6 +138,7 @@ ACCESSIBILITY_ATOM(object, "object")
ACCESSIBILITY_ATOM(ol, "ol")
ACCESSIBILITY_ATOM(optgroup, "optgroup")
ACCESSIBILITY_ATOM(option, "option")
ACCESSIBILITY_ATOM(output, "output")
ACCESSIBILITY_ATOM(panel, "panel") // XUL
ACCESSIBILITY_ATOM(q, "q")
ACCESSIBILITY_ATOM(select, "select")

Просмотреть файл

@ -1648,6 +1648,12 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
return accessible;
}
if (tag == nsAccessibilityAtoms::output) {
nsAccessible* accessible = new nsHTMLOutputAccessible(aContent, aWeakShell);
NS_IF_ADDREF(accessible);
return accessible;
}
return nsnull;
}

Просмотреть файл

@ -2158,9 +2158,18 @@ nsAccessible::GetRelationByType(PRUint32 aRelationType,
case nsIAccessibleRelation::RELATION_CONTROLLER_FOR:
{
return nsRelUtils::
nsresult rv = nsRelUtils::
AddTargetFromIDRefsAttr(aRelationType, aRelation, mContent,
nsAccessibilityAtoms::aria_controls);
NS_ENSURE_SUCCESS(rv,rv);
if (rv != NS_OK_NO_RELATION_TARGET)
return NS_OK; // XXX bug 381599, avoid performance problems
return nsRelUtils::
AddTargetFromNeighbour(aRelationType, aRelation, mContent,
nsAccessibilityAtoms::_for,
nsAccessibilityAtoms::output);
}
case nsIAccessibleRelation::RELATION_FLOWS_TO:

Просмотреть файл

@ -40,6 +40,8 @@
#include "nsHTMLTextAccessible.h"
#include "nsDocAccessible.h"
#include "nsAccUtils.h"
#include "nsRelUtils.h"
#include "nsTextEquivUtils.h"
#include "nsIFrame.h"
@ -195,6 +197,56 @@ nsHTMLLabelAccessible::NativeRole()
return nsIAccessibleRole::ROLE_LABEL;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLOuputAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLOutputAccessible::
nsHTMLOutputAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLOutputAccessible, nsHyperTextAccessible)
NS_IMETHODIMP
nsHTMLOutputAccessible::GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation** aRelation)
{
nsresult rv = nsAccessibleWrap::GetRelationByType(aRelationType, aRelation);
NS_ENSURE_SUCCESS(rv, rv);
if (rv != NS_OK_NO_RELATION_TARGET)
return NS_OK; // XXX bug 381599, avoid performance problems
if (aRelationType == nsIAccessibleRelation::RELATION_CONTROLLED_BY) {
return nsRelUtils::
AddTargetFromIDRefsAttr(aRelationType, aRelation, mContent,
nsAccessibilityAtoms::_for);
}
return NS_OK;
}
PRUint32
nsHTMLOutputAccessible::NativeRole()
{
return nsIAccessibleRole::ROLE_SECTION;
}
nsresult
nsHTMLOutputAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
{
nsresult rv = nsAccessibleWrap::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::live,
NS_LITERAL_STRING("polite"));
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLIAccessible
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -105,6 +105,25 @@ public:
virtual PRUint32 NativeRole();
};
/**
* Used for HTML output element.
*/
class nsHTMLOutputAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLOutputAccessible(nsIContent* aContent, nsIWeakReference* aShell);
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation** aRelation);
// nsAccessible
virtual PRUint32 NativeRole();
virtual nsresult GetAttributesInternal(nsIPersistentProperties* aAttributes);
};
/**
* Used for bullet of HTML list item element (for example, HTML li).
*/

Просмотреть файл

@ -3,6 +3,7 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=475006
https://bugzilla.mozilla.org/show_bug.cgi?id=391829
https://bugzilla.mozilla.org/show_bug.cgi?id=581952
https://bugzilla.mozilla.org/show_bug.cgi?id=558036
-->
<head>
<title>Group attributes tests</title>
@ -39,6 +40,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=581952
testAttrs("sortOther", {"sort" : "other"}, true);
// live object attribute
// HTML
testAttrs("output", {"live" : "polite"}, true);
// ARIA
testAttrs("live", {"live" : "polite"}, true);
testAttrs("live2", {"live" : "polite"}, true);
testAbsentAttrs("live3", {"live" : ""});
@ -108,6 +114,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=581952
title="Make explicit that aria-label is not an object attribute">
Mozilla Bug 475006
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
title="make HTML <output> accessible">
Mozilla Bug 558036
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -130,6 +141,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=581952
<div id="sortNone" role="columnheader" aria-sort="none"></div>
<div id="sortOther" role="columnheader" aria-sort="other"></div>
<!-- html -->
<output id="output"></output>
<!-- back to aria -->
<div id="live" aria-live="polite">excuse <div id="liveChild">me</div></div>
<div id="live2" role="marquee" aria-live="polite">excuse <div id="live2Child">me</div></div>
<div id="live3" role="region">excuse</div>

Просмотреть файл

@ -85,6 +85,11 @@
// 'default button' relation
testRelation("input", RELATION_DEFAULT_BUTTON, "submit");
// output 'for' relations
testRelation("output", RELATION_CONTROLLED_BY, ["input", "input2"]);
testRelation("input", RELATION_CONTROLLER_FOR, "output");
testRelation("input2", RELATION_CONTROLLER_FOR, "output");
// 'described by'/'description for' relation for html:table and
// html:caption
testRelation("caption", RELATION_DESCRIPTION_FOR, "table");
@ -125,6 +130,11 @@
title="mochitests for accessible relations">
Mozilla Bug 475298
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
title="make HTML <output> accessible">
Mozilla Bug 558036
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -189,9 +199,11 @@
<span id="flowfrom1">flow from</span>
<span id="flowfrom2">flow from</span>
<form>
<form id="form">
<input id="input" />
<input id="input2" />
<input type="submit" id="submit" />
<output id="output" style="display:block" for="input input2"></output>
</form>
<table id="table">

Просмотреть файл

@ -61,6 +61,16 @@
};
testAccessibleTree("image_submit", accTree);
accTree = {
role: ROLE_SECTION,
children: [
{
role: ROLE_TEXT_LEAF
}
]
};
testAccessibleTree("output", accTree);
SimpleTest.finish();
}
@ -80,6 +90,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=524521">
Mozilla Bug 524521
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
title="make HTML <output> accessible">
Mozilla Bug 558036
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -92,5 +107,6 @@
<input type="submit" id="submit">
<input type="image" id="image_submit">
<output id="output">1337</output>
</body>
</html>