Bug 736059 - do some cleanups of nsAccessible::GetAttributesInternal, r=tbsaunde

This commit is contained in:
Alexander Surkov 2012-03-26 13:37:07 +09:00
parent 724c186aec
commit cd624df4bc
5 changed files with 65 additions and 30 deletions

View File

@ -1352,17 +1352,13 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsresult
nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
// Don't calculate content based object attributes for not primary for the
// DOM node accessible (like list bullet or XUL tree items).
if (!IsPrimaryForNode())
return NS_OK;
// Attributes set by this method will not be used to override attributes on a sub-document accessible
// when there is a <frame>/<iframe> element that spawned the sub-document
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mContent));
nsAutoString tagName;
element->GetTagName(tagName);
if (!tagName.IsEmpty()) {
nsAutoString oldValueUnused;
aAttributes->SetStringProperty(NS_LITERAL_CSTRING("tag"), tagName,
oldValueUnused);
}
nsEventShell::GetEventAttributes(GetNode(), aAttributes);
@ -1378,12 +1374,13 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
// The inner nodes can be used to override live region behavior on more general outer nodes
// However, nodes in outer documents override nodes in inner documents:
// Outer doc author may want to override properties on a widget they used in an iframe
nsIContent *startContent = mContent;
while (true) {
NS_ENSURE_STATE(startContent);
nsIDocument *doc = startContent->GetDocument();
nsIContent* startContent = mContent;
while (startContent) {
nsIDocument* doc = startContent->GetDocument();
nsIContent* rootContent = nsCoreUtils::GetRoleContent(doc);
NS_ENSURE_STATE(rootContent);
if (!rootContent)
return NS_OK;
nsAccUtils::SetLiveContainerAttributes(aAttributes, startContent,
rootContent);
@ -1409,6 +1406,11 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
if (!mContent->IsElement())
return NS_OK;
// Expose tag.
nsAutoString tagName;
mContent->NodeInfo()->GetName(tagName);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tag, tagName);
// Expose draggable object attribute?
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
if (htmlElement) {
@ -1421,9 +1423,8 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
}
// Don't calculate CSS-based object attributes when no frame (i.e.
// the accessible is not unattached form three) or when the accessible is not
// primary for node (like list bullet or XUL tree items).
if (!mContent->GetPrimaryFrame() || !IsPrimaryForNode())
// the accessible is unattached from the three).
if (!mContent->GetPrimaryFrame())
return NS_OK;
// CSS style based object attributes.

View File

@ -105,6 +105,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
}
testAttrs(getApplicationAccessible(), attrs, false);
}
// no object attributes
testAbsentAttrs(getAccessible("listitem").firstChild, { "tag": "" });
SimpleTest.finish();
}
@ -193,5 +197,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
<th id="th2" abbr="SS#" axis="social">Social Security Number</th>
</tr>
</table>
<ul>
<li id="listitem">item
</ul>
</body>
</html>

View File

@ -1,9 +1,4 @@
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=439566
https://bugzilla.mozilla.org/show_bug.cgi?id=460932
https://bugzilla.mozilla.org/show_bug.cgi?id=689540
-->
<head>
<title>CSS-like attributes tests</title>
<link rel="stylesheet" type="text/css"
@ -16,8 +11,37 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=689540
src="../common.js"></script>
<script type="application/javascript"
src="../attributes.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
var gQueue = null;
function removeElm(aID)
{
this.node = getNode(aID);
this.accessible = getAccessible(aID);
this.eventSeq = [
new invokerChecker(EVENT_HIDE, this.accessible)
];
this.invoke = function removeElm_invoke()
{
this.node.parentNode.removeChild(this.node);
}
this.check = function removeElm_check()
{
testAbsentCSSAttrs(this.accessible);
}
this.getID = function removeElm_getID()
{
return "test CSS-based attributes on removed accessible";
}
}
function doTest()
{
// CSS display
@ -85,7 +109,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=689540
// no CSS-based object attributes
testAbsentCSSAttrs(getAccessible("listitem").firstChild);
SimpleTest.finish();
gQueue = new eventQueue();
gQueue.push(new removeElm("div"));
gQueue.invoke(); // SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();

View File

@ -34,12 +34,12 @@
testAttrs("main", {"xml-roles" : "main"}, true); // ARIA override
// And some AT may look for this
testAttrs("nav", {"tag" : "NAV"}, true);
testAttrs("header", {"tag" : "HEADER"}, true);
testAttrs("footer", {"tag" : "FOOTER"}, true);
testAttrs("article", {"tag" : "ARTICLE"}, true);
testAttrs("aside", {"tag" : "ASIDE"}, true);
testAttrs("main", {"tag" : "ARTICLE"}, true); // no override expected
testAttrs("nav", {"tag" : "nav"}, true);
testAttrs("header", {"tag" : "header"}, true);
testAttrs("footer", {"tag" : "footer"}, true);
testAttrs("article", {"tag" : "article"}, true);
testAttrs("aside", {"tag" : "aside"}, true);
testAttrs("main", {"tag" : "article"}, true); // no override expected
SimpleTest.finish();
}

View File

@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441737
// attributes should contain tag:body
attributes = docAcc.attributes;
is(attributes.getStringProperty("tag"), "BODY",
is(attributes.getStringProperty("tag"), "body",
"Wrong attribute on document!");
// nsIAccessibleDocument