Bug 345723. Support 3 new accessible object attributes: layout guess, id and xml-roles. r=Ming Gao

This commit is contained in:
aaronleventhal%moonset.net 2006-09-12 19:37:36 +00:00
Родитель 27b0c111bf
Коммит a6f38e7623
5 изменённых файлов: 44 добавлений и 8 удалений

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

@ -1913,17 +1913,32 @@ NS_IMETHODIMP nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
NS_ENSURE_TRUE(attributes, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(attributes, NS_ERROR_OUT_OF_MEMORY);
nsAutoString tagName;
nsresult result = element->GetTagName(tagName);
if (NS_SUCCEEDED(result)) {
nsAutoString oldValueUnused;
nsAutoString oldValueUnused;
element->GetTagName(tagName);
if (!tagName.IsEmpty()) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("tag"), tagName, oldValueUnused);
}
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
if (content) {
nsAutoString id;
if (content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::id, id)) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("id"), id, oldValueUnused);
}
// XXX In the future we may need to expose the dynamic content role inheritance chain
// through this attribute
nsAutoString xmlRole;
if (GetRoleAttribute(content, xmlRole)) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("xml roles"), xmlRole, oldValueUnused);
}
}
attributes.swap(*aAttributes);
return result;
return NS_OK;
}
PRBool nsAccessible::MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut,

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

@ -50,6 +50,7 @@
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIPersistentProperties2.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsITableLayout.h"
@ -133,6 +134,25 @@ NS_IMETHODIMP nsHTMLTableAccessible::GetName(nsAString& aName)
return NS_OK;
}
NS_IMETHODIMP nsHTMLTableAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
nsresult rv = nsAccessibleWrap::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
PRBool isProbablyForLayout;
IsProbablyForLayout(&isProbablyForLayout);
if (isProbablyForLayout) {
nsAutoString oldValueUnused;
(*aAttributes)->SetStringProperty(NS_LITERAL_CSTRING("layout guess"), NS_LITERAL_STRING("true"), oldValueUnused);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
{

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

@ -69,6 +69,7 @@ public:
NS_IMETHOD GetRole(PRUint32 *aResult);
NS_IMETHOD GetState(PRUint32 *aResult);
NS_IMETHOD GetName(nsAString& aResult);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
#ifdef SHOW_LAYOUT_HEURISTIC
NS_IMETHOD GetDescription(nsAString& aDescription);
#endif

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

@ -142,7 +142,7 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetAttributes(nsIPersistentProperties **aAtt
if (role == ROLE_STATICTEXT) {
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
NS_ENSURE_TRUE(attributes, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(attributes, NS_ERROR_OUT_OF_MEMORY);
nsAutoString oldValueUnused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("static"),
NS_LITERAL_STRING("true"), oldValueUnused);

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

@ -741,8 +741,8 @@ NS_IMETHODIMP nsHyperTextAccessible::GetAttributes(nsIPersistentProperties **aAt
return NS_ERROR_FAILURE; // Node already shut down
}
nsAccessibleWrap::GetAttributes(aAttributes);
NS_ENSURE_TRUE(*aAttributes, NS_ERROR_NULL_POINTER);
nsresult rv = nsAccessibleWrap::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);