Bug 439566 – Include the css display property as an IAccessible2 object attribute, r=MarcoZ

This commit is contained in:
Alexander Surkov 2008-07-03 12:12:45 +08:00
parent 2167147598
commit 2582693783
5 changed files with 97 additions and 0 deletions

View File

@ -157,6 +157,7 @@ ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
ACCESSIBILITY_ATOM(contenteditable, "contenteditable")
ACCESSIBILITY_ATOM(control, "control")
ACCESSIBILITY_ATOM(disabled, "disabled")
ACCESSIBILITY_ATOM(display, "display")
ACCESSIBILITY_ATOM(_class, "class")
ACCESSIBILITY_ATOM(cycles, "cycles") // used for XUL cycler attribute
ACCESSIBILITY_ATOM(curpos, "curpos") // XUL

View File

@ -2279,6 +2279,14 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
startContent = parentDoc->FindContentForSubDocument(doc);
}
// Expose 'display' attribute.
nsAutoString displayValue;
nsresult rv = GetComputedStyleValue(EmptyString(),
NS_LITERAL_STRING("display"),
displayValue);
if (NS_SUCCEEDED(rv))
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::display,
displayValue);
return NS_OK;
}

View File

@ -1135,6 +1135,8 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
// Indicate when the current object uses block-level formatting
// via formatting: block
// XXX: 'formatting' attribute is deprecated and will be removed in Mozilla2,
// use 'display' attribute instead.
nsIFrame *frame = GetFrame();
if (frame && frame->GetType() == nsAccessibilityAtoms::blockFrame) {
nsAutoString oldValueUnused;

View File

@ -51,6 +51,7 @@ _TEST_FILES =\
test_aria_role_article.html \
test_bug368835.xul \
test_bug420863.html \
test_cssattrs.html \
test_groupattrs.xul \
test_table_indexes.html \
test_nsIAccessibleTable_1.html \

View File

@ -0,0 +1,85 @@
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=439566
-->
<head>
<title>CSS-like attributes tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript">
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
var gAccRetrieval = null;
function testAttr(aID, aName, aValue)
{
var acc = null;
try {
acc = gAccRetrieval.getAccessibleFor(document.getElementById(aID));
} catch(e) { }
if (!acc) {
ok(false, "Can't get accessible object for " + aID);
return;
}
var attrs = null;
try {
attrs = acc.attributes;
} catch(e) { }
if (!attrs) {
ok(false, "Can't get accessible attributes for " + aID);
return;
}
is(attrs.getStringProperty(aName), aValue,
"Accessible with ID " + aID + " has wrong attribute value");
}
function doTest()
{
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(nsIAccessibleRetrieval);
testAttr("span", "display", "inline");
testAttr("div", "display", "block");
testAttr("p", "display", "block");
testAttr("input", "display", "inline");
testAttr("table", "display", "table");
testAttr("tr", "display", "table-row");
testAttr("td", "display", "table-cell");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=439566"
title="Include the css display property as an IAccessible2 object attribute">
Mozilla Bug 439566
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<span id="span" role="group">It's span</span>
<div id="div">It's div</div>
<p id="p">It's paragraph"</p>
<input id="input"/>
<table id="table">
<tr id="tr" role="group">
<td id="td">td</td>
</tr>
</table>
</body>
</html>