Bug 731276 - remove CSS computed style getters from nsIAccessible, r=tbsaunde

This commit is contained in:
Alexander Surkov 2012-03-12 21:00:29 -04:00
parent a6a66f92bd
commit e00c80c3b6
7 changed files with 15 additions and 142 deletions

View File

@ -59,7 +59,7 @@ interface nsIAccessibleRelation;
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
*/
[scriptable, uuid(3126544c-826c-4694-a2ed-67bfe56a1f37)]
[scriptable, uuid(e7c44e0d-736e-4ead-afee-b51f4b574020)]
interface nsIAccessible : nsISupports
{
/**
@ -110,26 +110,6 @@ interface nsIAccessible : nsISupports
*/
readonly attribute DOMString innerHTML;
/**
* Retrieve the computed style value for this DOM node, if it is a DOM element.
* Note: the meanings of width, height and other size measurements depend
* on the version of CSS being used. Therefore, for bounds information,
* it is better to use nsIAccessible::accGetBounds.
*
* @param pseudoElt [in] The pseudo element to retrieve style for, or NULL
* for general computed style information for this node.
* @param propertyName [in] Retrieve the computed style value for this property name,
* for example "border-bottom".
*/
DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
/**
* The method is similar to getComputedStyleValue() excepting that this one
* returns nsIDOMCSSPrimitiveValue.
*/
nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
in DOMString propertyName);
/**
* The DOM node this nsIAccessible is associated with.
*/

View File

@ -231,42 +231,6 @@ nsAccessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
mRoleMapEntry = aRoleMapEntry;
}
NS_IMETHODIMP
nsAccessible::GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsAString& aValue)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
return styleDecl->GetPropertyValue(aPropertyName, aValue);
}
NS_IMETHODIMP
nsAccessible::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsIDOMCSSPrimitiveValue **aCSSValue) {
NS_ENSURE_ARG_POINTER(aCSSValue);
*aCSSValue = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_STATE(styleDecl);
nsCOMPtr<nsIDOMCSSValue> cssValue;
styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
return CallQueryInterface(cssValue, aCSSValue);
}
NS_IMETHODIMP
nsAccessible::GetDocument(nsIAccessibleDocument **aDocument)
{

View File

@ -467,24 +467,6 @@ nsApplicationAccessible::ScrollToPoint(PRUint32 aCoordinateType,
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetComputedStyleValue(const nsAString &aPseudoElt,
const nsAString &aPropertyName,
nsAString &aValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetComputedStyleCSSValue(const nsAString &aPseudoElt,
const nsAString &aPropertyName,
nsIDOMCSSPrimitiveValue **aCSSPrimitiveValue)
{
NS_ENSURE_ARG_POINTER(aCSSPrimitiveValue);
*aCSSPrimitiveValue = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetLanguage(nsAString &aLanguage)
{

View File

@ -76,12 +76,6 @@ public:
NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
NS_SCRIPTABLE NS_IMETHOD ScrollTo(PRUint32 aScrollType);
NS_SCRIPTABLE NS_IMETHOD ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY);
NS_SCRIPTABLE NS_IMETHOD GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsAString& aValue NS_OUTPARAM);
NS_SCRIPTABLE NS_IMETHOD GetComputedStyleCSSValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsIDOMCSSPrimitiveValue** aValue NS_OUTPARAM);
NS_SCRIPTABLE NS_IMETHOD GetLanguage(nsAString& aLanguage);
NS_IMETHOD GetParent(nsIAccessible **aParent);
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);

View File

@ -43,6 +43,7 @@
#include "AccessibleComponent_i.c"
#include "nsAccessible.h"
#include "nsCoreUtils.h"
#include "States.h"
#include "nsString.h"
@ -156,17 +157,23 @@ __try {
*aColorValue = 0;
nsRefPtr<nsAccessible> acc(do_QueryObject(this));
if (!acc)
if (acc->IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMCSSPrimitiveValue> cssValue;
nsresult rv = acc->GetComputedStyleCSSValue(EmptyString(), aPropName,
getter_AddRefs(cssValue));
if (NS_FAILED(rv) || !cssValue)
return GetHRESULT(rv);
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), acc->GetContent());
NS_ENSURE_STATE(styleDecl);
nsCOMPtr<nsIDOMCSSValue> cssGenericValue;
styleDecl->GetPropertyCSSValue(aPropName, getter_AddRefs(cssGenericValue));
nsCOMPtr<nsIDOMCSSPrimitiveValue> cssValue =
do_QueryInterface(cssGenericValue);
if (!cssValue)
return E_FAIL;
nsCOMPtr<nsIDOMRGBColor> rgbColor;
rv = cssValue->GetRGBColorValue(getter_AddRefs(rgbColor));
nsresult rv = cssValue->GetRGBColorValue(getter_AddRefs(rgbColor));
if (NS_FAILED(rv) || !rgbColor)
return GetHRESULT(rv);

View File

@ -101,7 +101,6 @@ _TEST_FILES =\
test_descr.html \
test_nsIAccessibleDocument.html \
test_nsIAccessibleImage.html \
test_nsIAccessNode_utils.html \
test_nsOuterDocAccessible.html \
test_role_nsHyperTextAcc.html \
test_textboxes.html \

View File

@ -1,53 +0,0 @@
<html>
<head>
<title>nsIAccessNode util methods testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="common.js"></script>
<script type="application/javascript">
function doTest()
{
var elmObj = {};
var acc = getAccessible("span", null, elmObj);
computedStyle = document.defaultView.getComputedStyle(elmObj.value, "");
// html:span element
is(acc.getComputedStyleValue("", "color"), computedStyle.color,
"Wrong color for element with ID 'span'");
// text child of html:span element
acc = getAccessible(acc.firstChild);
is(acc.getComputedStyleValue("", "color"), computedStyle.color,
"Wrong color for text child of element with ID 'span'");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454211"
title="nsIAccessNode util methods testing">
Mozilla Bug 454211
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<span role="note" style="color: red" id="span">text</span>
</body>
</html>