Bug 1076816 - segregate XPCOM tree, r=davidb

This commit is contained in:
Alexander Surkov 2014-10-21 20:49:28 -04:00
parent a0eb4bde4d
commit 5a5c3c647d
116 changed files with 1497 additions and 1518 deletions

View File

@ -10,11 +10,8 @@
#include "ApplicationAccessibleWrap.h"
#include "InterfaceInitFuncs.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
#include "nsIAccessibleTable.h"
#include "ProxyAccessible.h"
#include "RootAccessible.h"
#include "nsIAccessibleValue.h"
#include "nsMai.h"
#include "nsMaiHyperlink.h"
#include "nsString.h"
@ -305,24 +302,25 @@ AccessibleWrap::SetMaiHyperlink(MaiHyperlink* aMaiHyperlink)
}
}
NS_IMETHODIMP
void
AccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = nullptr;
if (!mAtkObject) {
if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) {
// We don't create ATK objects for node which has been shutdown, or
// nsIAccessible plain text leaves
return NS_ERROR_FAILURE;
// We don't create ATK objects for node which has been shutdown or
// plain text leaves
return;
}
GType type = GetMaiAtkType(CreateMaiInterfaces());
NS_ENSURE_TRUE(type, NS_ERROR_FAILURE);
mAtkObject =
reinterpret_cast<AtkObject *>
(g_object_new(type, nullptr));
NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
if (!type)
return;
mAtkObject = reinterpret_cast<AtkObject*>(g_object_new(type, nullptr));
if (!mAtkObject)
return;
atk_object_initialize(mAtkObject, this);
mAtkObject->role = ATK_ROLE_INVALID;
@ -330,7 +328,6 @@ AccessibleWrap::GetNativeInterface(void** aOutAccessible)
}
*aOutAccessible = mAtkObject;
return NS_OK;
}
AtkObject *
@ -341,10 +338,10 @@ AccessibleWrap::GetAtkObject(void)
return static_cast<AtkObject *>(atkObj);
}
// Get AtkObject from nsIAccessible interface
// Get AtkObject from Accessible interface
/* static */
AtkObject *
AccessibleWrap::GetAtkObject(nsIAccessible* acc)
AccessibleWrap::GetAtkObject(Accessible* acc)
{
void *atkObjPtr = nullptr;
acc->GetNativeInterface(&atkObjPtr);
@ -374,12 +371,8 @@ AccessibleWrap::CreateMaiInterfaces(void)
}
// Value interface.
nsCOMPtr<nsIAccessibleValue> accessInterfaceValue;
QueryInterface(NS_GET_IID(nsIAccessibleValue),
getter_AddRefs(accessInterfaceValue));
if (accessInterfaceValue) {
if (HasNumericValue())
interfacesBits |= 1 << MAI_INTERFACE_VALUE;
}
// Document interface.
if (IsDoc())
@ -682,7 +675,7 @@ getRoleCB(AtkObject *aAtkObj)
} else {
#ifdef DEBUG
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
"Does not support nsIAccessibleText when it should");
"Does not support Text interface when it should");
#endif
role = accWrap->Role();
@ -849,8 +842,8 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
gint
getIndexInParentCB(AtkObject* aAtkObj)
{
// We don't use nsIAccessible::GetIndexInParent() because
// for ATK we don't want to include text leaf nodes as children
// We don't use Accessible::IndexInParent() because we don't include text
// leaf nodes as children in ATK.
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return -1;
@ -1041,8 +1034,8 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accessible);
// We don't create ATK objects for nsIAccessible plain text leaves,
// just return NS_OK in such case
// We don't create ATK objects for plain text leaves, just return NS_OK in
// such case.
if (!atkObj) {
NS_ASSERTION(type == nsIAccessibleEvent::EVENT_SHOW ||
type == nsIAccessibleEvent::EVENT_HIDE,
@ -1083,15 +1076,14 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
break;
}
case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
{
nsCOMPtr<nsIAccessibleValue> value(do_QueryObject(accessible));
if (value) { // Make sure this is a numeric value
// Don't fire for MSAA string value changes (e.g. text editing)
// ATK values are always numeric
if (accessible->HasNumericValue()) {
// Make sure this is a numeric value. Don't fire for string value changes
// (e.g. text editing) ATK values are always numeric.
g_object_notify((GObject*)atkObj, "accessible-value");
}
} break;
break;
case nsIAccessibleEvent::EVENT_SELECTION:
case nsIAccessibleEvent::EVENT_SELECTION_ADD:

View File

@ -55,11 +55,11 @@ public:
virtual void Shutdown();
// return the atk object for this AccessibleWrap
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
virtual nsresult HandleAccEvent(AccEvent* aEvent);
AtkObject * GetAtkObject(void);
static AtkObject * GetAtkObject(nsIAccessible * acc);
static AtkObject* GetAtkObject(Accessible* aAccessible);
bool IsValidObject();

View File

@ -89,16 +89,16 @@ ApplicationAccessibleWrap::Name(nsString& aName)
return eNameOK;
}
NS_IMETHODIMP
void
ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = nullptr;
if (!mAtkObject) {
mAtkObject =
reinterpret_cast<AtkObject *>
(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
reinterpret_cast<AtkObject*>(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
if (!mAtkObject)
return;
atk_object_initialize(mAtkObject, this);
mAtkObject->role = ATK_ROLE_INVALID;
@ -106,7 +106,6 @@ ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
}
*aOutAccessible = mAtkObject;
return NS_OK;
}
struct AtkRootAccessibleAddedEvent {

View File

@ -26,7 +26,7 @@ public:
/**
* Return the atk object for app root accessible.
*/
NS_IMETHOD GetNativeInterface(void** aOutAccessible);
virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -136,11 +136,10 @@ AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
}
}
NS_IMETHODIMP
void
AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = mAtkObject;
return NS_OK;
}
void

View File

@ -47,8 +47,7 @@ public:
virtual void Shutdown();
// nsIAccessible
NS_IMETHODIMP GetNativeInterface(void** aOutAccessible);
virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -39,8 +39,7 @@ getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
return nullptr;
nsAutoString description;
nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
NS_ENSURE_SUCCESS(rv, nullptr);
accWrap->ActionDescriptionAt(aActionIndex, description);
return AccessibleWrap::ReturnString(description);
}

View File

@ -83,7 +83,7 @@ getDocumentAttributesCB(AtkDocument *aDocument)
attributes = prependToList(attributes, kDocUrlName, aURL);
nsAutoString aW3CDocType;
document->GetDocType(aW3CDocType);
document->DocType(aW3CDocType);
attributes = prependToList(attributes, kDocTypeName, aW3CDocType);
nsAutoString aMimeType;
@ -102,10 +102,9 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
return nullptr;
DocAccessible* document = accWrap->AsDoc();
nsresult rv;
nsAutoString attrValue;
if (!strcasecmp(aAttrName, kDocTypeName))
rv = document->GetDocType(attrValue);
document->DocType(attrValue);
else if (!strcasecmp(aAttrName, kDocUrlName))
document->URL(attrValue);
else if (!strcasecmp(aAttrName, kMimeTypeName))
@ -113,7 +112,6 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
else
return nullptr;
NS_ENSURE_SUCCESS(rv, nullptr);
return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
}
}

View File

@ -31,8 +31,9 @@ getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
// Returned in screen coordinates
image->GetImagePosition(geckoCoordType, aAccX, aAccY);
nsIntPoint pos = image->Position(geckoCoordType);
*aAccX = pos.x;
*aAccY = pos.y;
}
static const gchar*
@ -48,10 +49,13 @@ getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
if (!accWrap || !accWrap->IsImage())
return;
accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
}
nsIntSize size = accWrap->AsImage()->Size();
*aAccWidth = size.width;
*aAccHeight = size.height;
}
} // extern "C"
void
imageInterfaceInitCB(AtkImageIface* aIface)
{

View File

@ -8,7 +8,7 @@
#include "AccessibleWrap.h"
/******************************************************************************
The following nsIAccessible states aren't translated, just ignored:
The following accessible states aren't translated, just ignored:
STATE_READONLY: Supported indirectly via EXT_STATE_EDITABLE
STATE_HOTTRACKED: No ATK equivalent. No known use case.
The nsIAccessible state is not currently supported.
@ -24,9 +24,11 @@ The following nsIAccessible states aren't translated, just ignored:
STATE_PROTECTED: The object is a password-protected edit control.
Supported via ATK_ROLE_PASSWORD_TEXT
STATE_HASPOPUP: Object displays a pop-up menu or window when invoked.
No ATK equivalent. The nsIAccessible state is not currently supported.
STATE_PINNED: The object is pinned, usually indicating it is fixed in place and has permanence.
No ATK equivalent. The nsIAccessible state is not currently supported.
No ATK equivalent. The accessible state is not
currently supported.
STATE_PINNED: The object is pinned, usually indicating it is fixed in
place and has permanence. No ATK equivalent. The
accessible state is not currently supported.
The following ATK states are not supported:
ATK_STATE_ARMED: No clear use case, used briefly when button is activated

View File

@ -30,12 +30,12 @@ static const uint32_t kGenericAccType = 0;
*
* Definition of nsRoleMapEntry contains comments explaining this table.
*
* When no nsIAccessibleRole enum mapping exists for an ARIA role, the
* role will be exposed via the object attribute "xml-roles".
* In addition, in MSAA, the unmapped role will also be exposed as a BSTR string role.
* When no Role enum mapping exists for an ARIA role, the role will be exposed
* via the object attribute "xml-roles".
*
* There are no nsIAccessibleRole enums for the following landmark roles:
* banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs
* There are no Role enums for the following landmark roles:
* banner, contentinfo, main, navigation, note, search, secondary,
* seealso, breadcrumbs.
*/
static nsRoleMapEntry sWAIRoleMaps[] =

View File

@ -21,17 +21,17 @@ class nsINode;
// Value constants
/**
* Used to define if role requires to expose nsIAccessibleValue.
* Used to define if role requires to expose Value interface.
*/
enum EValueRule
{
/**
* nsIAccessibleValue isn't exposed.
* Value interface isn't exposed.
*/
eNoValue,
/**
* nsIAccessibleValue is implemented, supports value, min and max from
* Value interface is implemented, supports value, min and max from
* aria-valuenow, aria-valuemin and aria-valuemax.
*/
eHasValueMinMax
@ -150,16 +150,16 @@ struct nsRoleMapEntry
// ARIA role: string representation such as "button"
nsIAtom** roleAtom;
// Role mapping rule: maps to this nsIAccessibleRole
// Role mapping rule: maps to enum Role
mozilla::a11y::role role;
// Role rule: whether to use mapped role or native semantics
bool roleRule;
// Value mapping rule: how to compute nsIAccessible value
// Value mapping rule: how to compute accessible value
EValueRule valueRule;
// Action mapping rule, how to expose nsIAccessible action
// Action mapping rule, how to expose accessible action
EActionRule actionRule;
// 'live' and 'container-live' object attributes mapping rule: how to expose
@ -169,11 +169,11 @@ struct nsRoleMapEntry
// Accessible types this role belongs to.
uint32_t accTypes;
// Automatic state mapping rule: always include in nsIAccessibleStates
uint64_t state; // or kNoReqStates if no nsIAccessibleStates are automatic for this role.
// Automatic state mapping rule: always include in states
uint64_t state; // or kNoReqStates if no default state for this role
// ARIA properties supported for this role
// (in other words, the aria-foo attribute to nsIAccessibleStates mapping rules)
// ARIA properties supported for this role (in other words, the aria-foo
// attribute to accessible states mapping rules).
// Currently you cannot have unlimited mappings, because
// a variable sized array would not allow the use of
// C++'s struct initialization feature.

View File

@ -10,6 +10,7 @@
#include "DocAccessible.h"
#include "xpcAccEvents.h"
#include "States.h"
#include "xpcAccessibleDocument.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/dom/Selection.h"
@ -184,7 +185,7 @@ AccTableChangeEvent::
AccVCChangeEvent::
AccVCChangeEvent(Accessible* aAccessible,
nsIAccessible* aOldAccessible,
Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
int16_t aReason, EIsFromUserInput aIsFromUserInput) :
AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
@ -210,7 +211,8 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
AccStateChangeEvent* sc = downcast_accEvent(aEvent);
bool extra = false;
uint32_t state = nsAccUtils::To32States(sc->GetState(), &extra);
xpEvent = new xpcAccStateChangeEvent(type, acc, doc, domNode, fromUser,
xpEvent = new xpcAccStateChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
domNode, fromUser,
state, extra, sc->IsStateEnabled());
return xpEvent.forget();
}
@ -219,7 +221,8 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
AccTextChangeEvent* tc = downcast_accEvent(aEvent);
nsString text;
tc->GetModifiedText(text);
xpEvent = new xpcAccTextChangeEvent(type, acc, doc, domNode, fromUser,
xpEvent = new xpcAccTextChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
domNode, fromUser,
tc->GetStartOffset(), tc->GetLength(),
tc->IsTextInserted(), text);
return xpEvent.forget();
@ -227,24 +230,28 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
if (eventGroup & (1 << AccEvent::eHideEvent)) {
AccHideEvent* hideEvent = downcast_accEvent(aEvent);
xpEvent = new xpcAccHideEvent(type, acc, doc, domNode, fromUser,
hideEvent->TargetParent(),
hideEvent->TargetNextSibling(),
hideEvent->TargetPrevSibling());
xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc),
domNode, fromUser,
ToXPC(hideEvent->TargetParent()),
ToXPC(hideEvent->TargetNextSibling()),
ToXPC(hideEvent->TargetPrevSibling()));
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eCaretMoveEvent)) {
AccCaretMoveEvent* cm = downcast_accEvent(aEvent);
xpEvent = new xpcAccCaretMoveEvent(type, acc, doc, domNode, fromUser,
xpEvent = new xpcAccCaretMoveEvent(type, ToXPC(acc), ToXPCDocument(doc),
domNode, fromUser,
cm->GetCaretOffset());
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eVirtualCursorChangeEvent)) {
AccVCChangeEvent* vcc = downcast_accEvent(aEvent);
xpEvent = new xpcAccVirtualCursorChangeEvent(type, acc, doc, domNode, fromUser,
vcc->OldAccessible(),
xpEvent = new xpcAccVirtualCursorChangeEvent(type,
ToXPC(acc), ToXPCDocument(doc),
domNode, fromUser,
ToXPC(vcc->OldAccessible()),
vcc->OldStartOffset(),
vcc->OldEndOffset(),
vcc->Reason());
@ -253,12 +260,14 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
if (eventGroup & (1 << AccEvent::eObjectAttrChangedEvent)) {
AccObjectAttrChangedEvent* oac = downcast_accEvent(aEvent);
xpEvent = new xpcAccObjectAttributeChangedEvent(type, acc, doc, domNode,
xpEvent = new xpcAccObjectAttributeChangedEvent(type,
ToXPC(acc),
ToXPCDocument(doc), domNode,
fromUser,
oac->GetAttribute());
return xpEvent.forget();
}
xpEvent = new xpcAccEvent(type, acc, doc, domNode, fromUser);
xpEvent = new xpcAccEvent(type, ToXPC(acc), ToXPCDocument(doc), domNode, fromUser);
return xpEvent.forget();
}

View File

@ -75,7 +75,7 @@ public:
eDoNotEmit
};
// Initialize with an nsIAccessible
// Initialize with an accessible.
AccEvent(uint32_t aEventType, Accessible* aAccessible,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
@ -470,7 +470,7 @@ class AccVCChangeEvent : public AccEvent
{
public:
AccVCChangeEvent(Accessible* aAccessible,
nsIAccessible* aOldAccessible,
Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
int16_t aReason,
EIsFromUserInput aIsFromUserInput = eFromUserInput);
@ -485,13 +485,13 @@ public:
}
// AccTableChangeEvent
nsIAccessible* OldAccessible() const { return mOldAccessible; }
Accessible* OldAccessible() const { return mOldAccessible; }
int32_t OldStartOffset() const { return mOldStart; }
int32_t OldEndOffset() const { return mOldEnd; }
int32_t Reason() const { return mReason; }
private:
nsRefPtr<nsIAccessible> mOldAccessible;
nsRefPtr<Accessible> mOldAccessible;
int32_t mOldStart;
int32_t mOldEnd;
int16_t mReason;

View File

@ -11,6 +11,7 @@
#include "DocAccessibleChild.h"
#include "nsAccessibilityService.h"
#include "RootAccessibleWrap.h"
#include "xpcAccessibleDocument.h"
#ifdef A11Y_LOG
#include "Logging.h"
@ -40,7 +41,7 @@ using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
DocManager::DocManager()
: mDocAccessibleCache(2)
: mDocAccessibleCache(2), mXPCDocumentCache(0)
{
}
@ -75,6 +76,34 @@ DocManager::FindAccessibleInCache(nsINode* aNode) const
return arg.mAccessible;
}
void
DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
nsIDocument* aDOMDocument)
{
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
if (xpcDoc) {
xpcDoc->Shutdown();
mXPCDocumentCache.Remove(aDocument);
}
mDocAccessibleCache.Remove(aDOMDocument);
RemoveListeners(aDOMDocument);
}
xpcAccessibleDocument*
DocManager::GetXPCDocument(DocAccessible* aDocument)
{
if (!aDocument)
return nullptr;
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
if (!xpcDoc) {
xpcDoc = new xpcAccessibleDocument(aDocument);
mXPCDocumentCache.Put(aDocument, xpcDoc);
}
return xpcDoc;
}
#ifdef DEBUG
bool
DocManager::IsProcessingRefreshDriverNotification() const

View File

@ -17,6 +17,7 @@ namespace a11y {
class Accessible;
class DocAccessible;
class xpcAccessibleDocument;
class DocAccessibleParent;
/**
@ -60,11 +61,15 @@ public:
/**
* Called by document accessible when it gets shutdown.
*/
inline void NotifyOfDocumentShutdown(nsIDocument* aDocument)
{
mDocAccessibleCache.Remove(aDocument);
RemoveListeners(aDocument);
}
void NotifyOfDocumentShutdown(DocAccessible* aDocument,
nsIDocument* aDOMDocument);
/**
* Return XPCOM accessible document.
*/
xpcAccessibleDocument* GetXPCDocument(DocAccessible* aDocument);
xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const
{ return mXPCDocumentCache.GetWeak(aDocument); }
/*
* Notification that a top level document in a content process has gone away.
@ -130,9 +135,6 @@ private:
*/
DocAccessible* CreateDocOrRootAccessible(nsIDocument* aDocument);
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
DocAccessibleHashtable;
/**
* Get first entry of the document accessible from cache.
*/
@ -163,8 +165,14 @@ private:
DocAccessible* aDocAccessible, void* aUserArg);
#endif
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
DocAccessibleHashtable;
DocAccessibleHashtable mDocAccessibleCache;
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
XPCDocumentHashtable;
XPCDocumentHashtable mXPCDocumentCache;
/*
* The list of remote top level documents.
*/

View File

@ -6,9 +6,7 @@
#ifndef _nsAccCache_H_
#define _nsAccCache_H_
#include "nsIAccessible.h"
#include "nsRefPtrHashtable.h"
#include "nsCycleCollectionParticipant.h"
#include "xpcAccessibleDocument.h"
////////////////////////////////////////////////////////////////////////////////
// Accessible cache utils
@ -38,44 +36,4 @@ ClearCache(mozilla::a11y::AccessibleHashtable& aCache)
aCache.Enumerate(ClearCacheEntry<mozilla::a11y::Accessible>, nullptr);
}
/**
* Traverse the accessible cache entry for cycle collector.
*/
template <class T>
static PLDHashOperator
CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
void *aUserArg)
{
nsCycleCollectionTraversalCallback *cb =
static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "accessible cache entry");
nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
cb->NoteXPCOMChild(supports);
return PL_DHASH_NEXT;
}
/**
* Unlink the accessible cache for the cycle collector.
*/
inline void
ImplCycleCollectionUnlink(mozilla::a11y::AccessibleHashtable& aCache)
{
ClearCache(aCache);
}
/**
* Traverse the accessible cache for cycle collector.
*/
inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
mozilla::a11y::AccessibleHashtable& aCache,
const char* aName,
uint32_t aFlags = 0)
{
aCache.EnumerateRead(CycleCollectorTraverseCacheEntry<mozilla::a11y::Accessible>,
&aCallback);
}
#endif

View File

@ -368,14 +368,7 @@ nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
}
}
if (foundText) {
// found text child node
nsCOMPtr<nsIAccessibleText> text = do_QueryObject(aAccessible);
if (!text)
return false;
}
return true;
return !foundText || aAccessible->IsHyperText();
}
#endif

View File

@ -35,6 +35,8 @@
#include "Statistics.h"
#include "TextLeafAccessibleWrap.h"
#include "TreeWalker.h"
#include "xpcAccessibleApplication.h"
#include "xpcAccessibleDocument.h"
#ifdef MOZ_ACCESSIBILITY_ATK
#include "AtkSocketAccessible.h"
@ -137,6 +139,7 @@ MustBeAccessible(nsIContent* aContent, DocAccessible* aDocument)
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nullptr;
ApplicationAccessible* nsAccessibilityService::gApplicationAccessible = nullptr;
xpcAccessibleApplication* nsAccessibilityService::gXPCApplicationAccessible = nullptr;
bool nsAccessibilityService::gIsShutdown = true;
nsAccessibilityService::nsAccessibilityService() :
@ -556,8 +559,7 @@ nsAccessibilityService::GetApplicationAccessible(nsIAccessible** aAccessibleAppl
{
NS_ENSURE_ARG_POINTER(aAccessibleApplication);
NS_IF_ADDREF(*aAccessibleApplication = ApplicationAcc());
NS_IF_ADDREF(*aAccessibleApplication = XPCApplicationAcc());
return NS_OK;
}
@ -576,7 +578,7 @@ nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
DocAccessible* document = GetDocAccessible(node->OwnerDoc());
if (document)
NS_IF_ADDREF(*aAccessible = document->GetAccessible(node));
NS_IF_ADDREF(*aAccessible = ToXPC(document->GetAccessible(node)));
return NS_OK;
}
@ -780,7 +782,7 @@ nsAccessibilityService::GetAccessibleFromCache(nsIDOMNode* aNode,
accessible = GetExistingDocAccessible(document);
}
NS_IF_ADDREF(*aAccessible = accessible);
NS_IF_ADDREF(*aAccessible = ToXPC(accessible));
return NS_OK;
}
@ -792,7 +794,7 @@ nsAccessibilityService::CreateAccessiblePivot(nsIAccessible* aRoot,
NS_ENSURE_ARG(aRoot);
*aPivot = nullptr;
nsRefPtr<Accessible> accessibleRoot(do_QueryObject(aRoot));
Accessible* accessibleRoot = aRoot->ToInternalAccessible();
NS_ENSURE_TRUE(accessibleRoot, NS_ERROR_INVALID_ARG);
nsAccessiblePivot* pivot = new nsAccessiblePivot(accessibleRoot);
@ -1179,6 +1181,9 @@ nsAccessibilityService::Shutdown()
gApplicationAccessible->Shutdown();
NS_RELEASE(gApplicationAccessible);
gApplicationAccessible = nullptr;
NS_IF_RELEASE(gXPCApplicationAccessible);
gXPCApplicationAccessible = nullptr;
}
already_AddRefed<Accessible>
@ -1666,6 +1671,20 @@ nsAccessibilityService::RemoveNativeRootAccessible(Accessible* aAccessible)
#endif
}
bool
nsAccessibilityService::HasAccessible(nsIDOMNode* aDOMNode)
{
nsCOMPtr<nsINode> node(do_QueryInterface(aDOMNode));
if (!node)
return false;
DocAccessible* document = GetDocAccessible(node->OwnerDoc());
if (!document)
return false;
return document->HasAccessible(node);
}
////////////////////////////////////////////////////////////////////////////////
// NS_GetAccessibilityService
////////////////////////////////////////////////////////////////////////////////
@ -1760,6 +1779,19 @@ ApplicationAcc()
return nsAccessibilityService::gApplicationAccessible;
}
xpcAccessibleApplication*
XPCApplicationAcc()
{
if (!nsAccessibilityService::gXPCApplicationAccessible &&
nsAccessibilityService::gApplicationAccessible) {
nsAccessibilityService::gXPCApplicationAccessible =
new xpcAccessibleApplication(nsAccessibilityService::gApplicationAccessible);
NS_ADDREF(nsAccessibilityService::gXPCApplicationAccessible);
}
return nsAccessibilityService::gXPCApplicationAccessible;
}
EPlatformDisabledState
PlatformDisabledState()
{

View File

@ -22,6 +22,7 @@ namespace mozilla {
namespace a11y {
class ApplicationAccessible;
class xpcAccessibleApplication;
/**
* Return focus manager.
@ -37,6 +38,7 @@ SelectionManager* SelectionMgr();
* Returns the application accessible.
*/
ApplicationAccessible* ApplicationAcc();
xpcAccessibleApplication* XPCApplicationAcc();
} // namespace a11y
} // namespace mozilla
@ -73,6 +75,9 @@ public:
virtual Accessible* AddNativeRootAccessible(void* aAtkAccessible);
virtual void RemoveNativeRootAccessible(Accessible* aRootAccessible);
virtual bool HasAccessible(nsIDOMNode* aDOMNode) MOZ_OVERRIDE;
// nsAccesibilityService
/**
* Notification used to update the accessible tree when deck panel is
* switched.
@ -215,6 +220,7 @@ private:
* Reference for application accessible instance.
*/
static mozilla::a11y::ApplicationAccessible* gApplicationAccessible;
static mozilla::a11y::xpcAccessibleApplication* gXPCApplicationAccessible;
/**
* Indicates whether accessibility service was shutdown.
@ -225,6 +231,7 @@ private:
friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr();
friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc();
friend mozilla::a11y::xpcAccessibleApplication* mozilla::a11y::XPCApplicationAcc();
friend nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult);
};

View File

@ -9,6 +9,7 @@
#include "HyperTextAccessible.h"
#include "nsAccUtils.h"
#include "States.h"
#include "xpcAccessibleDocument.h"
using namespace mozilla::a11y;
@ -70,7 +71,7 @@ nsAccessiblePivot::GetRoot(nsIAccessible** aRoot)
{
NS_ENSURE_ARG_POINTER(aRoot);
NS_IF_ADDREF(*aRoot = mRoot);
NS_IF_ADDREF(*aRoot = ToXPC(mRoot));
return NS_OK;
}
@ -80,7 +81,7 @@ nsAccessiblePivot::GetPosition(nsIAccessible** aPosition)
{
NS_ENSURE_ARG_POINTER(aPosition);
NS_IF_ADDREF(*aPosition = mPosition);
NS_IF_ADDREF(*aPosition = ToXPC(mPosition));
return NS_OK;
}
@ -88,19 +89,19 @@ nsAccessiblePivot::GetPosition(nsIAccessible** aPosition)
NS_IMETHODIMP
nsAccessiblePivot::SetPosition(nsIAccessible* aPosition)
{
nsRefPtr<Accessible> secondPosition;
nsRefPtr<Accessible> position = nullptr;
if (aPosition) {
secondPosition = do_QueryObject(aPosition);
if (!secondPosition || !IsDescendantOf(secondPosition, GetActiveRoot()))
position = aPosition->ToInternalAccessible();
if (!position || !IsDescendantOf(position, GetActiveRoot()))
return NS_ERROR_INVALID_ARG;
}
// Swap old position with new position, saves us an AddRef/Release.
mPosition.swap(secondPosition);
mPosition.swap(position);
int32_t oldStart = mStartOffset, oldEnd = mEndOffset;
mStartOffset = mEndOffset = -1;
NotifyOfPivotChange(secondPosition, oldStart, oldEnd,
NotifyOfPivotChange(position, oldStart, oldEnd,
nsIAccessiblePivot::REASON_NONE, false);
return NS_OK;
@ -111,7 +112,7 @@ nsAccessiblePivot::GetModalRoot(nsIAccessible** aModalRoot)
{
NS_ENSURE_ARG_POINTER(aModalRoot);
NS_IF_ADDREF(*aModalRoot = mModalRoot);
NS_IF_ADDREF(*aModalRoot = ToXPC(mModalRoot));
return NS_OK;
}
@ -119,16 +120,15 @@ nsAccessiblePivot::GetModalRoot(nsIAccessible** aModalRoot)
NS_IMETHODIMP
nsAccessiblePivot::SetModalRoot(nsIAccessible* aModalRoot)
{
nsRefPtr<Accessible> modalRoot;
Accessible* modalRoot = nullptr;
if (aModalRoot) {
modalRoot = do_QueryObject(aModalRoot);
modalRoot = aModalRoot->ToInternalAccessible();
if (!modalRoot || !IsDescendantOf(modalRoot, mRoot))
return NS_ERROR_INVALID_ARG;
}
mModalRoot.swap(modalRoot);
mModalRoot = modalRoot;
return NS_OK;
}
@ -165,28 +165,26 @@ nsAccessiblePivot::SetTextRange(nsIAccessibleText* aTextAccessible,
(aStartOffset >= 0 || (aStartOffset != -1 && aEndOffset != -1)),
NS_ERROR_INVALID_ARG);
nsRefPtr<Accessible> acc(do_QueryObject(aTextAccessible));
if (!acc)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIAccessible> xpcAcc = do_QueryInterface(aTextAccessible);
NS_ENSURE_ARG(xpcAcc);
HyperTextAccessible* newPosition = acc->AsHyperText();
if (!newPosition || !IsDescendantOf(newPosition, GetActiveRoot()))
nsRefPtr<Accessible> acc = xpcAcc->ToInternalAccessible();
NS_ENSURE_ARG(acc);
HyperTextAccessible* position = acc->AsHyperText();
if (!position || !IsDescendantOf(position, GetActiveRoot()))
return NS_ERROR_INVALID_ARG;
// Make sure the given offsets don't exceed the character count.
int32_t charCount = newPosition->CharacterCount();
if (aEndOffset > charCount)
if (aEndOffset > static_cast<int32_t>(position->CharacterCount()))
return NS_ERROR_FAILURE;
int32_t oldStart = mStartOffset, oldEnd = mEndOffset;
mStartOffset = aStartOffset;
mEndOffset = aEndOffset;
nsRefPtr<Accessible> oldPosition = mPosition.forget();
mPosition = newPosition;
NotifyOfPivotChange(oldPosition, oldStart, oldEnd,
mPosition.swap(acc);
NotifyOfPivotChange(acc, oldStart, oldEnd,
nsIAccessiblePivot::REASON_TEXT,
(aArgc > 0) ? aIsFromUserInput : true);
@ -202,13 +200,13 @@ nsAccessiblePivot::MoveNext(nsIAccessibleTraversalRule* aRule,
{
NS_ENSURE_ARG(aResult);
NS_ENSURE_ARG(aRule);
*aResult = false;
Accessible* root = GetActiveRoot();
nsRefPtr<Accessible> anchor =
(aArgc > 0) ? do_QueryObject(aAnchor) : mPosition;
if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, root)))
Accessible* anchor = mPosition;
if (aArgc > 0 && aAnchor)
anchor = aAnchor->ToInternalAccessible();
if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, GetActiveRoot())))
return NS_ERROR_NOT_IN_TREE;
nsresult rv = NS_OK;
@ -231,13 +229,13 @@ nsAccessiblePivot::MovePrevious(nsIAccessibleTraversalRule* aRule,
{
NS_ENSURE_ARG(aResult);
NS_ENSURE_ARG(aRule);
*aResult = false;
Accessible* root = GetActiveRoot();
nsRefPtr<Accessible> anchor =
(aArgc > 0) ? do_QueryObject(aAnchor) : mPosition;
if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, root)))
Accessible* anchor = mPosition;
if (aArgc > 0 && aAnchor)
anchor = aAnchor->ToInternalAccessible();
if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, GetActiveRoot())))
return NS_ERROR_NOT_IN_TREE;
nsresult rv = NS_OK;
@ -855,10 +853,11 @@ nsAccessiblePivot::NotifyOfPivotChange(Accessible* aOldPosition,
aOldStart == mStartOffset && aOldEnd == mEndOffset)
return false;
nsCOMPtr<nsIAccessible> xpcOldPos = ToXPC(aOldPosition); // death grip
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> >::ForwardIterator iter(mObservers);
while (iter.HasMore()) {
nsIAccessiblePivotObserver* obs = iter.GetNext();
obs->OnPivotChanged(this, aOldPosition, aOldStart, aOldEnd, aReason,
obs->OnPivotChanged(this, xpcOldPos, aOldStart, aOldEnd, aReason,
aIsFromUserInput);
}
@ -925,5 +924,5 @@ RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult)
return NS_OK;
}
return mRule->Match(aAccessible, aResult);
return mRule->Match(ToXPC(aAccessible), aResult);
}

View File

@ -28,29 +28,14 @@ using namespace mozilla::a11y;
ARIAGridAccessible::
ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
AccessibleWrap(aContent, aDoc)
{
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(ARIAGridAccessible,
Accessible,
nsIAccessibleTable)
NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// Accessible
void
ARIAGridAccessible::Shutdown()
{
mTable = nullptr;
AccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTable
// Table
uint32_t
ARIAGridAccessible::ColCount()
@ -405,28 +390,6 @@ ARIAGridAccessible::UnselectCol(uint32_t aColIdx)
////////////////////////////////////////////////////////////////////////////////
// Protected
bool
ARIAGridAccessible::IsValidRow(int32_t aRow)
{
if (aRow < 0)
return false;
int32_t rowCount = 0;
GetRowCount(&rowCount);
return aRow < rowCount;
}
bool
ARIAGridAccessible::IsValidColumn(int32_t aColumn)
{
if (aColumn < 0)
return false;
int32_t colCount = 0;
GetColumnCount(&colCount);
return aColumn < colCount;
}
Accessible*
ARIAGridAccessible::GetRowAt(int32_t aRow)
{
@ -532,20 +495,15 @@ ARIAGridAccessible::SetARIASelected(Accessible* aAccessible,
ARIAGridCellAccessible::
ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
HyperTextAccessibleWrap(aContent, aDoc)
{
mGenericTypes |= eTableCell;
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(ARIAGridCellAccessible,
HyperTextAccessible,
nsIAccessibleTableCell)
NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridCellAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTableCell
// TableCell
TableAccessible*
ARIAGridCellAccessible::Table() const
@ -648,10 +606,3 @@ ARIAGridCellAccessible::NativeAttributes()
return attributes.forget();
}
void
ARIAGridCellAccessible::Shutdown()
{
mTableCell = nullptr;
HyperTextAccessibleWrap::Shutdown();
}

View File

@ -6,13 +6,9 @@
#ifndef MOZILLA_A11Y_ARIAGridAccessible_h_
#define MOZILLA_A11Y_ARIAGridAccessible_h_
#include "nsIAccessibleTable.h"
#include "HyperTextAccessibleWrap.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "xpcAccessibleTable.h"
#include "xpcAccessibleTableCell.h"
namespace mozilla {
namespace a11y {
@ -21,22 +17,15 @@ namespace a11y {
* Accessible for ARIA grid and treegrid.
*/
class ARIAGridAccessible : public AccessibleWrap,
public xpcAccessibleTable,
public nsIAccessibleTable,
public TableAccessible
{
public:
ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTable
NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
// Accessible
virtual TableAccessible* AsTable() { return this; }
virtual void Shutdown();
// TableAccessible
virtual uint32_t ColCount();
@ -61,16 +50,6 @@ public:
protected:
virtual ~ARIAGridAccessible() {}
/**
* Return true if the given row index is valid.
*/
bool IsValidRow(int32_t aRow);
/**
* Retrn true if the given column index is valid.
*/
bool IsValidColumn(int32_t aColumn);
/**
* Return row accessible at the given row index.
*/
@ -98,22 +77,15 @@ protected:
* Accessible for ARIA gridcell and rowheader/columnheader.
*/
class ARIAGridCellAccessible : public HyperTextAccessibleWrap,
public nsIAccessibleTableCell,
public TableCellAccessible,
public xpcAccessibleTableCell
public TableCellAccessible
{
public:
ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTableCell
NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
virtual void Shutdown();
virtual void ApplyARIAState(uint64_t* aState) const;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;

View File

@ -94,14 +94,10 @@ NS_IMPL_CYCLE_COLLECTION(Accessible,
mContent, mParent, mChildren)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Accessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessible)
if (aIID.Equals(NS_GET_IID(Accessible)))
foundInterface = static_cast<nsIAccessible*>(this);
foundInterface = this;
else
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleSelectable, IsSelect())
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleValue, HasNumericValue())
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperLink, IsLink())
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessible)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, Accessible)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(Accessible)
@ -925,7 +921,7 @@ Accessible::NativeAttributes()
// documents, or text in an input.
if (HasNumericValue()) {
nsAutoString valuetext;
GetValue(valuetext);
Value(valuetext);
attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext,
unused);
}
@ -1718,10 +1714,9 @@ Accessible::RelationByType(RelationType aType)
}
}
/* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
NS_IMETHODIMP Accessible::GetNativeInterface(void **aOutAccessible)
void
Accessible::GetNativeInterface(void** aNativeAccessible)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
void
@ -2204,19 +2199,13 @@ Accessible::AnchorURIAt(uint32_t aAnchorIndex)
////////////////////////////////////////////////////////////////////////////////
// SelectAccessible
already_AddRefed<nsIArray>
Accessible::SelectedItems()
void
Accessible::SelectedItems(nsTArray<Accessible*>* aItems)
{
nsCOMPtr<nsIMutableArray> selectedItems = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (!selectedItems)
return nullptr;
AccIterator iter(this, filters::GetSelected);
nsIAccessible* selected = nullptr;
Accessible* selected = nullptr;
while ((selected = iter.Next()))
selectedItems->AppendElement(selected, false);
return selectedItems.forget();
aItems->AppendElement(selected);
}
uint32_t

View File

@ -11,12 +11,6 @@
#include "mozilla/a11y/Role.h"
#include "mozilla/a11y/States.h"
#include "xpcAccessible.h"
#include "xpcAccessibleHyperLink.h"
#include "nsIAccessibleStates.h"
#include "xpcAccessibleSelectable.h"
#include "xpcAccessibleValue.h"
#include "nsIContent.h"
#include "nsString.h"
#include "nsTArray.h"
@ -28,6 +22,7 @@ struct nsRect;
class nsIFrame;
class nsIAtom;
struct nsIntRect;
class nsIPersistentProperties;
class nsView;
namespace mozilla {
@ -36,6 +31,7 @@ namespace a11y {
class Accessible;
class AccEvent;
class AccGroupInfo;
class ApplicationAccessible;
class DocAccessible;
class EmbeddedObjCollector;
class HTMLImageMapAccessible;
@ -123,22 +119,16 @@ typedef nsRefPtrHashtable<nsPtrHashKey<const void>, Accessible>
{ 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad } \
}
class Accessible : public xpcAccessible,
public xpcAccessibleHyperLink,
public xpcAccessibleSelectable,
public xpcAccessibleValue
class Accessible : public nsISupports
{
public:
Accessible(nsIContent* aContent, DocAccessible* aDoc);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
NS_DECL_CYCLE_COLLECTION_CLASS(Accessible)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
// nsIAccessible
NS_IMETHOD GetNativeInterface(void** aOutAccessible);
//////////////////////////////////////////////////////////////////////////////
// Public methods
@ -194,6 +184,11 @@ public:
*/
virtual void Value(nsString& aValue);
/**
* Get help string for the accessible.
*/
void Help(nsString& aHelp) const { aHelp.Truncate(); }
/**
* Get the name of this accessible.
*
@ -533,6 +528,11 @@ public:
*/
virtual void SetSelected(bool aSelect);
/**
* Extend selection to this accessible.
*/
void ExtendSelection() { };
/**
* Select the accessible within its container.
*/
@ -553,6 +553,12 @@ public:
*/
void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
/**
* Get a pointer to accessibility interface for this node, which is specific
* to the OS/accessibility toolkit we're running on.
*/
virtual void GetNativeInterface(void** aNativeAccessible);
//////////////////////////////////////////////////////////////////////////////
// Downcasting and types
@ -563,6 +569,7 @@ public:
}
bool IsApplication() const { return mType == eApplicationType; }
ApplicationAccessible* AsApplication();
bool IsAutoComplete() const { return HasGenericType(eAutoComplete); }
@ -734,7 +741,7 @@ public:
/**
* Return an array of selected items.
*/
virtual already_AddRefed<nsIArray> SelectedItems();
virtual void SelectedItems(nsTArray<Accessible*>* aItems);
/**
* Return the number of selected items.

View File

@ -30,11 +30,7 @@ ApplicationAccessible::ApplicationAccessible() :
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(ApplicationAccessible, Accessible,
nsIAccessibleApplication)
NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible

View File

@ -9,7 +9,6 @@
#define mozilla_a11y_ApplicationAccessible_h__
#include "AccessibleWrap.h"
#include "xpcAccessibleApplication.h"
#include "nsIMutableArray.h"
#include "nsIXULAppInfo.h"
@ -27,14 +26,12 @@ namespace a11y {
* the ApplicationAccessible instance.
*/
class ApplicationAccessible : public AccessibleWrap,
public xpcAccessibleApplication
class ApplicationAccessible : public AccessibleWrap
{
public:
ApplicationAccessible();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// Accessible
@ -99,6 +96,12 @@ private:
nsCOMPtr<nsIXULAppInfo> mAppInfo;
};
inline ApplicationAccessible*
Accessible::AsApplication()
{
return IsApplication() ? static_cast<ApplicationAccessible*>(this) : nullptr;
}
} // namespace a11y
} // namespace mozilla

View File

@ -169,8 +169,7 @@ already_AddRefed<nsIURI>
LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex)
{
if (mIsLink) {
NS_ASSERTION(mActionAcc->IsLink(),
"nsIAccessibleHyperLink isn't implemented.");
NS_ASSERTION(mActionAcc->IsLink(), "HyperLink isn't implemented.");
if (mActionAcc->IsLink())
return mActionAcc->AnchorURIAt(aAnchorIndex);

View File

@ -118,14 +118,17 @@ protected:
class DummyAccessible : public AccessibleWrap
{
public:
DummyAccessible() : AccessibleWrap(nullptr, nullptr) { }
virtual ~DummyAccessible() { }
DummyAccessible(DocAccessible* aDocument = nullptr) :
AccessibleWrap(nullptr, aDocument) { }
virtual uint64_t NativeState() MOZ_OVERRIDE MOZ_FINAL;
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE MOZ_FINAL;
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE MOZ_FINAL;
virtual bool NativelyUnavailable() const MOZ_OVERRIDE MOZ_FINAL;
virtual void ApplyARIAState(uint64_t* aState) const MOZ_OVERRIDE MOZ_FINAL;
protected:
virtual ~DummyAccessible() { }
};
} // namespace a11y

View File

@ -16,6 +16,7 @@
#include "Role.h"
#include "RootAccessible.h"
#include "TreeWalker.h"
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsICommandManager.h"
@ -76,7 +77,7 @@ static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);
DocAccessible::
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell) :
HyperTextAccessibleWrap(aRootContent, this), xpcAccessibleDocument(),
HyperTextAccessibleWrap(aRootContent, this),
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessibleCache(kDefaultCacheLength),
mNodeToAccessibleMap(kDefaultCacheLength),
@ -128,33 +129,12 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DocAccessible, Accessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DocAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIAccessiblePivotObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleDocument)
foundInterface = 0;
nsresult status;
if (!foundInterface) {
// HTML document accessible must inherit from HyperTextAccessible to get
// support text interfaces. XUL document accessible doesn't need this.
// However at some point we may push <body> to implement the interfaces and
// return DocAccessible to inherit from AccessibleWrap.
status = IsHyperText() ?
HyperTextAccessible::QueryInterface(aIID, (void**)&foundInterface) :
Accessible::QueryInterface(aIID, (void**)&foundInterface);
} else {
NS_ADDREF(foundInterface);
status = NS_OK;
}
*aInstancePtr = foundInterface;
return status;
}
NS_INTERFACE_MAP_END_INHERITING(HyperTextAccessible)
NS_IMPL_ADDREF_INHERITED(DocAccessible, HyperTextAccessible)
NS_IMPL_RELEASE_INHERITED(DocAccessible, HyperTextAccessible)
@ -500,7 +480,7 @@ DocAccessible::Shutdown()
HyperTextAccessibleWrap::Shutdown();
GetAccService()->NotifyOfDocumentShutdown(kungFuDeathGripDoc);
GetAccService()->NotifyOfDocumentShutdown(this, kungFuDeathGripDoc);
}
nsIFrame*
@ -690,8 +670,10 @@ DocAccessible::OnPivotChanged(nsIAccessiblePivot* aPivot,
PivotMoveReason aReason,
bool aIsFromUserInput)
{
nsRefPtr<AccEvent> event = new AccVCChangeEvent(
this, aOldAccessible, aOldStart, aOldEnd, aReason,
nsRefPtr<AccEvent> event =
new AccVCChangeEvent(
this, (aOldAccessible ? aOldAccessible->ToInternalAccessible() : nullptr),
aOldStart, aOldEnd, aReason,
aIsFromUserInput ? eFromUserInput : eNoUserInput);
nsEventShell::FireEvent(event);
@ -1265,6 +1247,11 @@ DocAccessible::UnbindFromDocument(Accessible* aAccessible)
mNodeToAccessibleMap.Get(aAccessible->GetNode()) == aAccessible)
mNodeToAccessibleMap.Remove(aAccessible->GetNode());
// Update XPCOM part.
xpcAccessibleDocument* xpcDoc = GetAccService()->GetCachedXPCDocument(this);
if (xpcDoc)
xpcDoc->NotifyOfShutdown(aAccessible);
void* uniqueID = aAccessible->UniqueID();
NS_ASSERTION(!aAccessible->IsDefunct(), "Shutdown the shutdown accessible!");

View File

@ -6,7 +6,6 @@
#ifndef mozilla_a11y_DocAccessible_h__
#define mozilla_a11y_DocAccessible_h__
#include "xpcAccessibleDocument.h"
#include "nsIAccessiblePivot.h"
#include "AccEvent.h"
@ -39,7 +38,6 @@ template<class Class, class Arg>
class TNotification;
class DocAccessible : public HyperTextAccessibleWrap,
public xpcAccessibleDocument,
public nsIDocumentObserver,
public nsIObserver,
public nsIScrollPositionListener,
@ -50,7 +48,6 @@ class DocAccessible : public HyperTextAccessibleWrap,
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocAccessible, Accessible)
NS_DECL_NSIOBSERVER
NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
public:

View File

@ -22,20 +22,6 @@ using namespace mozilla::a11y;
template class mozilla::a11y::ProgressMeterAccessible<1>;
template class mozilla::a11y::ProgressMeterAccessible<100>;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
template<int Max>
NS_IMPL_ADDREF_INHERITED(ProgressMeterAccessible<Max>, LeafAccessible)
template<int Max>
NS_IMPL_RELEASE_INHERITED(ProgressMeterAccessible<Max>, LeafAccessible)
template<int Max>
NS_IMPL_QUERY_INTERFACE_INHERITED(ProgressMeterAccessible<Max>,
LeafAccessible,
nsIAccessibleValue)
////////////////////////////////////////////////////////////////////////////////
// Accessible
@ -73,7 +59,7 @@ ProgressMeterAccessible<Max>::IsWidget() const
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleValue
// ProgressMeterAccessible<Max>: Value
template<int Max>
void

View File

@ -27,8 +27,6 @@ public:
mType = eProgressType;
}
NS_DECL_ISUPPORTS_INHERITED
// Accessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;

View File

@ -48,19 +48,12 @@ using namespace mozilla::a11y;
HyperTextAccessible::
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
AccessibleWrap(aNode, aDoc), xpcAccessibleHyperText()
AccessibleWrap(aNode, aDoc)
{
mGenericTypes |= eHyperText;
}
nsresult
HyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
xpcAccessibleHyperText::QueryInterface(aIID, aInstancePtr);
return *aInstancePtr ? NS_OK : Accessible::QueryInterface(aIID, aInstancePtr);
}
NS_IMPL_ADDREF_INHERITED(HyperTextAccessible, AccessibleWrap)
NS_IMPL_RELEASE_INHERITED(HyperTextAccessible, AccessibleWrap)
NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessible, Accessible)
role
HyperTextAccessible::NativeRole()
@ -649,12 +642,12 @@ HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
adjustedOffset = AdjustCaretOffset(adjustedOffset);
switch (aBoundaryType) {
case BOUNDARY_CHAR:
case nsIAccessibleText::BOUNDARY_CHAR:
if (convertedOffset != 0)
CharAt(convertedOffset - 1, aText, aStartOffset, aEndOffset);
break;
case BOUNDARY_WORD_START: {
case nsIAccessibleText::BOUNDARY_WORD_START: {
// If the offset is a word start (except text length offset) then move
// backward to find a start offset (end offset is the given offset).
// Otherwise move backward twice to find both start and end offsets.
@ -673,7 +666,7 @@ HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
break;
}
case BOUNDARY_WORD_END: {
case nsIAccessibleText::BOUNDARY_WORD_END: {
// Move word backward twice to find start and end offsets.
*aEndOffset = FindWordBoundary(convertedOffset, eDirPrevious, eEndWord);
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
@ -681,13 +674,13 @@ HyperTextAccessible::TextBeforeOffset(int32_t aOffset,
break;
}
case BOUNDARY_LINE_START:
case nsIAccessibleText::BOUNDARY_LINE_START:
*aStartOffset = FindLineBoundary(adjustedOffset, ePrevLineBegin);
*aEndOffset = FindLineBoundary(adjustedOffset, eThisLineBegin);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_LINE_END: {
case nsIAccessibleText::BOUNDARY_LINE_END: {
*aEndOffset = FindLineBoundary(adjustedOffset, ePrevLineEnd);
int32_t tmpOffset = *aEndOffset;
// Adjust offset if line is wrapped.
@ -717,7 +710,7 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
}
switch (aBoundaryType) {
case BOUNDARY_CHAR:
case nsIAccessibleText::BOUNDARY_CHAR:
// Return no char if caret is at the end of wrapped line (case of no line
// end character). Returning a next line char is confusing for AT.
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET && IsCaretAtEndOfLine())
@ -726,7 +719,7 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
CharAt(adjustedOffset, aText, aStartOffset, aEndOffset);
break;
case BOUNDARY_WORD_START:
case nsIAccessibleText::BOUNDARY_WORD_START:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
@ -735,7 +728,7 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_WORD_END:
case nsIAccessibleText::BOUNDARY_WORD_END:
// Ignore the spec and follow what WebKitGtk does because Orca expects it,
// i.e. return a next word at word end offset of the current word
// (WebKitGtk behavior) instead the current word (AKT spec).
@ -744,7 +737,7 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_LINE_START:
case nsIAccessibleText::BOUNDARY_LINE_START:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
@ -753,7 +746,7 @@ HyperTextAccessible::TextAtOffset(int32_t aOffset,
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_LINE_END:
case nsIAccessibleText::BOUNDARY_LINE_END:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
@ -785,7 +778,7 @@ HyperTextAccessible::TextAfterOffset(int32_t aOffset,
adjustedOffset = AdjustCaretOffset(adjustedOffset);
switch (aBoundaryType) {
case BOUNDARY_CHAR:
case nsIAccessibleText::BOUNDARY_CHAR:
// If caret is at the end of wrapped line (case of no line end character)
// then char after the offset is a first char at next line.
if (adjustedOffset >= CharacterCount())
@ -794,14 +787,14 @@ HyperTextAccessible::TextAfterOffset(int32_t aOffset,
CharAt(adjustedOffset + 1, aText, aStartOffset, aEndOffset);
break;
case BOUNDARY_WORD_START:
case nsIAccessibleText::BOUNDARY_WORD_START:
// Move word forward twice to find start and end offsets.
*aStartOffset = FindWordBoundary(adjustedOffset, eDirNext, eStartWord);
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_WORD_END:
case nsIAccessibleText::BOUNDARY_WORD_END:
// If the offset is a word end (except 0 offset) then move forward to find
// end offset (start offset is the given offset). Otherwise move forward
// twice to find both start and end offsets.
@ -819,13 +812,13 @@ HyperTextAccessible::TextAfterOffset(int32_t aOffset,
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_LINE_START:
case nsIAccessibleText::BOUNDARY_LINE_START:
*aStartOffset = FindLineBoundary(adjustedOffset, eNextLineBegin);
*aEndOffset = FindLineBoundary(*aStartOffset, eNextLineBegin);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
case BOUNDARY_LINE_END:
case nsIAccessibleText::BOUNDARY_LINE_END:
*aStartOffset = FindLineBoundary(adjustedOffset, eThisLineEnd);
*aEndOffset = FindLineBoundary(adjustedOffset, eNextLineEnd);
TextSubstring(*aStartOffset, *aEndOffset, aText);

View File

@ -7,8 +7,8 @@
#define mozilla_a11y_HyperTextAccessible_h__
#include "AccessibleWrap.h"
#include "nsIAccessibleText.h"
#include "nsIAccessibleTypes.h"
#include "xpcAccessibleHyperText.h"
#include "nsDirection.h"
#include "WordMovementType.h"
#include "nsIFrame.h"
@ -37,7 +37,7 @@ struct DOMPoint {
int32_t idx;
};
// This character marks where in the text returned via nsIAccessibleText(),
// This character marks where in the text returned via Text interface,
// that embedded object characters exist
const char16_t kEmbeddedObjectChar = 0xfffc;
const char16_t kImaginaryEmbeddedObjectChar = ' ';
@ -46,8 +46,7 @@ const char16_t kForcedNewLineChar = '\n';
/**
* Special Accessible that knows how contain both text and embedded objects
*/
class HyperTextAccessible : public AccessibleWrap,
public xpcAccessibleHyperText
class HyperTextAccessible : public AccessibleWrap
{
public:
HyperTextAccessible(nsIContent* aContent, DocAccessible* aDoc);

View File

@ -39,9 +39,6 @@ ImageAccessible::~ImageAccessible()
{
}
NS_IMPL_ISUPPORTS_INHERITED(ImageAccessible, Accessible,
nsIAccessibleImage)
////////////////////////////////////////////////////////////////////////////////
// Accessible public
@ -100,7 +97,7 @@ ImageAccessible::NativeRole()
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
// Accessible
uint8_t
ImageAccessible::ActionCount()

View File

@ -7,7 +7,6 @@
#define mozilla_a11y_ImageAccessible_h__
#include "BaseAccessibles.h"
#include "xpcAccessibleImage.h"
class nsGenericHTMLElement;
@ -19,15 +18,11 @@ namespace a11y {
* - gets name, role
* - support basic state
*/
class ImageAccessible : public LinkableAccessible,
public xpcAccessibleImage
class ImageAccessible : public LinkableAccessible
{
public:
ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// Accessible
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;

View File

@ -25,7 +25,6 @@
#include "mozilla/dom/Element.h"
#include "nsIAccessibleRelation.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
#include "mozilla/dom/Event.h"
@ -53,7 +52,7 @@ using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(RootAccessible, DocAccessible, nsIAccessibleDocument)
NS_IMPL_ISUPPORTS_INHERITED0(RootAccessible, DocAccessible)
////////////////////////////////////////////////////////////////////////////////
// Constructor/destructor
@ -477,7 +476,6 @@ RootAccessible::Shutdown()
DocAccessibleWrap::Shutdown();
}
// nsIAccessible method
Relation
RootAccessible::RelationByType(RelationType aType)
{

View File

@ -7,7 +7,6 @@
#include "DocAccessible.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
#include "nsIPersistentProperties2.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"

View File

@ -15,7 +15,6 @@
#include "nsContentList.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "nsIAccessibleRelation.h"
#include "nsIDOMNSEditableElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIEditor.h"
@ -284,10 +283,8 @@ HTMLTextFieldAccessible::
mType = eHTMLTextFieldType;
}
NS_IMPL_ISUPPORTS_INHERITED(HTMLTextFieldAccessible,
Accessible,
nsIAccessibleText,
nsIAccessibleEditableText)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLTextFieldAccessible,
HyperTextAccessible)
role
HTMLTextFieldAccessible::NativeRole()

View File

@ -175,7 +175,7 @@ HTMLAreaAccessible::
}
////////////////////////////////////////////////////////////////////////////////
// HTMLAreaAccessible: nsIAccessible
// HTMLAreaAccessible: Accessible
ENameValueFlag
HTMLAreaAccessible::NativeName(nsString& aName)
@ -185,7 +185,7 @@ HTMLAreaAccessible::NativeName(nsString& aName)
return nameFlag;
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
GetValue(aName);
Value(aName);
return eNameOK;
}

View File

@ -27,9 +27,7 @@ HTMLLinkAccessible::
{
}
// Expose nsIAccessibleHyperLink unconditionally
NS_IMPL_ISUPPORTS_INHERITED(HTMLLinkAccessible, HyperTextAccessibleWrap,
nsIAccessibleHyperLink)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLLinkAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible

View File

@ -10,7 +10,6 @@
#include "nsAccUtils.h"
#include "DocAccessible.h"
#include "nsEventShell.h"
#include "nsIAccessibleEvent.h"
#include "nsTextEquivUtils.h"
#include "Role.h"
#include "States.h"
@ -393,8 +392,7 @@ HTMLComboboxAccessible::CacheChildren()
return;
if (!mListAccessible) {
mListAccessible =
new HTMLComboboxListAccessible(mParent, mContent, mDoc);
mListAccessible = new HTMLComboboxListAccessible(mParent, mContent, mDoc);
// Initialize and put into cache.
Document()->BindToDocument(mListAccessible, nullptr);
@ -559,7 +557,7 @@ HTMLComboboxAccessible::SelectedOption() const
////////////////////////////////////////////////////////////////////////////////
HTMLComboboxListAccessible::
HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
DocAccessible* aDoc) :
HTMLSelectListAccessible(aContent, aDoc)
{

View File

@ -209,7 +209,7 @@ class HTMLComboboxListAccessible : public HTMLSelectListAccessible
{
public:
HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
DocAccessible* aDoc);
virtual ~HTMLComboboxListAccessible() {}

View File

@ -11,7 +11,6 @@
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "DocAccessible.h"
#include "nsIAccessibleRelation.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
#include "Role.h"
@ -47,28 +46,16 @@ using namespace mozilla::a11y;
HTMLTableCellAccessible::
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
HyperTextAccessibleWrap(aContent, aDoc)
{
mGenericTypes |= eTableCell;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessible: nsISupports implementation
NS_IMPL_ISUPPORTS_INHERITED(HTMLTableCellAccessible,
HyperTextAccessible,
nsIAccessibleTableCell)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableCellAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessible: Accessible implementation
void
HTMLTableCellAccessible::Shutdown()
{
mTableCell = nullptr;
HyperTextAccessibleWrap::Shutdown();
}
role
HTMLTableCellAccessible::NativeRole()
{
@ -146,7 +133,7 @@ HTMLTableCellAccessible::NativeAttributes()
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessible: nsIAccessibleTableCell implementation
// HTMLTableCellAccessible: TableCellAccessible implementation
TableAccessible*
HTMLTableCellAccessible::Table() const
@ -361,19 +348,11 @@ HTMLTableRowAccessible::NativeRole()
// HTMLTableAccessible
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED(HTMLTableAccessible, Accessible,
nsIAccessibleTable)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible: Accessible
void
HTMLTableAccessible::Shutdown()
{
mTable = nullptr;
AccessibleWrap::Shutdown();
}
void
HTMLTableAccessible::CacheChildren()
{
@ -444,7 +423,7 @@ HTMLTableAccessible::NativeAttributes()
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible: nsIAccessible implementation
// HTMLTableAccessible: Accessible
Relation
HTMLTableAccessible::RelationByType(RelationType aType)
@ -457,7 +436,7 @@ HTMLTableAccessible::RelationByType(RelationType aType)
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible: nsIAccessibleTable implementation
// HTMLTableAccessible: Table
Accessible*
HTMLTableAccessible::Caption() const
@ -1013,18 +992,17 @@ HTMLTableAccessible::IsProbablyLayoutTable()
}
// If only 1 column or only 1 row, it's for layout
int32_t columns, rows;
GetColumnCount(&columns);
if (columns <=1) {
uint32_t colCount = ColCount();
if (colCount <=1) {
RETURN_LAYOUT_ANSWER(true, "Has only 1 column");
}
GetRowCount(&rows);
if (rows <=1) {
uint32_t rowCount = RowCount();
if (rowCount <=1) {
RETURN_LAYOUT_ANSWER(true, "Has only 1 row");
}
// Check for many columns
if (columns >= 5) {
if (colCount >= 5) {
RETURN_LAYOUT_ANSWER(false, ">=5 columns");
}
@ -1067,8 +1045,8 @@ HTMLTableAccessible::IsProbablyLayoutTable()
}
// Check for many rows
const int32_t kMaxLayoutRows = 20;
if (rows > kMaxLayoutRows) { // A ton of rows, this is probably for data
const uint32_t kMaxLayoutRows = 20;
if (rowCount > kMaxLayoutRows) { // A ton of rows, this is probably for data
RETURN_LAYOUT_ANSWER(false, ">= kMaxLayoutRows (20) and non-bordered");
}
@ -1087,7 +1065,7 @@ HTMLTableAccessible::IsProbablyLayoutTable()
}
// Two column rules
if (rows * columns <= 10) {
if (rowCount * colCount <= 10) {
RETURN_LAYOUT_ANSWER(true, "2-4 columns, 10 cells or less, non-bordered");
}

View File

@ -7,11 +7,8 @@
#define mozilla_a11y_HTMLTableAccessible_h__
#include "HyperTextAccessibleWrap.h"
#include "nsIAccessibleTable.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "xpcAccessibleTable.h"
#include "xpcAccessibleTableCell.h"
class nsITableLayout;
class nsITableCellLayout;
@ -23,9 +20,7 @@ namespace a11y {
* HTML table cell accessible (html:td).
*/
class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
public nsIAccessibleTableCell,
public TableCellAccessible,
public xpcAccessibleTableCell
public TableCellAccessible
{
public:
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
@ -33,12 +28,8 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTableCell
NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
virtual void Shutdown();
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
@ -57,11 +48,6 @@ public:
protected:
virtual ~HTMLTableCellAccessible() {}
/**
* Return host table accessible.
*/
already_AddRefed<nsIAccessibleTable> GetTableAccessible();
/**
* Return nsITableCellLayout of the table cell frame.
*/
@ -120,13 +106,11 @@ protected:
// #define SHOW_LAYOUT_HEURISTIC
class HTMLTableAccessible : public AccessibleWrap,
public xpcAccessibleTable,
public nsIAccessibleTable,
public TableAccessible
{
public:
HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
AccessibleWrap(aContent, aDoc)
{
mType = eHTMLTableType;
mGenericTypes |= eTable;
@ -134,9 +118,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible Table
NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
// TableAccessible
virtual Accessible* Caption() const;
virtual void Summary(nsString& aSummary);
@ -168,7 +149,6 @@ public:
virtual Accessible* AsAccessible() { return this; }
// Accessible
virtual void Shutdown();
virtual TableAccessible* AsTable() { return this; }
virtual void Description(nsString& aDescription);
virtual a11y::role NativeRole() MOZ_OVERRIDE;
@ -229,13 +209,13 @@ class HTMLCaptionAccessible : public HyperTextAccessibleWrap
public:
HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc) { }
virtual ~HTMLCaptionAccessible() { }
// nsIAccessible
// Accessible
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
protected:
virtual ~HTMLCaptionAccessible() { }
};
} // namespace a11y

View File

@ -26,10 +26,10 @@ class nsIFrame;
class nsIPresShell;
class nsPluginFrame;
// 10ff6dca-b219-4b64-9a4c-67a62b86edce
// 0e7e6879-854b-4260-bc6e-525b5fb5cf34
#define NS_IACCESSIBILITYSERVICE_IID \
{ 0x84dd9182, 0x6639, 0x4377, \
{ 0xa4, 0x13, 0xad, 0xe1, 0xae, 0x4e, 0x52, 0xdd } }
{ 0x0e7e6879, 0x854b, 0x4260, \
{ 0xbc, 0x6e, 0x52, 0x5b, 0x5f, 0xb5, 0xcf, 0x34 } }
class nsIAccessibilityService : public nsIAccessibleRetrieval
{
@ -64,6 +64,11 @@ public:
*/
virtual void FireAccessibleEvent(uint32_t aEvent,
mozilla::a11y::Accessible* aTarget) = 0;
/**
* Return true if the given DOM node has accessible object.
*/
virtual bool HasAccessible(nsIDOMNode* aDOMNode) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIAccessibilityService,

View File

@ -12,6 +12,14 @@ interface nsIDOMNode;
interface nsIAccessibleDocument;
interface nsIAccessibleRelation;
%{C++
namespace mozilla {
namespace a11y {
class Accessible;
}
}
%}
/**
* A cross-platform interface that supports platform-specific
* accessibility APIs like MSAA and ATK. Contains the sum of what's needed
@ -166,7 +174,6 @@ interface nsIAccessible : nsISupports
* inclusive of the current item
* @param positionInGroup - 1-based, similar to ARIA 'posinset' property
*/
[binaryname(ScriptableGroupPosition)]
void groupPosition(out long aGroupLevel, out long aSimilarItemsInGroup,
out long aPositionInGroup);
@ -198,7 +205,6 @@ interface nsIAccessible : nsISupports
/**
* Nth accessible child using zero-based index or last child if index less than zero
*/
[binaryname(ScriptableGetChildAt)]
nsIAccessible getChildAt(in long aChildIndex);
/**
@ -221,7 +227,6 @@ interface nsIAccessible : nsISupports
/**
* Add or remove this accessible to the current selection
*/
[binaryname(ScriptableSetSelected)]
void setSelected(in boolean isSelected);
/**
@ -233,7 +238,6 @@ interface nsIAccessible : nsISupports
/**
* Select this accessible node only
*/
[binaryname(ScriptableTakeSelection)]
void takeSelection();
/**
@ -244,7 +248,6 @@ interface nsIAccessible : nsISupports
* will still set focus on that node, although normally that will not be visually
* indicated in most style sheets.
*/
[binaryname(ScriptableTakeFocus)]
void takeFocus();
/**
@ -266,7 +269,6 @@ interface nsIAccessible : nsISupports
* Perform the accessible action at the given zero-based index
* Action number 0 is the default action
*/
[binaryname(ScriptableDoAction)]
void doAction(in uint8_t index);
/**
@ -276,7 +278,6 @@ interface nsIAccessible : nsISupports
* the screen (see nsIAccessibleScrollType for
* available constants).
*/
[binaryname(ScriptableScrollTo)]
void scrollTo(in unsigned long aScrollType);
/**
@ -288,13 +289,11 @@ interface nsIAccessible : nsISupports
* @param x [in] - defines the x coordinate
* @param y [in] - defines the y coordinate
*/
[binaryname(ScriptableScrollToPoint)]
void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
/**
* Get a pointer to accessibility interface for this node, which is specific
* to the OS/accessibility toolkit we're running on.
*/
[noscript] void getNativeInterface(out voidPtr aOutAccessible);
%{C++
virtual mozilla::a11y::Accessible* ToInternalAccessible() const = 0;
%}
};

View File

@ -19,7 +19,7 @@ interface nsIDOMWindow;
* the root node of a document or you can get one from
* nsIAccessible::GetDocument().
*/
[scriptable, uuid(c80f6600-3210-4893-8f71-fde381ca39c9)]
[scriptable, uuid(2be938df-0210-4609-9ece-26b197a517e5)]
interface nsIAccessibleDocument : nsISupports
{
/**
@ -70,6 +70,5 @@ interface nsIAccessibleDocument : nsISupports
/**
* Return the child document accessible at the given index.
*/
[binaryname(ScriptableGetChildDocumentAt)]
nsIAccessibleDocument getChildDocumentAt(in unsigned long index);
};

View File

@ -6,7 +6,7 @@
#include "nsISupports.idl"
[scriptable, uuid(93d0ba57-0d20-49d1-aede-8fde6699855d)]
[scriptable, uuid(28915cca-3366-4034-ba1d-b7afb9b37639)]
interface nsIAccessibleEditableText : nsISupports
{
/**
@ -20,7 +20,6 @@ interface nsIAccessibleEditableText : nsISupports
* @param text - text that is inserted.
* @param position - index at which to insert the text.
*/
[binaryname(ScriptableInsertText)]
void insertText(in AString text, in long position);
/**
@ -29,7 +28,6 @@ interface nsIAccessibleEditableText : nsISupports
* @param startPos - start index of the text to moved into the clipboard.
* @param endPos - end index of the text to moved into the clipboard.
*/
[binaryname(ScriptableCopyText)]
void copyText(in long startPos, in long endPos);
/**
@ -38,7 +36,6 @@ interface nsIAccessibleEditableText : nsISupports
* @param startPos - start index of the text to be deleted.
* @param endOffset - end index of the text to be deleted.
*/
[binaryname(ScriptableCutText)]
void cutText(in long startPos, in long endPos);
/**
@ -47,7 +44,6 @@ interface nsIAccessibleEditableText : nsISupports
* @param startPos - start index of the text to be deleted.
* @param endPos - end index of the text to be deleted.
*/
[binaryname(ScriptableDeleteText)]
void deleteText(in long startPos, in long endPos);
/**
@ -56,6 +52,5 @@ interface nsIAccessibleEditableText : nsISupports
* @param position - index at which to insert the text from the system
* clipboard into the text represented by this object.
*/
[binaryname(ScriptablePasteText)]
void pasteText(in long position);
};

View File

@ -11,7 +11,7 @@ interface nsIArray;
/**
* An accessibility interface for selectable widgets.
*/
[scriptable, uuid(3e507fc4-4fcc-4223-a674-a095f591eba1)]
[scriptable, uuid(8efb03d4-1354-4875-94cf-261336057626)]
interface nsIAccessibleSelectable : nsISupports
{
/**
@ -32,19 +32,16 @@ interface nsIAccessibleSelectable : nsISupports
/**
* Return true if the given item is selected.
*/
[binaryname(ScriptableIsItemSelected)]
boolean isItemSelected(in unsigned long index);
/**
* Adds the specified item to the widget's selection.
*/
[binaryname(ScriptableAddItemToSelection)]
void addItemToSelection(in unsigned long index);
/**
* Removes the specified item from the widget's selection.
*/
[binaryname(ScriptableRemoveItemFromSelection)]
void removeItemFromSelection(in unsigned long index);
/**
@ -53,12 +50,10 @@ interface nsIAccessibleSelectable : nsISupports
* @return false if the object does not accept multiple selection,
* otherwise true.
*/
[binaryname(ScriptableSelectAll)]
boolean selectAll();
/**
* Unselect all items.
*/
[binaryname(ScriptableUnselectAll)]
void unselectAll();
};

View File

@ -13,7 +13,7 @@ interface nsIArray;
interface nsIPersistentProperties;
interface nsIAccessibleTextRange;
[scriptable, uuid(88789f40-54c9-494a-846d-3acaaf4cf46a)]
[scriptable, uuid(93ad2ca1-f12b-4ab9-a793-95d9fa9d1774)]
interface nsIAccessibleText : nsISupports
{
// In parameters for character offsets:
@ -34,7 +34,6 @@ interface nsIAccessibleText : nsISupports
* The current current caret offset.
* If set < 0 then caret will be placed at the end of the text
*/
[binaryname(ScriptableCaretOffset)]
attribute long caretOffset;
readonly attribute long characterCount;
@ -171,7 +170,6 @@ interface nsIAccessibleText : nsISupports
* @param scrollType defines how to scroll (see nsIAccessibleScrollType for
* available constants)
*/
[binaryname(ScriptableScrollSubstringTo)]
void scrollSubstringTo(in long startIndex, in long endIndex,
in unsigned long scrollType);
@ -187,7 +185,6 @@ interface nsIAccessibleText : nsISupports
* @param x defines the x coordinate
* @param y defines the y coordinate
*/
[binaryname(ScriptableScrollSubstringToPoint)]
void scrollSubstringToPoint(in long startIndex, in long endIndex,
in unsigned long coordinateType,
in long x, in long y);

View File

@ -36,7 +36,7 @@ public: // construction, destruction
/**
* Get the native Obj-C object (mozAccessible).
*/
NS_IMETHOD GetNativeInterface (void** aOutAccessible);
virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
/**
* The objective-c |Class| type that this accessible's native object

View File

@ -43,14 +43,10 @@ AccessibleWrap::GetNativeObject()
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
NS_IMETHODIMP
void
AccessibleWrap::GetNativeInterface(void** aOutInterface)
{
NS_ENSURE_ARG_POINTER(aOutInterface);
*aOutInterface = static_cast<void*>(GetNativeObject());
return *aOutInterface ? NS_OK : NS_ERROR_FAILURE;
}
// overridden in subclasses to create the right kind of object. by default we create a generic

View File

@ -24,7 +24,7 @@ GetObjectOrRepresentedView(id <mozAccessible> aObject)
}
inline mozAccessible*
GetNativeFromGeckoAccessible(nsIAccessible* aAccessible)
GetNativeFromGeckoAccessible(mozilla::a11y::Accessible* aAccessible)
{
mozAccessible* native = nil;
aAccessible->GetNativeInterface((void**)&native);
@ -49,7 +49,7 @@ GetNativeFromGeckoAccessible(nsIAccessible* aAccessible)
mozAccessible* mParent;
/**
* The nsIAccessible role of our gecko accessible.
* The role of our gecko accessible.
*/
mozilla::a11y::role mRole;
}

View File

@ -11,7 +11,6 @@
#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
#include "nsIAccessibleText.h"
#include "nsIAccessibleEditableText.h"
#include "nsIPersistentProperties2.h"
#include "Relation.h"
@ -303,8 +302,8 @@ GetClosestInterestingAccessible(id anObject)
// (which might be the owning NSWindow in the application, for example).
//
// get the native root accessible, and tell it to return its first parent unignored accessible.
RootAccessible* root = mGeckoAccessible->RootAccessible();
id nativeParent = GetNativeFromGeckoAccessible(static_cast<nsIAccessible*>(root));
id nativeParent =
GetNativeFromGeckoAccessible(mGeckoAccessible->RootAccessible());
NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
return GetClosestInterestingAccessible(nativeParent);
@ -393,12 +392,11 @@ GetClosestInterestingAccessible(id anObject)
if (!mGeckoAccessible)
return nil;
int32_t x = 0, y = 0, width = 0, height = 0;
mGeckoAccessible->GetBounds (&x, &y, &width, &height);
nsIntRect rect = mGeckoAccessible->Bounds();
CGFloat scaleFactor =
nsCocoaUtils::GetBackingScaleFactor([[NSScreen screens] objectAtIndex:0]);
return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(width) / scaleFactor,
static_cast<CGFloat>(height) / scaleFactor)];
return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(rect.width) / scaleFactor,
static_cast<CGFloat>(rect.height) / scaleFactor)];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
@ -410,7 +408,7 @@ GetClosestInterestingAccessible(id anObject)
#ifdef DEBUG_A11Y
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
"Does not support nsIAccessibleText when it should");
"Does not support Text when it should");
#endif
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
@ -533,7 +531,7 @@ GetClosestInterestingAccessible(id anObject)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString value;
mGeckoAccessible->GetValue (value);
mGeckoAccessible->Value(value);
return value.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(value.BeginReading())
length:value.Length()];
@ -578,7 +576,7 @@ GetClosestInterestingAccessible(id anObject)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString helpText;
mGeckoAccessible->GetHelp (helpText);
mGeckoAccessible->Help(helpText);
return helpText.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(helpText.BeginReading())
length:helpText.Length()];

View File

@ -300,8 +300,7 @@ enum CheckboxValue {
return nil;
mozAccessible* nativeAcc = nil;
nsresult rv = accessible->GetNativeInterface((void**)&nativeAcc);
NS_ENSURE_SUCCESS(rv, nil);
accessible->GetNativeInterface((void**)&nativeAcc);
return nativeAcc;
}

View File

@ -11,7 +11,6 @@
// both of these are the same old mGeckoAccessible, but already
// QI'd for us, to the right type, for convenience.
mozilla::a11y::HyperTextAccessible* mGeckoTextAccessible; // strong
nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
}
@end

View File

@ -59,7 +59,6 @@ ToNSString(id aValue)
if ((self = [super initWithAccessible:accessible])) {
mGeckoTextAccessible = accessible->AsHyperText();
CallQueryInterface(accessible, &mGeckoEditableTextAccessible);
}
return self;
@ -309,7 +308,6 @@ ToNSString(id aValue)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mGeckoTextAccessible = nullptr;
NS_IF_RELEASE(mGeckoEditableTextAccessible);
[super expire];
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -324,7 +322,7 @@ ToNSString(id aValue)
if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
return YES;
if (mGeckoEditableTextAccessible)
if (mGeckoTextAccessible)
return (mGeckoAccessible->State() & states::READONLY) == 0;
return NO;
@ -344,10 +342,10 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (mGeckoEditableTextAccessible) {
if (mGeckoTextAccessible) {
nsString text;
nsCocoaUtils::GetStringForNSString(aNewString, text);
mGeckoEditableTextAccessible->SetTextContents(text);
mGeckoTextAccessible->ReplaceText(text);
}
NS_OBJC_END_TRY_ABORT_BLOCK;

View File

@ -34,7 +34,6 @@ const nsIAccessibleEditableText = Components.interfaces.nsIAccessibleEditableTex
const nsIAccessibleHyperLink = Components.interfaces.nsIAccessibleHyperLink;
const nsIAccessibleHyperText = Components.interfaces.nsIAccessibleHyperText;
const nsIAccessibleCursorable = Components.interfaces.nsIAccessibleCursorable;
const nsIAccessibleImage = Components.interfaces.nsIAccessibleImage;
const nsIAccessiblePivot = Components.interfaces.nsIAccessiblePivot;
const nsIAccessibleSelectable = Components.interfaces.nsIAccessibleSelectable;
@ -173,7 +172,7 @@ function getNode(aAccOrNodeOrID, aDocument)
if (aAccOrNodeOrID instanceof nsIAccessible)
return aAccOrNodeOrID.DOMNode;
node = (aDocument || document).getElementById(aAccOrNodeOrID);
var node = (aDocument || document).getElementById(aAccOrNodeOrID);
if (!node) {
ok(false, "Can't get DOM element for " + aAccOrNodeOrID);
return null;

View File

@ -77,7 +77,6 @@ ia2AccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
if (!aDescription)
return E_INVALIDARG;
*aDescription = nullptr;
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
@ -86,10 +85,7 @@ ia2AccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
nsAutoString description;
uint8_t index = static_cast<uint8_t>(aActionIndex);
nsresult rv = acc->GetActionDescription(index, description);
if (NS_FAILED(rv))
return GetHRESULT(rv);
acc->ActionDescriptionAt(index, description);
if (description.IsEmpty())
return S_FALSE;

View File

@ -9,7 +9,6 @@
#define _ACCESSIBLE_EDITABLETEXT_H
#include "nsISupports.h"
#include "nsIAccessibleEditableText.h"
#include "AccessibleEditableText.h"

View File

@ -55,10 +55,7 @@ ia2AccessibleImage::get_description(BSTR* aDescription)
return CO_E_OBJNOTCONNECTED;
nsAutoString description;
nsresult rv = acc->GetName(description);
if (NS_FAILED(rv))
return GetHRESULT(rv);
acc->Name(description);
if (description.IsEmpty())
return S_FALSE;
@ -88,14 +85,10 @@ ia2AccessibleImage::get_imagePosition(enum IA2CoordinateType aCoordType,
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
int32_t x = 0, y = 0;
nsresult rv = imageAcc->GetImagePosition(geckoCoordType, &x, &y);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aX = x;
*aY = y;
nsIntPoint pos = imageAcc->Position(geckoCoordType);
*aX = pos.x;
*aY = pos.y;
return S_OK;
A11Y_TRYBLOCK_END
@ -116,13 +109,9 @@ ia2AccessibleImage::get_imageSize(long* aHeight, long* aWidth)
if (imageAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
int32_t width = 0, height = 0;
nsresult rv = imageAcc->GetImageSize(&width, &height);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aHeight = width;
*aWidth = height;
nsIntSize size = imageAcc->Size();
*aHeight = size.width;
*aWidth = size.height;
return S_OK;
A11Y_TRYBLOCK_END

View File

@ -8,7 +8,6 @@
#include "ia2AccessibleRelation.h"
#include "Relation.h"
#include "nsIAccessibleRelation.h"
#include "nsID.h"
#include "AccessibleRelation_i.c"

View File

@ -10,7 +10,6 @@
#include "Accessible.h"
#include "IUnknownImpl.h"
#include "nsIAccessibleRelation.h"
#include <utility>
#include "nsTArray.h"

View File

@ -419,8 +419,8 @@ ia2AccessibleTable::get_summary(IUnknown** aAccessible)
// Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
// link an accessible object to specify a summary. There is closes method
// in nsIAccessibleTable::summary to get a summary as a string which is not
// mapped directly to IAccessible2.
// in Table::summary to get a summary as a string which is not mapped
// directly to IAccessible2.
*aAccessible = nullptr;
return S_FALSE;

View File

@ -9,7 +9,6 @@
#define _ACCESSIBLE_TEXT_H
#include "nsISupports.h"
#include "nsIAccessibleText.h"
#include "AccessibleText.h"

View File

@ -13,7 +13,6 @@
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "nsIAccessibleEvent.h"
#include "nsIAccessibleRelation.h"
#include "nsWinUtils.h"
#include "ServiceProvider.h"
#include "Relation.h"
@ -365,7 +364,7 @@ AccessibleWrap::get_accRole(
#ifdef DEBUG
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(xpAccessible),
"Does not support nsIAccessibleText when it should");
"Does not support Text when it should");
#endif
a11y::role geckoRole = xpAccessible->Role();
@ -588,12 +587,15 @@ AccessibleWrap::get_accFocus(
A11Y_TRYBLOCK_END
}
// This helper class implements IEnumVARIANT for a nsIArray containing nsIAccessible objects.
/**
* This helper class implements IEnumVARIANT for a nsTArray containing
* accessible objects.
*/
class AccessibleEnumerator MOZ_FINAL : public IEnumVARIANT
{
public:
AccessibleEnumerator(nsIArray* aArray) : mArray(aArray), mCurIndex(0) { }
AccessibleEnumerator(const nsTArray<Accessible*>& aArray) :
mArray(aArray), mCurIndex(0) { }
AccessibleEnumerator(const AccessibleEnumerator& toCopy) :
mArray(toCopy.mArray), mCurIndex(toCopy.mCurIndex) { }
~AccessibleEnumerator() { }
@ -612,7 +614,7 @@ public:
STDMETHODIMP Clone(IEnumVARIANT FAR* FAR* ppenum);
private:
nsCOMPtr<nsIArray> mArray;
nsTArray<Accessible*> mArray;
uint32_t mCurIndex;
};
@ -643,9 +645,7 @@ AccessibleEnumerator::Next(unsigned long celt, VARIANT FAR* rgvar, unsigned long
{
A11Y_TRYBLOCK_BEGIN
uint32_t length = 0;
mArray->GetLength(&length);
uint32_t length = mArray.Length();
HRESULT hr = S_OK;
// Can't get more elements than there are...
@ -654,15 +654,10 @@ AccessibleEnumerator::Next(unsigned long celt, VARIANT FAR* rgvar, unsigned long
celt = length - mCurIndex;
}
// Copy the elements of the array into rgvar.
for (uint32_t i = 0; i < celt; ++i, ++mCurIndex) {
// Copy the elements of the array into rgvar
nsCOMPtr<nsIAccessible> accel(do_QueryElementAt(mArray, mCurIndex));
NS_ASSERTION(accel, "Invalid pointer in mArray");
if (accel) {
rgvar[i].vt = VT_DISPATCH;
rgvar[i].pdispVal = AccessibleWrap::NativeAccessible(accel);
}
rgvar[i].pdispVal = AccessibleWrap::NativeAccessible(mArray[mCurIndex]);
}
if (pceltFetched)
@ -692,8 +687,7 @@ AccessibleEnumerator::Skip(unsigned long celt)
{
A11Y_TRYBLOCK_BEGIN
uint32_t length = 0;
mArray->GetLength(&length);
uint32_t length = mArray.Length();
// Check if we can skip the requested number of elements
if (celt > length - mCurIndex) {
mCurIndex = length;
@ -708,7 +702,7 @@ AccessibleEnumerator::Skip(unsigned long celt)
/**
* This method is called when a client wants to know which children of a node
* are selected. Note that this method can only find selected children for
* nsIAccessible object which implement SelectAccessible.
* accessible object which implement SelectAccessible.
*
* The VARIANT return value arguement is expected to either contain a single IAccessible
* or an IEnumVARIANT of IAccessibles. We return the IEnumVARIANT regardless of the number
@ -737,19 +731,14 @@ AccessibleWrap::get_accSelection(VARIANT __RPC_FAR *pvarChildren)
return CO_E_OBJNOTCONNECTED;
if (IsSelect()) {
nsCOMPtr<nsIArray> selectedItems = SelectedItems();
if (selectedItems) {
// 1) Create and initialize the enumeration
nsRefPtr<AccessibleEnumerator> pEnum =
new AccessibleEnumerator(selectedItems);
nsAutoTArray<Accessible*, 10> selectedItems;
SelectedItems(&selectedItems);
// 2) Put the enumerator in the VARIANT
if (!pEnum)
return E_OUTOFMEMORY;
// 1) Create and initialize the enumeration
nsRefPtr<AccessibleEnumerator> pEnum = new AccessibleEnumerator(selectedItems);
pvarChildren->vt = VT_UNKNOWN; // this must be VT_UNKNOWN for an IEnumVARIANT
NS_ADDREF(pvarChildren->punkVal = pEnum);
}
}
return S_OK;
A11Y_TRYBLOCK_END
@ -1081,14 +1070,11 @@ AccessibleWrap::Invoke(DISPID dispIdMember, REFIID riid,
puArgErr);
}
// nsIAccessible method
NS_IMETHODIMP
void
AccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = static_cast<IAccessible*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
@ -1222,7 +1208,7 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible)
}
IDispatch*
AccessibleWrap::NativeAccessible(nsIAccessible* aAccessible)
AccessibleWrap::NativeAccessible(Accessible* aAccessible)
{
if (!aAccessible) {
NS_WARNING("Not passing in an aAccessible");

View File

@ -170,9 +170,9 @@ public: // construction, destruction
*/
Accessible* GetXPAccessibleFor(const VARIANT& aVarChild);
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
virtual void GetNativeInterface(void **aOutAccessible) MOZ_OVERRIDE;
static IDispatch *NativeAccessible(nsIAccessible *aXPAccessible);
static IDispatch* NativeAccessible(Accessible* aAccessible);
protected:
virtual ~AccessibleWrap() { }

View File

@ -21,7 +21,7 @@ HTMLWin32ObjectOwnerAccessible::
{
// Our only child is a HTMLWin32ObjectAccessible object.
if (mHwnd)
mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd);
mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd, aDoc);
}
////////////////////////////////////////////////////////////////////////////////
@ -63,8 +63,9 @@ HTMLWin32ObjectOwnerAccessible::CacheChildren()
// HTMLWin32ObjectAccessible
////////////////////////////////////////////////////////////////////////////////
HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
DummyAccessible()
HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd,
DocAccessible* aDoc) :
DummyAccessible(aDoc)
{
mHwnd = aHwnd;
if (mHwnd) {
@ -79,7 +80,7 @@ HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
}
}
NS_IMETHODIMP
void
HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
{
if (mHwnd) {
@ -87,6 +88,5 @@ HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
OBJID_WINDOW, IID_IAccessible,
aNativeAccessible);
}
return NS_OK;
}

View File

@ -44,7 +44,7 @@ protected:
* This class is used only internally, we never! send out an IAccessible linked
* back to this object. This class is used to represent a plugin object when
* referenced as a child or sibling of another Accessible node. We need only
* a limited portion of the nsIAccessible interface implemented here. The
* a limited portion of the Accessible interface implemented here. The
* in depth accessible information will be returned by the actual IAccessible
* object returned by us in Accessible::NewAccessible() that gets the IAccessible
* from the windows system from the window handle.
@ -52,10 +52,10 @@ protected:
class HTMLWin32ObjectAccessible : public DummyAccessible
{
public:
HTMLWin32ObjectAccessible(void* aHwnd);
HTMLWin32ObjectAccessible(void* aHwnd, DocAccessible* aDoc);
virtual ~HTMLWin32ObjectAccessible() {}
NS_IMETHOD GetNativeInterface(void** aNativeAccessible) MOZ_OVERRIDE;
virtual void GetNativeInterface(void** aNativeAccessible) MOZ_OVERRIDE;
protected:
void* mHwnd;

View File

@ -21,7 +21,7 @@ XULMenuitemAccessibleWrap::
ENameValueFlag
XULMenuitemAccessibleWrap::Name(nsString& aName)
{
// XXX This should be done in get_accName() so that nsIAccessible::GetName()]
// XXX This should be done in MSAA's get_accName() so that Accessible::Name()]
// provides the same results on all platforms
XULMenuitemAccessible::Name(aName);
if (aName.IsEmpty())

View File

@ -77,10 +77,7 @@ sdnDocAccessible::get_mimeType(BSTR __RPC_FAR* aMimeType)
return CO_E_OBJNOTCONNECTED;
nsAutoString mimeType;
nsresult rv = mAccessible->GetMimeType(mimeType);
if (NS_FAILED(rv))
return E_FAIL;
mAccessible->MimeType(mimeType);
if (mimeType.IsEmpty())
return S_FALSE;
@ -103,10 +100,7 @@ sdnDocAccessible::get_docType(BSTR __RPC_FAR* aDocType)
return CO_E_OBJNOTCONNECTED;
nsAutoString docType;
nsresult rv = mAccessible->GetDocType(docType);
if (NS_FAILED(rv))
return E_FAIL;
mAccessible->DocType(docType);
if (docType.IsEmpty())
return S_FALSE;

View File

@ -4,20 +4,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
'xpcAccessible.h',
'xpcAccessibleDocument.h',
'xpcAccessibleHyperLink.h',
'xpcAccessibleHyperText.h',
'xpcAccessibleSelectable.h',
'xpcAccessibleValue.h',
]
UNIFIED_SOURCES += [
'nsAccessibleRelation.cpp',
'xpcAccessible.cpp',
'xpcAccessibleApplication.cpp',
'xpcAccessibleDocument.cpp',
'xpcAccessibleGeneric.cpp',
'xpcAccessibleHyperLink.cpp',
'xpcAccessibleHyperText.cpp',
'xpcAccessibleImage.cpp',

View File

@ -7,6 +7,7 @@
#include "Relation.h"
#include "Accessible.h"
#include "xpcAccessibleDocument.h"
#include "nsArrayUtils.h"
#include "nsComponentManagerUtils.h"
@ -18,9 +19,9 @@ nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
mType(aType)
{
mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
nsIAccessible* targetAcc = nullptr;
Accessible* targetAcc = nullptr;
while ((targetAcc = aRel->Next()))
mTargets->AppendElement(targetAcc, false);
mTargets->AppendElement(static_cast<nsIAccessible*>(ToXPC(targetAcc)), false);
}
nsAccessibleRelation::~nsAccessibleRelation()

View File

@ -4,8 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessible.h"
#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
@ -14,6 +12,7 @@
#include "Relation.h"
#include "Role.h"
#include "RootAccessible.h"
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsIPersistentProperties2.h"
@ -24,10 +23,10 @@ NS_IMETHODIMP
xpcAccessible::GetParent(nsIAccessible** aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aParent = static_cast<Accessible*>(this)->Parent());
NS_IF_ADDREF(*aParent = ToXPC(Intl()->Parent()));
return NS_OK;
}
@ -37,11 +36,11 @@ xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
NS_ENSURE_ARG_POINTER(aNextSibling);
*aNextSibling = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
NS_IF_ADDREF(*aNextSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(1, &rv));
NS_IF_ADDREF(*aNextSibling = ToXPC(Intl()->GetSiblingAtOffset(1, &rv)));
return rv;
}
@ -51,11 +50,11 @@ xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
NS_ENSURE_ARG_POINTER(aPreviousSibling);
*aPreviousSibling = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
NS_IF_ADDREF(*aPreviousSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(-1, &rv));
NS_IF_ADDREF(*aPreviousSibling = ToXPC(Intl()->GetSiblingAtOffset(-1, &rv)));
return rv;
}
@ -65,10 +64,10 @@ xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
NS_ENSURE_ARG_POINTER(aFirstChild);
*aFirstChild = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aFirstChild = static_cast<Accessible*>(this)->FirstChild());
NS_IF_ADDREF(*aFirstChild = ToXPC(Intl()->FirstChild()));
return NS_OK;
}
@ -78,10 +77,10 @@ xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
NS_ENSURE_ARG_POINTER(aLastChild);
*aLastChild = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aLastChild = static_cast<Accessible*>(this)->LastChild());
NS_IF_ADDREF(*aLastChild = ToXPC(Intl()->LastChild()));
return NS_OK;
}
@ -90,32 +89,32 @@ xpcAccessible::GetChildCount(int32_t* aChildCount)
{
NS_ENSURE_ARG_POINTER(aChildCount);
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aChildCount = static_cast<Accessible*>(this)->ChildCount();
*aChildCount = Intl()->ChildCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ScriptableGetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
xpcAccessible::GetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
// If child index is negative, then return last child.
// XXX: do we really need this?
if (aChildIndex < 0)
aChildIndex = static_cast<Accessible*>(this)->ChildCount() - 1;
aChildIndex = Intl()->ChildCount() - 1;
Accessible* child = static_cast<Accessible*>(this)->GetChildAt(aChildIndex);
Accessible* child = Intl()->GetChildAt(aChildIndex);
if (!child)
return NS_ERROR_INVALID_ARG;
NS_ADDREF(*aChild = child);
NS_ADDREF(*aChild = ToXPC(child));
return NS_OK;
}
@ -125,7 +124,7 @@ xpcAccessible::GetChildren(nsIArray** aChildren)
NS_ENSURE_ARG_POINTER(aChildren);
*aChildren = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
@ -133,10 +132,10 @@ xpcAccessible::GetChildren(nsIArray** aChildren)
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t childCount = static_cast<Accessible*>(this)->ChildCount();
uint32_t childCount = Intl()->ChildCount();
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
nsIAccessible* child = static_cast<Accessible*>(this)->GetChildAt(childIdx);
children->AppendElement(child, false);
Accessible* child = Intl()->GetChildAt(childIdx);
children->AppendElement(static_cast<nsIAccessible*>(ToXPC(child)), false);
}
NS_ADDREF(*aChildren = children);
@ -148,7 +147,7 @@ xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
{
NS_ENSURE_ARG_POINTER(aIndexInParent);
*aIndexInParent = static_cast<Accessible*>(this)->IndexInParent();
*aIndexInParent = Intl()->IndexInParent();
return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
}
@ -158,7 +157,7 @@ xpcAccessible::GetDOMNode(nsIDOMNode** aDOMNode)
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nullptr;
nsINode *node = static_cast<Accessible*>(this)->GetNode();
nsINode* node = Intl()->GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
@ -170,7 +169,7 @@ xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
NS_IF_ADDREF(*aDocument = static_cast<Accessible*>(this)->Document());
NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->Document()));
return NS_OK;
}
@ -179,7 +178,7 @@ xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
NS_IF_ADDREF(*aRootDocument = static_cast<Accessible*>(this)->RootAccessible());
NS_IF_ADDREF(*aRootDocument = ToXPCDocument(Intl()->RootAccessible()));
return NS_OK;
}
@ -189,10 +188,10 @@ xpcAccessible::GetRole(uint32_t* aRole)
NS_ENSURE_ARG_POINTER(aRole);
*aRole = nsIAccessibleRole::ROLE_NOTHING;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aRole = static_cast<Accessible*>(this)->Role();
*aRole = Intl()->Role();
return NS_OK;
}
@ -201,8 +200,7 @@ xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
{
NS_ENSURE_ARG_POINTER(aState);
nsAccUtils::To32States(static_cast<Accessible*>(this)->State(),
aState, aExtraState);
nsAccUtils::To32States(Intl()->State(), aState, aExtraState);
return NS_OK;
}
@ -211,11 +209,11 @@ xpcAccessible::GetName(nsAString& aName)
{
aName.Truncate();
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString name;
static_cast<Accessible*>(this)->Name(name);
Intl()->Name(name);
aName.Assign(name);
return NS_OK;
@ -224,11 +222,11 @@ xpcAccessible::GetName(nsAString& aName)
NS_IMETHODIMP
xpcAccessible::GetDescription(nsAString& aDescription)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString desc;
static_cast<Accessible*>(this)->Description(desc);
Intl()->Description(desc);
aDescription.Assign(desc);
return NS_OK;
@ -237,21 +235,21 @@ xpcAccessible::GetDescription(nsAString& aDescription)
NS_IMETHODIMP
xpcAccessible::GetLanguage(nsAString& aLanguage)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->Language(aLanguage);
Intl()->Language(aLanguage);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetValue(nsAString& aValue)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString value;
static_cast<Accessible*>(this)->Value(value);
Intl()->Value(value);
aValue.Assign(value);
return NS_OK;
@ -260,7 +258,14 @@ xpcAccessible::GetValue(nsAString& aValue)
NS_IMETHODIMP
xpcAccessible::GetHelp(nsAString& aHelp)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString help;
Intl()->Help(help);
aHelp.Assign(help);
return NS_OK;
}
NS_IMETHODIMP
@ -268,10 +273,10 @@ xpcAccessible::GetAccessKey(nsAString& aAccessKey)
{
aAccessKey.Truncate();
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->AccessKey().ToString(aAccessKey);
Intl()->AccessKey().ToString(aAccessKey);
return NS_OK;
}
@ -279,10 +284,10 @@ NS_IMETHODIMP
xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
{
aKeyBinding.Truncate();
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->KeyboardShortcut().ToString(aKeyBinding);
Intl()->KeyboardShortcut().ToString(aKeyBinding);
return NS_OK;
}
@ -292,11 +297,10 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> attributes =
static_cast<Accessible*>(this)->Attributes();
nsCOMPtr<nsIPersistentProperties> attributes = Intl()->Attributes();
attributes.swap(*aAttributes);
return NS_OK;
@ -315,10 +319,10 @@ xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsIntRect rect = static_cast<Accessible*>(this)->Bounds();
nsIntRect rect = Intl()->Bounds();
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
@ -328,7 +332,7 @@ xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
}
NS_IMETHODIMP
xpcAccessible::ScriptableGroupPosition(int32_t* aGroupLevel,
xpcAccessible::GroupPosition(int32_t* aGroupLevel,
int32_t* aSimilarItemsInGroup,
int32_t* aPositionInGroup)
{
@ -341,10 +345,10 @@ xpcAccessible::ScriptableGroupPosition(int32_t* aGroupLevel,
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
GroupPos groupPos = static_cast<Accessible*>(this)->GroupPosition();
GroupPos groupPos = Intl()->GroupPosition();
*aGroupLevel = groupPos.level;
*aSimilarItemsInGroup = groupPos.setSize;
@ -362,10 +366,10 @@ xpcAccessible::GetRelationByType(uint32_t aType,
NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
Relation rel = static_cast<Accessible*>(this)->RelationByType(static_cast<RelationType>(aType));
Relation rel = Intl()->RelationByType(static_cast<RelationType>(aType));
NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
return *aRelation ? NS_OK : NS_ERROR_FAILURE;
}
@ -376,7 +380,7 @@ xpcAccessible::GetRelations(nsIArray** aRelations)
NS_ENSURE_ARG_POINTER(aRelations);
*aRelations = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
@ -427,10 +431,10 @@ xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aChild = static_cast<Accessible*>(this)->FocusedChild());
NS_IF_ADDREF(*aChild = ToXPC(Intl()->FocusedChild()));
return NS_OK;
}
@ -441,12 +445,11 @@ xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aAccessible =
static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
Accessible::eDirectChild));
ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
return NS_OK;
}
@ -457,48 +460,51 @@ xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aAccessible =
static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
Accessible::eDeepestChild));
ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ScriptableSetSelected(bool aSelect)
xpcAccessible::SetSelected(bool aSelect)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->SetSelected(aSelect);
Intl()->SetSelected(aSelect);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ExtendSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
xpcAccessible::ScriptableTakeSelection()
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->TakeSelection();
Intl()->ExtendSelection();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ScriptableTakeFocus()
xpcAccessible::TakeSelection()
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->TakeFocus();
Intl()->TakeSelection();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::TakeFocus()
{
if (!Intl())
return NS_ERROR_FAILURE;
Intl()->TakeFocus();
return NS_OK;
}
@ -507,66 +513,65 @@ xpcAccessible::GetActionCount(uint8_t* aActionCount)
{
NS_ENSURE_ARG_POINTER(aActionCount);
*aActionCount = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aActionCount = static_cast<Accessible*>(this)->ActionCount();
*aActionCount = Intl()->ActionCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
if (aIndex >= Intl()->ActionCount())
return NS_ERROR_INVALID_ARG;
static_cast<Accessible*>(this)->ActionNameAt(aIndex, aName);
Intl()->ActionNameAt(aIndex, aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
if (aIndex >= Intl()->ActionCount())
return NS_ERROR_INVALID_ARG;
static_cast<Accessible*>(this)->ActionDescriptionAt(aIndex, aDescription);
Intl()->ActionDescriptionAt(aIndex, aDescription);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ScriptableDoAction(uint8_t aIndex)
xpcAccessible::DoAction(uint8_t aIndex)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
return static_cast<Accessible*>(this)->DoAction(aIndex) ?
return Intl()->DoAction(aIndex) ?
NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
xpcAccessible::ScriptableScrollTo(uint32_t aHow)
xpcAccessible::ScrollTo(uint32_t aHow)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->ScrollTo(aHow);
Intl()->ScrollTo(aHow);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ScriptableScrollToPoint(uint32_t aCoordinateType,
int32_t aX, int32_t aY)
xpcAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY)
{
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<Accessible*>(this)->ScrollToPoint(aCoordinateType, aX, aY);
Intl()->ScrollToPoint(aCoordinateType, aX, aY);
return NS_OK;
}

View File

@ -14,17 +14,23 @@ class nsIAccessible;
namespace mozilla {
namespace a11y {
class Accessible;
/**
* XPCOM nsIAccessible interface implementation, used by xpcAccessibleGeneric
* class.
*/
class xpcAccessible : public nsIAccessible
{
public:
// nsIAccessible
NS_IMETHOD GetParent(nsIAccessible** aParent) MOZ_FINAL;
NS_IMETHOD GetNextSibling(nsIAccessible** aNextSibling) MOZ_FINAL;
NS_IMETHOD GetPreviousSibling(nsIAccessible** aPreviousSibling) MOZ_FINAL;
NS_IMETHOD GetFirstChild(nsIAccessible** aFirstChild) MOZ_FINAL;
NS_IMETHOD GetLastChild(nsIAccessible** aLastChild) MOZ_FINAL;
NS_IMETHOD GetChildCount(int32_t* aChildCount) MOZ_FINAL;
NS_IMETHOD ScriptableGetChildAt(int32_t aChildIndex,
nsIAccessible** aChild) MOZ_FINAL;
NS_IMETHOD GetChildAt(int32_t aChildIndex, nsIAccessible** aChild) MOZ_FINAL;
NS_IMETHOD GetChildren(nsIArray** aChildren) MOZ_FINAL;
NS_IMETHOD GetIndexInParent(int32_t* aIndexInParent) MOZ_FINAL;
@ -47,8 +53,7 @@ public:
NS_IMETHOD GetAttributes(nsIPersistentProperties** aAttributes) MOZ_FINAL;
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
NS_IMETHOD ScriptableGroupPosition(int32_t* aGroupLevel,
int32_t* aSimilarItemsInGroup,
NS_IMETHOD GroupPosition(int32_t* aGroupLevel, int32_t* aSimilarItemsInGroup,
int32_t* aPositionInGroup) MOZ_FINAL;
NS_IMETHOD GetRelationByType(uint32_t aType,
nsIAccessibleRelation** aRelation) MOZ_FINAL;
@ -60,23 +65,26 @@ public:
NS_IMETHOD GetDeepestChildAtPoint(int32_t aX, int32_t aY,
nsIAccessible** aAccessible) MOZ_FINAL;
NS_IMETHOD ScriptableSetSelected(bool aSelect) MOZ_FINAL;
NS_IMETHOD SetSelected(bool aSelect) MOZ_FINAL;
NS_IMETHOD ExtendSelection() MOZ_FINAL;
NS_IMETHOD ScriptableTakeSelection() MOZ_FINAL;
NS_IMETHOD ScriptableTakeFocus() MOZ_FINAL;
NS_IMETHOD TakeSelection() MOZ_FINAL;
NS_IMETHOD TakeFocus() MOZ_FINAL;
NS_IMETHOD GetActionCount(uint8_t* aActionCount) MOZ_FINAL;
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription) MOZ_FINAL;
NS_IMETHOD ScriptableDoAction(uint8_t aIndex) MOZ_FINAL;
NS_IMETHOD DoAction(uint8_t aIndex) MOZ_FINAL;
NS_IMETHOD ScriptableScrollTo(uint32_t aHow) MOZ_FINAL;
NS_IMETHOD ScriptableScrollToPoint(uint32_t aCoordinateType,
NS_IMETHOD ScrollTo(uint32_t aHow) MOZ_FINAL;
NS_IMETHOD ScrollToPoint(uint32_t aCoordinateType,
int32_t aX, int32_t aY) MOZ_FINAL;
private:
protected:
xpcAccessible() { }
friend class Accessible;
virtual ~xpcAccessible() {}
private:
Accessible* Intl();
xpcAccessible(const xpcAccessible&) MOZ_DELETE;
xpcAccessible& operator =(const xpcAccessible&) MOZ_DELETE;

View File

@ -10,15 +10,25 @@
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleApplication,
xpcAccessibleGeneric,
nsIAccessibleApplication)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleApplication
NS_IMETHODIMP
xpcAccessibleApplication::GetAppName(nsAString& aName)
{
aName.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->AppName(aName);
Intl()->AppName(aName);
return NS_OK;
}
@ -27,10 +37,10 @@ xpcAccessibleApplication::GetAppVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->AppVersion(aVersion);
Intl()->AppVersion(aVersion);
return NS_OK;
}
@ -39,10 +49,10 @@ xpcAccessibleApplication::GetPlatformName(nsAString& aName)
{
aName.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->PlatformName(aName);
Intl()->PlatformName(aName);
return NS_OK;
}
@ -51,9 +61,9 @@ xpcAccessibleApplication::GetPlatformVersion(nsAString& aVersion)
{
aVersion.Truncate();
if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<ApplicationAccessible*>(this)->PlatformVersion(aVersion);
Intl()->PlatformVersion(aVersion);
return NS_OK;
}

View File

@ -8,23 +8,34 @@
#define mozilla_a11y_xpcAccessibleApplication_h_
#include "nsIAccessibleApplication.h"
class nsIAccessible;
#include "ApplicationAccessible.h"
#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleApplication : public nsIAccessibleApplication
/**
* XPCOM wrapper around ApplicationAccessible class.
*/
class xpcAccessibleApplication : public xpcAccessibleGeneric,
public nsIAccessibleApplication
{
public:
xpcAccessibleApplication(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleApplication
NS_IMETHOD GetAppName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetAppVersion(nsAString& aVersion) MOZ_FINAL;
NS_IMETHOD GetPlatformName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetPlatformVersion(nsAString& aVersion) MOZ_FINAL;
protected:
virtual ~xpcAccessibleApplication() {}
private:
xpcAccessibleApplication() { }
friend class ApplicationAccessible;
ApplicationAccessible* Intl() { return mIntl->AsApplication(); }
xpcAccessibleApplication(const xpcAccessibleApplication&) MOZ_DELETE;
xpcAccessibleApplication& operator =(const xpcAccessibleApplication&) MOZ_DELETE;

View File

@ -5,30 +5,58 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleDocument.h"
#include "xpcAccessibleImage.h"
#include "xpcAccessibleTable.h"
#include "xpcAccessibleTableCell.h"
#include "DocAccessible-inl.h"
#include "nsIDOMDocument.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports and cycle collection
NS_IMPL_CYCLE_COLLECTION_CLASS(xpcAccessibleDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(xpcAccessibleDocument,
xpcAccessibleGeneric)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCache)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(xpcAccessibleDocument,
xpcAccessibleGeneric)
tmp->mCache.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(xpcAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
NS_INTERFACE_MAP_END_INHERITING(xpcAccessibleHyperText)
NS_IMPL_ADDREF_INHERITED(xpcAccessibleDocument, xpcAccessibleHyperText)
NS_IMPL_RELEASE_INHERITED(xpcAccessibleDocument, xpcAccessibleHyperText)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleDocument
NS_IMETHODIMP
xpcAccessibleDocument::GetURL(nsAString& aURL)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->URL(aURL);
Intl()->URL(aURL);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetTitle(nsAString& aTitle)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString title;
static_cast<DocAccessible*>(this)->Title(title);
Intl()->Title(title);
aTitle = title;
return NS_OK;
}
@ -36,20 +64,20 @@ xpcAccessibleDocument::GetTitle(nsAString& aTitle)
NS_IMETHODIMP
xpcAccessibleDocument::GetMimeType(nsAString& aType)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->MimeType(aType);
Intl()->MimeType(aType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetDocType(nsAString& aType)
{
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
static_cast<DocAccessible*>(this)->DocType(aType);
Intl()->DocType(aType);
return NS_OK;
}
@ -59,11 +87,11 @@ xpcAccessibleDocument::GetDOMDocument(nsIDOMDocument** aDOMDocument)
NS_ENSURE_ARG_POINTER(aDOMDocument);
*aDOMDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (static_cast<DocAccessible*>(this)->DocumentNode())
CallQueryInterface(static_cast<DocAccessible*>(this)->DocumentNode(), aDOMDocument);
if (Intl()->DocumentNode())
CallQueryInterface(Intl()->DocumentNode(), aDOMDocument);
return NS_OK;
}
@ -74,10 +102,10 @@ xpcAccessibleDocument::GetWindow(nsIDOMWindow** aDOMWindow)
NS_ENSURE_ARG_POINTER(aDOMWindow);
*aDOMWindow = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDOMWindow = static_cast<DocAccessible*>(this)->DocumentNode()->GetWindow());
NS_IF_ADDREF(*aDOMWindow = Intl()->DocumentNode()->GetWindow());
return NS_OK;
}
@ -87,10 +115,10 @@ xpcAccessibleDocument::GetParentDocument(nsIAccessibleDocument** aDocument)
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->ParentDocument());
NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->ParentDocument()));
return NS_OK;
}
@ -100,24 +128,24 @@ xpcAccessibleDocument::GetChildDocumentCount(uint32_t* aCount)
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aCount = static_cast<DocAccessible*>(this)->ChildDocumentCount();
*aCount = Intl()->ChildDocumentCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::ScriptableGetChildDocumentAt(uint32_t aIndex,
xpcAccessibleDocument::GetChildDocumentAt(uint32_t aIndex,
nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->GetChildDocumentAt(aIndex));
NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->GetChildDocumentAt(aIndex)));
return *aDocument ? NS_OK : NS_ERROR_INVALID_ARG;
}
@ -127,9 +155,49 @@ xpcAccessibleDocument::GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
NS_ENSURE_ARG_POINTER(aVirtualCursor);
*aVirtualCursor = nullptr;
if (static_cast<DocAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_ADDREF(*aVirtualCursor = static_cast<DocAccessible*>(this)->VirtualCursor());
NS_ADDREF(*aVirtualCursor = Intl()->VirtualCursor());
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// xpcAccessibleDocument
xpcAccessibleGeneric*
xpcAccessibleDocument::GetAccessible(Accessible* aAccessible)
{
if (ToXPCDocument(aAccessible->Document()) != this) {
NS_ERROR("This XPCOM document is not related with given internal accessible!");
return nullptr;
}
if (aAccessible->IsDoc())
return this;
xpcAccessibleGeneric* xpcAcc = mCache.GetWeak(aAccessible);
if (xpcAcc)
return xpcAcc;
if (aAccessible->IsImage())
xpcAcc = new xpcAccessibleImage(aAccessible);
else if (aAccessible->IsTable())
xpcAcc = new xpcAccessibleTable(aAccessible);
else if (aAccessible->IsTableCell())
xpcAcc = new xpcAccessibleTableCell(aAccessible);
else if (aAccessible->IsHyperText())
xpcAcc = new xpcAccessibleHyperText(aAccessible);
else
xpcAcc = new xpcAccessibleGeneric(aAccessible);
mCache.Put(aAccessible, xpcAcc);
return xpcAcc;
}
void
xpcAccessibleDocument::Shutdown()
{
mCache.Clear();
xpcAccessibleGeneric::Shutdown();
}

View File

@ -9,12 +9,29 @@
#include "nsIAccessibleDocument.h"
#include "DocAccessible.h"
#include "nsAccessibilityService.h"
#include "xpcAccessibleApplication.h"
#include "xpcAccessibleHyperText.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleDocument : public nsIAccessibleDocument
/**
* XPCOM wrapper around DocAccessible class.
*/
class xpcAccessibleDocument : public xpcAccessibleHyperText,
public nsIAccessibleDocument
{
public:
xpcAccessibleDocument(DocAccessible* aIntl) :
xpcAccessibleHyperText(aIntl), mCache(kDefaultCacheLength) { }
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(xpcAccessibleDocument,
xpcAccessibleGeneric)
// nsIAccessibleDocument
NS_IMETHOD GetURL(nsAString& aURL) MOZ_FINAL;
NS_IMETHOD GetTitle(nsAString& aTitle) MOZ_FINAL;
NS_IMETHOD GetMimeType(nsAString& aType) MOZ_FINAL;
@ -23,19 +40,72 @@ public:
NS_IMETHOD GetWindow(nsIDOMWindow** aDOMWindow) MOZ_FINAL;
NS_IMETHOD GetParentDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetChildDocumentCount(uint32_t* aCount) MOZ_FINAL;
NS_IMETHOD ScriptableGetChildDocumentAt(uint32_t aIndex,
NS_IMETHOD GetChildDocumentAt(uint32_t aIndex,
nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor) MOZ_FINAL;
private:
friend class DocAccessible;
/**
* Return XPCOM wrapper for the internal accessible.
*/
xpcAccessibleGeneric* GetAccessible(Accessible* aAccessible);
xpcAccessibleDocument() { }
virtual void Shutdown() MOZ_OVERRIDE;
protected:
virtual ~xpcAccessibleDocument() {}
private:
DocAccessible* Intl() { return mIntl->AsDoc(); }
void NotifyOfShutdown(Accessible* aAccessible)
{
xpcAccessibleGeneric* xpcAcc = mCache.GetWeak(aAccessible);
if (xpcAcc)
xpcAcc->Shutdown();
mCache.Remove(aAccessible);
}
friend class DocManager;
friend class DocAccessible;
xpcAccessibleDocument(const xpcAccessibleDocument&) MOZ_DELETE;
xpcAccessibleDocument& operator =(const xpcAccessibleDocument&) MOZ_DELETE;
nsRefPtrHashtable<nsPtrHashKey<const Accessible>, xpcAccessibleGeneric> mCache;
};
inline xpcAccessibleGeneric*
ToXPC(Accessible* aAccessible)
{
if (!aAccessible)
return nullptr;
if (aAccessible->IsApplication())
return XPCApplicationAcc();
xpcAccessibleDocument* xpcDoc =
GetAccService()->GetXPCDocument(aAccessible->Document());
return xpcDoc ? xpcDoc->GetAccessible(aAccessible) : nullptr;
}
inline xpcAccessibleHyperText*
ToXPCText(HyperTextAccessible* aAccessible)
{
if (!aAccessible)
return nullptr;
xpcAccessibleDocument* xpcDoc =
GetAccService()->GetXPCDocument(aAccessible->Document());
return static_cast<xpcAccessibleHyperText*>(xpcDoc->GetAccessible(aAccessible));
}
inline xpcAccessibleDocument*
ToXPCDocument(DocAccessible* aAccessible)
{
return GetAccService()->GetXPCDocument(aAccessible);
}
} // namespace a11y
} // namespace mozilla

View File

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleGeneric.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports and cycle collection
NS_IMPL_CYCLE_COLLECTION_0(xpcAccessibleGeneric)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(xpcAccessibleGeneric)
NS_INTERFACE_MAP_ENTRY(nsIAccessible)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleSelectable,
mSupportedIfaces & eSelectable)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleValue,
mSupportedIfaces & eValue)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperLink,
mSupportedIfaces & eHyperLink)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessible)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(xpcAccessibleGeneric)
NS_IMPL_CYCLE_COLLECTING_RELEASE(xpcAccessibleGeneric)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
Accessible*
xpcAccessibleGeneric::ToInternalAccessible() const
{
return mIntl;
}
////////////////////////////////////////////////////////////////////////////////
// xpcAccessibleGeneric
void
xpcAccessibleGeneric::Shutdown()
{
mIntl = nullptr;
}

View File

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_xpcAccessibleGeneric_h_
#define mozilla_a11y_xpcAccessibleGeneric_h_
#include "xpcAccessible.h"
#include "xpcAccessibleHyperLink.h"
#include "xpcAccessibleSelectable.h"
#include "xpcAccessibleValue.h"
#include "Accessible.h"
namespace mozilla {
namespace a11y {
/**
* XPCOM wrapper around Accessible class.
*/
class xpcAccessibleGeneric : public xpcAccessible,
public xpcAccessibleHyperLink,
public xpcAccessibleSelectable,
public xpcAccessibleValue
{
public:
xpcAccessibleGeneric(Accessible* aInternal) :
mIntl(aInternal), mSupportedIfaces(0)
{
if (mIntl->IsSelect())
mSupportedIfaces |= eSelectable;
if (mIntl->HasNumericValue())
mSupportedIfaces |= eValue;
if (mIntl->IsLink())
mSupportedIfaces |= eHyperLink;
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(xpcAccessibleGeneric, nsIAccessible)
// nsIAccessible
virtual Accessible* ToInternalAccessible() const MOZ_FINAL;
// xpcAccessibleGeneric
virtual void Shutdown();
protected:
virtual ~xpcAccessibleGeneric() {}
Accessible* mIntl;
enum {
eSelectable = 1 << 0,
eValue = 1 << 1,
eHyperLink = 1 << 2,
eText = 1 << 3
};
uint8_t mSupportedIfaces;
private:
friend class Accessible;
friend class xpcAccessible;
friend class xpcAccessibleHyperLink;
friend class xpcAccessibleSelectable;
friend class xpcAccessibleValue;
xpcAccessibleGeneric(const xpcAccessibleGeneric&) MOZ_DELETE;
xpcAccessibleGeneric& operator =(const xpcAccessibleGeneric&) MOZ_DELETE;
};
inline Accessible*
xpcAccessible::Intl()
{
return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
}
inline Accessible*
xpcAccessibleHyperLink::Intl()
{
return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
}
inline Accessible*
xpcAccessibleSelectable::Intl()
{
return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
}
inline Accessible*
xpcAccessibleValue::Intl()
{
return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
}
} // namespace a11y
} // namespace mozilla
#endif

View File

@ -4,9 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleHyperLink.h"
#include "Accessible-inl.h"
#include "xpcAccessibleDocument.h"
using namespace mozilla::a11y;
@ -16,10 +15,10 @@ xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
NS_ENSURE_ARG_POINTER(aStartIndex);
*aStartIndex = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aStartIndex = static_cast<Accessible*>(this)->StartOffset();
*aStartIndex = Intl()->StartOffset();
return NS_OK;
}
@ -29,10 +28,10 @@ xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
NS_ENSURE_ARG_POINTER(aEndIndex);
*aEndIndex = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aEndIndex = static_cast<Accessible*>(this)->EndOffset();
*aEndIndex = Intl()->EndOffset();
return NS_OK;
}
@ -42,10 +41,10 @@ xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
NS_ENSURE_ARG_POINTER(aAnchorCount);
*aAnchorCount = 0;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aAnchorCount = static_cast<Accessible*>(this)->AnchorCount();
*aAnchorCount = Intl()->AnchorCount();
return NS_OK;
}
@ -54,14 +53,13 @@ xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
Accessible* thisAcc = static_cast<Accessible*>(this);
if (thisAcc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
return NS_ERROR_INVALID_ARG;
nsRefPtr<nsIURI>(thisAcc->AnchorURIAt(aIndex)).forget(aURI);
nsRefPtr<nsIURI>(Intl()->AnchorURIAt(aIndex)).forget(aURI);
return NS_OK;
}
@ -72,14 +70,13 @@ xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
Accessible* thisAcc = static_cast<Accessible*>(this);
if (thisAcc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
return NS_ERROR_INVALID_ARG;
NS_IF_ADDREF(*aAccessible = thisAcc->AnchorAt(aIndex));
NS_IF_ADDREF(*aAccessible = ToXPC(Intl()->AnchorAt(aIndex)));
return NS_OK;
}
@ -89,9 +86,9 @@ xpcAccessibleHyperLink::GetValid(bool* aValid)
NS_ENSURE_ARG_POINTER(aValid);
*aValid = false;
if (static_cast<Accessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aValid = static_cast<Accessible*>(this)->IsLinkValid();
*aValid = Intl()->IsLinkValid();
return NS_OK;
}

View File

@ -14,6 +14,12 @@ class nsIAccessible;
namespace mozilla {
namespace a11y {
class Accessible;
/**
* XPCOM nsIAccessibleHyperLink implementation, used by xpcAccessibleGeneric
* class.
*/
class xpcAccessibleHyperLink : public nsIAccessibleHyperLink
{
public:
@ -24,12 +30,15 @@ public:
NS_IMETHOD GetAnchor(int32_t aIndex, nsIAccessible** aAccessible) MOZ_FINAL;
NS_IMETHOD GetValid(bool* aValid) MOZ_FINAL;
private:
protected:
xpcAccessibleHyperLink() { }
friend class Accessible;
virtual ~xpcAccessibleHyperLink() {}
private:
xpcAccessibleHyperLink(const xpcAccessibleHyperLink&) MOZ_DELETE;
xpcAccessibleHyperLink& operator =(const xpcAccessibleHyperLink&) MOZ_DELETE;
Accessible* Intl();
};
} // namespace a11y

View File

@ -6,8 +6,10 @@
#include "xpcAccessibleHyperText.h"
#include "Accessible-inl.h"
#include "HyperTextAccessible-inl.h"
#include "TextRange.h"
#include "xpcAccessibleDocument.h"
#include "xpcAccessibleTextRange.h"
#include "nsIPersistentProperties2.h"
@ -18,27 +20,17 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
nsresult
xpcAccessibleHyperText::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
*aInstancePtr = nullptr;
NS_INTERFACE_MAP_BEGIN(xpcAccessibleHyperText)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleText,
mSupportedIfaces & eText)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleEditableText,
mSupportedIfaces & eText)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperText,
mSupportedIfaces & eText)
NS_INTERFACE_MAP_END_INHERITING(xpcAccessibleGeneric)
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (!text->IsTextRole())
return NS_ERROR_NO_INTERFACE;
if (aIID.Equals(NS_GET_IID(nsIAccessibleText)))
*aInstancePtr = static_cast<nsIAccessibleText*>(text);
else if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText)))
*aInstancePtr = static_cast<nsIAccessibleEditableText*>(text);
else if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText)))
*aInstancePtr = static_cast<nsIAccessibleHyperText*>(text);
else
return NS_ERROR_NO_INTERFACE;
NS_ADDREF(text);
return NS_OK;
}
NS_IMPL_ADDREF_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
NS_IMPL_RELEASE_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleText
@ -49,11 +41,10 @@ xpcAccessibleHyperText::GetCharacterCount(int32_t* aCharacterCount)
NS_ENSURE_ARG_POINTER(aCharacterCount);
*aCharacterCount = 0;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aCharacterCount = text->CharacterCount();
*aCharacterCount = Intl()->CharacterCount();
return NS_OK;
}
@ -63,11 +54,10 @@ xpcAccessibleHyperText::GetText(int32_t aStartOffset, int32_t aEndOffset,
{
aText.Truncate();
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->TextSubstring(aStartOffset, aEndOffset, aText);
Intl()->TextSubstring(aStartOffset, aEndOffset, aText);
return NS_OK;
}
@ -83,11 +73,10 @@ xpcAccessibleHyperText::GetTextBeforeOffset(int32_t aOffset,
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
Intl()->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
@ -102,11 +91,10 @@ xpcAccessibleHyperText::GetTextAtOffset(int32_t aOffset,
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
Intl()->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
@ -121,11 +109,10 @@ xpcAccessibleHyperText::GetTextAfterOffset(int32_t aOffset,
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
Intl()->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
@ -136,11 +123,10 @@ xpcAccessibleHyperText::GetCharacterAtOffset(int32_t aOffset,
NS_ENSURE_ARG_POINTER(aCharacter);
*aCharacter = L'\0';
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aCharacter = text->CharAt(aOffset);
*aCharacter = Intl()->CharAt(aOffset);
return NS_OK;
}
@ -157,12 +143,11 @@ xpcAccessibleHyperText::GetTextAttributes(bool aIncludeDefAttrs,
*aStartOffset = *aEndOffset = 0;
*aAttributes = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> attrs =
text->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
attrs.swap(*aAttributes);
return NS_OK;
@ -174,11 +159,10 @@ xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties** aAttr
NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> attrs = text->DefaultTextAttributes();
nsCOMPtr<nsIPersistentProperties> attrs = Intl()->DefaultTextAttributes();
attrs.swap(*aAttributes);
return NS_OK;
}
@ -195,11 +179,10 @@ xpcAccessibleHyperText::GetCharacterExtents(int32_t aOffset,
NS_ENSURE_ARG_POINTER(aHeight);
*aX = *aY = *aWidth = *aHeight;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsIntRect rect = text->CharBounds(aOffset, aCoordType);
nsIntRect rect = Intl()->CharBounds(aOffset, aCoordType);
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
return NS_OK;
@ -217,11 +200,10 @@ xpcAccessibleHyperText::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset
NS_ENSURE_ARG_POINTER(aHeight);
*aX = *aY = *aWidth = *aHeight = 0;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsIntRect rect = text->TextBounds(aStartOffset, aEndOffset, aCoordType);
nsIntRect rect = Intl()->TextBounds(aStartOffset, aEndOffset, aCoordType);
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
return NS_OK;
@ -234,36 +216,33 @@ xpcAccessibleHyperText::GetOffsetAtPoint(int32_t aX, int32_t aY,
NS_ENSURE_ARG_POINTER(aOffset);
*aOffset = -1;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aOffset = text->OffsetAtPoint(aX, aY, aCoordType);
*aOffset = Intl()->OffsetAtPoint(aX, aY, aCoordType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetScriptableCaretOffset(int32_t* aCaretOffset)
xpcAccessibleHyperText::GetCaretOffset(int32_t* aCaretOffset)
{
NS_ENSURE_ARG_POINTER(aCaretOffset);
*aCaretOffset = -1;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aCaretOffset = text->CaretOffset();
*aCaretOffset = Intl()->CaretOffset();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::SetScriptableCaretOffset(int32_t aCaretOffset)
xpcAccessibleHyperText::SetCaretOffset(int32_t aCaretOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->SetCaretOffset(aCaretOffset);
Intl()->SetCaretOffset(aCaretOffset);
return NS_OK;
}
@ -273,11 +252,10 @@ xpcAccessibleHyperText::GetSelectionCount(int32_t* aSelectionCount)
NS_ENSURE_ARG_POINTER(aSelectionCount);
*aSelectionCount = 0;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aSelectionCount = text->SelectionCount();
*aSelectionCount = Intl()->SelectionCount();
return NS_OK;
}
@ -290,14 +268,13 @@ xpcAccessibleHyperText::GetSelectionBounds(int32_t aSelectionNum,
NS_ENSURE_ARG_POINTER(aEndOffset);
*aStartOffset = *aEndOffset = 0;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aSelectionNum < 0 || aSelectionNum >= text->SelectionCount())
if (aSelectionNum < 0 || aSelectionNum >= Intl()->SelectionCount())
return NS_ERROR_INVALID_ARG;
text->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
Intl()->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
return NS_OK;
}
@ -306,12 +283,11 @@ xpcAccessibleHyperText::SetSelectionBounds(int32_t aSelectionNum,
int32_t aStartOffset,
int32_t aEndOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
if (aSelectionNum < 0 ||
!text->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
!Intl()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
return NS_ERROR_INVALID_ARG;
return NS_OK;
@ -320,49 +296,45 @@ xpcAccessibleHyperText::SetSelectionBounds(int32_t aSelectionNum,
NS_IMETHODIMP
xpcAccessibleHyperText::AddSelection(int32_t aStartOffset, int32_t aEndOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->AddToSelection(aStartOffset, aEndOffset);
Intl()->AddToSelection(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::RemoveSelection(int32_t aSelectionNum)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->RemoveFromSelection(aSelectionNum);
Intl()->RemoveFromSelection(aSelectionNum);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableScrollSubstringTo(int32_t aStartOffset,
xpcAccessibleHyperText::ScrollSubstringTo(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aScrollType)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
Intl()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableScrollSubstringToPoint(int32_t aStartOffset,
xpcAccessibleHyperText::ScrollSubstringToPoint(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordinateType,
int32_t aX, int32_t aY)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
Intl()->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
return NS_OK;
}
@ -372,12 +344,11 @@ xpcAccessibleHyperText::GetEnclosingRange(nsIAccessibleTextRange** aRange)
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
text->EnclosingRange(range->mRange);
Intl()->EnclosingRange(range->mRange);
NS_ASSERTION(range->mRange.IsValid(),
"Should always have an enclosing range!");
@ -392,8 +363,7 @@ xpcAccessibleHyperText::GetSelectionRanges(nsIArray** aRanges)
NS_ENSURE_ARG_POINTER(aRanges);
*aRanges = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
@ -402,7 +372,7 @@ xpcAccessibleHyperText::GetSelectionRanges(nsIArray** aRanges)
NS_ENSURE_SUCCESS(rv, rv);
nsAutoTArray<TextRange, 1> ranges;
text->SelectionRanges(&ranges);
Intl()->SelectionRanges(&ranges);
uint32_t len = ranges.Length();
for (uint32_t idx = 0; idx < len; idx++)
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
@ -418,8 +388,7 @@ xpcAccessibleHyperText::GetVisibleRanges(nsIArray** aRanges)
NS_ENSURE_ARG_POINTER(aRanges);
*aRanges = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
@ -428,7 +397,7 @@ xpcAccessibleHyperText::GetVisibleRanges(nsIArray** aRanges)
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<TextRange> ranges;
text->VisibleRanges(&ranges);
Intl()->VisibleRanges(&ranges);
uint32_t len = ranges.Length();
for (uint32_t idx = 0; idx < len; idx++)
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
@ -445,14 +414,13 @@ xpcAccessibleHyperText::GetRangeByChild(nsIAccessible* aChild,
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<Accessible> child = do_QueryObject(aChild);
Accessible* child = aChild->ToInternalAccessible();
if (child) {
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
text->RangeByChild(child, range->mRange);
Intl()->RangeByChild(child, range->mRange);
if (range->mRange.IsValid())
range.forget(aRange);
}
@ -467,12 +435,11 @@ xpcAccessibleHyperText::GetRangeAtPoint(int32_t aX, int32_t aY,
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
text->RangeAtPoint(aX, aY, range->mRange);
Intl()->RangeAtPoint(aX, aY, range->mRange);
if (range->mRange.IsValid())
range.forget(aRange);
@ -485,70 +452,60 @@ xpcAccessibleHyperText::GetRangeAtPoint(int32_t aX, int32_t aY,
NS_IMETHODIMP
xpcAccessibleHyperText::SetTextContents(const nsAString& aText)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->ReplaceText(aText);
Intl()->ReplaceText(aText);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableInsertText(const nsAString& aText,
int32_t aOffset)
xpcAccessibleHyperText::InsertText(const nsAString& aText, int32_t aOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->InsertText(aText, aOffset);
Intl()->InsertText(aText, aOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableCopyText(int32_t aStartOffset,
int32_t aEndOffset)
xpcAccessibleHyperText::CopyText(int32_t aStartOffset, int32_t aEndOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->CopyText(aStartOffset, aEndOffset);
Intl()->CopyText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableCutText(int32_t aStartOffset,
int32_t aEndOffset)
xpcAccessibleHyperText::CutText(int32_t aStartOffset, int32_t aEndOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->CutText(aStartOffset, aEndOffset);
Intl()->CutText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptableDeleteText(int32_t aStartOffset,
int32_t aEndOffset)
xpcAccessibleHyperText::DeleteText(int32_t aStartOffset, int32_t aEndOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->DeleteText(aStartOffset, aEndOffset);
Intl()->DeleteText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::ScriptablePasteText(int32_t aOffset)
xpcAccessibleHyperText::PasteText(int32_t aOffset)
{
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
text->PasteText(aOffset);
Intl()->PasteText(aOffset);
return NS_OK;
}
@ -561,11 +518,10 @@ xpcAccessibleHyperText::GetLinkCount(int32_t* aLinkCount)
NS_ENSURE_ARG_POINTER(aLinkCount);
*aLinkCount = 0;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aLinkCount = text->LinkCount();
*aLinkCount = Intl()->LinkCount();
return NS_OK;
}
@ -575,13 +531,10 @@ xpcAccessibleHyperText::GetLinkAt(int32_t aIndex, nsIAccessibleHyperLink** aLink
NS_ENSURE_ARG_POINTER(aLink);
*aLink = nullptr;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleHyperLink> link = text->LinkAt(aIndex);
link.forget(aLink);
NS_IF_ADDREF(*aLink = ToXPC(Intl()->LinkAt(aIndex)));
return NS_OK;
}
@ -593,12 +546,14 @@ xpcAccessibleHyperText::GetLinkIndex(nsIAccessibleHyperLink* aLink,
NS_ENSURE_ARG_POINTER(aIndex);
*aIndex = -1;
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<Accessible> link(do_QueryObject(aLink));
*aIndex = text->LinkIndexOf(link);
nsCOMPtr<nsIAccessible> xpcLink(do_QueryInterface(aLink));
Accessible* link = xpcLink->ToInternalAccessible();
if (link)
*aIndex = Intl()->LinkIndexOf(link);
return NS_OK;
}
@ -609,10 +564,9 @@ xpcAccessibleHyperText::GetLinkIndexAtOffset(int32_t aOffset,
NS_ENSURE_ARG_POINTER(aLinkIndex);
*aLinkIndex = -1; // API says this magic value means 'not found'
HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
if (text->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
*aLinkIndex = text->LinkIndexAtOffset(aOffset);
*aLinkIndex = Intl()->LinkIndexAtOffset(aOffset);
return NS_OK;
}

View File

@ -11,23 +11,35 @@
#include "nsIAccessibleHyperText.h"
#include "nsIAccessibleEditableText.h"
#include "HyperTextAccessible.h"
#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleHyperText : public nsIAccessibleText,
class xpcAccessibleHyperText : public xpcAccessibleGeneric,
public nsIAccessibleText,
public nsIAccessibleEditableText,
public nsIAccessibleHyperText
{
public:
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
xpcAccessibleHyperText(Accessible* aIntl) : xpcAccessibleGeneric(aIntl)
{
if (mIntl->IsHyperText() && mIntl->AsHyperText()->IsTextRole())
mSupportedIfaces |= eText;
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXT
NS_DECL_NSIACCESSIBLEHYPERTEXT
NS_DECL_NSIACCESSIBLEEDITABLETEXT
protected:
virtual ~xpcAccessibleHyperText() {}
private:
xpcAccessibleHyperText() { }
friend class HyperTextAccessible;
HyperTextAccessible* Intl() { return mIntl->AsHyperText(); }
xpcAccessibleHyperText(const xpcAccessibleHyperText&) MOZ_DELETE;
xpcAccessibleHyperText& operator =(const xpcAccessibleHyperText&) MOZ_DELETE;

View File

@ -10,18 +10,29 @@
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleImage,
xpcAccessibleGeneric,
nsIAccessibleImage)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleImage
NS_IMETHODIMP
xpcAccessibleImage::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
xpcAccessibleImage::GetImagePosition(uint32_t aCoordType,
int32_t* aX, int32_t* aY)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
if (static_cast<ImageAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsIntPoint point = static_cast<ImageAccessible*>(this)->Position(aCoordType);
nsIntPoint point = Intl()->Position(aCoordType);
*aX = point.x; *aY = point.y;
return NS_OK;
}
@ -34,10 +45,10 @@ xpcAccessibleImage::GetImageSize(int32_t* aWidth, int32_t* aHeight)
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
if (static_cast<ImageAccessible*>(this)->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
nsIntSize size = static_cast<ImageAccessible*>(this)->Size();
nsIntSize size = Intl()->Size();
*aWidth = size.width;
*aHeight = size.height;
return NS_OK;

View File

@ -9,20 +9,28 @@
#include "nsIAccessibleImage.h"
#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
class xpcAccessibleImage : public nsIAccessibleImage
class xpcAccessibleImage : public xpcAccessibleGeneric,
public nsIAccessibleImage
{
public:
xpcAccessibleImage(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetImagePosition(uint32_t aCoordType,
int32_t* aX, int32_t* aY) MOZ_FINAL;
NS_IMETHOD GetImageSize(int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
private:
friend class ImageAccessible;
protected:
virtual ~xpcAccessibleImage() {}
xpcAccessibleImage() { }
private:
ImageAccessible* Intl() { return mIntl->AsImage(); }
xpcAccessibleImage(const xpcAccessibleImage&) MOZ_DELETE;
xpcAccessibleImage& operator =(const xpcAccessibleImage&) MOZ_DELETE;

View File

@ -4,9 +4,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleSelectable.h"
#include "Accessible-inl.h"
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
using namespace mozilla::a11y;
@ -16,19 +17,26 @@ xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems)
NS_ENSURE_ARG_POINTER(aSelectedItems);
*aSelectedItems = nullptr;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
nsCOMPtr<nsIArray> items = acc->SelectedItems();
if (items) {
uint32_t length = 0;
items->GetLength(&length);
if (length)
items.swap(*aSelectedItems);
}
nsAutoTArray<Accessible*, 10> items;
Intl()->SelectedItems(&items);
uint32_t itemCount = items.Length();
if (itemCount == 0)
return NS_OK;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> xpcItems =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
for (uint32_t idx = 0; idx < itemCount; idx++)
xpcItems->AppendElement(static_cast<nsIAccessible*>(ToXPC(items[idx])), false);
NS_ADDREF(*aSelectedItems = xpcItems);
return NS_OK;
}
@ -38,12 +46,11 @@ xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount)
NS_ENSURE_ARG_POINTER(aSelectionCount);
*aSelectionCount = 0;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
*aSelectionCount = acc->SelectedItemCount();
*aSelectionCount = Intl()->SelectedItemCount();
return NS_OK;
}
@ -54,12 +61,11 @@ xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = nullptr;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
*aSelected = acc->GetSelectedItem(aIndex);
*aSelected = ToXPC(Intl()->GetSelectedItem(aIndex));
if (*aSelected) {
NS_ADDREF(*aSelected);
return NS_OK;
@ -69,66 +75,60 @@ xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
}
NS_IMETHODIMP
xpcAccessibleSelectable::ScriptableIsItemSelected(uint32_t aIndex,
bool* aIsSelected)
xpcAccessibleSelectable::IsItemSelected(uint32_t aIndex, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
*aIsSelected = acc->IsItemSelected(aIndex);
*aIsSelected = Intl()->IsItemSelected(aIndex);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleSelectable::ScriptableAddItemToSelection(uint32_t aIndex)
xpcAccessibleSelectable::AddItemToSelection(uint32_t aIndex)
{
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
return acc->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
return Intl()->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
xpcAccessibleSelectable::ScriptableRemoveItemFromSelection(uint32_t aIndex)
xpcAccessibleSelectable::RemoveItemFromSelection(uint32_t aIndex)
{
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
return acc->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
return Intl()->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
xpcAccessibleSelectable::ScriptableSelectAll(bool* aIsMultiSelect)
xpcAccessibleSelectable::SelectAll(bool* aIsMultiSelect)
{
NS_ENSURE_ARG_POINTER(aIsMultiSelect);
*aIsMultiSelect = false;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
*aIsMultiSelect = acc->SelectAll();
*aIsMultiSelect = Intl()->SelectAll();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleSelectable::ScriptableUnselectAll()
xpcAccessibleSelectable::UnselectAll()
{
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (!Intl())
return NS_ERROR_FAILURE;
NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
acc->UnselectAll();
Intl()->UnselectAll();
return NS_OK;
}

View File

@ -15,24 +15,34 @@ class nsIArray;
namespace mozilla {
namespace a11y {
class Accessible;
/**
* XPCOM nsIAccessibleSelectable inteface implementation, used by
* xpcAccessibleGeneric class.
*/
class xpcAccessibleSelectable : public nsIAccessibleSelectable
{
public:
// nsIAccessibleSelectable
NS_IMETHOD GetSelectedItems(nsIArray** aSelectedItems) MOZ_FINAL;
NS_IMETHOD GetSelectedItemCount(uint32_t* aSelectedItemCount) MOZ_FINAL;
NS_IMETHOD GetSelectedItemAt(uint32_t aIndex, nsIAccessible** aItem) MOZ_FINAL;
NS_IMETHOD ScriptableIsItemSelected(uint32_t aIndex, bool* aIsSelected) MOZ_FINAL;
NS_IMETHOD ScriptableAddItemToSelection(uint32_t aIndex) MOZ_FINAL;
NS_IMETHOD ScriptableRemoveItemFromSelection(uint32_t aIndex) MOZ_FINAL;
NS_IMETHOD ScriptableSelectAll(bool* aIsMultiSelect) MOZ_FINAL;
NS_IMETHOD ScriptableUnselectAll() MOZ_FINAL;
NS_IMETHOD IsItemSelected(uint32_t aIndex, bool* aIsSelected) MOZ_FINAL;
NS_IMETHOD AddItemToSelection(uint32_t aIndex) MOZ_FINAL;
NS_IMETHOD RemoveItemFromSelection(uint32_t aIndex) MOZ_FINAL;
NS_IMETHOD SelectAll(bool* aIsMultiSelect) MOZ_FINAL;
NS_IMETHOD UnselectAll() MOZ_FINAL;
protected:
xpcAccessibleSelectable() { }
virtual ~xpcAccessibleSelectable() {}
private:
xpcAccessibleSelectable() { }
friend class Accessible;
xpcAccessibleSelectable(const xpcAccessibleSelectable&) MOZ_DELETE;
xpcAccessibleSelectable& operator =(const xpcAccessibleSelectable&) MOZ_DELETE;
Accessible* Intl();
};
} // namespace a11y

View File

@ -8,6 +8,7 @@
#include "Accessible.h"
#include "TableAccessible.h"
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
@ -16,266 +17,276 @@ using namespace mozilla::a11y;
static const uint32_t XPC_TABLE_DEFAULT_SIZE = 40;
nsresult
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTable,
xpcAccessibleGeneric,
nsIAccessibleTable)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTable
NS_IMETHODIMP
xpcAccessibleTable::GetCaption(nsIAccessible** aCaption)
{
NS_ENSURE_ARG_POINTER(aCaption);
*aCaption = nullptr;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aCaption = mTable->Caption());
NS_IF_ADDREF(*aCaption = ToXPC(Intl()->Caption()));
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetColumnCount(int32_t* aColumnCount)
{
NS_ENSURE_ARG_POINTER(aColumnCount);
*aColumnCount = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aColumnCount = mTable->ColCount();
*aColumnCount = Intl()->ColCount();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetRowCount(int32_t* aRowCount)
{
NS_ENSURE_ARG_POINTER(aRowCount);
*aRowCount = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aRowCount = mTable->RowCount();
*aRowCount = Intl()->RowCount();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetCellAt(int32_t aRowIdx, int32_t aColIdx,
nsIAccessible** aCell)
{
NS_ENSURE_ARG_POINTER(aCell);
*aCell = nullptr;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
NS_IF_ADDREF(*aCell = mTable->CellAt(aRowIdx, aColIdx));
NS_IF_ADDREF(*aCell = ToXPC(Intl()->CellAt(aRowIdx, aColIdx)));
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetCellIndexAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aCellIdx)
{
NS_ENSURE_ARG_POINTER(aCellIdx);
*aCellIdx = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aCellIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
*aCellIdx = Intl()->CellIndexAt(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetColumnExtentAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aColumnExtent)
{
NS_ENSURE_ARG_POINTER(aColumnExtent);
*aColumnExtent = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aColumnExtent = mTable->ColExtentAt(aRowIdx, aColIdx);
*aColumnExtent = Intl()->ColExtentAt(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetRowExtentAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aRowExtent)
{
NS_ENSURE_ARG_POINTER(aRowExtent);
*aRowExtent = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aRowExtent = mTable->RowExtentAt(aRowIdx, aColIdx);
*aRowExtent = Intl()->RowExtentAt(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetColumnDescription(int32_t aColIdx,
nsAString& aDescription)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
nsAutoString description;
mTable->ColDescription(aColIdx, description);
Intl()->ColDescription(aColIdx, description);
aDescription.Assign(description);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetRowDescription(int32_t aRowIdx, nsAString& aDescription)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
nsAutoString description;
mTable->RowDescription(aRowIdx, description);
Intl()->RowDescription(aRowIdx, description);
aDescription.Assign(description);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::IsColumnSelected(int32_t aColIdx, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aIsSelected = mTable->IsColSelected(aColIdx);
*aIsSelected = Intl()->IsColSelected(aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::IsRowSelected(int32_t aRowIdx, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
*aIsSelected = mTable->IsRowSelected(aRowIdx);
*aIsSelected = Intl()->IsRowSelected(aRowIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::IsCellSelected(int32_t aRowIdx, int32_t aColIdx,
bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
*aIsSelected = Intl()->IsCellSelected(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCellCount(uint32_t* aSelectedCellCount)
{
NS_ENSURE_ARG_POINTER(aSelectedCellCount);
*aSelectedCellCount = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aSelectedCellCount = mTable->SelectedCellCount();
*aSelectedCellCount = Intl()->SelectedCellCount();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedColumnCount(uint32_t* aSelectedColumnCount)
{
NS_ENSURE_ARG_POINTER(aSelectedColumnCount);
*aSelectedColumnCount = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aSelectedColumnCount = mTable->SelectedColCount();
*aSelectedColumnCount = Intl()->SelectedColCount();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedRowCount(uint32_t* aSelectedRowCount)
{
NS_ENSURE_ARG_POINTER(aSelectedRowCount);
*aSelectedRowCount = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aSelectedRowCount = mTable->SelectedRowCount();
*aSelectedRowCount = Intl()->SelectedRowCount();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCells(nsIArray** aSelectedCells)
{
NS_ENSURE_ARG_POINTER(aSelectedCells);
*aSelectedCells = nullptr;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
NS_IMETHODIMP rv = NS_OK;
nsCOMPtr<nsIMutableArray> selCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoTArray<Accessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
mTable->SelectedCells(&cellsArray);
Intl()->SelectedCells(&cellsArray);
uint32_t totalCount = cellsArray.Length();
for (uint32_t idx = 0; idx < totalCount; idx++) {
Accessible* cell = cellsArray.ElementAt(idx);
selCells -> AppendElement(static_cast<nsIAccessible*>(cell), false);
selCells->AppendElement(static_cast<nsIAccessible*>(ToXPC(cell)), false);
}
NS_ADDREF(*aSelectedCells = selCells);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCellIndices(uint32_t* aCellsArraySize,
int32_t** aCellsArray)
{
@ -285,11 +296,11 @@ xpcAccessibleTable::GetSelectedCellIndices(uint32_t* aCellsArraySize,
NS_ENSURE_ARG_POINTER(aCellsArray);
*aCellsArray = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> cellsArray;
mTable->SelectedCellIndices(&cellsArray);
Intl()->SelectedCellIndices(&cellsArray);
*aCellsArraySize = cellsArray.Length();
*aCellsArray = static_cast<int32_t*>
@ -300,7 +311,7 @@ xpcAccessibleTable::GetSelectedCellIndices(uint32_t* aCellsArraySize,
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedColumnIndices(uint32_t* aColsArraySize,
int32_t** aColsArray)
{
@ -310,11 +321,11 @@ xpcAccessibleTable::GetSelectedColumnIndices(uint32_t* aColsArraySize,
NS_ENSURE_ARG_POINTER(aColsArray);
*aColsArray = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> colsArray;
mTable->SelectedColIndices(&colsArray);
Intl()->SelectedColIndices(&colsArray);
*aColsArraySize = colsArray.Length();
*aColsArray = static_cast<int32_t*>
@ -325,7 +336,7 @@ xpcAccessibleTable::GetSelectedColumnIndices(uint32_t* aColsArraySize,
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSelectedRowIndices(uint32_t* aRowsArraySize,
int32_t** aRowsArray)
{
@ -335,11 +346,11 @@ xpcAccessibleTable::GetSelectedRowIndices(uint32_t* aRowsArraySize,
NS_ENSURE_ARG_POINTER(aRowsArray);
*aRowsArray = 0;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> rowsArray;
mTable->SelectedRowIndices(&rowsArray);
Intl()->SelectedRowIndices(&rowsArray);
*aRowsArraySize = rowsArray.Length();
*aRowsArray = static_cast<int32_t*>
@ -350,43 +361,41 @@ xpcAccessibleTable::GetSelectedRowIndices(uint32_t* aRowsArraySize,
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetColumnIndexAt(int32_t aCellIdx, int32_t* aColIdx)
{
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aCellIdx < 0
|| static_cast<uint32_t>(aCellIdx)
>= mTable->RowCount() * mTable->ColCount())
if (aCellIdx < 0 ||
static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aColIdx = mTable->ColIndexAt(aCellIdx);
*aColIdx = Intl()->ColIndexAt(aCellIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetRowIndexAt(int32_t aCellIdx, int32_t* aRowIdx)
{
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aCellIdx < 0
|| static_cast<uint32_t>(aCellIdx)
>= mTable->RowCount() * mTable->ColCount())
if (aCellIdx < 0 ||
static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
*aRowIdx = mTable->RowIndexAt(aCellIdx);
*aRowIdx = Intl()->RowIndexAt(aCellIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetRowAndColumnIndicesAt(int32_t aCellIdx, int32_t* aRowIdx,
int32_t* aColIdx)
{
@ -395,93 +404,90 @@ xpcAccessibleTable::GetRowAndColumnIndicesAt(int32_t aCellIdx, int32_t* aRowIdx,
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aCellIdx < 0
|| static_cast<uint32_t>(aCellIdx)
>= mTable->RowCount() * mTable->ColCount())
if (aCellIdx < 0 ||
static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
mTable->RowAndColIndicesAt(aCellIdx, aRowIdx, aColIdx);
Intl()->RowAndColIndicesAt(aCellIdx, aRowIdx, aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::GetSummary(nsAString& aSummary)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString summary;
mTable->Summary(summary);
Intl()->Summary(summary);
aSummary.Assign(summary);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::IsProbablyForLayout(bool* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = false;
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
*aResult = mTable->IsProbablyLayoutTable();
*aResult = Intl()->IsProbablyLayoutTable();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::SelectColumn(int32_t aColIdx)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
mTable->SelectCol(aColIdx);
Intl()->SelectCol(aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::SelectRow(int32_t aRowIdx)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
mTable->SelectRow(aRowIdx);
Intl()->SelectRow(aRowIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::UnselectColumn(int32_t aColIdx)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
mTable->UnselectCol(aColIdx);
Intl()->UnselectCol(aColIdx);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTable::UnselectRow(int32_t aRowIdx)
{
if (!mTable)
if (!Intl())
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
mTable->UnselectRow(aRowIdx);
Intl()->UnselectRow(aRowIdx);
return NS_OK;
}

View File

@ -1,73 +1,78 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++ MOZ_FINAL; tab-width: 2 MOZ_FINAL; indent-tabs-mode: nil MOZ_FINAL; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
#define MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
#ifndef mozilla_a11y_xpcAccessibleTable_h_
#define mozilla_a11y_xpcAccessibleTable_h_
#include "nsAString.h"
#include "nscore.h"
class nsIAccessible;
class nsIArray;
#include "nsIAccessibleTable.h"
#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
class TableAccessible;
class xpcAccessibleTable
/**
* XPCOM wrapper around TableAccessible class.
*/
class xpcAccessibleTable : public xpcAccessibleGeneric,
public nsIAccessibleTable
{
public:
explicit xpcAccessibleTable(TableAccessible* aTable) :
mTable(aTable)
{
}
xpcAccessibleTable(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
nsresult GetCaption(nsIAccessible** aCaption);
nsresult GetSummary(nsAString& aSummary);
nsresult GetColumnCount(int32_t* aColumnCount);
nsresult GetRowCount(int32_t* aRowCount);
nsresult GetCellAt(int32_t aRowIndex, int32_t aColumnIndex,
nsIAccessible** aCell);
nsresult GetCellIndexAt(int32_t aRowIndex, int32_t aColumnIndex,
int32_t* aCellIndex);
nsresult GetColumnIndexAt(int32_t aCellIndex, int32_t* aColumnIndex);
nsresult GetRowIndexAt(int32_t aCellIndex, int32_t* aRowIndex);
nsresult GetRowAndColumnIndicesAt(int32_t aCellIndex, int32_t* aRowIndex,
int32_t* aColumnIndex);
nsresult GetColumnExtentAt(int32_t row, int32_t column,
int32_t* aColumnExtent);
nsresult GetRowExtentAt(int32_t row, int32_t column,
int32_t* aRowExtent);
nsresult GetColumnDescription(int32_t aColIdx, nsAString& aDescription);
nsresult GetRowDescription(int32_t aRowIdx, nsAString& aDescription);
nsresult IsColumnSelected(int32_t aColIdx, bool* _retval);
nsresult IsRowSelected(int32_t aRowIdx, bool* _retval);
nsresult IsCellSelected(int32_t aRowIdx, int32_t aColIdx, bool* _retval);
nsresult GetSelectedCellCount(uint32_t* aSelectedCellCount);
nsresult GetSelectedColumnCount(uint32_t* aSelectedColumnCount);
nsresult GetSelectedRowCount(uint32_t* aSelectedRowCount);
nsresult GetSelectedCells(nsIArray** aSelectedCell);
nsresult GetSelectedCellIndices(uint32_t* aCellsArraySize,
int32_t** aCellsArray);
nsresult GetSelectedColumnIndices(uint32_t* aColsArraySize,
int32_t** aColsArray);
nsresult GetSelectedRowIndices(uint32_t* aRowsArraySize,
int32_t** aRowsArray);
nsresult SelectColumn(int32_t aColIdx);
nsresult SelectRow(int32_t aRowIdx);
nsresult UnselectColumn(int32_t aColIdx);
nsresult UnselectRow(int32_t aRowIdx);
nsresult IsProbablyForLayout(bool* aIsForLayout);
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTable
NS_IMETHOD GetCaption(nsIAccessible** aCaption) MOZ_FINAL;
NS_IMETHOD GetSummary(nsAString& aSummary) MOZ_FINAL;
NS_IMETHOD GetColumnCount(int32_t* aColumnCount) MOZ_FINAL;
NS_IMETHOD GetRowCount(int32_t* aRowCount) MOZ_FINAL;
NS_IMETHOD GetCellAt(int32_t aRowIndex, int32_t aColumnIndex,
nsIAccessible** aCell) MOZ_FINAL;
NS_IMETHOD GetCellIndexAt(int32_t aRowIndex, int32_t aColumnIndex,
int32_t* aCellIndex) MOZ_FINAL;
NS_IMETHOD GetColumnIndexAt(int32_t aCellIndex, int32_t* aColumnIndex) MOZ_FINAL;
NS_IMETHOD GetRowIndexAt(int32_t aCellIndex, int32_t* aRowIndex) MOZ_FINAL;
NS_IMETHOD GetRowAndColumnIndicesAt(int32_t aCellIndex, int32_t* aRowIndex,
int32_t* aColumnIndex) MOZ_FINAL;
NS_IMETHOD GetColumnExtentAt(int32_t row, int32_t column,
int32_t* aColumnExtent) MOZ_FINAL;
NS_IMETHOD GetRowExtentAt(int32_t row, int32_t column,
int32_t* aRowExtent) MOZ_FINAL;
NS_IMETHOD GetColumnDescription(int32_t aColIdx, nsAString& aDescription) MOZ_FINAL;
NS_IMETHOD GetRowDescription(int32_t aRowIdx, nsAString& aDescription) MOZ_FINAL;
NS_IMETHOD IsColumnSelected(int32_t aColIdx, bool* _retval) MOZ_FINAL;
NS_IMETHOD IsRowSelected(int32_t aRowIdx, bool* _retval) MOZ_FINAL;
NS_IMETHOD IsCellSelected(int32_t aRowIdx, int32_t aColIdx, bool* _retval) MOZ_FINAL;
NS_IMETHOD GetSelectedCellCount(uint32_t* aSelectedCellCount) MOZ_FINAL;
NS_IMETHOD GetSelectedColumnCount(uint32_t* aSelectedColumnCount) MOZ_FINAL;
NS_IMETHOD GetSelectedRowCount(uint32_t* aSelectedRowCount) MOZ_FINAL;
NS_IMETHOD GetSelectedCells(nsIArray** aSelectedCell) MOZ_FINAL;
NS_IMETHOD GetSelectedCellIndices(uint32_t* aCellsArraySize,
int32_t** aCellsArray) MOZ_FINAL;
NS_IMETHOD GetSelectedColumnIndices(uint32_t* aColsArraySize,
int32_t** aColsArray) MOZ_FINAL;
NS_IMETHOD GetSelectedRowIndices(uint32_t* aRowsArraySize,
int32_t** aRowsArray) MOZ_FINAL;
NS_IMETHOD SelectColumn(int32_t aColIdx) MOZ_FINAL;
NS_IMETHOD SelectRow(int32_t aRowIdx) MOZ_FINAL;
NS_IMETHOD UnselectColumn(int32_t aColIdx) MOZ_FINAL;
NS_IMETHOD UnselectRow(int32_t aRowIdx) MOZ_FINAL;
NS_IMETHOD IsProbablyForLayout(bool* aIsForLayout) MOZ_FINAL;
protected:
mozilla::a11y::TableAccessible* mTable;
virtual ~xpcAccessibleTable() {}
private:
TableAccessible* Intl() { return mIntl->AsTable(); }
xpcAccessibleTable(const xpcAccessibleTable&) MOZ_DELETE;
xpcAccessibleTable& operator =(const xpcAccessibleTable&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
#endif // MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
#endif // mozilla_a11y_xpcAccessibleTable_h_

View File

@ -7,10 +7,10 @@
#include "xpcAccessibleTableCell.h"
#include "Accessible.h"
#include "nsIAccessibleTable.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "nsIAccessibleTable.h"
#include "xpcAccessibleDocument.h"
#include "nsComponentManagerUtils.h"
#include "nsIMutableArray.h"
@ -18,99 +18,104 @@
using namespace mozilla;
using namespace mozilla::a11y;
nsresult
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTableCell,
xpcAccessibleHyperText,
nsIAccessibleTableCell)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTableCell
NS_IMETHODIMP
xpcAccessibleTableCell::GetTable(nsIAccessibleTable** aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nullptr;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
TableAccessible* table = mTableCell->Table();
TableAccessible* table = Intl()->Table();
if (!table)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> xpcTable =
do_QueryInterface(static_cast<nsIAccessible*>(table->AsAccessible()));
do_QueryInterface(static_cast<nsIAccessible*>(ToXPC(table->AsAccessible())));
xpcTable.forget(aTable);
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnIndex(int32_t* aColIdx)
{
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
*aColIdx = mTableCell->ColIdx();
*aColIdx = Intl()->ColIdx();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowIndex(int32_t* aRowIdx)
{
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
*aRowIdx = mTableCell->RowIdx();
*aRowIdx = Intl()->RowIdx();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnExtent(int32_t* aExtent)
{
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
*aExtent = mTableCell->ColExtent();
*aExtent = Intl()->ColExtent();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowExtent(int32_t* aExtent)
{
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
*aExtent = mTableCell->RowExtent();
*aExtent = Intl()->RowExtent();
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<Accessible*, 10> headerCells;
mTableCell->ColHeaderCells(&headerCells);
Intl()->ColHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
cells->
AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
false);
}
@ -118,24 +123,23 @@ xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells)
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<Accessible*, 10> headerCells;
mTableCell->RowHeaderCells(&headerCells);
Intl()->RowHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
cells->
AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
false);
}
@ -143,16 +147,15 @@ xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells)
return NS_OK;
}
nsresult
NS_IMETHODIMP
xpcAccessibleTableCell::IsSelected(bool* aSelected)
{
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = false;
if (!mTableCell)
if (!Intl())
return NS_ERROR_FAILURE;
*aSelected = mTableCell->Selected();
*aSelected = Intl()->Selected();
return NS_OK;
}

View File

@ -7,40 +7,42 @@
#ifndef mozilla_a11y_xpcom_xpcAccessibletableCell_h_
#define mozilla_a11y_xpcom_xpcAccessibletableCell_h_
#include "nscore.h"
#include "nsIAccessibleTable.h"
class nsIAccessibleTable;
class nsIArray;
#include "xpcAccessibleHyperText.h"
namespace mozilla {
namespace a11y {
class TableAccessible;
class TableCellAccessible;
/**
* This class provides an implementation of the nsIAccessibleTableCell
* interface's methods.
* XPCOM wrapper around TableAccessibleCell class.
*/
class xpcAccessibleTableCell
class xpcAccessibleTableCell : public xpcAccessibleHyperText,
public nsIAccessibleTableCell
{
public:
explicit xpcAccessibleTableCell(TableCellAccessible* aTableCell) :
mTableCell(aTableCell)
{
}
xpcAccessibleTableCell(Accessible* aIntl) : xpcAccessibleHyperText(aIntl) { }
nsresult GetTable(nsIAccessibleTable** aTable);
nsresult GetColumnIndex(int32_t* aColIdx);
nsresult GetRowIndex(int32_t* aRowIdx);
nsresult GetColumnExtent(int32_t* aExtent);
nsresult GetRowExtent(int32_t* aExtent);
nsresult GetColumnHeaderCells(nsIArray** aHeaderCells);
nsresult GetRowHeaderCells(nsIArray** aHeaderCells);
nsresult IsSelected(bool* aSelected);
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTableCell
NS_IMETHOD GetTable(nsIAccessibleTable** aTable) MOZ_FINAL;
NS_IMETHOD GetColumnIndex(int32_t* aColIdx) MOZ_FINAL;
NS_IMETHOD GetRowIndex(int32_t* aRowIdx) MOZ_FINAL;
NS_IMETHOD GetColumnExtent(int32_t* aExtent) MOZ_FINAL;
NS_IMETHOD GetRowExtent(int32_t* aExtent) MOZ_FINAL;
NS_IMETHOD GetColumnHeaderCells(nsIArray** aHeaderCells) MOZ_FINAL;
NS_IMETHOD GetRowHeaderCells(nsIArray** aHeaderCells) MOZ_FINAL;
NS_IMETHOD IsSelected(bool* aSelected) MOZ_FINAL;
protected:
mozilla::a11y::TableCellAccessible* mTableCell;
virtual ~xpcAccessibleTableCell() {}
private:
TableCellAccessible* Intl() { return mIntl->AsTableCell(); }
xpcAccessibleTableCell(const xpcAccessibleTableCell&) MOZ_DELETE;
xpcAccessibleTableCell& operator =(const xpcAccessibleTableCell&) MOZ_DELETE;
};
} // namespace a11y

View File

@ -6,8 +6,9 @@
#include "xpcAccessibleTextRange.h"
#include "HyperTextAccessible.h"
#include "TextRange.h"
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
@ -36,7 +37,7 @@ NS_IMETHODIMP
xpcAccessibleTextRange::GetStartContainer(nsIAccessibleText** aAnchor)
{
NS_ENSURE_ARG_POINTER(aAnchor);
NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessibleText*>(mRange.StartContainer()));
NS_IF_ADDREF(*aAnchor = ToXPCText(mRange.StartContainer()));
return NS_OK;
}
@ -52,7 +53,7 @@ NS_IMETHODIMP
xpcAccessibleTextRange::GetEndContainer(nsIAccessibleText** aAnchor)
{
NS_ENSURE_ARG_POINTER(aAnchor);
NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessibleText*>(mRange.EndContainer()));
NS_IF_ADDREF(*aAnchor = ToXPCText(mRange.EndContainer()));
return NS_OK;
}
@ -68,7 +69,7 @@ NS_IMETHODIMP
xpcAccessibleTextRange::GetContainer(nsIAccessible** aContainer)
{
NS_ENSURE_ARG_POINTER(aContainer);
NS_IF_ADDREF(*aContainer = static_cast<nsIAccessible*>(mRange.Container()));
NS_IF_ADDREF(*aContainer = ToXPC(mRange.Container()));
return NS_OK;
}
@ -85,7 +86,7 @@ xpcAccessibleTextRange::GetEmbeddedChildren(nsIArray** aList)
uint32_t len = objects.Length();
for (uint32_t idx = 0; idx < len; idx++)
xpcList->AppendElement(static_cast<nsIAccessible*>(objects[idx]), false);
xpcList->AppendElement(static_cast<nsIAccessible*>(ToXPC(objects[idx])), false);
xpcList.forget(aList);

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleValue.h"
#include "xpcAccessibleGeneric.h"
#include "Accessible.h"
using namespace mozilla;
@ -16,11 +16,10 @@ xpcAccessibleValue::GetMaximumValue(double* aValue)
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
double value = acc->MaxValue();
double value = Intl()->MaxValue();
if (!IsNaN(value))
*aValue = value;
@ -33,11 +32,10 @@ xpcAccessibleValue::GetMinimumValue(double* aValue)
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
double value = acc->MinValue();
double value = Intl()->MinValue();
if (!IsNaN(value))
*aValue = value;
@ -50,11 +48,10 @@ xpcAccessibleValue::GetCurrentValue(double* aValue)
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
double value = acc->CurValue();
double value = Intl()->CurValue();
if (!IsNaN(value))
*aValue = value;
@ -64,11 +61,10 @@ xpcAccessibleValue::GetCurrentValue(double* aValue)
NS_IMETHODIMP
xpcAccessibleValue::SetCurrentValue(double aValue)
{
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
acc->SetCurValue(aValue);
Intl()->SetCurValue(aValue);
return NS_OK;
}
@ -78,11 +74,10 @@ xpcAccessibleValue::GetMinimumIncrement(double* aValue)
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
Accessible* acc = static_cast<Accessible*>(this);
if (acc->IsDefunct())
if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
double value = acc->Step();
double value = Intl()->Step();
if (!IsNaN(value))
*aValue = value;

View File

@ -12,6 +12,12 @@
namespace mozilla {
namespace a11y {
class Accessible;
/**
* XPCOM nsIAccessibleValue interface implementation, used by
* xpcAccessibleGeneric class.
*/
class xpcAccessibleValue : public nsIAccessibleValue
{
public:
@ -21,9 +27,12 @@ public:
NS_IMETHOD SetCurrentValue(double aValue) MOZ_FINAL MOZ_OVERRIDE;
NS_IMETHOD GetMinimumIncrement(double* aMinIncrement) MOZ_FINAL MOZ_OVERRIDE;
private:
protected:
xpcAccessibleValue() { }
friend class Accessible;
virtual ~xpcAccessibleValue() {}
private:
Accessible* Intl();
xpcAccessibleValue(const xpcAccessibleValue&) MOZ_DELETE;
xpcAccessibleValue& operator =(const xpcAccessibleValue&) MOZ_DELETE;

View File

@ -28,7 +28,7 @@ XULColorPickerTileAccessible::
}
////////////////////////////////////////////////////////////////////////////////
// XULColorPickerTileAccessible: nsIAccessible
// XULColorPickerTileAccessible: Accessible
void
XULColorPickerTileAccessible::Value(nsString& aValue)
@ -38,9 +38,6 @@ XULColorPickerTileAccessible::Value(nsString& aValue)
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
}
////////////////////////////////////////////////////////////////////////////////
// XULColorPickerTileAccessible: Accessible
role
XULColorPickerTileAccessible::NativeRole()
{

View File

@ -20,7 +20,6 @@
#include "Logging.h"
#endif
#include "nsIAccessibleRelation.h"
#include "nsIDOMXULDescriptionElement.h"
#include "nsNameSpaceManager.h"
#include "nsNetUtil.h"
@ -188,12 +187,8 @@ XULLinkAccessible::~XULLinkAccessible()
{
}
// Expose nsIAccessibleHyperLink unconditionally
NS_IMPL_ISUPPORTS_INHERITED(XULLinkAccessible, XULLabelAccessible,
nsIAccessibleHyperLink)
////////////////////////////////////////////////////////////////////////////////
// XULLinkAccessible. nsIAccessible
// XULLinkAccessible: Accessible
void
XULLinkAccessible::Value(nsString& aValue)

Some files were not shown because too many files have changed in this diff Show More