Bug 729831 - Don't expose CSS-based object attributes on not in tree accessible and accessible having no DOM element, r=marcoz

This commit is contained in:
Alexander Surkov 2012-03-09 23:20:17 +09:00
Родитель faacb3c669
Коммит 762ddc766a
3 изменённых файлов: 46 добавлений и 11 удалений

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

@ -1450,6 +1450,23 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
if (!mContent->IsElement())
return NS_OK;
// Expose draggable object attribute?
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
if (htmlElement) {
bool draggable = false;
htmlElement->GetDraggable(&draggable);
if (draggable) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::draggable,
NS_LITERAL_STRING("true"));
}
}
// 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())
return NS_OK;
// CSS style based object attributes.
nsAutoString value;
StyleInfo styleInfo(mContent->AsElement(), mDoc->PresShell());
@ -1482,17 +1499,6 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
styleInfo.MarginBottom(value);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginBottom, value);
// Expose draggable object attribute?
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
if (htmlElement) {
bool draggable = false;
htmlElement->GetDraggable(&draggable);
if (draggable) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::draggable,
NS_LITERAL_STRING("true"));
}
}
return NS_OK;
}

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

@ -47,6 +47,23 @@ function testCSSAttrs(aID)
testAttrs(aID, attrs, true);
}
/**
* Test the accessible that it doesn't have CSS-based object attributes.
*/
function testAbsentCSSAttrs(aID)
{
var attrs = {
"display": "",
"text-align": "",
"text-indent": "",
"margin-left": "",
"margin-right": "",
"margin-top": "",
"margin-bottom": ""
};
testAbsentAttrs(aID, attrs);
}
/**
* Test group object attributes (posinset, setsize and level) and
* nsIAccessible::groupPosition() method.

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

@ -82,6 +82,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=689540
testCSSAttrs("tr");
testCSSAttrs("td");
// no CSS-based object attributes
testAbsentCSSAttrs(getAccessible("listitem").firstChild);
SimpleTest.finish();
}
@ -111,6 +114,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=689540
title="Don't use GetComputedStyle for object attribute calculation">
Mozilla Bug 714579
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=729831"
title="Don't expose CSS-based object attributes on not in tree accessible and accessible having no DOM element">
Mozilla Bug 729831
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -189,5 +197,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=689540
<td id="td">td</td>
</tr>
</table>
<ul>
<li id="listitem">item
</ul>
</body>
</html>