Bug 340670. Implement first accessible text attribute. Patch by Ming Gao. r=aaronlev

This commit is contained in:
aaronleventhal%moonset.net 2006-09-12 17:06:12 +00:00
parent c201dc57d6
commit a8a37c95df
4 changed files with 56 additions and 11 deletions

View File

@ -827,17 +827,13 @@ getRoleCB(AtkObject *aAtkObj)
}
AtkAttributeSet *
getAttributesCB(AtkObject *aAtkObj)
GetAttributeSet(nsIAccessible* aAccessible)
{
NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
nsAccessibleWrap *accWrap =
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
AtkAttributeSet *objAttributeSet = nsnull;
nsCOMPtr<nsIPersistentProperties> attributes;
accWrap->GetAttributes(getter_AddRefs(attributes));
if (attributes) {
aAccessible->GetAttributes(getter_AddRefs(attributes));
if (attributes) {
nsCOMPtr<nsISimpleEnumerator> propEnum;
nsresult rv = attributes->Enumerate(getter_AddRefs(propEnum));
NS_ENSURE_SUCCESS(rv, nsnull);
@ -867,6 +863,16 @@ getAttributesCB(AtkObject *aAtkObj)
return objAttributeSet;
}
AtkAttributeSet *
getAttributesCB(AtkObject *aAtkObj)
{
NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
nsAccessibleWrap *accWrap =
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
return GetAttributeSet(accWrap);
}
AtkObject *
getParentCB(AtkObject *aAtkObj)
{

View File

@ -42,6 +42,8 @@
#include "nsMaiInterfaceText.h"
#include "nsString.h"
AtkAttributeSet * GetAttributeSet(nsIAccessible* aAccessible);
void
textInterfaceInitCB(AtkTextIface *aIface)
{
@ -254,9 +256,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
*aEndOffset = endOffset;
NS_ENSURE_SUCCESS(rv, nsnull);
// XXX Turn accessibleWithAttrs into AtkAttributeSet by getting CSS for it
// Look at nsAccessNodeWrap::get_computedStyle() for MSAA implementation
return nsnull;
return GetAttributeSet(accessibleWithAttrs);
}
AtkAttributeSet *

View File

@ -47,6 +47,8 @@
#include "nsIPresShell.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPersistentProperties2.h"
#include "nsComponentManagerUtils.h"
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell, nsIFrame *aFrame):
nsTextAccessibleWrap(aDomNode, aShell), mFrame(aFrame)
@ -97,6 +99,19 @@ NS_IMETHODIMP nsHTMLTextAccessible::FireToolkitEvent(PRUint32 aEvent,
return nsTextAccessibleWrap::FireToolkitEvent(aEvent, aTarget, aData);
}
NS_IMETHODIMP nsHTMLTextAccessible::GetRole(PRUint32 *aRole)
{
nsIFrame *frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_NULL_POINTER);
if (frame->IsGeneratedContentFrame()) {
*aRole = ROLE_STATICTEXT;
return NS_OK;
}
return nsTextAccessible::GetRole(aRole);
}
NS_IMETHODIMP nsHTMLTextAccessible::GetState(PRUint32 *aState)
{
nsTextAccessible::GetState(aState);
@ -114,6 +129,29 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetState(PRUint32 *aState)
return NS_OK;
}
NS_IMETHODIMP nsHTMLTextAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
*aAttributes = nsnull;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
PRUint32 role;
GetRole(&role);
if (role == ROLE_STATICTEXT) {
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
NS_ENSURE_TRUE(attributes, NS_ERROR_NULL_POINTER);
nsAutoString oldValueUnused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("static"),
NS_LITERAL_STRING("true"), oldValueUnused);
attributes.swap(*aAttributes);
}
return NS_OK;
}
nsHTMLHRAccessible::nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsLeafAccessible(aDomNode, aShell)
{
@ -296,4 +334,3 @@ NS_IMETHODIMP nsHTMLListBulletAccessible::GetName(nsAString &aName)
aName = mBulletText;
return NS_OK;
}

View File

@ -53,6 +53,8 @@ public:
// nsIAccessible
NS_IMETHOD GetName(nsAString& _retval);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
// nsPIAccessNode
NS_IMETHOD_(nsIFrame *) GetFrame(void);